Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php |
— | — | @@ -231,21 +231,16 @@ |
232 | 232 | } |
233 | 233 | |
234 | 234 | function expressionIsBoundToDefinedMeaning( $definedMeaningId, $expressionId ) { |
235 | | - global $dataSet; |
236 | | - |
237 | 235 | $dc = wdGetDataSetContext(); |
238 | 236 | $dbr = wfGetDB( DB_SLAVE ); |
239 | 237 | |
240 | | - $queryResult = $dbr->query( |
241 | | - selectLatest( |
242 | | - array( $dataSet->syntrans->expressionId ), |
243 | | - array( $dataSet->syntrans ), |
244 | | - array( |
245 | | - equals( $dataSet->syntrans->definedMeaningId, $definedMeaningId ), |
246 | | - equals( $dataSet->syntrans->expressionId, $expressionId ) |
247 | | - ) |
248 | | - ) |
249 | | - ); |
| 238 | + $query = "SELECT * FROM {$dc}_syntrans " |
| 239 | + . " WHERE defined_meaning_id = $definedMeaningId " |
| 240 | + . " AND expression_id = $expressionId " |
| 241 | + . " AND remove_transaction_id IS NULL" |
| 242 | + . " LIMIT 1" ; |
| 243 | + |
| 244 | + $queryResult = $dbr->query( $query ); |
250 | 245 | |
251 | 246 | return $dbr->numRows( $queryResult ) > 0; |
252 | 247 | } |
— | — | @@ -407,6 +402,7 @@ |
408 | 403 | function classAttributeExists( $classMeaningId, $levelMeaningId, $attributeMeaningId, $attributeType ) { |
409 | 404 | $dc = wdGetDataSetContext(); |
410 | 405 | $dbr = wfGetDB( DB_SLAVE ); |
| 406 | + |
411 | 407 | $queryResult = $dbr->query( "SELECT object_id FROM {$dc}_class_attributes" . |
412 | 408 | " WHERE class_mid=$classMeaningId AND level_mid=$levelMeaningId AND attribute_mid=$attributeMeaningId AND attribute_type = " . $dbr->addQuotes( $attributeType ) . |
413 | 409 | ' AND ' . getLatestTransactionRestriction( "{$dc}_class_attributes" ) . " LIMIT 1" ); |
— | — | @@ -432,6 +428,7 @@ |
433 | 429 | function getClassAttributeId( $classMeaningId, $levelMeaningId, $attributeMeaningId, $attributeType ) { |
434 | 430 | $dc = wdGetDataSetContext(); |
435 | 431 | $dbr = wfGetDB( DB_SLAVE ); |
| 432 | + |
436 | 433 | $queryResult = $dbr->query( "SELECT object_id FROM {$dc}_class_attributes " . |
437 | 434 | "WHERE class_mid=$classMeaningId AND level_mid =$levelMeaningId AND attribute_mid=$attributeMeaningId AND attribute_type = " . $dbr->addQuotes( $attributeType ) ); |
438 | 435 | |
— | — | @@ -1166,6 +1163,10 @@ |
1167 | 1164 | |
1168 | 1165 | } |
1169 | 1166 | |
| 1167 | +/** |
| 1168 | + * Returns true if the concept corresponding to the |
| 1169 | + * definedMeaningID $objectId is a class |
| 1170 | + */ |
1170 | 1171 | function isClass( $objectId ) { |
1171 | 1172 | global $wgDefaultClassMids; |
1172 | 1173 | |
— | — | @@ -1178,13 +1179,13 @@ |
1179 | 1180 | "SELECT {$dc}_collection.collection_id " . |
1180 | 1181 | " FROM ({$dc}_collection_contents INNER JOIN {$dc}_collection ON {$dc}_collection.collection_id = {$dc}_collection_contents.collection_id) " . |
1181 | 1182 | " WHERE {$dc}_collection_contents.member_mid = $objectId AND {$dc}_collection.collection_type = 'CLAS' " . |
1182 | | - " AND " . getLatestTransactionRestriction( "{$dc}_collection_contents" ) . " " . |
1183 | | - " AND " . getLatestTransactionRestriction( "{$dc}_collection" ) . " LIMIT 1" ; |
| 1183 | + " AND {$dc}_collection_contents.remove_transaction_id is NULL" . |
| 1184 | + " AND {$dc}_collection.remove_transaction_id is NULL LIMIT 1" ; |
1184 | 1185 | $queryResult = $dbr->query( $query ); |
1185 | 1186 | |
1186 | 1187 | $result = $dbr->numRows( $queryResult ) > 0; |
1187 | 1188 | } |
1188 | | - |
| 1189 | + |
1189 | 1190 | return $result; |
1190 | 1191 | } |
1191 | 1192 | |
— | — | @@ -1205,15 +1206,15 @@ |
1206 | 1207 | } |
1207 | 1208 | |
1208 | 1209 | function getCollectionContents( $collectionId ) { |
1209 | | - global $dataSet; |
| 1210 | + global $wgWikidataDataSet; |
1210 | 1211 | |
1211 | 1212 | $dc = wdGetDataSetContext(); |
1212 | 1213 | $dbr = & wfGetDB( DB_SLAVE ); |
1213 | 1214 | $queryResult = $dbr->query( |
1214 | 1215 | selectLatest( |
1215 | | - array( $dataSet->collectionMemberships->memberMid, $dataSet->collectionMemberships->internalMemberId ), |
1216 | | - array( $dataSet->collectionMemberships ), |
1217 | | - array( equals( $dataSet->collectionMemberships->collectionId, $collectionId ) ) |
| 1216 | + array( $wgWikidataDataSet->collectionMemberships->memberMid, $wgWikidataDataSet->collectionMemberships->internalMemberId ), |
| 1217 | + array( $wgWikidataDataSet->collectionMemberships ), |
| 1218 | + array( equals( $wgWikidataDataSet->collectionMemberships->collectionId, $collectionId ) ) |
1218 | 1219 | ) |
1219 | 1220 | ); |
1220 | 1221 | |
— | — | @@ -1775,33 +1776,52 @@ |
1776 | 1777 | $dc = wdGetDataSetContext(); |
1777 | 1778 | $dbr = wfGetDB( DB_SLAVE ); |
1778 | 1779 | |
1779 | | - global |
1780 | | - $wgDefaultClassMids, $dataSet; |
| 1780 | + global $wgDefaultClassMids, $wgWikidataDataSet; |
1781 | 1781 | |
1782 | | - $queryResult = $dbr->query( |
1783 | | - SelectLatestDistinct( |
1784 | | - array( |
1785 | | - $dataSet->classAttributes->attributeMid, |
1786 | | - $dataSet->classAttributes->attributeType, |
1787 | | - $dataSet->bootstrappedDefinedMeanings->name |
1788 | | - ), |
1789 | | - array( $dataSet->classAttributes, $dataSet->bootstrappedDefinedMeanings ), |
1790 | | - array( |
1791 | | - equals( $dataSet->classAttributes->levelMid, $dataSet->bootstrappedDefinedMeanings->definedMeaningId ), |
1792 | | - sqlOr( |
1793 | | - in( $dataSet->classAttributes->classMid, |
1794 | | - selectLatest( |
1795 | | - array( $dataSet->classMemberships->classMid ), |
1796 | | - array( $dataSet->classMemberships ), |
1797 | | - array( equals( $dataSet->classMemberships->classMemberMid, $definedMeaningId ) ) |
1798 | | - ) |
1799 | | - ), |
1800 | | - inArray( $dataSet->classAttributes->classMid, $wgDefaultClassMids ) |
1801 | | - ) |
| 1782 | +/* |
| 1783 | + $query = SelectLatestDistinct( |
| 1784 | + array( |
| 1785 | + $wgWikidataDataSet->classAttributes->attributeMid, |
| 1786 | + $wgWikidataDataSet->classAttributes->attributeType, |
| 1787 | + $wgWikidataDataSet->bootstrappedDefinedMeanings->name |
| 1788 | + ), |
| 1789 | + array( $wgWikidataDataSet->classAttributes, $wgWikidataDataSet->bootstrappedDefinedMeanings ), |
| 1790 | + array( |
| 1791 | + equals( $wgWikidataDataSet->classAttributes->levelMid, $wgWikidataDataSet->bootstrappedDefinedMeanings->definedMeaningId ), |
| 1792 | + sqlOr( |
| 1793 | + in( $wgWikidataDataSet->classAttributes->classMid, |
| 1794 | + selectLatest( |
| 1795 | + array( $wgWikidataDataSet->classMemberships->classMid ), |
| 1796 | + array( $wgWikidataDataSet->classMemberships ), |
| 1797 | + array( equals( $wgWikidataDataSet->classMemberships->classMemberMid, $definedMeaningId ) ) |
| 1798 | + ) |
| 1799 | + ), |
| 1800 | + inArray( $wgWikidataDataSet->classAttributes->classMid, $wgDefaultClassMids ) |
1802 | 1801 | ) |
1803 | 1802 | ) |
1804 | | - ); |
| 1803 | + ) ; |
1805 | 1804 | |
| 1805 | + generates something like this: |
| 1806 | +SELECT DISTINCT uw_class_attributes.attribute_mid, uw_class_attributes.attribute_type, uw_bootstrapped_defined_meanings.name |
| 1807 | +FROM uw_class_attributes, uw_bootstrapped_defined_meanings |
| 1808 | +WHERE ((uw_class_attributes.level_mid) = (uw_bootstrapped_defined_meanings.defined_meaning_id)) |
| 1809 | +AND ((uw_class_attributes.class_mid IN (SELECT uw_class_membership.class_mid FROM uw_class_membership |
| 1810 | +WHERE ((uw_class_membership.class_member_mid) = (37)) AND (uw_class_membership.remove_transaction_id IS NULL))) |
| 1811 | +OR (uw_class_attributes.class_mid IN (37))) AND (uw_class_attributes.remove_transaction_id IS NULL) |
| 1812 | + |
| 1813 | +FIXME: the above query does not take into account language specific annotations |
| 1814 | +(i.e. existing annotations are not shown). |
| 1815 | +the query below is more simple (and faster), but might show annotations that are empty |
| 1816 | +when one clicks on the combobox. |
| 1817 | +*/ |
| 1818 | + $query = "SELECT DISTINCT {$dc}_class_attributes.attribute_mid, " |
| 1819 | + . " {$dc}_class_attributes.attribute_type, {$dc}_bootstrapped_defined_meanings.name " |
| 1820 | + . " FROM {$dc}_class_attributes, {$dc}_bootstrapped_defined_meanings " |
| 1821 | + . " WHERE {$dc}_class_attributes.level_mid = {$dc}_bootstrapped_defined_meanings.defined_meaning_id " |
| 1822 | + . " AND {$dc}_class_attributes.remove_transaction_id IS NULL "; |
| 1823 | + |
| 1824 | + $queryResult = $dbr->query($query); |
| 1825 | + |
1806 | 1826 | $this->classAttributes = array(); |
1807 | 1827 | |
1808 | 1828 | while ( $row = $dbr->fetchRow( $queryResult ) ) { |
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php |
— | — | @@ -23,8 +23,7 @@ |
24 | 24 | protected $showDataSetPanel = false; |
25 | 25 | |
26 | 26 | public function __construct() { |
27 | | - global |
28 | | - $wgFilterLanguageId, |
| 27 | + global $wgFilterLanguageId, |
29 | 28 | $wgShowClassicPageTitles, |
30 | 29 | $wgPropertyToColumnFilters; |
31 | 30 | |
— | — | @@ -269,92 +268,9 @@ |
270 | 269 | |
271 | 270 | return $wgTitle->getText(); |
272 | 271 | } |
273 | | - |
274 | 272 | } |
275 | 273 | |
276 | 274 | |
277 | | -# Global context override. This is an evil hack to allow saving, basically. |
278 | | -global $wdCurrentContext; |
279 | | -$wdCurrentContext = null; |
280 | | - |
281 | | -/** |
282 | | - * A Wikidata application can manage multiple data sets. |
283 | | - * The current "context" is dependent on multiple factors: |
284 | | - * - the URL can have a dataset parameter |
285 | | - * - there is a global default |
286 | | - * - there can be defaults for different user groups |
287 | | - * @param $dc optional, for convenience. |
288 | | - * if the dataset context is already set, will |
289 | | - return that value, else will find the relevant value |
290 | | - * @return prefix (without underscore) |
291 | | -**/ |
292 | | -function wdGetDataSetContext( $dc = null ) { |
293 | | - global $wgRequest, $wdDefaultViewDataSet, $wdGroupDefaultView, $wgUser, |
294 | | - $wdCurrentContext; |
295 | | - |
296 | | - # overrides |
297 | | - if ( !is_null( $dc ) ) |
298 | | - return $dc; # local override |
299 | | - if ( !is_null( $wdCurrentContext ) ) |
300 | | - return $wdCurrentContext; # global override |
301 | | - |
302 | | - $datasets = wdGetDataSets(); |
303 | | - $groups = $wgUser->getGroups(); |
304 | | - $dbs = wfGetDB( DB_SLAVE ); |
305 | | - $pref = $wgUser->getOption( 'ow_uipref_datasets' ); |
306 | | - |
307 | | - $trydefault = ''; |
308 | | - foreach ( $groups as $group ) { |
309 | | - if ( isset( $wdGroupDefaultView[$group] ) ) { |
310 | | - # We don't know yet if this prefix is valid. |
311 | | - $trydefault = $wdGroupDefaultView[$group]; |
312 | | - } |
313 | | - } |
314 | | - |
315 | | - # URL parameter takes precedence over all else |
316 | | - if ( ( $ds = $wgRequest->getText( 'dataset' ) ) && array_key_exists( $ds, $datasets ) && $dbs->tableExists( $ds . "_transactions" ) ) { |
317 | | - return $datasets[$ds]; |
318 | | - # User preference |
319 | | - } elseif ( !empty( $pref ) && array_key_exists( $pref, $datasets ) ) { |
320 | | - return $datasets[$pref]; |
321 | | - } |
322 | | - # Group preference |
323 | | - elseif ( !empty( $trydefault ) && array_key_exists( $trydefault, $datasets ) ) { |
324 | | - return $datasets[$trydefault]; |
325 | | - } else { |
326 | | - return $datasets[$wdDefaultViewDataSet]; |
327 | | - } |
328 | | -} |
329 | | - |
330 | | - |
331 | | -/** |
332 | | - * Load dataset definitions from the database if necessary. |
333 | | - * |
334 | | - * @return an array of all available datasets |
335 | | -**/ |
336 | | -function &wdGetDataSets() { |
337 | | - |
338 | | - static $datasets, $wgGroupPermissions; |
339 | | - if ( empty( $datasets ) ) { |
340 | | - // Load defs from the DB |
341 | | - $dbs = wfGetDB( DB_SLAVE ); |
342 | | - $res = $dbs->select( 'wikidata_sets', array( 'set_prefix' ) ); |
343 | | - |
344 | | - while ( $row = $dbs->fetchObject( $res ) ) { |
345 | | - |
346 | | - $dc = new DataSet(); |
347 | | - $dc->setPrefix( $row->set_prefix ); |
348 | | - if ( $dc->isValidPrefix() ) { |
349 | | - $datasets[$row->set_prefix] = $dc; |
350 | | - wfDebug( "Imported data set: " . $dc->fetchName() . "\n" ); |
351 | | - } else { |
352 | | - wfDebug( $row->set_prefix . " does not appear to be a valid dataset!\n" ); |
353 | | - } |
354 | | - } |
355 | | - } |
356 | | - return $datasets; |
357 | | -} |
358 | | - |
359 | 275 | class DataSet { |
360 | 276 | |
361 | 277 | private $dataSetPrefix; |
Index: trunk/extensions/Wikidata/OmegaWiki/Search.php |
— | — | @@ -45,9 +45,7 @@ |
46 | 46 | function getSearchResultAsRecordSet( $queryResult ) { |
47 | 47 | |
48 | 48 | $o = OmegaWikiAttributes::getInstance(); |
49 | | - global |
50 | | - $definedMeaningReferenceType, |
51 | | - $wgDefinedMeaning; |
| 49 | + global $definedMeaningReferenceType ; |
52 | 50 | |
53 | 51 | $dbr = wfGetDB( DB_SLAVE ); |
54 | 52 | $spellingAttribute = new Attribute( "found-word", "Found word", "short-text" ); |
— | — | @@ -56,7 +54,7 @@ |
57 | 55 | $expressionStructure = new Structure( $spellingAttribute, $languageAttribute ); |
58 | 56 | $expressionAttribute = new Attribute( "expression", "Expression", $expressionStructure ); |
59 | 57 | |
60 | | - $definedMeaningAttribute = new Attribute( $wgDefinedMeaning, "Defined meaning", $definedMeaningReferenceType ); |
| 58 | + $definedMeaningAttribute = new Attribute( WD_DEFINED_MEANING, "Defined meaning", $definedMeaningReferenceType ); |
61 | 59 | $definitionAttribute = new Attribute( "definition", "Definition", "definition" ); |
62 | 60 | |
63 | 61 | $meaningStructure = new Structure( $definedMeaningAttribute, $definitionAttribute ); |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php |
— | — | @@ -294,7 +294,7 @@ |
295 | 295 | $linkValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor( $o->objectAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter ); |
296 | 296 | $translatedTextValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor( $o->objectAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter ); |
297 | 297 | $optionValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor( $o->objectAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter ); |
298 | | - |
| 298 | + |
299 | 299 | foreach ( $definedMeaningValueObjectAttributesEditors as $definedMeaningValueObjectAttributesEditor ) |
300 | 300 | addObjectAttributesEditors( $definedMeaningValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher( 0, $o->relationType ) ); |
301 | 301 | |
— | — | @@ -371,7 +371,6 @@ |
372 | 372 | |
373 | 373 | foreach ( $viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter ) { |
374 | 374 | $attribute = $propertyToColumnFilter->getAttribute(); |
375 | | - |
376 | 375 | $editor->addEditor( new PopUpEditor( |
377 | 376 | createDefinitionObjectAttributesEditor( |
378 | 377 | $viewInformation, |
— | — | @@ -385,7 +384,7 @@ |
386 | 385 | $attribute->name |
387 | 386 | ) ); |
388 | 387 | } |
389 | | - |
| 388 | + |
390 | 389 | $editor->addEditor( new PopUpEditor( |
391 | 390 | createDefinitionObjectAttributesEditor( $viewInformation, $o->objectAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), $o->definedMeaningId, $definitionMeaningName, $viewInformation->getLeftOverAttributeFilter() ), |
392 | 391 | wfMsgSc( "PopupAnnotation" ) |
— | — | @@ -440,7 +439,7 @@ |
441 | 440 | function addObjectAttributesEditors( ObjectAttributeValuesEditor $objectAttributesEditor, ViewInformation $viewInformation, ContextFetcher $annotatedObjectIdFetcher ) { |
442 | 441 | $attributeIDFilter = $objectAttributesEditor->getAttributeIDfilter(); |
443 | 442 | $annotationLevelName = $objectAttributesEditor->getLevelName(); |
444 | | - |
| 443 | + |
445 | 444 | $objectAttributesEditor->addEditor( getDefinedMeaningAttributeValuesEditor( $viewInformation, new DefinedMeaningAttributeValuesController( $annotatedObjectIdFetcher, $annotationLevelName, $attributeIDFilter ), $annotationLevelName, $attributeIDFilter ) ); |
446 | 445 | $objectAttributesEditor->addEditor( getTextAttributeValuesEditor( $viewInformation, new TextAttributeValuesController( $annotatedObjectIdFetcher, $annotationLevelName, $attributeIDFilter ), $annotationLevelName, $attributeIDFilter ) ); |
447 | 446 | $objectAttributesEditor->addEditor( getTranslatedTextAttributeValuesEditor( $viewInformation, new TranslatedTextAttributeValuesController( $annotatedObjectIdFetcher, $annotationLevelName, $attributeIDFilter, $viewInformation->filterLanguageId ), $annotationLevelName, $attributeIDFilter ) ); |
— | — | @@ -513,9 +512,9 @@ |
514 | 513 | $editor->addEditor( new LanguageEditor( $o->language, new SimplePermissionController( false ), true ) ); |
515 | 514 | $editor->addEditor( new SpellingEditor( $o->spelling, new SimplePermissionController( false ), true ) ); |
516 | 515 | } |
517 | | - else |
| 516 | + else { |
518 | 517 | $editor = new SpellingEditor( $attribute, new SimplePermissionController( false ), true ); |
519 | | - |
| 518 | + } |
520 | 519 | return $editor; |
521 | 520 | } |
522 | 521 | |
— | — | @@ -552,7 +551,8 @@ |
553 | 552 | $tableEditor->addEditor( new BooleanEditor( $o->identicalMeaning, new SimplePermissionController( true ), true, true ) ); |
554 | 553 | |
555 | 554 | addPropertyToColumnFilterEditors( $tableEditor, $viewInformation, $o->syntransId, $synTransMeaningName ); |
556 | | - |
| 555 | + |
| 556 | + // Add annotation editor on the rightmost column. |
557 | 557 | $tableEditor->addEditor( new PopUpEditor( |
558 | 558 | createObjectAttributesEditor( $viewInformation, $o->objectAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), $o->syntransId, $synTransMeaningName, $viewInformation->getLeftOverAttributeFilter() ), |
559 | 559 | wfMsgSc( "PopupAnnotation" ) |
— | — | @@ -663,8 +663,7 @@ |
664 | 664 | } |
665 | 665 | |
666 | 666 | function getLinkAttributeValuesEditor( ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, AttributeIDFilter $attributeIDFilter ) { |
667 | | - global |
668 | | - $linkValueObjectAttributesEditors; |
| 667 | + global $linkValueObjectAttributesEditors; |
669 | 668 | |
670 | 669 | $o = OmegaWikiAttributes::getInstance(); |
671 | 670 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialConceptMapping.php |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | |
53 | 53 | protected function ui() { |
54 | 54 | |
55 | | - global $wgOut, $wgRequest, $wgLang, $wgDefinedMeaning; |
| 55 | + global $wgOut, $wgRequest, $wgLang; |
56 | 56 | $lang = $wgLang->getCode(); |
57 | 57 | require_once( "forms.php" ); |
58 | 58 | $wgOut->addHTML( wfMsgSc( "conceptmapping_uitext" ) ); |
— | — | @@ -69,9 +69,9 @@ |
70 | 70 | if ( $rq[$set] ) { |
71 | 71 | $dmModel = new DefinedMeaningModel( $rq[$set], null, $setObject ); |
72 | 72 | $defaultSel = $dmModel->getSyntransByLanguageCode( $lang ); |
73 | | - $options[$setObject->fetchName()] = getSuggest( "set_$set", $wgDefinedMeaning, array(), $rq[$set], $defaultSel, array( 0 ), $setObject ); |
| 73 | + $options[$setObject->fetchName()] = getSuggest( "set_$set", WD_DEFINED_MEANING, array(), $rq[$set], $defaultSel, array( 0 ), $setObject ); |
74 | 74 | } else { |
75 | | - $options[$setObject->fetchName()] = getSuggest( "set_$set", $wgDefinedMeaning, array(), null, null, array( 0 ), $setObject ); |
| 75 | + $options[$setObject->fetchName()] = getSuggest( "set_$set", WD_DEFINED_MEANING, array(), null, null, array( 0 ), $setObject ); |
76 | 76 | } |
77 | 77 | |
78 | 78 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php |
— | — | @@ -80,8 +80,7 @@ |
81 | 81 | |
82 | 82 | |
83 | 83 | function fetchDefinedMeaningReferenceRecords( $sql, array &$definedMeaningIds, array &$definedMeaningReferenceRecords, $usedAs = '' ) { |
84 | | - global $wgDefinedMeaning ; |
85 | | - if ( $usedAs == '' ) $usedAs = $wgDefinedMeaning ; |
| 84 | + if ( $usedAs == '' ) $usedAs = WD_DEFINED_MEANING ; |
86 | 85 | $dc = wdGetDataSetContext(); |
87 | 86 | $o = OmegaWikiAttributes::getInstance(); |
88 | 87 | |
— | — | @@ -513,7 +512,7 @@ |
514 | 513 | |
515 | 514 | |
516 | 515 | function getClassAttributesRecordSet( $definedMeaningId, ViewInformation $viewInformation ) { |
517 | | - global $dataSet; |
| 516 | + global $wgWikidataDataSet; |
518 | 517 | |
519 | 518 | $o = OmegaWikiAttributes::getInstance(); |
520 | 519 | |
— | — | @@ -527,7 +526,7 @@ |
528 | 527 | new TableColumnsToAttribute( array( 'attribute_mid' ), $o->classAttributeAttribute ), |
529 | 528 | new TableColumnsToAttribute( array( 'attribute_type' ), $o->classAttributeType ) |
530 | 529 | ), |
531 | | - $dataSet->classAttributes, |
| 530 | + $wgWikidataDataSet->classAttributes, |
532 | 531 | array( "class_mid=$definedMeaningId" ) |
533 | 532 | ); |
534 | 533 | |
— | — | @@ -549,7 +548,7 @@ |
550 | 549 | } |
551 | 550 | |
552 | 551 | function getAlternativeDefinitionsRecordSet( $definedMeaningId, ViewInformation $viewInformation ) { |
553 | | - global $dataSet; |
| 552 | + global $wgWikidataDataSet; |
554 | 553 | |
555 | 554 | $o = OmegaWikiAttributes::getInstance(); |
556 | 555 | |
— | — | @@ -561,7 +560,7 @@ |
562 | 561 | new TableColumnsToAttribute( array( 'meaning_text_tcid' ), $o->definitionId ), |
563 | 562 | new TableColumnsToAttribute( array( 'source_id' ), $o->source ) |
564 | 563 | ), |
565 | | - $dataSet->alternativeDefinitions, |
| 564 | + $wgWikidataDataSet->alternativeDefinitions, |
566 | 565 | array( "meaning_mid=$definedMeaningId" ) |
567 | 566 | ); |
568 | 567 | |
— | — | @@ -703,7 +702,7 @@ |
704 | 703 | } |
705 | 704 | |
706 | 705 | function getTranslatedContentRecordSet( $translatedContentId, ViewInformation $viewInformation ) { |
707 | | - global $dataSet; |
| 706 | + global $wgWikidataDataSet; |
708 | 707 | |
709 | 708 | $o = OmegaWikiAttributes::getInstance(); |
710 | 709 | |
— | — | @@ -715,7 +714,7 @@ |
716 | 715 | new TableColumnsToAttribute( array( 'language_id' ), $o->language ), |
717 | 716 | new TableColumnsToAttribute( array( 'text_id' ), $o->text ) |
718 | 717 | ), |
719 | | - $dataSet->translatedContent, |
| 718 | + $wgWikidataDataSet->translatedContent, |
720 | 719 | array( "translated_content_id=$translatedContentId" ) |
721 | 720 | ); |
722 | 721 | |
— | — | @@ -725,7 +724,7 @@ |
726 | 725 | } |
727 | 726 | |
728 | 727 | function getFilteredTranslatedContentRecordSet( $translatedContentId, ViewInformation $viewInformation ) { |
729 | | - global $dataSet; |
| 728 | + global $wgWikidataDataSet; |
730 | 729 | |
731 | 730 | $o = OmegaWikiAttributes::getInstance(); |
732 | 731 | |
— | — | @@ -737,7 +736,7 @@ |
738 | 737 | new TableColumnsToAttribute( array( 'language_id' ), $o->language ), |
739 | 738 | new TableColumnsToAttribute( array( 'text_id' ), $o->text ) |
740 | 739 | ), |
741 | | - $dataSet->translatedContent, |
| 740 | + $wgWikidataDataSet->translatedContent, |
742 | 741 | array( |
743 | 742 | "translated_content_id=$translatedContentId", |
744 | 743 | "language_id=" . $viewInformation->filterLanguageId |
— | — | @@ -750,7 +749,7 @@ |
751 | 750 | } |
752 | 751 | |
753 | 752 | function getSynonymAndTranslationRecordSet( $definedMeaningId, ViewInformation $viewInformation ) { |
754 | | - global $dataSet; |
| 753 | + global $wgWikidataDataSet; |
755 | 754 | |
756 | 755 | $o = OmegaWikiAttributes::getInstance(); |
757 | 756 | $dc = wdGetDataSetContext(); |
— | — | @@ -775,7 +774,7 @@ |
776 | 775 | new TableColumnsToAttribute( array( 'expression_id' ), $o->expression ), |
777 | 776 | new TableColumnsToAttribute( array( 'identical_meaning' ), $o->identicalMeaning ) |
778 | 777 | ), |
779 | | - $dataSet->syntrans, |
| 778 | + $wgWikidataDataSet->syntrans, |
780 | 779 | $restrictions |
781 | 780 | ); |
782 | 781 | |
— | — | @@ -918,8 +917,7 @@ |
919 | 918 | } |
920 | 919 | |
921 | 920 | function getDefinedMeaningAttributeValuesRecordSet( array $objectIds, ViewInformation $viewInformation ) { |
922 | | - global |
923 | | - $dataSet; |
| 921 | + global $wgWikidataDataSet; |
924 | 922 | |
925 | 923 | $o = OmegaWikiAttributes::getInstance(); |
926 | 924 | |
— | — | @@ -932,7 +930,7 @@ |
933 | 931 | new TableColumnsToAttribute( array( 'relationtype_mid' ), $o->relationType ), |
934 | 932 | new TableColumnsToAttribute( array( 'meaning2_mid' ), $o->otherDefinedMeaning ) |
935 | 933 | ), |
936 | | - $dataSet->meaningRelations, |
| 934 | + $wgWikidataDataSet->meaningRelations, |
937 | 935 | array( "meaning1_mid IN (" . implode( ", ", $objectIds ) . ")" ), |
938 | 936 | array( 'add_transaction_id' ) |
939 | 937 | ); |
— | — | @@ -944,8 +942,7 @@ |
945 | 943 | } |
946 | 944 | |
947 | 945 | function getDefinedMeaningReciprocalRelationsRecordSet( $definedMeaningId, ViewInformation $viewInformation ) { |
948 | | - global |
949 | | - $dataSet; |
| 946 | + global $wgWikidataDataSet; |
950 | 947 | |
951 | 948 | $o = OmegaWikiAttributes::getInstance(); |
952 | 949 | $recordSet = queryRecordSet( |
— | — | @@ -957,7 +954,7 @@ |
958 | 955 | new TableColumnsToAttribute( array( 'relationtype_mid' ), $o->relationType ), |
959 | 956 | new TableColumnsToAttribute( array( 'meaning1_mid' ), $o->otherDefinedMeaning ) |
960 | 957 | ), |
961 | | - $dataSet->meaningRelations, |
| 958 | + $wgWikidataDataSet->meaningRelations, |
962 | 959 | array( "meaning2_mid=$definedMeaningId" ), |
963 | 960 | array( 'relationtype_mid' ) |
964 | 961 | ); |
— | — | @@ -980,7 +977,7 @@ |
981 | 978 | |
982 | 979 | function getDefinedMeaningCollectionMembershipRecordSet( $definedMeaningId, ViewInformation $viewInformation ) { |
983 | 980 | global |
984 | | - $dataSet; |
| 981 | + $wgWikidataDataSet; |
985 | 982 | |
986 | 983 | $o = OmegaWikiAttributes::getInstance(); |
987 | 984 | |
— | — | @@ -992,7 +989,7 @@ |
993 | 990 | new TableColumnsToAttribute( array( 'collection_id' ), $o->collectionId ), |
994 | 991 | new TableColumnsToAttribute( array( 'internal_member_id' ), $o->sourceIdentifier ) |
995 | 992 | ), |
996 | | - $dataSet->collectionMemberships, |
| 993 | + $wgWikidataDataSet->collectionMemberships, |
997 | 994 | array( "member_mid=$definedMeaningId" ) |
998 | 995 | ); |
999 | 996 | |
— | — | @@ -1013,7 +1010,7 @@ |
1014 | 1011 | |
1015 | 1012 | function getTextAttributesValuesRecordSet( array $objectIds, ViewInformation $viewInformation ) { |
1016 | 1013 | global |
1017 | | - $dataSet; |
| 1014 | + $wgWikidataDataSet; |
1018 | 1015 | |
1019 | 1016 | $o = OmegaWikiAttributes::getInstance(); |
1020 | 1017 | |
— | — | @@ -1027,7 +1024,7 @@ |
1028 | 1025 | new TableColumnsToAttribute( array( 'attribute_mid' ), $o->textAttribute ), |
1029 | 1026 | new TableColumnsToAttribute( array( 'text' ), $o->text ) |
1030 | 1027 | ), |
1031 | | - $dataSet->textAttributeValues, |
| 1028 | + $wgWikidataDataSet->textAttributeValues, |
1032 | 1029 | array( "object_id IN (" . implode( ", ", $objectIds ) . ")" ) |
1033 | 1030 | ); |
1034 | 1031 | |
— | — | @@ -1039,7 +1036,7 @@ |
1040 | 1037 | |
1041 | 1038 | function getLinkAttributeValuesRecordSet( array $objectIds, ViewInformation $viewInformation ) { |
1042 | 1039 | global |
1043 | | - $dataSet; |
| 1040 | + $wgWikidataDataSet; |
1044 | 1041 | |
1045 | 1042 | $o = OmegaWikiAttributes::getInstance(); |
1046 | 1043 | $recordSet = queryRecordSet( |
— | — | @@ -1052,7 +1049,7 @@ |
1053 | 1050 | new TableColumnsToAttribute( array( 'attribute_mid' ), $o->linkAttribute ), |
1054 | 1051 | new TableColumnsToAttribute( array( 'label', 'url' ), $o->link ) |
1055 | 1052 | ), |
1056 | | - $dataSet->linkAttributeValues, |
| 1053 | + $wgWikidataDataSet->linkAttributeValues, |
1057 | 1054 | array( "object_id IN (" . implode( ", ", $objectIds ) . ")" ) |
1058 | 1055 | ); |
1059 | 1056 | |
— | — | @@ -1064,7 +1061,7 @@ |
1065 | 1062 | |
1066 | 1063 | function getTranslatedTextAttributeValuesRecordSet( array $objectIds, ViewInformation $viewInformation ) { |
1067 | 1064 | global |
1068 | | - $dataSet; |
| 1065 | + $wgWikidataDataSet; |
1069 | 1066 | |
1070 | 1067 | $o = OmegaWikiAttributes::getInstance(); |
1071 | 1068 | |
— | — | @@ -1078,7 +1075,7 @@ |
1079 | 1076 | new TableColumnsToAttribute( array( 'attribute_mid' ), $o->translatedTextAttribute ), |
1080 | 1077 | new TableColumnsToAttribute( array( 'value_tcid' ), $o->translatedTextValueId ) |
1081 | 1078 | ), |
1082 | | - $dataSet->translatedContentAttributeValues, |
| 1079 | + $wgWikidataDataSet->translatedContentAttributeValues, |
1083 | 1080 | array( "object_id IN (" . implode( ", ", $objectIds ) . ")" ) |
1084 | 1081 | ); |
1085 | 1082 | |
— | — | @@ -1092,7 +1089,7 @@ |
1093 | 1090 | |
1094 | 1091 | function getOptionAttributeOptionsRecordSet( $attributeId, ViewInformation $viewInformation ) { |
1095 | 1092 | global |
1096 | | - $dataSet; |
| 1093 | + $wgWikidataDataSet; |
1097 | 1094 | |
1098 | 1095 | $o = OmegaWikiAttributes::getInstance(); |
1099 | 1096 | $recordSet = queryRecordSet( |
— | — | @@ -1105,7 +1102,7 @@ |
1106 | 1103 | new TableColumnsToAttribute( array( 'option_mid' ), $o->optionAttributeOption ), |
1107 | 1104 | new TableColumnsToAttribute( array( 'language_id' ), $o->language ) |
1108 | 1105 | ), |
1109 | | - $dataSet->optionAttributeOptions, |
| 1106 | + $wgWikidataDataSet->optionAttributeOptions, |
1110 | 1107 | array( 'attribute_id = ' . $attributeId ) |
1111 | 1108 | ); |
1112 | 1109 | |
— | — | @@ -1116,7 +1113,7 @@ |
1117 | 1114 | |
1118 | 1115 | function getOptionAttributeValuesRecordSet( array $objectIds, ViewInformation $viewInformation ) { |
1119 | 1116 | global |
1120 | | - $dataSet; |
| 1117 | + $wgWikidataDataSet; |
1121 | 1118 | |
1122 | 1119 | $o = OmegaWikiAttributes::getInstance(); |
1123 | 1120 | $recordSet = queryRecordSet( |
— | — | @@ -1128,7 +1125,7 @@ |
1129 | 1126 | new TableColumnsToAttribute( array( 'object_id' ), $o->optionAttributeObject ), |
1130 | 1127 | new TableColumnsToAttribute( array( 'option_id' ), $o->optionAttributeOptionId ) |
1131 | 1128 | ), |
1132 | | - $dataSet->optionAttributeValues, |
| 1129 | + $wgWikidataDataSet->optionAttributeValues, |
1133 | 1130 | array( "object_id IN (" . implode( ", ", $objectIds ) . ")" ) |
1134 | 1131 | ); |
1135 | 1132 | |
— | — | @@ -1142,7 +1139,7 @@ |
1143 | 1140 | /* XXX: This can probably be combined with other functions. In fact, it probably should be. Do it. */ |
1144 | 1141 | function expandOptionsInRecordSet( RecordSet $recordSet, ViewInformation $viewInformation ) { |
1145 | 1142 | global |
1146 | | - $dataSet; |
| 1143 | + $wgWikidataDataSet; |
1147 | 1144 | |
1148 | 1145 | $o = OmegaWikiAttributes::getInstance(); |
1149 | 1146 | |
— | — | @@ -1160,7 +1157,7 @@ |
1161 | 1158 | new TableColumnsToAttribute( array( 'attribute_id' ), $o->optionAttributeId ), |
1162 | 1159 | new TableColumnsToAttribute( array( 'option_mid' ), $o->optionAttributeOption ) |
1163 | 1160 | ), |
1164 | | - $dataSet->optionAttributeOptions, |
| 1161 | + $wgWikidataDataSet->optionAttributeOptions, |
1165 | 1162 | array( 'option_id = ' . $record->optionAttributeOptionId ) |
1166 | 1163 | ); |
1167 | 1164 | |
— | — | @@ -1172,7 +1169,7 @@ |
1173 | 1170 | $viewInformation->queryTransactionInformation, |
1174 | 1171 | $o->optionAttributeId, |
1175 | 1172 | new TableColumnsToAttributesMapping( new TableColumnsToAttribute( array( 'attribute_mid' ), $o->optionAttribute ) ), |
1176 | | - $dataSet->classAttributes, |
| 1173 | + $wgWikidataDataSet->classAttributes, |
1177 | 1174 | array( 'object_id = ' . $optionRecord->optionAttributeId ) |
1178 | 1175 | ); |
1179 | 1176 | |
— | — | @@ -1183,7 +1180,7 @@ |
1184 | 1181 | |
1185 | 1182 | function getDefinedMeaningClassMembershipRecordSet( $definedMeaningId, ViewInformation $viewInformation ) { |
1186 | 1183 | global |
1187 | | - $dataSet; |
| 1184 | + $wgWikidataDataSet; |
1188 | 1185 | |
1189 | 1186 | $o = OmegaWikiAttributes::getInstance(); |
1190 | 1187 | |
— | — | @@ -1195,7 +1192,7 @@ |
1196 | 1193 | new TableColumnsToAttribute( array( 'class_membership_id' ), $o->classMembershipId ), |
1197 | 1194 | new TableColumnsToAttribute( array( 'class_mid' ), $o->class ) |
1198 | 1195 | ), |
1199 | | - $dataSet->classMemberships, |
| 1196 | + $wgWikidataDataSet->classMemberships, |
1200 | 1197 | array( "class_member_mid=$definedMeaningId" ) |
1201 | 1198 | ); |
1202 | 1199 | |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWiki.php |
— | — | @@ -100,8 +100,7 @@ |
101 | 101 | } |
102 | 102 | |
103 | 103 | protected function getIdStack() { |
104 | | - global $wgExpression ; |
105 | | - return new IdStack( $wgExpression ); |
| 104 | + return new IdStack( WD_EXPRESSION ); |
106 | 105 | } |
107 | 106 | } |
108 | 107 | |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -221,13 +221,12 @@ |
222 | 222 | */ |
223 | 223 | protected function getIdStack( $definedMeaningId ) { |
224 | 224 | $o = OmegaWikiAttributes::getInstance(); |
225 | | - global $wgDefinedMeaning ; |
226 | 225 | |
227 | 226 | $definedMeaningIdStructure = new Structure( $o->definedMeaningId ); |
228 | 227 | $definedMeaningIdRecord = new ArrayRecord( $definedMeaningIdStructure, $definedMeaningIdStructure ); |
229 | 228 | $definedMeaningIdRecord->definedMeaningId = $definedMeaningId; |
230 | 229 | |
231 | | - $idStack = new IdStack( $wgDefinedMeaning ); |
| 230 | + $idStack = new IdStack( WD_DEFINED_MEANING ); |
232 | 231 | $idStack->pushKey( $definedMeaningIdRecord ); |
233 | 232 | |
234 | 233 | return $idStack; |
Index: trunk/extensions/Wikidata/OmegaWiki/type.php |
— | — | @@ -119,12 +119,11 @@ |
120 | 120 | } |
121 | 121 | |
122 | 122 | function convertToHTML( $value, $type ) { |
123 | | - global $wgDefinedMeaning; |
124 | 123 | switch( $type ) { |
125 | 124 | case "boolean": return booleanAsHTML( $value ); |
126 | 125 | case "spelling": return spellingAsLink( $value ); |
127 | 126 | case "collection": return collectionAsLink( $value ); |
128 | | - case "$wgDefinedMeaning": return definedMeaningAsLink( $value ); |
| 127 | + case WD_DEFINED_MEANING: return definedMeaningAsLink( $value ); |
129 | 128 | case "defining-expression": return definingExpressionAsLink( $value ); |
130 | 129 | case "relation-type": return definedMeaningAsLink( $value ); |
131 | 130 | case "attribute": return definedMeaningAsLink( $value ); |
— | — | @@ -136,14 +135,13 @@ |
137 | 136 | } |
138 | 137 | |
139 | 138 | function getInputFieldForType( $name, $type, $value ) { |
140 | | - global $wgDefinedMeaning; |
141 | 139 | switch( $type ) { |
142 | 140 | case "language": return getLanguageSelect( $name ); |
143 | 141 | case "spelling": return getTextBox( $name, $value ); |
144 | 142 | case "boolean": return getCheckBox( $name, $value ); |
145 | | - case "$wgDefinedMeaning": |
| 143 | + case WD_DEFINED_MEANING: |
146 | 144 | case "defining-expression": |
147 | | - return getSuggest( $name, $wgDefinedMeaning ); |
| 145 | + return getSuggest( $name, WD_DEFINED_MEANING ); |
148 | 146 | case "relation-type": return getSuggest( $name, "relation-type" ); |
149 | 147 | case "attribute": return getSuggest( $name, "attribute" ); |
150 | 148 | case "collection": return getSuggest( $name, "collection" ); |
— | — | @@ -153,12 +151,11 @@ |
154 | 152 | } |
155 | 153 | function getInputFieldValueForType( $name, $type ) { |
156 | 154 | global $wgRequest; |
157 | | - global $wgDefinedMeaning; |
158 | 155 | switch( $type ) { |
159 | 156 | case "language": return $wgRequest->getInt( $name ); |
160 | 157 | case "spelling": return trim( $wgRequest->getText( $name ) ); |
161 | 158 | case "boolean": return $wgRequest->getCheck( $name ); |
162 | | - case "$wgDefinedMeaning": |
| 159 | + case WD_DEFINED_MEANING: |
163 | 160 | case "defining-expression": |
164 | 161 | return $wgRequest->getInt( $name ); |
165 | 162 | case "relation-type": return $wgRequest->getInt( $name ); |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -1464,8 +1464,7 @@ |
1465 | 1465 | |
1466 | 1466 | class DefinedMeaningReferenceEditor extends SuggestEditor { |
1467 | 1467 | protected function suggestType() { |
1468 | | - global $wgDefinedMeaning; |
1469 | | - return $wgDefinedMeaning; |
| 1468 | + return WD_DEFINED_MEANING; |
1470 | 1469 | } |
1471 | 1470 | |
1472 | 1471 | public function getViewHTML( IdStack $idPath, $value ) { |
— | — | @@ -1603,8 +1602,7 @@ |
1604 | 1603 | |
1605 | 1604 | class DefinedMeaningAttributeEditor extends AttributeEditor { |
1606 | 1605 | protected function suggestType() { |
1607 | | - global $wgDefinedMeaningAttributes; |
1608 | | - return $wgDefinedMeaningAttributes; |
| 1606 | + return WD_DEFINED_MEANING_ATTRIBUTES; |
1609 | 1607 | } |
1610 | 1608 | } |
1611 | 1609 | |
— | — | @@ -1622,19 +1620,16 @@ |
1623 | 1621 | |
1624 | 1622 | class LinkAttributeEditor extends AttributeEditor { |
1625 | 1623 | protected function suggestType() { |
1626 | | - global $wgLinkAttribute; |
1627 | | - return $wgLinkAttribute; |
| 1624 | + return WD_LINK_ATTRIBUTE; |
1628 | 1625 | } |
1629 | 1626 | } |
1630 | 1627 | |
1631 | 1628 | class OptionAttributeEditor extends AttributeEditor { |
1632 | 1629 | protected function suggestType() { |
1633 | | - global $wgOptionAttribute; |
1634 | | - return $wgOptionAttribute; |
| 1630 | + return WD_OPTION_ATTRIBUTE; |
1635 | 1631 | } |
1636 | 1632 | |
1637 | 1633 | public function add( IdStack $idPath ) { |
1638 | | - global $wgOptionSuffix; |
1639 | 1634 | if ( $this->isAddField ) { |
1640 | 1635 | $syntransId = $idPath->getKeyStack()->peek( 0 )->syntransId; |
1641 | 1636 | if ( ! $syntransId ) $syntransId = 0 ; // in the case of a DM option attribute, there is no syntrans in the PathId |
— | — | @@ -1645,7 +1640,7 @@ |
1646 | 1641 | "definedMeaningId" => $idPath->getDefinedMeaningId(), |
1647 | 1642 | "syntransId" => $syntransId, |
1648 | 1643 | "annotationAttributeId" => $idPath->getAnnotationAttribute()->getId(), |
1649 | | - "onUpdate" => 'updateSelectOptions(\'' . $this->addId( $idPath->getId() ) . $wgOptionSuffix . '\',' . $syntransId |
| 1644 | + "onUpdate" => 'updateSelectOptions(\'' . $this->addId( $idPath->getId() ) . WD_OPTION_SUFFIX . '\',' . $syntransId |
1650 | 1645 | ); |
1651 | 1646 | return getSuggest( $this->addId( $idPath->getId() ), $this->suggestType(), $parameters ); |
1652 | 1647 | } |
— | — | @@ -1653,11 +1648,10 @@ |
1654 | 1649 | } |
1655 | 1650 | |
1656 | 1651 | public function getEditHTML( IdStack $idPath, $value ) { |
1657 | | - global $wgOptionSuffix; |
1658 | 1652 | // note: it is normal that the "updateSelectOptions(" has no closing parenthesis. An additional parameter and ')' is added by the function updateSuggestValue (suggest.js) |
1659 | 1653 | $parameters = array( |
1660 | 1654 | "level" => $this->attributesLevelName, |
1661 | | - "onUpdate" => 'updateSelectOptions(\'' . $this->updateId( $idPath->getId() ) . $wgOptionSuffix . '\'' |
| 1655 | + "onUpdate" => 'updateSelectOptions(\'' . $this->updateId( $idPath->getId() ) . WD_OPTION_SUFFIX . '\'' |
1662 | 1656 | ); |
1663 | 1657 | |
1664 | 1658 | return getSuggest( $this->updateId( $idPath->getId() ), $this->suggestType(), $parameters ); |
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataTables.php |
— | — | @@ -15,6 +15,8 @@ |
16 | 16 | * 3) Table: represents a specific table in the database, meant as a base class for specific tables |
17 | 17 | */ |
18 | 18 | |
| 19 | +require_once( "Wikidata.php" ); |
| 20 | + |
19 | 21 | interface DatabaseExpression { |
20 | 22 | public function toExpression(); |
21 | 23 | } |
— | — | @@ -332,7 +334,7 @@ |
333 | 335 | |
334 | 336 | public function __construct( $name ) { |
335 | 337 | parent::__construct( $name ); |
336 | | - |
| 338 | + |
337 | 339 | $this->objectId = $this->createColumn( "object_id" ); |
338 | 340 | $this->classMid = $this->createColumn( "class_mid" ); |
339 | 341 | $this->levelMid = $this->createColumn( "level_mid" ); |
— | — | @@ -732,13 +734,10 @@ |
733 | 735 | } |
734 | 736 | } |
735 | 737 | |
736 | | -global |
737 | | - $dataSet; |
| 738 | +global $wgWikidataDataSet; |
| 739 | +$wgWikidataDataSet = new WikiDataSet( wdGetDataSetContext() ); |
738 | 740 | |
739 | | -require_once( "Wikidata.php" ); |
740 | 741 | |
741 | | -$dataSet = new WikiDataSet( wdGetDataSetContext() ); |
742 | | - |
743 | 742 | function genericSelect( $selectCommand, array $expressions, array $tables, array $restrictions ) { |
744 | 743 | $result = $selectCommand . " " . $expressions[0]->toExpression(); |
745 | 744 | |
— | — | @@ -833,5 +832,3 @@ |
834 | 833 | function sqlAnd( $expression1, $expression2 ) { |
835 | 834 | return new DefaultDatabaseExpression( '(' . expressionToSQL( $expression1 ) . ') AND (' . expressionToSQL( $expression2 ) . ')' ); |
836 | 835 | } |
837 | | - |
838 | | -?> |
\ No newline at end of file |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | |
112 | 112 | public function history() { |
113 | 113 | global |
114 | | - $wgOut, $wgTitle, $wgDefinedMeaning ; |
| 114 | + $wgOut, $wgTitle ; |
115 | 115 | |
116 | 116 | parent::history(); |
117 | 117 | |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | $dmModel = new DefinedMeaningModel( $definedMeaningId, $this->viewInformation ); |
120 | 120 | $wgOut->addHTML( |
121 | 121 | getDefinedMeaningEditor( $this->viewInformation )->view( |
122 | | - new IdStack( $wgDefinedMeaning ), |
| 122 | + new IdStack( WD_DEFINED_MEANING ), |
123 | 123 | $dmModel->getRecord() |
124 | 124 | ) |
125 | 125 | ); |
— | — | @@ -147,13 +147,12 @@ |
148 | 148 | protected function getIdStack( $definedMeaningId ) { |
149 | 149 | |
150 | 150 | $o = OmegaWikiAttributes::getInstance(); |
151 | | - global $wgDefinedMeaning ; |
152 | 151 | |
153 | 152 | $definedMeaningIdStructure = new Structure( $o->definedMeaningId ); |
154 | 153 | $definedMeaningIdRecord = new ArrayRecord( $definedMeaningIdStructure, $definedMeaningIdStructure ); |
155 | 154 | $definedMeaningIdRecord->definedMeaningId = $definedMeaningId; |
156 | 155 | |
157 | | - $idStack = new IdStack( $wgDefinedMeaning ); |
| 156 | + $idStack = new IdStack( WD_DEFINED_MEANING ); |
158 | 157 | $idStack->pushKey( $definedMeaningIdRecord ); |
159 | 158 | |
160 | 159 | return $idStack; |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialDatasearch.php |
— | — | @@ -32,9 +32,7 @@ |
33 | 33 | |
34 | 34 | initializeOmegaWikiAttributes( new ViewInformation() ); |
35 | 35 | |
36 | | - global |
37 | | - $definedMeaningReferenceType, |
38 | | - $wgDefinedMeaning; |
| 36 | + global $definedMeaningReferenceType ; |
39 | 37 | |
40 | 38 | require_once( "WikiDataGlobals.php" ); |
41 | 39 | require_once( "forms.php" ); |
— | — | @@ -53,7 +51,7 @@ |
54 | 52 | $this->expressionStructure = new Structure( $this->spellingAttribute, $this->languageAttribute ); |
55 | 53 | $this->expressionAttribute = new Attribute( "expression", wfMsg( 'ow_Expression' ), $this->expressionStructure ); |
56 | 54 | |
57 | | - $this->definedMeaningAttribute = new Attribute( $wgDefinedMeaning, wfMsg( 'ow_DefinedMeaning' ), $definedMeaningReferenceType ); |
| 55 | + $this->definedMeaningAttribute = new Attribute( WD_DEFINED_MEANING, wfMsg( 'ow_DefinedMeaning' ), $definedMeaningReferenceType ); |
58 | 56 | $this->definitionAttribute = new Attribute( "definition", wfMsg( 'ow_Definition' ), "definition" ); |
59 | 57 | |
60 | 58 | $this->meaningStructure = new Structure( $this->definedMeaningAttribute, $this->definitionAttribute ); |
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php |
— | — | @@ -2,95 +2,65 @@ |
3 | 3 | |
4 | 4 | define( 'NS_EXPRESSION', 16 ); |
5 | 5 | define( 'NS_DEFINEDMEANING', 24 ); |
| 6 | +define( 'WD_ENGLISH_LANG_ID', 85 ); |
6 | 7 | |
7 | | -require_once( "Wikidata.php" ); |
| 8 | +// Achtung: the following defines should match the strings used in |
| 9 | +// the Javascript files |
| 10 | +define ( 'WD_ALTERNATIVE_DEF', "altDef" ); |
| 11 | +define ( 'WD_ALTERNATIVE_DEFINITIONS', "altDefs" ); |
| 12 | +define ( 'WD_CLASS_ATTRIBUTES', "classAtt" ); |
| 13 | +define ( 'WD_CLASS_MEMBERSHIP', "classMembers" ); |
| 14 | +define ( 'WD_COLLECTION_MEMBERSHIP', "colMembers" ); |
| 15 | +define ( 'WD_DEFINED_MEANING', "dm" ); |
| 16 | +define ( 'WD_DEFINED_MEANING_ATTRIBUTES', "dmAtt" ); |
| 17 | +define ( 'WD_DEFINITION', "def" ); |
| 18 | +define ( 'WD_EXPRESSION', "exp" ); |
| 19 | +define ( 'WD_EXPRESSION_APPROX_MEANINGS', "approx" ); |
| 20 | +define ( 'WD_EXPRESSION_EXACT_MEANINGS', "exact" ); |
| 21 | +define ( 'WD_EXPRESSION_MEANINGS', "meanings" ); |
| 22 | +define ( 'WD_INCOMING_RELATIONS', "incomingRel" ); |
| 23 | +define ( 'WD_LINK_ATTRIBUTE', "linkAtt" ); |
| 24 | +define ( 'WD_LINK_ATTRIBUTE_VALUES', "linkAttVal" ); |
| 25 | +define ( 'WD_OBJECT_ATTRIBUTES', "objAtt" ); |
| 26 | +define ( 'WD_OPTION_ATTRIBUTE', "optnAtt" ); |
| 27 | +define ( 'WD_OPTION_ATTRIBUTE_OPTION', "optnAttOptn" ); // WD_OPTION_ATTRIBUTE . WD_OPTION_SUFFIX |
| 28 | +define ( 'WD_OPTION_ATTRIBUTE_VALUES', "optnAttVal" ); // WD_OPTION_ATTRIBUTE . "Val" |
| 29 | +define ( 'WD_OPTION_SUFFIX', "Optn" ); |
| 30 | +define ( 'WD_OTHER_DEFINED_MEANING', "otherDm" ); |
| 31 | +define ( 'WD_RELATIONS', "rel" ); |
| 32 | +define ( 'WD_SYNONYMS_TRANSLATIONS', "syntrans" ); |
| 33 | +define ( 'WD_TEXT_ATTRIBUTES_VALUES', "txtAttVal" ); |
| 34 | +define ( 'WD_TRANSLATED_TEXT', "transl" ); |
8 | 35 | |
9 | | -// Ids |
10 | | -// Work in progress: (Kip) |
11 | | -// global variables here should be created for each Attribute in OmegaWikiAttributes.php |
12 | | -// sometimes, other php files have to be adapted... |
13 | 36 | |
14 | | -global $wgOptionSuffix; |
15 | | -$wgOptionSuffix = "Optn" ; |
| 37 | +require_once( "Wikidata.php" ); |
| 38 | +require_once( "GotoSourceTemplate.php" ); |
| 39 | +require_once( "PropertyToColumnFilter.php" ); |
16 | 40 | |
| 41 | +# Global context override. This is an evil hack to allow saving, basically. |
| 42 | +global $wdCurrentContext; |
| 43 | +$wdCurrentContext = null; |
17 | 44 | |
18 | | -global |
19 | | - $wgAlternativeDefinition, |
20 | | - $wgAlternativeDefinitions, |
21 | | - $wgClassAttributes, |
22 | | - $wgClassMembership, |
23 | | - $wgCollectionMembership, |
24 | | - $wgDefinedMeaning, |
25 | | - $wgDefinedMeaningAttributes, |
26 | | - $wgDefinition, |
27 | | - $wgExpression, |
28 | | - $wgExpressionApproximateMeanings, |
29 | | - $wgExpressionExactMeanings, |
30 | | - $wgExpressionMeanings, |
31 | | - $wgIncomingRelations, |
32 | | - $wgLinkAttribute, |
33 | | - $wgLinkAttributeValues, |
34 | | - $wgObjectAttributes, |
35 | | - $wgOptionAttribute, |
36 | | - $wgOptionAttributeOption, |
37 | | - $wgOptionAttributeValues, |
38 | | - $wgOtherDefinedMeaning, |
39 | | - $wgRelations, |
40 | | - $wgSynonymsAndTranslations, |
41 | | - $wgTextAttributeValues, |
42 | | - $wgTranslatedText; |
| 45 | +global $wgIso639_3CollectionId; |
| 46 | +$wgIso639_3CollectionId = null; |
43 | 47 | |
44 | | - |
45 | | - $wgAlternativeDefinition = "altDef"; |
46 | | - $wgAlternativeDefinitions = "altDefs"; |
47 | | - $wgClassAttributes = "classAtt"; |
48 | | - $wgClassMembership = "classMembers"; |
49 | | - $wgCollectionMembership = "colMembers"; |
50 | | - $wgDefinedMeaning = "dm"; |
51 | | - $wgDefinedMeaningAttributes = "dmAtt"; |
52 | | - $wgDefinition = "def"; |
53 | | - $wgExpression = "exp"; |
54 | | - $wgExpressionApproximateMeanings = "approx" ; |
55 | | - $wgExpressionExactMeanings = "exact" ; |
56 | | - $wgExpressionMeanings = "meanings"; |
57 | | - $wgIncomingRelations = "incomingRel"; |
58 | | - $wgLinkAttribute = "linkAtt"; |
59 | | - $wgLinkAttributeValues = $wgLinkAttribute."Val"; |
60 | | - $wgObjectAttributes = "objAtt"; |
61 | | - $wgOptionAttribute = "optnAtt"; // must be the same in suggest.js |
62 | | - $wgOptionAttributeOption = $wgOptionAttribute.$wgOptionSuffix; |
63 | | - $wgOptionAttributeValues = $wgOptionAttribute."Val"; |
64 | | - $wgOtherDefinedMeaning = "otherDm"; |
65 | | - $wgRelations = "rel"; |
66 | | - $wgSynonymsAndTranslations = "syntrans"; |
67 | | - $wgTextAttributeValues = "txtAttVal"; |
68 | | - $wgTranslatedText = "transl" ; |
69 | | - |
70 | | - |
71 | | - |
72 | 48 | // Defined meaning editor |
73 | | - |
74 | | -global |
75 | | - $wdDefinedMeaningAttributesOrder; |
| 49 | +global $wdDefinedMeaningAttributesOrder; |
76 | 50 | |
77 | 51 | $wdDefinedMeaningAttributesOrder = array( |
78 | | - $wgDefinition, |
79 | | - $wgClassAttributes, |
80 | | - $wgAlternativeDefinitions, |
81 | | - $wgSynonymsAndTranslations, |
82 | | - $wgIncomingRelations, |
83 | | - $wgClassMembership, |
84 | | - $wgCollectionMembership, |
85 | | - $wgDefinedMeaningAttributes |
| 52 | + WD_DEFINITION, |
| 53 | + WD_ALTERNATIVE_DEFINITIONS, |
| 54 | + WD_SYNONYMS_TRANSLATIONS, |
| 55 | + WD_DEFINED_MEANING_ATTRIBUTES, |
| 56 | + WD_CLASS_MEMBERSHIP, |
| 57 | + WD_CLASS_ATTRIBUTES, |
| 58 | + WD_COLLECTION_MEMBERSHIP, |
| 59 | + WD_INCOMING_RELATIONS |
86 | 60 | ); |
87 | 61 | |
88 | | -// Go to source templates |
89 | 62 | |
90 | | -require_once( "GotoSourceTemplate.php" ); |
| 63 | +global $wgGotoSourceTemplates; |
91 | 64 | |
92 | | -global |
93 | | - $wgGotoSourceTemplates; |
94 | | - |
95 | 65 | $wgGotoSourceTemplates = array(); // Map of collection id => GotoSourceTemplate |
96 | 66 | |
97 | 67 | // Page titles |
— | — | @@ -117,10 +87,6 @@ |
118 | 88 | $wgShowSearchWithinExternalIdentifiersOption = true; |
119 | 89 | $wgShowSearchWithinWordsOption = true; |
120 | 90 | |
121 | | -// Annotation to column filtering |
122 | | - |
123 | | -require_once( "PropertyToColumnFilter.php" ); |
124 | | - |
125 | 91 | global |
126 | 92 | $wgPropertyToColumnFilters; |
127 | 93 | |
— | — | @@ -135,6 +101,91 @@ |
136 | 102 | */ |
137 | 103 | $wgPropertyToColumnFilters = array(); |
138 | 104 | |
| 105 | + |
| 106 | + |
| 107 | +/** |
| 108 | +* A Wikidata application can manage multiple data sets. |
| 109 | +* The current "context" is dependent on multiple factors: |
| 110 | +* - the URL can have a dataset parameter |
| 111 | +* - there is a global default |
| 112 | +* - there can be defaults for different user groups |
| 113 | +* @param $dc optional, for convenience. |
| 114 | +* if the dataset context is already set, will |
| 115 | + return that value, else will find the relevant value |
| 116 | +* @return prefix (without underscore) |
| 117 | +**/ |
| 118 | +function wdGetDataSetContext( $dc = null ) { |
| 119 | + global $wgRequest, $wdDefaultViewDataSet, $wdGroupDefaultView, $wgUser, |
| 120 | + $wdCurrentContext; |
| 121 | + |
| 122 | + # overrides |
| 123 | + if ( !is_null( $dc ) ) |
| 124 | + return $dc; # local override |
| 125 | + if ( !is_null( $wdCurrentContext ) ) |
| 126 | + return $wdCurrentContext; # global override |
| 127 | + |
| 128 | + $datasets = wdGetDataSets(); |
| 129 | + $groups = $wgUser->getGroups(); |
| 130 | + $dbs = wfGetDB( DB_SLAVE ); |
| 131 | + $pref = $wgUser->getOption( 'ow_uipref_datasets' ); |
| 132 | + |
| 133 | + $trydefault = ''; |
| 134 | + foreach ( $groups as $group ) { |
| 135 | + if ( isset( $wdGroupDefaultView[$group] ) ) { |
| 136 | + # We don't know yet if this prefix is valid. |
| 137 | + $trydefault = $wdGroupDefaultView[$group]; |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + # URL parameter takes precedence over all else |
| 142 | + if ( ( $ds = $wgRequest->getText( 'dataset' ) ) && array_key_exists( $ds, $datasets ) && $dbs->tableExists( $ds . "_transactions" ) ) { |
| 143 | + return $datasets[$ds]; |
| 144 | + # User preference |
| 145 | + } elseif ( !empty( $pref ) && array_key_exists( $pref, $datasets ) ) { |
| 146 | + return $datasets[$pref]; |
| 147 | + } |
| 148 | + # Group preference |
| 149 | + elseif ( !empty( $trydefault ) && array_key_exists( $trydefault, $datasets ) ) { |
| 150 | + return $datasets[$trydefault]; |
| 151 | + } else { |
| 152 | + return $datasets[$wdDefaultViewDataSet]; |
| 153 | + } |
| 154 | +} |
| 155 | + |
| 156 | + |
| 157 | +/** |
| 158 | +* Load dataset definitions from the database if necessary. |
| 159 | +* |
| 160 | +* @return an array of all available datasets |
| 161 | +**/ |
| 162 | +function &wdGetDataSets() { |
| 163 | + |
| 164 | + static $datasets, $wgGroupPermissions; |
| 165 | + if ( empty( $datasets ) ) { |
| 166 | + // Load defs from the DB |
| 167 | + $dbs = wfGetDB( DB_SLAVE ); |
| 168 | + $res = $dbs->select( 'wikidata_sets', array( 'set_prefix' ) ); |
| 169 | + |
| 170 | + while ( $row = $dbs->fetchObject( $res ) ) { |
| 171 | + |
| 172 | + $dc = new DataSet(); |
| 173 | + $dc->setPrefix( $row->set_prefix ); |
| 174 | + if ( $dc->isValidPrefix() ) { |
| 175 | + $datasets[$row->set_prefix] = $dc; |
| 176 | + wfDebug( "Imported data set: " . $dc->fetchName() . "\n" ); |
| 177 | + } else { |
| 178 | + wfDebug( $row->set_prefix . " does not appear to be a valid dataset!\n" ); |
| 179 | + } |
| 180 | + } |
| 181 | + } |
| 182 | + return $datasets; |
| 183 | +} |
| 184 | + |
| 185 | + |
| 186 | + |
| 187 | + |
| 188 | + |
| 189 | + |
139 | 190 | // Hook: replace the proposition to "create new page" by a custom, allowing to create new expression as well |
140 | 191 | $wgHooks[ 'SpecialSearchNogomatch' ][] = 'owNoGoMatchHook'; |
141 | 192 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSelect.php |
— | — | @@ -13,12 +13,12 @@ |
14 | 14 | function execute( $par ) { |
15 | 15 | require_once( 'languages.php' ); |
16 | 16 | require_once( 'Transaction.php' ); |
17 | | - global $wgOut, $wgLang, $wgRequest, $wgOptionAttribute; |
| 17 | + global $wgOut, $wgLang, $wgRequest; |
18 | 18 | |
19 | 19 | $wgOut->disable(); |
20 | 20 | |
21 | 21 | $dc = wdGetDataSetContext(); |
22 | | - $optionAttribute = $wgRequest->getVal( $wgOptionAttribute ); |
| 22 | + $optionAttribute = $wgRequest->getVal( WD_OPTION_ATTRIBUTE ); |
23 | 23 | $attributeObject = $wgRequest->getVal( 'attribute-object' ); |
24 | 24 | $lang_code = $wgLang->getCode(); |
25 | 25 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php |
— | — | @@ -9,9 +9,7 @@ |
10 | 10 | } |
11 | 11 | |
12 | 12 | function execute( $par ) { |
13 | | - global $wgOut, $wgLang, $wgRequest, $IP, |
14 | | - $wgDefinedMeaning, $wgDefinedMeaningAttributes, |
15 | | - $wgOptionAttribute, $wgLinkAttribute; |
| 13 | + global $wgOut, $wgLang, $wgRequest, $IP; |
16 | 14 | |
17 | 15 | $wgOut->disable(); |
18 | 16 | require_once( "$IP/includes/Setup.php" ); |
— | — | @@ -55,7 +53,7 @@ |
56 | 54 | // so : not using it. The English fall back has been included in the SQL query |
57 | 55 | $sql = $this->getSQLForClasses( $langCode ); |
58 | 56 | break; |
59 | | - case $wgDefinedMeaningAttributes: |
| 57 | + case WD_DEFINED_MEANING_ATTRIBUTES: |
60 | 58 | $sql = $this->getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'DM' ); |
61 | 59 | break; |
62 | 60 | case 'text-attribute': |
— | — | @@ -64,10 +62,10 @@ |
65 | 63 | case 'translated-text-attribute': |
66 | 64 | $sql = $this->getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'TRNS' ); |
67 | 65 | break; |
68 | | - case $wgLinkAttribute: |
| 66 | + case WD_LINK_ATTRIBUTE: |
69 | 67 | $sql = $this->getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'URL' ); |
70 | 68 | break; |
71 | | - case $wgOptionAttribute: |
| 69 | + case WD_OPTION_ATTRIBUTE: |
72 | 70 | $sql = $this->getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'OPTN' ); |
73 | 71 | break; |
74 | 72 | case 'language': |
— | — | @@ -75,7 +73,7 @@ |
76 | 74 | $sql = getSQLForLanguageNames( $langCode ); |
77 | 75 | $rowText = 'language_name'; |
78 | 76 | break; |
79 | | - case $wgDefinedMeaning: |
| 77 | + case WD_DEFINED_MEANING: |
80 | 78 | $sql = |
81 | 79 | "SELECT {$dc}_syntrans.defined_meaning_id AS defined_meaning_id, {$dc}_expression.spelling AS spelling, {$dc}_expression.language_id AS language_id " . |
82 | 80 | " FROM {$dc}_expression, {$dc}_syntrans " . |
— | — | @@ -109,9 +107,9 @@ |
110 | 108 | elseif ( $query == 'class' ) { |
111 | 109 | $searchCondition = " AND $rowText LIKE " . $dbr->addQuotes( "$search%" ); |
112 | 110 | } |
113 | | - elseif ( $query == "$wgDefinedMeaningAttributes" or // should be 'relation-type' in html, there is a bug I cannot find |
114 | | - $query == "$wgLinkAttribute" or |
115 | | - $query == "$wgOptionAttribute" or |
| 111 | + elseif ( $query == WD_DEFINED_MEANING_ATTRIBUTES or // should be 'relation-type' in html, there is a bug I cannot find |
| 112 | + $query == WD_LINK_ATTRIBUTE or |
| 113 | + $query == WD_OPTION_ATTRIBUTE or |
116 | 114 | $query == 'translated-text-attribute' or |
117 | 115 | $query == 'text-attribute' ) |
118 | 116 | { |
— | — | @@ -159,7 +157,7 @@ |
160 | 158 | case 'class': |
161 | 159 | list( $recordSet, $editor ) = $this->getClassAsRecordSet( $queryResult ); |
162 | 160 | break; |
163 | | - case "$wgDefinedMeaningAttributes": |
| 161 | + case WD_DEFINED_MEANING_ATTRIBUTES: |
164 | 162 | list( $recordSet, $editor ) = $this->getDefinedMeaningAttributeAsRecordSet( $queryResult ); |
165 | 163 | break; |
166 | 164 | case 'text-attribute': |
— | — | @@ -168,13 +166,13 @@ |
169 | 167 | case 'translated-text-attribute': |
170 | 168 | list( $recordSet, $editor ) = $this->getTranslatedTextAttributeAsRecordSet( $queryResult ); |
171 | 169 | break; |
172 | | - case "$wgLinkAttribute": |
| 170 | + case WD_LINK_ATTRIBUTE: |
173 | 171 | list( $recordSet, $editor ) = $this->getLinkAttributeAsRecordSet( $queryResult ); |
174 | 172 | break; |
175 | | - case "$wgOptionAttribute": |
| 173 | + case WD_OPTION_ATTRIBUTE: |
176 | 174 | list( $recordSet, $editor ) = $this->getOptionAttributeAsRecordSet( $queryResult ); |
177 | 175 | break; |
178 | | - case "$wgDefinedMeaning": |
| 176 | + case WD_DEFINED_MEANING: |
179 | 177 | list( $recordSet, $editor ) = $this->getDefinedMeaningAsRecordSet( $queryResult ); |
180 | 178 | break; |
181 | 179 | case 'class-attributes-level': |
— | — | @@ -236,8 +234,7 @@ |
237 | 235 | * @param $language the 2 letter wikimedia code |
238 | 236 | */ |
239 | 237 | private function getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, $attributesType ) { |
240 | | - global $wgDefaultClassMids, $wgLang; |
241 | | - |
| 238 | + global $wgDefaultClassMids, $wgLang, $wgIso639_3CollectionId; |
242 | 239 | $dc = wdGetDataSetContext(); |
243 | 240 | $dbr = wfGetDB( DB_SLAVE ); |
244 | 241 | |
— | — | @@ -251,7 +248,7 @@ |
252 | 249 | |
253 | 250 | $classMids = $wgDefaultClassMids ; |
254 | 251 | |
255 | | - if ( $syntransId != 0 ) { |
| 252 | + if ( ( $syntransId != 0 ) && ( !is_null($wgIso639_3CollectionId)) ) { |
256 | 253 | // find the language of the syntrans and add attributes of that language by adding the language DM to the list of default classes |
257 | 254 | // this first query returns the language_id |
258 | 255 | $sql = 'SELECT language_id' . |
— | — | @@ -262,10 +259,9 @@ |
263 | 260 | $language_id = $dbr->fetchObject( $lang_res )->language_id; |
264 | 261 | |
265 | 262 | // this second query finds the DM number for a given language_id |
266 | | - // 145264 is the collection_id of the "ISO 639-3 codes" collection |
267 | 263 | $sql = "SELECT member_mid FROM {$dc}_collection_contents, language" . |
268 | 264 | " WHERE language.language_id = $language_id" . |
269 | | - " AND {$dc}_collection_contents.collection_id = 145264" . |
| 265 | + " AND {$dc}_collection_contents.collection_id = $wgIso639_3CollectionId" . |
270 | 266 | " AND language.iso639_3 = {$dc}_collection_contents.internal_member_id" . |
271 | 267 | ' AND ' . getLatestTransactionRestriction( "{$dc}_collection_contents" ) . |
272 | 268 | ' LIMIT 1 ' ; |
— | — | @@ -330,35 +326,38 @@ |
331 | 327 | |
332 | 328 | private function getPropertyToColumnFilterForAttribute( $annotationAttributeId ) { |
333 | 329 | global $wgPropertyToColumnFilters; |
334 | | - |
| 330 | + |
335 | 331 | $i = 0; |
336 | 332 | $result = null; |
337 | 333 | |
338 | | - while ( $result == null && $i < count( $wgPropertyToColumnFilters ) ) |
339 | | - if ( $wgPropertyToColumnFilters[$i]->getAttribute()->id == $annotationAttributeId ) |
| 334 | + while ( $result == null && $i < count( $wgPropertyToColumnFilters ) ) { |
| 335 | + if ( $wgPropertyToColumnFilters[$i]->getAttribute()->id == $annotationAttributeId ) { |
340 | 336 | $result = $wgPropertyToColumnFilters[$i]; |
341 | | - else |
| 337 | + } else { |
342 | 338 | $i++; |
343 | | - |
| 339 | + } |
| 340 | + } |
344 | 341 | return $result; |
345 | 342 | } |
346 | 343 | |
347 | 344 | private function getFilteredAttributes( $annotationAttributeId ) { |
348 | 345 | $propertyToColumnFilter = $this->getPropertyToColumnFilterForAttribute( $annotationAttributeId ); |
349 | 346 | |
350 | | - if ( $propertyToColumnFilter != null ) |
| 347 | + if ( $propertyToColumnFilter != null ) { |
351 | 348 | return $propertyToColumnFilter->attributeIDs; |
352 | | - else |
| 349 | + } else { |
353 | 350 | return array(); |
| 351 | + } |
354 | 352 | } |
355 | 353 | |
356 | 354 | private function getAllFilteredAttributes() { |
357 | 355 | global $wgPropertyToColumnFilters; |
358 | 356 | |
359 | 357 | $result = array(); |
360 | | - |
361 | | - foreach ( $wgPropertyToColumnFilters as $propertyToColumnFilter ) |
| 358 | + |
| 359 | + foreach ( $wgPropertyToColumnFilters as $propertyToColumnFilter ) { |
362 | 360 | $result = array_merge( $result, $propertyToColumnFilter->attributeIDs ); |
| 361 | + } |
363 | 362 | |
364 | 363 | return $result; |
365 | 364 | } |
— | — | @@ -371,18 +370,20 @@ |
372 | 371 | if ( $propertyToColumnFilter != null ) { |
373 | 372 | $filteredAttributes = $propertyToColumnFilter->attributeIDs; |
374 | 373 | |
375 | | - if ( count( $filteredAttributes ) > 0 ) |
| 374 | + if ( count( $filteredAttributes ) > 0 ) { |
376 | 375 | $result = " AND {$dc}_class_attributes.attribute_mid IN (" . join( $filteredAttributes, ", " ) . ")"; |
377 | | - else |
| 376 | + } else { |
378 | 377 | $result = " AND 0 "; |
| 378 | + } |
379 | 379 | } |
380 | 380 | else { |
381 | 381 | $allFilteredAttributes = $this->getAllFilteredAttributes(); |
382 | 382 | |
383 | | - if ( count( $allFilteredAttributes ) > 0 ) |
| 383 | + if ( count( $allFilteredAttributes ) > 0 ) { |
384 | 384 | $result = " AND {$dc}_class_attributes.attribute_mid NOT IN (" . join( $allFilteredAttributes, ", " ) . ")"; |
385 | | - else |
| 385 | + } else { |
386 | 386 | $result = ""; |
| 387 | + } |
387 | 388 | } |
388 | 389 | |
389 | 390 | return $result; |
— | — | @@ -484,18 +485,18 @@ |
485 | 486 | } |
486 | 487 | |
487 | 488 | private function getSQLForLevels( $language = "<ANY>" ) { |
488 | | - global $classAttributeLevels, $dataSet; |
| 489 | + global $classAttributeLevels, $wgWikidataDataSet; |
489 | 490 | |
490 | 491 | $o = OmegaWikiAttributes::getInstance(); |
491 | 492 | // TO DO: Add support for multiple languages here |
492 | 493 | return |
493 | 494 | selectLatest( |
494 | | - array( $dataSet->bootstrappedDefinedMeanings->definedMeaningId, $dataSet->expression->spelling ), |
495 | | - array( $dataSet->definedMeaning, $dataSet->expression, $dataSet->bootstrappedDefinedMeanings ), |
| 495 | + array( $wgWikidataDataSet->bootstrappedDefinedMeanings->definedMeaningId, $wgWikidataDataSet->expression->spelling ), |
| 496 | + array( $wgWikidataDataSet->definedMeaning, $wgWikidataDataSet->expression, $wgWikidataDataSet->bootstrappedDefinedMeanings ), |
496 | 497 | array( |
497 | 498 | 'name IN (' . implodeFixed( $classAttributeLevels ) . ')', |
498 | | - equals( $dataSet->definedMeaning->definedMeaningId, $dataSet->bootstrappedDefinedMeanings->definedMeaningId ), |
499 | | - equals( $dataSet->definedMeaning->expressionId, $dataSet->expression->expressionId ) |
| 499 | + equals( $wgWikidataDataSet->definedMeaning->definedMeaningId, $wgWikidataDataSet->bootstrappedDefinedMeanings->definedMeaningId ), |
| 500 | + equals( $wgWikidataDataSet->definedMeaning->expressionId, $wgWikidataDataSet->expression->expressionId ) |
500 | 501 | ) |
501 | 502 | ); |
502 | 503 | } |
— | — | @@ -550,13 +551,11 @@ |
551 | 552 | } |
552 | 553 | |
553 | 554 | private function getDefinedMeaningAttributeAsRecordSet( $queryResult ) { |
554 | | - global $wgDefinedMeaningAttributes; |
555 | | - |
556 | 555 | $o = OmegaWikiAttributes::getInstance(); |
557 | 556 | |
558 | 557 | $dbr = wfGetDB( DB_SLAVE ); |
559 | 558 | |
560 | | - $definedMeaningAttributeAttribute = new Attribute( $wgDefinedMeaningAttributes, wfMsgSc( "DefinedMeaningAttributes" ), "short-text" ); |
| 559 | + $definedMeaningAttributeAttribute = new Attribute( WD_DEFINED_MEANING_ATTRIBUTES, wfMsgSc( "DefinedMeaningAttributes" ), "short-text" ); |
561 | 560 | $recordSet = new ArrayRecordSet( new Structure( $o->id, $definedMeaningAttributeAttribute ), new Structure( $o->id ) ); |
562 | 561 | |
563 | 562 | while ( $row = $dbr->fetchObject( $queryResult ) ) |
— | — | @@ -587,13 +586,11 @@ |
588 | 587 | } |
589 | 588 | |
590 | 589 | private function getLinkAttributeAsRecordSet( $queryResult ) { |
591 | | - global $wgLinkAttribute; |
592 | | - |
593 | 590 | $o = OmegaWikiAttributes::getInstance(); |
594 | 591 | |
595 | 592 | $dbr = wfGetDB( DB_SLAVE ); |
596 | 593 | |
597 | | - $linkAttributeAttribute = new Attribute( $wgLinkAttribute, wfMsg( 'ow_LinkAttributeHeader' ), "short-text" ); |
| 594 | + $linkAttributeAttribute = new Attribute( WD_LINK_ATTRIBUTE, wfMsg( 'ow_LinkAttributeHeader' ), "short-text" ); |
598 | 595 | $recordSet = new ArrayRecordSet( new Structure( $o->id, $linkAttributeAttribute ), new Structure( $o->id ) ); |
599 | 596 | |
600 | 597 | while ( $row = $dbr->fetchObject( $queryResult ) ) |
— | — | @@ -624,13 +621,11 @@ |
625 | 622 | } |
626 | 623 | |
627 | 624 | private function getOptionAttributeAsRecordSet( $queryResult ) { |
628 | | - global $wgOptionAttribute; |
629 | | - |
630 | 625 | $o = OmegaWikiAttributes::getInstance(); |
631 | 626 | |
632 | 627 | $dbr = wfGetDB( DB_SLAVE ); |
633 | 628 | |
634 | | - $optionAttributeAttribute = new Attribute( $wgOptionAttribute, wfMsg( 'ow_OptionAttributeHeader' ), "short-text" ); |
| 629 | + $optionAttributeAttribute = new Attribute( WD_OPTION_ATTRIBUTE, wfMsg( 'ow_OptionAttributeHeader' ), "short-text" ); |
635 | 630 | $recordSet = new ArrayRecordSet( new Structure( $o->id, $optionAttributeAttribute ), new Structure( $o->id ) ); |
636 | 631 | |
637 | 632 | while ( $row = $dbr->fetchObject( $queryResult ) ) |
— | — | @@ -643,15 +638,13 @@ |
644 | 639 | } |
645 | 640 | |
646 | 641 | private function getDefinedMeaningAsRecordSet( $queryResult ) { |
647 | | - global $wgDefinedMeaning ; |
648 | | - |
649 | 642 | $o = OmegaWikiAttributes::getInstance(); |
650 | 643 | |
651 | 644 | $dbr = wfGetDB( DB_SLAVE ); |
652 | 645 | $spellingAttribute = new Attribute( "spelling", wfMsg( 'ow_Spelling' ), "short-text" ); |
653 | 646 | $languageAttribute = new Attribute( "language", wfMsg( 'ow_Language' ), "language" ); |
654 | 647 | |
655 | | - $expressionStructure = new Structure( $wgDefinedMeaning, $spellingAttribute, $languageAttribute ); |
| 648 | + $expressionStructure = new Structure( WD_DEFINED_MEANING, $spellingAttribute, $languageAttribute ); |
656 | 649 | $definedMeaningAttribute = new Attribute( null, wfMsg( 'ow_DefinedMeaning' ), $expressionStructure ); |
657 | 650 | $definitionAttribute = new Attribute( "definition", wfMsg( 'ow_Definition' ), "definition" ); |
658 | 651 | |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php |
— | — | @@ -93,34 +93,16 @@ |
94 | 94 | $t->spelling = new Attribute( "spelling", wfMsgSc( "Spelling" ), "spelling" ); |
95 | 95 | $t->text = new Attribute( "text", wfMsgSc( "Text" ), "text" ); |
96 | 96 | |
97 | | - global |
98 | | - $wgAlternativeDefinition, $wgAlternativeDefinitions, |
99 | | - $wgClassAttributes, |
100 | | - $wgClassMembership, |
101 | | - $wgCollectionMembership, |
102 | | - $wgDefinedMeaning, $wgDefinedMeaningAttributes, |
103 | | - $wgDefinition, |
104 | | - $wgExpression, $wgExpressionApproximateMeanings, $wgExpressionExactMeanings, $wgExpressionMeanings, |
105 | | - $wgIncomingRelations, |
106 | | - $wgLinkAttribute, $wgLinkAttributeValues, |
107 | | - $wgObjectAttributes, |
108 | | - $wgOptionAttribute, $wgOptionAttributeOption, $wgOptionAttributeValues, |
109 | | - $wgOtherDefinedMeaning, |
110 | | - $wgRelations, |
111 | | - $wgSynonymsAndTranslations, |
112 | | - $wgTextAttributeValues, |
113 | | - $wgTranslatedText; |
114 | | - |
115 | | - $t->definedMeaningAttributes = new Attribute( $wgDefinedMeaningAttributes, wfMsgSc( "DefinedMeaningAttributes" ), "will-be-specified-below" ); |
116 | | - $t->objectAttributes = new Attribute( $wgObjectAttributes, wfMsgSc( "Annotation" ), "will-be-specified-below" ); |
| 97 | + $t->definedMeaningAttributes = new Attribute( WD_DEFINED_MEANING_ATTRIBUTES, wfMsgSc( "DefinedMeaningAttributes" ), "will-be-specified-below" ); |
| 98 | + $t->objectAttributes = new Attribute( WD_OBJECT_ATTRIBUTES, wfMsgSc( "Annotation" ), "will-be-specified-below" ); |
117 | 99 | $t->expressionId = new Attribute( "expression-id", "Expression Id", "expression-id" ); |
118 | 100 | $t->identicalMeaning = new Attribute( "identMeaning", wfMsgSc( "IdenticalMeaning" ), "boolean" ); |
119 | 101 | |
120 | | - if ( $viewInformation->filterOnLanguage() ) |
121 | | - $t->expression = new Attribute( $wgExpression, wfMsgSc( "Spelling" ), "spelling" ); |
122 | | - else { |
123 | | - $t->expressionStructure = new Structure( $wgExpression, $t->language, $t->spelling ); |
124 | | - $t->expression = new Attribute( $wgExpression, wfMsgSc( "Expression" ), $t->expressionStructure ); |
| 102 | + if ( $viewInformation->filterOnLanguage() ) { |
| 103 | + $t->expression = new Attribute( WD_EXPRESSION, wfMsgSc( "Spelling" ), "spelling" ); |
| 104 | + } else { |
| 105 | + $t->expressionStructure = new Structure( WD_EXPRESSION, $t->language, $t->spelling ); |
| 106 | + $t->expression = new Attribute( WD_EXPRESSION, wfMsgSc( "Expression" ), $t->expressionStructure ); |
125 | 107 | } |
126 | 108 | |
127 | 109 | $t->definedMeaningId = new Attribute( "defined-meaning-id", "Defined meaning identifier", "defined-meaning-id" ); |
— | — | @@ -132,13 +114,13 @@ |
133 | 115 | $t->language |
134 | 116 | ); |
135 | 117 | # try this |
136 | | - $t->definedMeaningCompleteDefiningExpressionStructure->setStructureType( $wgExpression ); |
| 118 | + $t->definedMeaningCompleteDefiningExpressionStructure->setStructureType( WD_EXPRESSION ); |
137 | 119 | $t->definedMeaningCompleteDefiningExpression = new Attribute( null, "Defining expression", $t->definedMeaningCompleteDefiningExpressionStructure ); |
138 | 120 | |
139 | 121 | global $definedMeaningReferenceType; |
140 | 122 | |
141 | 123 | $t->definedMeaningLabel = new Attribute( "defined-meaning-label", "Defined meaning label", "short-text" ); |
142 | | - $t->definedMeaningReferenceStructure = new Structure( $wgDefinedMeaning, $t->definedMeaningId, $t->definedMeaningLabel, $t->definedMeaningDefiningExpression ); |
| 124 | + $t->definedMeaningReferenceStructure = new Structure( WD_DEFINED_MEANING, $t->definedMeaningId, $t->definedMeaningLabel, $t->definedMeaningDefiningExpression ); |
143 | 125 | $definedMeaningReferenceType = $t->definedMeaningReferenceStructure; |
144 | 126 | $t->definedMeaningReference = new Attribute( null, wfMsgSc( "DefinedMeaningReference" ), $definedMeaningReferenceType ); |
145 | 127 | $t->collectionId = new Attribute( "collection", "Collection", "collection-id" ); |
— | — | @@ -147,36 +129,36 @@ |
148 | 130 | $t->gotoSourceStructure = new Structure( "goto-source", $t->collectionId, $t->sourceIdentifier ); |
149 | 131 | $t->gotoSource = new Attribute( null, wfMsgSc( "GotoSource" ), $t->gotoSourceStructure ); |
150 | 132 | |
151 | | - $t->collectionMembershipStructure = new Structure( $wgCollectionMembership, $t->collectionId, $t->collectionMeaning, $t->sourceIdentifier ); |
| 133 | + $t->collectionMembershipStructure = new Structure( WD_COLLECTION_MEMBERSHIP, $t->collectionId, $t->collectionMeaning, $t->sourceIdentifier ); |
152 | 134 | $t->collectionMembership = new Attribute( null, wfMsgSc( "CollectionMembership" ), $t->collectionMembershipStructure ); |
153 | 135 | |
154 | 136 | $t->classMembershipId = new Attribute( "class-membership-id", "Class membership id", "integer" ); |
155 | 137 | $t->class = new Attribute( "class", wfMsg( 'ow_Class' ), $t->definedMeaningReferenceStructure ); |
156 | | - $t->classMembershipStructure = new Structure( $wgClassMembership, $t->classMembershipId, $t->class ); |
| 138 | + $t->classMembershipStructure = new Structure( WD_CLASS_MEMBERSHIP, $t->classMembershipId, $t->class ); |
157 | 139 | $t->classMembership = new Attribute( null, wfMsgSc( "ClassMembership" ), $t->classMembershipStructure ); |
158 | 140 | |
159 | 141 | global $relationTypeType; |
160 | 142 | |
161 | 143 | $t->relationId = new Attribute( "relation-id", "Relation identifier", "object-id" ); |
162 | 144 | $t->relationType = new Attribute( "relation-type", wfMsgSc( "RelationType" ), $t->definedMeaningReferenceStructure ); |
163 | | - $t->otherDefinedMeaning = new Attribute( $wgOtherDefinedMeaning, wfMsgSc( "OtherDefinedMeaning" ), $definedMeaningReferenceType ); |
| 145 | + $t->otherDefinedMeaning = new Attribute( WD_OTHER_DEFINED_MEANING, wfMsgSc( "OtherDefinedMeaning" ), $definedMeaningReferenceType ); |
164 | 146 | |
165 | | - $t->relationStructure = new Structure( $wgRelations, $t->relationId, $t->relationType, $t->otherDefinedMeaning ); |
166 | | - $t->relations = new Attribute( $wgRelations, wfMsgSc( "Relations" ), $t->relationStructure ); |
167 | | - $t->reciprocalRelations = new Attribute( $wgIncomingRelations, wfMsgSc( "IncomingRelations" ), $t->relationStructure ); |
| 147 | + $t->relationStructure = new Structure( WD_RELATIONS, $t->relationId, $t->relationType, $t->otherDefinedMeaning ); |
| 148 | + $t->relations = new Attribute( WD_RELATIONS, wfMsgSc( "Relations" ), $t->relationStructure ); |
| 149 | + $t->reciprocalRelations = new Attribute( WD_INCOMING_RELATIONS, wfMsgSc( "IncomingRelations" ), $t->relationStructure ); |
168 | 150 | $t->translatedTextId = new Attribute( "translated-text-id", "Translated text ID", "integer" ); |
169 | | - $t->translatedTextStructure = new Structure( $wgTranslatedText, $t->language, $t->text ); |
| 151 | + $t->translatedTextStructure = new Structure( WD_TRANSLATED_TEXT, $t->language, $t->text ); |
170 | 152 | |
171 | 153 | $t->definitionId = new Attribute( "definition-id", "Definition identifier", "integer" ); |
172 | 154 | |
173 | | - if ( $viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes() ) |
174 | | - $t->alternativeDefinition = new Attribute( $wgAlternativeDefinition, wfMsgSc( "AlternativeDefinition" ), "text" ); |
175 | | - else |
176 | | - $t->alternativeDefinition = new Attribute( $wgAlternativeDefinition, wfMsgSc( "AlternativeDefinition" ), $t->translatedTextStructure ); |
177 | | - |
| 155 | + if ( $viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes() ) { |
| 156 | + $t->alternativeDefinition = new Attribute( WD_ALTERNATIVE_DEF, wfMsgSc( "AlternativeDefinition" ), "text" ); |
| 157 | + } else { |
| 158 | + $t->alternativeDefinition = new Attribute( WD_ALTERNATIVE_DEF, wfMsgSc( "AlternativeDefinition" ), $t->translatedTextStructure ); |
| 159 | + } |
178 | 160 | $t->source = new Attribute( "source-id", wfMsgSc( "Source" ), $definedMeaningReferenceType ); |
179 | 161 | |
180 | | - $t->alternativeDefinitionsStructure = new Structure( $wgAlternativeDefinitions, $t->definitionId, $t->alternativeDefinition, $t->source ); |
| 162 | + $t->alternativeDefinitionsStructure = new Structure( WD_ALTERNATIVE_DEFINITIONS, $t->definitionId, $t->alternativeDefinition, $t->source ); |
181 | 163 | $t->alternativeDefinitions = new Attribute( null, wfMsgSc( "AlternativeDefinitions" ), $t->alternativeDefinitionsStructure ); |
182 | 164 | |
183 | 165 | if ( $viewInformation->filterOnLanguage() ) |
— | — | @@ -185,7 +167,7 @@ |
186 | 168 | $synonymsAndTranslationsCaption = wfMsgSc( "SynonymsAndTranslations" ); |
187 | 169 | |
188 | 170 | $t->syntransId = new Attribute( "syntrans-id", "$synonymsAndTranslationsCaption identifier", "integer" ); |
189 | | - $t->synonymsTranslationsStructure = new Structure( $wgSynonymsAndTranslations, $t->syntransId, $t->expression, $t->identicalMeaning ); |
| 171 | + $t->synonymsTranslationsStructure = new Structure( WD_SYNONYMS_TRANSLATIONS, $t->syntransId, $t->expression, $t->identicalMeaning ); |
190 | 172 | $t->synonymsAndTranslations = new Attribute( null, "$synonymsAndTranslationsCaption", $t->synonymsTranslationsStructure ); |
191 | 173 | $t->translatedTextAttributeId = new Attribute( "translated-text-attribute-id", "Attribute identifier", "object-id" ); |
192 | 174 | $t->translatedTextAttribute = new Attribute( "translated-text-attribute", wfMsgSc( "TranslatedTextAttribute" ), $definedMeaningReferenceType ); |
— | — | @@ -205,7 +187,7 @@ |
206 | 188 | $t->textAttributeId = new Attribute( "text-attribute-id", "Attribute identifier", "object-id" ); |
207 | 189 | $t->textAttributeObject = new Attribute( "text-attribute-object-id", "Attribute object", "object-id" ); |
208 | 190 | $t->textAttribute = new Attribute( "text-attribute", wfMsgSc( "TextAttribute" ), $t->definedMeaningReferenceStructure ); |
209 | | - $t->textAttributeValuesStructure = new Structure( $wgTextAttributeValues, $t->textAttributeId, $t->textAttributeObject, $t->textAttribute, $t->text ); |
| 191 | + $t->textAttributeValuesStructure = new Structure( WD_TEXT_ATTRIBUTES_VALUES, $t->textAttributeId, $t->textAttributeObject, $t->textAttribute, $t->text ); |
210 | 192 | $t->textAttributeValues = new Attribute( null, wfMsgSc( "TextAttributeValues" ), $t->textAttributeValuesStructure ); |
211 | 193 | |
212 | 194 | $t->linkLabel = new Attribute( "label", wfMsg( 'ow_Label' ), "short-text" ); |
— | — | @@ -213,38 +195,38 @@ |
214 | 196 | $t->link = new Attribute( "link", wfMsg( 'ow_Link' ), new Structure( $t->linkLabel, $t->linkURL ) ); |
215 | 197 | $t->linkAttributeId = new Attribute( "link-attribute-id", "Attribute identifier", "object-id" ); |
216 | 198 | $t->linkAttributeObject = new Attribute( "link-attribute-object-id", "Attribute object", "object-id" ); |
217 | | - $t->linkAttribute = new Attribute( $wgLinkAttribute, wfMsgSc( "LinkAttribute" ), $t->definedMeaningReferenceStructure ); |
218 | | - $t->linkAttributeValuesStructure = new Structure( $wgLinkAttributeValues, $t->linkAttributeId, $t->linkAttributeObject, $t->linkAttribute, $t->link ); |
| 199 | + $t->linkAttribute = new Attribute( WD_LINK_ATTRIBUTE, wfMsgSc( "LinkAttribute" ), $t->definedMeaningReferenceStructure ); |
| 200 | + $t->linkAttributeValuesStructure = new Structure( WD_LINK_ATTRIBUTE_VALUES, $t->linkAttributeId, $t->linkAttributeObject, $t->linkAttribute, $t->link ); |
219 | 201 | $t->linkAttributeValues = new Attribute( null, wfMsgSc( "LinkAttributeValues" ), $t->linkAttributeValuesStructure ); |
220 | 202 | |
221 | 203 | $t->optionAttributeId = new Attribute( "option-attribute-id", "Attribute identifier", "object-id" ); |
222 | 204 | $t->optionAttributeObject = new Attribute( "option-attribute-object-id", "Attribute object", "object-id" ); |
223 | | - $t->optionAttribute = new Attribute( $wgOptionAttribute, wfMsgSc( "OptionAttribute" ), $definedMeaningReferenceType ); |
224 | | - $t->optionAttributeOption = new Attribute( $wgOptionAttributeOption, wfMsgSc( "OptionAttributeOption" ), $definedMeaningReferenceType ); |
225 | | - $t->optionAttributeValuesStructure = new Structure( $wgOptionAttributeValues, $t->optionAttributeId, $t->optionAttribute, $t->optionAttributeObject, $t->optionAttributeOption ); |
| 205 | + $t->optionAttribute = new Attribute( WD_OPTION_ATTRIBUTE, wfMsgSc( "OptionAttribute" ), $definedMeaningReferenceType ); |
| 206 | + $t->optionAttributeOption = new Attribute( WD_OPTION_ATTRIBUTE_OPTION, wfMsgSc( "OptionAttributeOption" ), $definedMeaningReferenceType ); |
| 207 | + $t->optionAttributeValuesStructure = new Structure( WD_OPTION_ATTRIBUTE_VALUES, $t->optionAttributeId, $t->optionAttribute, $t->optionAttributeObject, $t->optionAttributeOption ); |
226 | 208 | $t->optionAttributeValues = new Attribute( null, wfMsgSc( "OptionAttributeValues" ), $t->optionAttributeValuesStructure ); |
227 | 209 | $t->optionAttributeOptionId = new Attribute( "option-attribute-option-id", "Option identifier", "object-id" ); |
228 | 210 | $t->optionAttributeOptionsStructure = new Structure( "option-attribute-options", $t->optionAttributeOptionId, $t->optionAttribute, $t->optionAttributeOption, $t->language ); |
229 | 211 | $t->optionAttributeOptions = new Attribute( null, wfMsgSc( "OptionAttributeOptions" ), $t->optionAttributeOptionsStructure ); |
230 | 212 | |
231 | | - if ( $viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes() ) |
232 | | - $t->translatedText = new Attribute( $wgTranslatedText, wfMsgSc( "Text" ), "text" ); |
233 | | - else |
234 | | - $t->translatedText = new Attribute( $wgTranslatedText, wfMsgSc( "TranslatedText" ), $t->translatedTextStructure ); |
235 | | - |
| 213 | + if ( $viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes() ) { |
| 214 | + $t->translatedText = new Attribute( WD_TRANSLATED_TEXT, wfMsgSc( "Text" ), "text" ); |
| 215 | + } else { |
| 216 | + $t->translatedText = new Attribute( WD_TRANSLATED_TEXT, wfMsgSc( "TranslatedText" ), $t->translatedTextStructure ); |
| 217 | + } |
236 | 218 | |
237 | | - $t->definition = new Attribute( null, wfMsgSc( "Definition" ), new Structure( $wgDefinition, $t->translatedText ) ); |
| 219 | + $t->definition = new Attribute( null, wfMsgSc( "Definition" ), new Structure( WD_DEFINITION, $t->translatedText ) ); |
238 | 220 | |
239 | 221 | $t->classAttributeId = new Attribute( "class-attribute-id", "Class attribute identifier", "object-id" ); |
240 | 222 | $t->classAttributeAttribute = new Attribute( "class-attribute-attribute", wfMsgSc( "ClassAttributeAttribute" ), $t->definedMeaningReferenceStructure ); |
241 | 223 | $t->classAttributeLevel = new Attribute( "class-attribute-level", wfMsgSc( "ClassAttributeLevel" ), $t->definedMeaningReferenceStructure ); |
242 | 224 | $t->classAttributeType = new Attribute( "class-attribute-type", wfMsgSc( "ClassAttributeType" ), "short-text" ); |
243 | | - $t->classAttributesStructure = new Structure( $wgClassAttributes, $t->classAttributeId, $t->classAttributeAttribute, $t->classAttributeLevel, $t->classAttributeType, $t->optionAttributeOptions ); |
| 225 | + $t->classAttributesStructure = new Structure( WD_CLASS_ATTRIBUTES, $t->classAttributeId, $t->classAttributeAttribute, $t->classAttributeLevel, $t->classAttributeType, $t->optionAttributeOptions ); |
244 | 226 | $t->classAttributes = new Attribute( null, wfMsgSc( "ClassAttributes" ), $t->classAttributesStructure ); |
245 | 227 | |
246 | 228 | $t->definedMeaning = new Attribute( null, wfMsgSc( "DefinedMeaning" ), |
247 | 229 | new Structure( |
248 | | - $wgDefinedMeaning, |
| 230 | + WD_DEFINED_MEANING, |
249 | 231 | $t->definedMeaningId, |
250 | 232 | $t->definedMeaningCompleteDefiningExpression, |
251 | 233 | $t->definition, |
— | — | @@ -259,9 +241,9 @@ |
260 | 242 | ); |
261 | 243 | |
262 | 244 | $t->expressionMeaningStructure = new Structure( $t->definedMeaningId, $t->text, $t->definedMeaning ); |
263 | | - $t->expressionExactMeanings = new Attribute( $wgExpressionExactMeanings, wfMsgSc( "ExactMeanings" ), $t->expressionMeaningStructure ); |
264 | | - $t->expressionApproximateMeanings = new Attribute( $wgExpressionApproximateMeanings, wfMsgSc( "ApproximateMeanings" ), $t->expressionMeaningStructure ); |
265 | | - $t->expressionMeaningsStructure = new Structure( $wgExpressionMeanings, $t->expressionExactMeanings, $t->expressionApproximateMeanings ); |
| 245 | + $t->expressionExactMeanings = new Attribute( WD_EXPRESSION_EXACT_MEANINGS, wfMsgSc( "ExactMeanings" ), $t->expressionMeaningStructure ); |
| 246 | + $t->expressionApproximateMeanings = new Attribute( WD_EXPRESSION_APPROX_MEANINGS, wfMsgSc( "ApproximateMeanings" ), $t->expressionMeaningStructure ); |
| 247 | + $t->expressionMeaningsStructure = new Structure( WD_EXPRESSION_MEANINGS, $t->expressionExactMeanings, $t->expressionApproximateMeanings ); |
266 | 248 | $t->expressionMeanings = new Attribute( null, wfMsgSc( "ExpressionMeanings" ), $t->expressionMeaningsStructure ); |
267 | 249 | $t->expressionsStructure = new Structure( "expressions", $t->expressionId, $t->expression, $t->expressionMeanings ); |
268 | 250 | $t->expressions = new Attribute( null, wfMsgSc( "Expressions" ), $t->expressionsStructure ); |