r58436 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58435‎ | r58436 | r58437 >
Date:18:32, 2 November 2009
Author:yaron
Status:deferred
Tags:
Comment:
Improved special-property initialization to handle missing property labels, as well as English-language aliases for non-English aliases
Modified paths:
  • /trunk/extensions/SemanticDrilldown/includes/SD_GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/includes/SD_GlobalFunctions.php
@@ -7,7 +7,7 @@
88
99 if (!defined('MEDIAWIKI')) die();
1010
11 -define('SD_VERSION','0.6.1');
 11+define('SD_VERSION','0.6.2');
1212
1313 // constants for special properties
1414 define('SD_SP_HAS_FILTER', 1);
@@ -162,19 +162,33 @@
163163 }
164164
165165 function sdfInitProperties() {
166 - global $sdgContLang;
167 - $sd_props = $sdgContLang->getPropertyLabels();
168 - SMWPropertyValue::registerProperty('_SD_F', '_wpg', $sd_props[SD_SP_HAS_FILTER], true);
169 - SMWPropertyValue::registerProperty('_SD_CP', '_wpp', $sd_props[SD_SP_COVERS_PROPERTY], true);
170 - SMWPropertyValue::registerProperty('_SD_V', '_str', $sd_props[SD_SP_HAS_VALUE], true);
171 - SMWPropertyValue::registerProperty('_SD_VC', '_wpc', $sd_props[SD_SP_GETS_VALUES_FROM_CATEGORY], true);
172 - SMWPropertyValue::registerProperty('_SD_TP', '_str', $sd_props[SD_SP_USES_TIME_PERIOD], true);
173 - SMWPropertyValue::registerProperty('_SD_IT', '_str', $sd_props[SD_SP_HAS_INPUT_TYPE], true);
174 - SMWPropertyValue::registerProperty('_SD_RF', '_wpg', $sd_props[SD_SP_REQUIRES_FILTER], true);
175 - SMWPropertyValue::registerProperty('_SD_L', '_str', $sd_props[SD_SP_HAS_LABEL], true);
176 - SMWPropertyValue::registerProperty('_SD_DT', '_str', $sd_props[SD_SP_HAS_DRILLDOWN_TITLE], true);
177 - SMWPropertyValue::registerProperty('_SD_DP', '_str', $sd_props[SD_SP_HAS_DISPLAY_PARAMETERS], true);
178 -
 166+ global $sdgContLang, $wgLanguageCode;
 167+ $sd_property_vals = array(
 168+ SD_SP_HAS_FILTER => array('_SD_F', '_wpg'),
 169+ SD_SP_COVERS_PROPERTY => array('_SD_CP', '_wpp'),
 170+ SD_SP_HAS_VALUE => array('_SD_V', '_str'),
 171+ SD_SP_GETS_VALUES_FROM_CATEGORY => array('_SD_VC', '_wpc'),
 172+ SD_SP_USES_TIME_PERIOD => array('_SD_TP', '_str'),
 173+ SD_SP_HAS_INPUT_TYPE => array('_SD_IT', '_str'),
 174+ SD_SP_REQUIRES_FILTER => array('_SD_RF', '_wpg'),
 175+ SD_SP_HAS_LABEL => array('_SD_L', '_str'),
 176+ SD_SP_HAS_DRILLDOWN_TITLE => array('_SD_DT', '_str'),
 177+ SD_SP_HAS_DISPLAY_PARAMETERS => array('_SD_DP', '_str'),
 178+ );
 179+ // register main property labels
 180+ $sd_prop_labels = $sdgContLang->getPropertyLabels();
 181+ foreach ($sd_prop_labels as $prop_id => $prop_alias) {
 182+ $prop_vals = $sd_property_vals[$prop_id];
 183+ SMWPropertyValue::registerProperty($prop_vals[0], $prop_vals[1], $prop_alias, true);
 184+ }
 185+ // if it's not English, add the English-language aliases as well
 186+ if ($wgLanguageCode != 'en') {
 187+ $sd_prop_aliases = $sdgContLang->getPropertyAliases();
 188+ foreach ($sd_prop_aliases as $prop_alias => $prop_id) {
 189+ $prop_vals = $sd_property_vals[$prop_id];
 190+ SMWPropertyValue::registerProperty($prop_vals[0], $prop_vals[1], $prop_alias, true);
 191+ }
 192+ }
179193 return true;
180194 }
181195

Status & tagging log