r113057 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113056‎ | r113057 | r113058 >
Date:18:15, 5 March 2012
Author:kipcool
Status:deferred
Tags:
Comment:
changed global variables to defines ;
made Iso 639-3 collection id configurable and optional ;
renamed $dataset to $wgWikidataDataSet
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Editor.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWiki.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Search.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialConceptMapping.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialDatasearch.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialSelect.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataTables.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Wikidata.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/type.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php
@@ -231,21 +231,16 @@
232232 }
233233
234234 function expressionIsBoundToDefinedMeaning( $definedMeaningId, $expressionId ) {
235 - global $dataSet;
236 -
237235 $dc = wdGetDataSetContext();
238236 $dbr = wfGetDB( DB_SLAVE );
239237
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 );
250245
251246 return $dbr->numRows( $queryResult ) > 0;
252247 }
@@ -407,6 +402,7 @@
408403 function classAttributeExists( $classMeaningId, $levelMeaningId, $attributeMeaningId, $attributeType ) {
409404 $dc = wdGetDataSetContext();
410405 $dbr = wfGetDB( DB_SLAVE );
 406+
411407 $queryResult = $dbr->query( "SELECT object_id FROM {$dc}_class_attributes" .
412408 " WHERE class_mid=$classMeaningId AND level_mid=$levelMeaningId AND attribute_mid=$attributeMeaningId AND attribute_type = " . $dbr->addQuotes( $attributeType ) .
413409 ' AND ' . getLatestTransactionRestriction( "{$dc}_class_attributes" ) . " LIMIT 1" );
@@ -432,6 +428,7 @@
433429 function getClassAttributeId( $classMeaningId, $levelMeaningId, $attributeMeaningId, $attributeType ) {
434430 $dc = wdGetDataSetContext();
435431 $dbr = wfGetDB( DB_SLAVE );
 432+
436433 $queryResult = $dbr->query( "SELECT object_id FROM {$dc}_class_attributes " .
437434 "WHERE class_mid=$classMeaningId AND level_mid =$levelMeaningId AND attribute_mid=$attributeMeaningId AND attribute_type = " . $dbr->addQuotes( $attributeType ) );
438435
@@ -1166,6 +1163,10 @@
11671164
11681165 }
11691166
 1167+/**
 1168+ * Returns true if the concept corresponding to the
 1169+ * definedMeaningID $objectId is a class
 1170+ */
11701171 function isClass( $objectId ) {
11711172 global $wgDefaultClassMids;
11721173
@@ -1178,13 +1179,13 @@
11791180 "SELECT {$dc}_collection.collection_id " .
11801181 " FROM ({$dc}_collection_contents INNER JOIN {$dc}_collection ON {$dc}_collection.collection_id = {$dc}_collection_contents.collection_id) " .
11811182 " 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" ;
11841185 $queryResult = $dbr->query( $query );
11851186
11861187 $result = $dbr->numRows( $queryResult ) > 0;
11871188 }
1188 -
 1189+
11891190 return $result;
11901191 }
11911192
@@ -1205,15 +1206,15 @@
12061207 }
12071208
12081209 function getCollectionContents( $collectionId ) {
1209 - global $dataSet;
 1210+ global $wgWikidataDataSet;
12101211
12111212 $dc = wdGetDataSetContext();
12121213 $dbr = & wfGetDB( DB_SLAVE );
12131214 $queryResult = $dbr->query(
12141215 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 ) )
12181219 )
12191220 );
12201221
@@ -1775,33 +1776,52 @@
17761777 $dc = wdGetDataSetContext();
17771778 $dbr = wfGetDB( DB_SLAVE );
17781779
1779 - global
1780 - $wgDefaultClassMids, $dataSet;
 1780+ global $wgDefaultClassMids, $wgWikidataDataSet;
17811781
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 )
18021801 )
18031802 )
1804 - );
 1803+ ) ;
18051804
 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+
18061826 $this->classAttributes = array();
18071827
18081828 while ( $row = $dbr->fetchRow( $queryResult ) ) {
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php
@@ -23,8 +23,7 @@
2424 protected $showDataSetPanel = false;
2525
2626 public function __construct() {
27 - global
28 - $wgFilterLanguageId,
 27+ global $wgFilterLanguageId,
2928 $wgShowClassicPageTitles,
3029 $wgPropertyToColumnFilters;
3130
@@ -269,92 +268,9 @@
270269
271270 return $wgTitle->getText();
272271 }
273 -
274272 }
275273
276274
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 -
359275 class DataSet {
360276
361277 private $dataSetPrefix;
Index: trunk/extensions/Wikidata/OmegaWiki/Search.php
@@ -45,9 +45,7 @@
4646 function getSearchResultAsRecordSet( $queryResult ) {
4747
4848 $o = OmegaWikiAttributes::getInstance();
49 - global
50 - $definedMeaningReferenceType,
51 - $wgDefinedMeaning;
 49+ global $definedMeaningReferenceType ;
5250
5351 $dbr = wfGetDB( DB_SLAVE );
5452 $spellingAttribute = new Attribute( "found-word", "Found word", "short-text" );
@@ -56,7 +54,7 @@
5755 $expressionStructure = new Structure( $spellingAttribute, $languageAttribute );
5856 $expressionAttribute = new Attribute( "expression", "Expression", $expressionStructure );
5957
60 - $definedMeaningAttribute = new Attribute( $wgDefinedMeaning, "Defined meaning", $definedMeaningReferenceType );
 58+ $definedMeaningAttribute = new Attribute( WD_DEFINED_MEANING, "Defined meaning", $definedMeaningReferenceType );
6159 $definitionAttribute = new Attribute( "definition", "Definition", "definition" );
6260
6361 $meaningStructure = new Structure( $definedMeaningAttribute, $definitionAttribute );
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php
@@ -294,7 +294,7 @@
295295 $linkValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor( $o->objectAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter );
296296 $translatedTextValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor( $o->objectAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter );
297297 $optionValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor( $o->objectAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter );
298 -
 298+
299299 foreach ( $definedMeaningValueObjectAttributesEditors as $definedMeaningValueObjectAttributesEditor )
300300 addObjectAttributesEditors( $definedMeaningValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher( 0, $o->relationType ) );
301301
@@ -371,7 +371,6 @@
372372
373373 foreach ( $viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter ) {
374374 $attribute = $propertyToColumnFilter->getAttribute();
375 -
376375 $editor->addEditor( new PopUpEditor(
377376 createDefinitionObjectAttributesEditor(
378377 $viewInformation,
@@ -385,7 +384,7 @@
386385 $attribute->name
387386 ) );
388387 }
389 -
 388+
390389 $editor->addEditor( new PopUpEditor(
391390 createDefinitionObjectAttributesEditor( $viewInformation, $o->objectAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), $o->definedMeaningId, $definitionMeaningName, $viewInformation->getLeftOverAttributeFilter() ),
392391 wfMsgSc( "PopupAnnotation" )
@@ -440,7 +439,7 @@
441440 function addObjectAttributesEditors( ObjectAttributeValuesEditor $objectAttributesEditor, ViewInformation $viewInformation, ContextFetcher $annotatedObjectIdFetcher ) {
442441 $attributeIDFilter = $objectAttributesEditor->getAttributeIDfilter();
443442 $annotationLevelName = $objectAttributesEditor->getLevelName();
444 -
 443+
445444 $objectAttributesEditor->addEditor( getDefinedMeaningAttributeValuesEditor( $viewInformation, new DefinedMeaningAttributeValuesController( $annotatedObjectIdFetcher, $annotationLevelName, $attributeIDFilter ), $annotationLevelName, $attributeIDFilter ) );
446445 $objectAttributesEditor->addEditor( getTextAttributeValuesEditor( $viewInformation, new TextAttributeValuesController( $annotatedObjectIdFetcher, $annotationLevelName, $attributeIDFilter ), $annotationLevelName, $attributeIDFilter ) );
447446 $objectAttributesEditor->addEditor( getTranslatedTextAttributeValuesEditor( $viewInformation, new TranslatedTextAttributeValuesController( $annotatedObjectIdFetcher, $annotationLevelName, $attributeIDFilter, $viewInformation->filterLanguageId ), $annotationLevelName, $attributeIDFilter ) );
@@ -513,9 +512,9 @@
514513 $editor->addEditor( new LanguageEditor( $o->language, new SimplePermissionController( false ), true ) );
515514 $editor->addEditor( new SpellingEditor( $o->spelling, new SimplePermissionController( false ), true ) );
516515 }
517 - else
 516+ else {
518517 $editor = new SpellingEditor( $attribute, new SimplePermissionController( false ), true );
519 -
 518+ }
520519 return $editor;
521520 }
522521
@@ -552,7 +551,8 @@
553552 $tableEditor->addEditor( new BooleanEditor( $o->identicalMeaning, new SimplePermissionController( true ), true, true ) );
554553
555554 addPropertyToColumnFilterEditors( $tableEditor, $viewInformation, $o->syntransId, $synTransMeaningName );
556 -
 555+
 556+ // Add annotation editor on the rightmost column.
557557 $tableEditor->addEditor( new PopUpEditor(
558558 createObjectAttributesEditor( $viewInformation, $o->objectAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), $o->syntransId, $synTransMeaningName, $viewInformation->getLeftOverAttributeFilter() ),
559559 wfMsgSc( "PopupAnnotation" )
@@ -663,8 +663,7 @@
664664 }
665665
666666 function getLinkAttributeValuesEditor( ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, AttributeIDFilter $attributeIDFilter ) {
667 - global
668 - $linkValueObjectAttributesEditors;
 667+ global $linkValueObjectAttributesEditors;
669668
670669 $o = OmegaWikiAttributes::getInstance();
671670
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialConceptMapping.php
@@ -51,7 +51,7 @@
5252
5353 protected function ui() {
5454
55 - global $wgOut, $wgRequest, $wgLang, $wgDefinedMeaning;
 55+ global $wgOut, $wgRequest, $wgLang;
5656 $lang = $wgLang->getCode();
5757 require_once( "forms.php" );
5858 $wgOut->addHTML( wfMsgSc( "conceptmapping_uitext" ) );
@@ -69,9 +69,9 @@
7070 if ( $rq[$set] ) {
7171 $dmModel = new DefinedMeaningModel( $rq[$set], null, $setObject );
7272 $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 );
7474 } 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 );
7676 }
7777
7878 }
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php
@@ -80,8 +80,7 @@
8181
8282
8383 function fetchDefinedMeaningReferenceRecords( $sql, array &$definedMeaningIds, array &$definedMeaningReferenceRecords, $usedAs = '' ) {
84 - global $wgDefinedMeaning ;
85 - if ( $usedAs == '' ) $usedAs = $wgDefinedMeaning ;
 84+ if ( $usedAs == '' ) $usedAs = WD_DEFINED_MEANING ;
8685 $dc = wdGetDataSetContext();
8786 $o = OmegaWikiAttributes::getInstance();
8887
@@ -513,7 +512,7 @@
514513
515514
516515 function getClassAttributesRecordSet( $definedMeaningId, ViewInformation $viewInformation ) {
517 - global $dataSet;
 516+ global $wgWikidataDataSet;
518517
519518 $o = OmegaWikiAttributes::getInstance();
520519
@@ -527,7 +526,7 @@
528527 new TableColumnsToAttribute( array( 'attribute_mid' ), $o->classAttributeAttribute ),
529528 new TableColumnsToAttribute( array( 'attribute_type' ), $o->classAttributeType )
530529 ),
531 - $dataSet->classAttributes,
 530+ $wgWikidataDataSet->classAttributes,
532531 array( "class_mid=$definedMeaningId" )
533532 );
534533
@@ -549,7 +548,7 @@
550549 }
551550
552551 function getAlternativeDefinitionsRecordSet( $definedMeaningId, ViewInformation $viewInformation ) {
553 - global $dataSet;
 552+ global $wgWikidataDataSet;
554553
555554 $o = OmegaWikiAttributes::getInstance();
556555
@@ -561,7 +560,7 @@
562561 new TableColumnsToAttribute( array( 'meaning_text_tcid' ), $o->definitionId ),
563562 new TableColumnsToAttribute( array( 'source_id' ), $o->source )
564563 ),
565 - $dataSet->alternativeDefinitions,
 564+ $wgWikidataDataSet->alternativeDefinitions,
566565 array( "meaning_mid=$definedMeaningId" )
567566 );
568567
@@ -703,7 +702,7 @@
704703 }
705704
706705 function getTranslatedContentRecordSet( $translatedContentId, ViewInformation $viewInformation ) {
707 - global $dataSet;
 706+ global $wgWikidataDataSet;
708707
709708 $o = OmegaWikiAttributes::getInstance();
710709
@@ -715,7 +714,7 @@
716715 new TableColumnsToAttribute( array( 'language_id' ), $o->language ),
717716 new TableColumnsToAttribute( array( 'text_id' ), $o->text )
718717 ),
719 - $dataSet->translatedContent,
 718+ $wgWikidataDataSet->translatedContent,
720719 array( "translated_content_id=$translatedContentId" )
721720 );
722721
@@ -725,7 +724,7 @@
726725 }
727726
728727 function getFilteredTranslatedContentRecordSet( $translatedContentId, ViewInformation $viewInformation ) {
729 - global $dataSet;
 728+ global $wgWikidataDataSet;
730729
731730 $o = OmegaWikiAttributes::getInstance();
732731
@@ -737,7 +736,7 @@
738737 new TableColumnsToAttribute( array( 'language_id' ), $o->language ),
739738 new TableColumnsToAttribute( array( 'text_id' ), $o->text )
740739 ),
741 - $dataSet->translatedContent,
 740+ $wgWikidataDataSet->translatedContent,
742741 array(
743742 "translated_content_id=$translatedContentId",
744743 "language_id=" . $viewInformation->filterLanguageId
@@ -750,7 +749,7 @@
751750 }
752751
753752 function getSynonymAndTranslationRecordSet( $definedMeaningId, ViewInformation $viewInformation ) {
754 - global $dataSet;
 753+ global $wgWikidataDataSet;
755754
756755 $o = OmegaWikiAttributes::getInstance();
757756 $dc = wdGetDataSetContext();
@@ -775,7 +774,7 @@
776775 new TableColumnsToAttribute( array( 'expression_id' ), $o->expression ),
777776 new TableColumnsToAttribute( array( 'identical_meaning' ), $o->identicalMeaning )
778777 ),
779 - $dataSet->syntrans,
 778+ $wgWikidataDataSet->syntrans,
780779 $restrictions
781780 );
782781
@@ -918,8 +917,7 @@
919918 }
920919
921920 function getDefinedMeaningAttributeValuesRecordSet( array $objectIds, ViewInformation $viewInformation ) {
922 - global
923 - $dataSet;
 921+ global $wgWikidataDataSet;
924922
925923 $o = OmegaWikiAttributes::getInstance();
926924
@@ -932,7 +930,7 @@
933931 new TableColumnsToAttribute( array( 'relationtype_mid' ), $o->relationType ),
934932 new TableColumnsToAttribute( array( 'meaning2_mid' ), $o->otherDefinedMeaning )
935933 ),
936 - $dataSet->meaningRelations,
 934+ $wgWikidataDataSet->meaningRelations,
937935 array( "meaning1_mid IN (" . implode( ", ", $objectIds ) . ")" ),
938936 array( 'add_transaction_id' )
939937 );
@@ -944,8 +942,7 @@
945943 }
946944
947945 function getDefinedMeaningReciprocalRelationsRecordSet( $definedMeaningId, ViewInformation $viewInformation ) {
948 - global
949 - $dataSet;
 946+ global $wgWikidataDataSet;
950947
951948 $o = OmegaWikiAttributes::getInstance();
952949 $recordSet = queryRecordSet(
@@ -957,7 +954,7 @@
958955 new TableColumnsToAttribute( array( 'relationtype_mid' ), $o->relationType ),
959956 new TableColumnsToAttribute( array( 'meaning1_mid' ), $o->otherDefinedMeaning )
960957 ),
961 - $dataSet->meaningRelations,
 958+ $wgWikidataDataSet->meaningRelations,
962959 array( "meaning2_mid=$definedMeaningId" ),
963960 array( 'relationtype_mid' )
964961 );
@@ -980,7 +977,7 @@
981978
982979 function getDefinedMeaningCollectionMembershipRecordSet( $definedMeaningId, ViewInformation $viewInformation ) {
983980 global
984 - $dataSet;
 981+ $wgWikidataDataSet;
985982
986983 $o = OmegaWikiAttributes::getInstance();
987984
@@ -992,7 +989,7 @@
993990 new TableColumnsToAttribute( array( 'collection_id' ), $o->collectionId ),
994991 new TableColumnsToAttribute( array( 'internal_member_id' ), $o->sourceIdentifier )
995992 ),
996 - $dataSet->collectionMemberships,
 993+ $wgWikidataDataSet->collectionMemberships,
997994 array( "member_mid=$definedMeaningId" )
998995 );
999996
@@ -1013,7 +1010,7 @@
10141011
10151012 function getTextAttributesValuesRecordSet( array $objectIds, ViewInformation $viewInformation ) {
10161013 global
1017 - $dataSet;
 1014+ $wgWikidataDataSet;
10181015
10191016 $o = OmegaWikiAttributes::getInstance();
10201017
@@ -1027,7 +1024,7 @@
10281025 new TableColumnsToAttribute( array( 'attribute_mid' ), $o->textAttribute ),
10291026 new TableColumnsToAttribute( array( 'text' ), $o->text )
10301027 ),
1031 - $dataSet->textAttributeValues,
 1028+ $wgWikidataDataSet->textAttributeValues,
10321029 array( "object_id IN (" . implode( ", ", $objectIds ) . ")" )
10331030 );
10341031
@@ -1039,7 +1036,7 @@
10401037
10411038 function getLinkAttributeValuesRecordSet( array $objectIds, ViewInformation $viewInformation ) {
10421039 global
1043 - $dataSet;
 1040+ $wgWikidataDataSet;
10441041
10451042 $o = OmegaWikiAttributes::getInstance();
10461043 $recordSet = queryRecordSet(
@@ -1052,7 +1049,7 @@
10531050 new TableColumnsToAttribute( array( 'attribute_mid' ), $o->linkAttribute ),
10541051 new TableColumnsToAttribute( array( 'label', 'url' ), $o->link )
10551052 ),
1056 - $dataSet->linkAttributeValues,
 1053+ $wgWikidataDataSet->linkAttributeValues,
10571054 array( "object_id IN (" . implode( ", ", $objectIds ) . ")" )
10581055 );
10591056
@@ -1064,7 +1061,7 @@
10651062
10661063 function getTranslatedTextAttributeValuesRecordSet( array $objectIds, ViewInformation $viewInformation ) {
10671064 global
1068 - $dataSet;
 1065+ $wgWikidataDataSet;
10691066
10701067 $o = OmegaWikiAttributes::getInstance();
10711068
@@ -1078,7 +1075,7 @@
10791076 new TableColumnsToAttribute( array( 'attribute_mid' ), $o->translatedTextAttribute ),
10801077 new TableColumnsToAttribute( array( 'value_tcid' ), $o->translatedTextValueId )
10811078 ),
1082 - $dataSet->translatedContentAttributeValues,
 1079+ $wgWikidataDataSet->translatedContentAttributeValues,
10831080 array( "object_id IN (" . implode( ", ", $objectIds ) . ")" )
10841081 );
10851082
@@ -1092,7 +1089,7 @@
10931090
10941091 function getOptionAttributeOptionsRecordSet( $attributeId, ViewInformation $viewInformation ) {
10951092 global
1096 - $dataSet;
 1093+ $wgWikidataDataSet;
10971094
10981095 $o = OmegaWikiAttributes::getInstance();
10991096 $recordSet = queryRecordSet(
@@ -1105,7 +1102,7 @@
11061103 new TableColumnsToAttribute( array( 'option_mid' ), $o->optionAttributeOption ),
11071104 new TableColumnsToAttribute( array( 'language_id' ), $o->language )
11081105 ),
1109 - $dataSet->optionAttributeOptions,
 1106+ $wgWikidataDataSet->optionAttributeOptions,
11101107 array( 'attribute_id = ' . $attributeId )
11111108 );
11121109
@@ -1116,7 +1113,7 @@
11171114
11181115 function getOptionAttributeValuesRecordSet( array $objectIds, ViewInformation $viewInformation ) {
11191116 global
1120 - $dataSet;
 1117+ $wgWikidataDataSet;
11211118
11221119 $o = OmegaWikiAttributes::getInstance();
11231120 $recordSet = queryRecordSet(
@@ -1128,7 +1125,7 @@
11291126 new TableColumnsToAttribute( array( 'object_id' ), $o->optionAttributeObject ),
11301127 new TableColumnsToAttribute( array( 'option_id' ), $o->optionAttributeOptionId )
11311128 ),
1132 - $dataSet->optionAttributeValues,
 1129+ $wgWikidataDataSet->optionAttributeValues,
11331130 array( "object_id IN (" . implode( ", ", $objectIds ) . ")" )
11341131 );
11351132
@@ -1142,7 +1139,7 @@
11431140 /* XXX: This can probably be combined with other functions. In fact, it probably should be. Do it. */
11441141 function expandOptionsInRecordSet( RecordSet $recordSet, ViewInformation $viewInformation ) {
11451142 global
1146 - $dataSet;
 1143+ $wgWikidataDataSet;
11471144
11481145 $o = OmegaWikiAttributes::getInstance();
11491146
@@ -1160,7 +1157,7 @@
11611158 new TableColumnsToAttribute( array( 'attribute_id' ), $o->optionAttributeId ),
11621159 new TableColumnsToAttribute( array( 'option_mid' ), $o->optionAttributeOption )
11631160 ),
1164 - $dataSet->optionAttributeOptions,
 1161+ $wgWikidataDataSet->optionAttributeOptions,
11651162 array( 'option_id = ' . $record->optionAttributeOptionId )
11661163 );
11671164
@@ -1172,7 +1169,7 @@
11731170 $viewInformation->queryTransactionInformation,
11741171 $o->optionAttributeId,
11751172 new TableColumnsToAttributesMapping( new TableColumnsToAttribute( array( 'attribute_mid' ), $o->optionAttribute ) ),
1176 - $dataSet->classAttributes,
 1173+ $wgWikidataDataSet->classAttributes,
11771174 array( 'object_id = ' . $optionRecord->optionAttributeId )
11781175 );
11791176
@@ -1183,7 +1180,7 @@
11841181
11851182 function getDefinedMeaningClassMembershipRecordSet( $definedMeaningId, ViewInformation $viewInformation ) {
11861183 global
1187 - $dataSet;
 1184+ $wgWikidataDataSet;
11881185
11891186 $o = OmegaWikiAttributes::getInstance();
11901187
@@ -1195,7 +1192,7 @@
11961193 new TableColumnsToAttribute( array( 'class_membership_id' ), $o->classMembershipId ),
11971194 new TableColumnsToAttribute( array( 'class_mid' ), $o->class )
11981195 ),
1199 - $dataSet->classMemberships,
 1196+ $wgWikidataDataSet->classMemberships,
12001197 array( "class_member_mid=$definedMeaningId" )
12011198 );
12021199
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWiki.php
@@ -100,8 +100,7 @@
101101 }
102102
103103 protected function getIdStack() {
104 - global $wgExpression ;
105 - return new IdStack( $wgExpression );
 104+ return new IdStack( WD_EXPRESSION );
106105 }
107106 }
108107
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php
@@ -221,13 +221,12 @@
222222 */
223223 protected function getIdStack( $definedMeaningId ) {
224224 $o = OmegaWikiAttributes::getInstance();
225 - global $wgDefinedMeaning ;
226225
227226 $definedMeaningIdStructure = new Structure( $o->definedMeaningId );
228227 $definedMeaningIdRecord = new ArrayRecord( $definedMeaningIdStructure, $definedMeaningIdStructure );
229228 $definedMeaningIdRecord->definedMeaningId = $definedMeaningId;
230229
231 - $idStack = new IdStack( $wgDefinedMeaning );
 230+ $idStack = new IdStack( WD_DEFINED_MEANING );
232231 $idStack->pushKey( $definedMeaningIdRecord );
233232
234233 return $idStack;
Index: trunk/extensions/Wikidata/OmegaWiki/type.php
@@ -119,12 +119,11 @@
120120 }
121121
122122 function convertToHTML( $value, $type ) {
123 - global $wgDefinedMeaning;
124123 switch( $type ) {
125124 case "boolean": return booleanAsHTML( $value );
126125 case "spelling": return spellingAsLink( $value );
127126 case "collection": return collectionAsLink( $value );
128 - case "$wgDefinedMeaning": return definedMeaningAsLink( $value );
 127+ case WD_DEFINED_MEANING: return definedMeaningAsLink( $value );
129128 case "defining-expression": return definingExpressionAsLink( $value );
130129 case "relation-type": return definedMeaningAsLink( $value );
131130 case "attribute": return definedMeaningAsLink( $value );
@@ -136,14 +135,13 @@
137136 }
138137
139138 function getInputFieldForType( $name, $type, $value ) {
140 - global $wgDefinedMeaning;
141139 switch( $type ) {
142140 case "language": return getLanguageSelect( $name );
143141 case "spelling": return getTextBox( $name, $value );
144142 case "boolean": return getCheckBox( $name, $value );
145 - case "$wgDefinedMeaning":
 143+ case WD_DEFINED_MEANING:
146144 case "defining-expression":
147 - return getSuggest( $name, $wgDefinedMeaning );
 145+ return getSuggest( $name, WD_DEFINED_MEANING );
148146 case "relation-type": return getSuggest( $name, "relation-type" );
149147 case "attribute": return getSuggest( $name, "attribute" );
150148 case "collection": return getSuggest( $name, "collection" );
@@ -153,12 +151,11 @@
154152 }
155153 function getInputFieldValueForType( $name, $type ) {
156154 global $wgRequest;
157 - global $wgDefinedMeaning;
158155 switch( $type ) {
159156 case "language": return $wgRequest->getInt( $name );
160157 case "spelling": return trim( $wgRequest->getText( $name ) );
161158 case "boolean": return $wgRequest->getCheck( $name );
162 - case "$wgDefinedMeaning":
 159+ case WD_DEFINED_MEANING:
163160 case "defining-expression":
164161 return $wgRequest->getInt( $name );
165162 case "relation-type": return $wgRequest->getInt( $name );
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php
@@ -1464,8 +1464,7 @@
14651465
14661466 class DefinedMeaningReferenceEditor extends SuggestEditor {
14671467 protected function suggestType() {
1468 - global $wgDefinedMeaning;
1469 - return $wgDefinedMeaning;
 1468+ return WD_DEFINED_MEANING;
14701469 }
14711470
14721471 public function getViewHTML( IdStack $idPath, $value ) {
@@ -1603,8 +1602,7 @@
16041603
16051604 class DefinedMeaningAttributeEditor extends AttributeEditor {
16061605 protected function suggestType() {
1607 - global $wgDefinedMeaningAttributes;
1608 - return $wgDefinedMeaningAttributes;
 1606+ return WD_DEFINED_MEANING_ATTRIBUTES;
16091607 }
16101608 }
16111609
@@ -1622,19 +1620,16 @@
16231621
16241622 class LinkAttributeEditor extends AttributeEditor {
16251623 protected function suggestType() {
1626 - global $wgLinkAttribute;
1627 - return $wgLinkAttribute;
 1624+ return WD_LINK_ATTRIBUTE;
16281625 }
16291626 }
16301627
16311628 class OptionAttributeEditor extends AttributeEditor {
16321629 protected function suggestType() {
1633 - global $wgOptionAttribute;
1634 - return $wgOptionAttribute;
 1630+ return WD_OPTION_ATTRIBUTE;
16351631 }
16361632
16371633 public function add( IdStack $idPath ) {
1638 - global $wgOptionSuffix;
16391634 if ( $this->isAddField ) {
16401635 $syntransId = $idPath->getKeyStack()->peek( 0 )->syntransId;
16411636 if ( ! $syntransId ) $syntransId = 0 ; // in the case of a DM option attribute, there is no syntrans in the PathId
@@ -1645,7 +1640,7 @@
16461641 "definedMeaningId" => $idPath->getDefinedMeaningId(),
16471642 "syntransId" => $syntransId,
16481643 "annotationAttributeId" => $idPath->getAnnotationAttribute()->getId(),
1649 - "onUpdate" => 'updateSelectOptions(\'' . $this->addId( $idPath->getId() ) . $wgOptionSuffix . '\',' . $syntransId
 1644+ "onUpdate" => 'updateSelectOptions(\'' . $this->addId( $idPath->getId() ) . WD_OPTION_SUFFIX . '\',' . $syntransId
16501645 );
16511646 return getSuggest( $this->addId( $idPath->getId() ), $this->suggestType(), $parameters );
16521647 }
@@ -1653,11 +1648,10 @@
16541649 }
16551650
16561651 public function getEditHTML( IdStack $idPath, $value ) {
1657 - global $wgOptionSuffix;
16581652 // note: it is normal that the "updateSelectOptions(" has no closing parenthesis. An additional parameter and ')' is added by the function updateSuggestValue (suggest.js)
16591653 $parameters = array(
16601654 "level" => $this->attributesLevelName,
1661 - "onUpdate" => 'updateSelectOptions(\'' . $this->updateId( $idPath->getId() ) . $wgOptionSuffix . '\''
 1655+ "onUpdate" => 'updateSelectOptions(\'' . $this->updateId( $idPath->getId() ) . WD_OPTION_SUFFIX . '\''
16621656 );
16631657
16641658 return getSuggest( $this->updateId( $idPath->getId() ), $this->suggestType(), $parameters );
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataTables.php
@@ -15,6 +15,8 @@
1616 * 3) Table: represents a specific table in the database, meant as a base class for specific tables
1717 */
1818
 19+require_once( "Wikidata.php" );
 20+
1921 interface DatabaseExpression {
2022 public function toExpression();
2123 }
@@ -332,7 +334,7 @@
333335
334336 public function __construct( $name ) {
335337 parent::__construct( $name );
336 -
 338+
337339 $this->objectId = $this->createColumn( "object_id" );
338340 $this->classMid = $this->createColumn( "class_mid" );
339341 $this->levelMid = $this->createColumn( "level_mid" );
@@ -732,13 +734,10 @@
733735 }
734736 }
735737
736 -global
737 - $dataSet;
 738+global $wgWikidataDataSet;
 739+$wgWikidataDataSet = new WikiDataSet( wdGetDataSetContext() );
738740
739 -require_once( "Wikidata.php" );
740741
741 -$dataSet = new WikiDataSet( wdGetDataSetContext() );
742 -
743742 function genericSelect( $selectCommand, array $expressions, array $tables, array $restrictions ) {
744743 $result = $selectCommand . " " . $expressions[0]->toExpression();
745744
@@ -833,5 +832,3 @@
834833 function sqlAnd( $expression1, $expression2 ) {
835834 return new DefaultDatabaseExpression( '(' . expressionToSQL( $expression1 ) . ') AND (' . expressionToSQL( $expression2 ) . ')' );
836835 }
837 -
838 -?>
\ No newline at end of file
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php
@@ -110,7 +110,7 @@
111111
112112 public function history() {
113113 global
114 - $wgOut, $wgTitle, $wgDefinedMeaning ;
 114+ $wgOut, $wgTitle ;
115115
116116 parent::history();
117117
@@ -118,7 +118,7 @@
119119 $dmModel = new DefinedMeaningModel( $definedMeaningId, $this->viewInformation );
120120 $wgOut->addHTML(
121121 getDefinedMeaningEditor( $this->viewInformation )->view(
122 - new IdStack( $wgDefinedMeaning ),
 122+ new IdStack( WD_DEFINED_MEANING ),
123123 $dmModel->getRecord()
124124 )
125125 );
@@ -147,13 +147,12 @@
148148 protected function getIdStack( $definedMeaningId ) {
149149
150150 $o = OmegaWikiAttributes::getInstance();
151 - global $wgDefinedMeaning ;
152151
153152 $definedMeaningIdStructure = new Structure( $o->definedMeaningId );
154153 $definedMeaningIdRecord = new ArrayRecord( $definedMeaningIdStructure, $definedMeaningIdStructure );
155154 $definedMeaningIdRecord->definedMeaningId = $definedMeaningId;
156155
157 - $idStack = new IdStack( $wgDefinedMeaning );
 156+ $idStack = new IdStack( WD_DEFINED_MEANING );
158157 $idStack->pushKey( $definedMeaningIdRecord );
159158
160159 return $idStack;
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialDatasearch.php
@@ -32,9 +32,7 @@
3333
3434 initializeOmegaWikiAttributes( new ViewInformation() );
3535
36 - global
37 - $definedMeaningReferenceType,
38 - $wgDefinedMeaning;
 36+ global $definedMeaningReferenceType ;
3937
4038 require_once( "WikiDataGlobals.php" );
4139 require_once( "forms.php" );
@@ -53,7 +51,7 @@
5452 $this->expressionStructure = new Structure( $this->spellingAttribute, $this->languageAttribute );
5553 $this->expressionAttribute = new Attribute( "expression", wfMsg( 'ow_Expression' ), $this->expressionStructure );
5654
57 - $this->definedMeaningAttribute = new Attribute( $wgDefinedMeaning, wfMsg( 'ow_DefinedMeaning' ), $definedMeaningReferenceType );
 55+ $this->definedMeaningAttribute = new Attribute( WD_DEFINED_MEANING, wfMsg( 'ow_DefinedMeaning' ), $definedMeaningReferenceType );
5856 $this->definitionAttribute = new Attribute( "definition", wfMsg( 'ow_Definition' ), "definition" );
5957
6058 $this->meaningStructure = new Structure( $this->definedMeaningAttribute, $this->definitionAttribute );
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php
@@ -2,95 +2,65 @@
33
44 define( 'NS_EXPRESSION', 16 );
55 define( 'NS_DEFINEDMEANING', 24 );
 6+define( 'WD_ENGLISH_LANG_ID', 85 );
67
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" );
835
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...
1336
14 -global $wgOptionSuffix;
15 -$wgOptionSuffix = "Optn" ;
 37+require_once( "Wikidata.php" );
 38+require_once( "GotoSourceTemplate.php" );
 39+require_once( "PropertyToColumnFilter.php" );
1640
 41+# Global context override. This is an evil hack to allow saving, basically.
 42+global $wdCurrentContext;
 43+$wdCurrentContext = null;
1744
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;
4347
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 -
7248 // Defined meaning editor
73 -
74 -global
75 - $wdDefinedMeaningAttributesOrder;
 49+global $wdDefinedMeaningAttributesOrder;
7650
7751 $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
8660 );
8761
88 -// Go to source templates
8962
90 -require_once( "GotoSourceTemplate.php" );
 63+global $wgGotoSourceTemplates;
9164
92 -global
93 - $wgGotoSourceTemplates;
94 -
9565 $wgGotoSourceTemplates = array(); // Map of collection id => GotoSourceTemplate
9666
9767 // Page titles
@@ -117,10 +87,6 @@
11888 $wgShowSearchWithinExternalIdentifiersOption = true;
11989 $wgShowSearchWithinWordsOption = true;
12090
121 -// Annotation to column filtering
122 -
123 -require_once( "PropertyToColumnFilter.php" );
124 -
12591 global
12692 $wgPropertyToColumnFilters;
12793
@@ -135,6 +101,91 @@
136102 */
137103 $wgPropertyToColumnFilters = array();
138104
 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+
139190 // Hook: replace the proposition to "create new page" by a custom, allowing to create new expression as well
140191 $wgHooks[ 'SpecialSearchNogomatch' ][] = 'owNoGoMatchHook';
141192
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSelect.php
@@ -13,12 +13,12 @@
1414 function execute( $par ) {
1515 require_once( 'languages.php' );
1616 require_once( 'Transaction.php' );
17 - global $wgOut, $wgLang, $wgRequest, $wgOptionAttribute;
 17+ global $wgOut, $wgLang, $wgRequest;
1818
1919 $wgOut->disable();
2020
2121 $dc = wdGetDataSetContext();
22 - $optionAttribute = $wgRequest->getVal( $wgOptionAttribute );
 22+ $optionAttribute = $wgRequest->getVal( WD_OPTION_ATTRIBUTE );
2323 $attributeObject = $wgRequest->getVal( 'attribute-object' );
2424 $lang_code = $wgLang->getCode();
2525
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php
@@ -9,9 +9,7 @@
1010 }
1111
1212 function execute( $par ) {
13 - global $wgOut, $wgLang, $wgRequest, $IP,
14 - $wgDefinedMeaning, $wgDefinedMeaningAttributes,
15 - $wgOptionAttribute, $wgLinkAttribute;
 13+ global $wgOut, $wgLang, $wgRequest, $IP;
1614
1715 $wgOut->disable();
1816 require_once( "$IP/includes/Setup.php" );
@@ -55,7 +53,7 @@
5654 // so : not using it. The English fall back has been included in the SQL query
5755 $sql = $this->getSQLForClasses( $langCode );
5856 break;
59 - case $wgDefinedMeaningAttributes:
 57+ case WD_DEFINED_MEANING_ATTRIBUTES:
6058 $sql = $this->getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'DM' );
6159 break;
6260 case 'text-attribute':
@@ -64,10 +62,10 @@
6563 case 'translated-text-attribute':
6664 $sql = $this->getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'TRNS' );
6765 break;
68 - case $wgLinkAttribute:
 66+ case WD_LINK_ATTRIBUTE:
6967 $sql = $this->getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'URL' );
7068 break;
71 - case $wgOptionAttribute:
 69+ case WD_OPTION_ATTRIBUTE:
7270 $sql = $this->getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'OPTN' );
7371 break;
7472 case 'language':
@@ -75,7 +73,7 @@
7674 $sql = getSQLForLanguageNames( $langCode );
7775 $rowText = 'language_name';
7876 break;
79 - case $wgDefinedMeaning:
 77+ case WD_DEFINED_MEANING:
8078 $sql =
8179 "SELECT {$dc}_syntrans.defined_meaning_id AS defined_meaning_id, {$dc}_expression.spelling AS spelling, {$dc}_expression.language_id AS language_id " .
8280 " FROM {$dc}_expression, {$dc}_syntrans " .
@@ -109,9 +107,9 @@
110108 elseif ( $query == 'class' ) {
111109 $searchCondition = " AND $rowText LIKE " . $dbr->addQuotes( "$search%" );
112110 }
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
116114 $query == 'translated-text-attribute' or
117115 $query == 'text-attribute' )
118116 {
@@ -159,7 +157,7 @@
160158 case 'class':
161159 list( $recordSet, $editor ) = $this->getClassAsRecordSet( $queryResult );
162160 break;
163 - case "$wgDefinedMeaningAttributes":
 161+ case WD_DEFINED_MEANING_ATTRIBUTES:
164162 list( $recordSet, $editor ) = $this->getDefinedMeaningAttributeAsRecordSet( $queryResult );
165163 break;
166164 case 'text-attribute':
@@ -168,13 +166,13 @@
169167 case 'translated-text-attribute':
170168 list( $recordSet, $editor ) = $this->getTranslatedTextAttributeAsRecordSet( $queryResult );
171169 break;
172 - case "$wgLinkAttribute":
 170+ case WD_LINK_ATTRIBUTE:
173171 list( $recordSet, $editor ) = $this->getLinkAttributeAsRecordSet( $queryResult );
174172 break;
175 - case "$wgOptionAttribute":
 173+ case WD_OPTION_ATTRIBUTE:
176174 list( $recordSet, $editor ) = $this->getOptionAttributeAsRecordSet( $queryResult );
177175 break;
178 - case "$wgDefinedMeaning":
 176+ case WD_DEFINED_MEANING:
179177 list( $recordSet, $editor ) = $this->getDefinedMeaningAsRecordSet( $queryResult );
180178 break;
181179 case 'class-attributes-level':
@@ -236,8 +234,7 @@
237235 * @param $language the 2 letter wikimedia code
238236 */
239237 private function getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, $attributesType ) {
240 - global $wgDefaultClassMids, $wgLang;
241 -
 238+ global $wgDefaultClassMids, $wgLang, $wgIso639_3CollectionId;
242239 $dc = wdGetDataSetContext();
243240 $dbr = wfGetDB( DB_SLAVE );
244241
@@ -251,7 +248,7 @@
252249
253250 $classMids = $wgDefaultClassMids ;
254251
255 - if ( $syntransId != 0 ) {
 252+ if ( ( $syntransId != 0 ) && ( !is_null($wgIso639_3CollectionId)) ) {
256253 // find the language of the syntrans and add attributes of that language by adding the language DM to the list of default classes
257254 // this first query returns the language_id
258255 $sql = 'SELECT language_id' .
@@ -262,10 +259,9 @@
263260 $language_id = $dbr->fetchObject( $lang_res )->language_id;
264261
265262 // 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
267263 $sql = "SELECT member_mid FROM {$dc}_collection_contents, language" .
268264 " WHERE language.language_id = $language_id" .
269 - " AND {$dc}_collection_contents.collection_id = 145264" .
 265+ " AND {$dc}_collection_contents.collection_id = $wgIso639_3CollectionId" .
270266 " AND language.iso639_3 = {$dc}_collection_contents.internal_member_id" .
271267 ' AND ' . getLatestTransactionRestriction( "{$dc}_collection_contents" ) .
272268 ' LIMIT 1 ' ;
@@ -330,35 +326,38 @@
331327
332328 private function getPropertyToColumnFilterForAttribute( $annotationAttributeId ) {
333329 global $wgPropertyToColumnFilters;
334 -
 330+
335331 $i = 0;
336332 $result = null;
337333
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 ) {
340336 $result = $wgPropertyToColumnFilters[$i];
341 - else
 337+ } else {
342338 $i++;
343 -
 339+ }
 340+ }
344341 return $result;
345342 }
346343
347344 private function getFilteredAttributes( $annotationAttributeId ) {
348345 $propertyToColumnFilter = $this->getPropertyToColumnFilterForAttribute( $annotationAttributeId );
349346
350 - if ( $propertyToColumnFilter != null )
 347+ if ( $propertyToColumnFilter != null ) {
351348 return $propertyToColumnFilter->attributeIDs;
352 - else
 349+ } else {
353350 return array();
 351+ }
354352 }
355353
356354 private function getAllFilteredAttributes() {
357355 global $wgPropertyToColumnFilters;
358356
359357 $result = array();
360 -
361 - foreach ( $wgPropertyToColumnFilters as $propertyToColumnFilter )
 358+
 359+ foreach ( $wgPropertyToColumnFilters as $propertyToColumnFilter ) {
362360 $result = array_merge( $result, $propertyToColumnFilter->attributeIDs );
 361+ }
363362
364363 return $result;
365364 }
@@ -371,18 +370,20 @@
372371 if ( $propertyToColumnFilter != null ) {
373372 $filteredAttributes = $propertyToColumnFilter->attributeIDs;
374373
375 - if ( count( $filteredAttributes ) > 0 )
 374+ if ( count( $filteredAttributes ) > 0 ) {
376375 $result = " AND {$dc}_class_attributes.attribute_mid IN (" . join( $filteredAttributes, ", " ) . ")";
377 - else
 376+ } else {
378377 $result = " AND 0 ";
 378+ }
379379 }
380380 else {
381381 $allFilteredAttributes = $this->getAllFilteredAttributes();
382382
383 - if ( count( $allFilteredAttributes ) > 0 )
 383+ if ( count( $allFilteredAttributes ) > 0 ) {
384384 $result = " AND {$dc}_class_attributes.attribute_mid NOT IN (" . join( $allFilteredAttributes, ", " ) . ")";
385 - else
 385+ } else {
386386 $result = "";
 387+ }
387388 }
388389
389390 return $result;
@@ -484,18 +485,18 @@
485486 }
486487
487488 private function getSQLForLevels( $language = "<ANY>" ) {
488 - global $classAttributeLevels, $dataSet;
 489+ global $classAttributeLevels, $wgWikidataDataSet;
489490
490491 $o = OmegaWikiAttributes::getInstance();
491492 // TO DO: Add support for multiple languages here
492493 return
493494 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 ),
496497 array(
497498 '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 )
500501 )
501502 );
502503 }
@@ -550,13 +551,11 @@
551552 }
552553
553554 private function getDefinedMeaningAttributeAsRecordSet( $queryResult ) {
554 - global $wgDefinedMeaningAttributes;
555 -
556555 $o = OmegaWikiAttributes::getInstance();
557556
558557 $dbr = wfGetDB( DB_SLAVE );
559558
560 - $definedMeaningAttributeAttribute = new Attribute( $wgDefinedMeaningAttributes, wfMsgSc( "DefinedMeaningAttributes" ), "short-text" );
 559+ $definedMeaningAttributeAttribute = new Attribute( WD_DEFINED_MEANING_ATTRIBUTES, wfMsgSc( "DefinedMeaningAttributes" ), "short-text" );
561560 $recordSet = new ArrayRecordSet( new Structure( $o->id, $definedMeaningAttributeAttribute ), new Structure( $o->id ) );
562561
563562 while ( $row = $dbr->fetchObject( $queryResult ) )
@@ -587,13 +586,11 @@
588587 }
589588
590589 private function getLinkAttributeAsRecordSet( $queryResult ) {
591 - global $wgLinkAttribute;
592 -
593590 $o = OmegaWikiAttributes::getInstance();
594591
595592 $dbr = wfGetDB( DB_SLAVE );
596593
597 - $linkAttributeAttribute = new Attribute( $wgLinkAttribute, wfMsg( 'ow_LinkAttributeHeader' ), "short-text" );
 594+ $linkAttributeAttribute = new Attribute( WD_LINK_ATTRIBUTE, wfMsg( 'ow_LinkAttributeHeader' ), "short-text" );
598595 $recordSet = new ArrayRecordSet( new Structure( $o->id, $linkAttributeAttribute ), new Structure( $o->id ) );
599596
600597 while ( $row = $dbr->fetchObject( $queryResult ) )
@@ -624,13 +621,11 @@
625622 }
626623
627624 private function getOptionAttributeAsRecordSet( $queryResult ) {
628 - global $wgOptionAttribute;
629 -
630625 $o = OmegaWikiAttributes::getInstance();
631626
632627 $dbr = wfGetDB( DB_SLAVE );
633628
634 - $optionAttributeAttribute = new Attribute( $wgOptionAttribute, wfMsg( 'ow_OptionAttributeHeader' ), "short-text" );
 629+ $optionAttributeAttribute = new Attribute( WD_OPTION_ATTRIBUTE, wfMsg( 'ow_OptionAttributeHeader' ), "short-text" );
635630 $recordSet = new ArrayRecordSet( new Structure( $o->id, $optionAttributeAttribute ), new Structure( $o->id ) );
636631
637632 while ( $row = $dbr->fetchObject( $queryResult ) )
@@ -643,15 +638,13 @@
644639 }
645640
646641 private function getDefinedMeaningAsRecordSet( $queryResult ) {
647 - global $wgDefinedMeaning ;
648 -
649642 $o = OmegaWikiAttributes::getInstance();
650643
651644 $dbr = wfGetDB( DB_SLAVE );
652645 $spellingAttribute = new Attribute( "spelling", wfMsg( 'ow_Spelling' ), "short-text" );
653646 $languageAttribute = new Attribute( "language", wfMsg( 'ow_Language' ), "language" );
654647
655 - $expressionStructure = new Structure( $wgDefinedMeaning, $spellingAttribute, $languageAttribute );
 648+ $expressionStructure = new Structure( WD_DEFINED_MEANING, $spellingAttribute, $languageAttribute );
656649 $definedMeaningAttribute = new Attribute( null, wfMsg( 'ow_DefinedMeaning' ), $expressionStructure );
657650 $definitionAttribute = new Attribute( "definition", wfMsg( 'ow_Definition' ), "definition" );
658651
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php
@@ -93,34 +93,16 @@
9494 $t->spelling = new Attribute( "spelling", wfMsgSc( "Spelling" ), "spelling" );
9595 $t->text = new Attribute( "text", wfMsgSc( "Text" ), "text" );
9696
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" );
11799 $t->expressionId = new Attribute( "expression-id", "Expression Id", "expression-id" );
118100 $t->identicalMeaning = new Attribute( "identMeaning", wfMsgSc( "IdenticalMeaning" ), "boolean" );
119101
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 );
125107 }
126108
127109 $t->definedMeaningId = new Attribute( "defined-meaning-id", "Defined meaning identifier", "defined-meaning-id" );
@@ -132,13 +114,13 @@
133115 $t->language
134116 );
135117 # try this
136 - $t->definedMeaningCompleteDefiningExpressionStructure->setStructureType( $wgExpression );
 118+ $t->definedMeaningCompleteDefiningExpressionStructure->setStructureType( WD_EXPRESSION );
137119 $t->definedMeaningCompleteDefiningExpression = new Attribute( null, "Defining expression", $t->definedMeaningCompleteDefiningExpressionStructure );
138120
139121 global $definedMeaningReferenceType;
140122
141123 $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 );
143125 $definedMeaningReferenceType = $t->definedMeaningReferenceStructure;
144126 $t->definedMeaningReference = new Attribute( null, wfMsgSc( "DefinedMeaningReference" ), $definedMeaningReferenceType );
145127 $t->collectionId = new Attribute( "collection", "Collection", "collection-id" );
@@ -147,36 +129,36 @@
148130 $t->gotoSourceStructure = new Structure( "goto-source", $t->collectionId, $t->sourceIdentifier );
149131 $t->gotoSource = new Attribute( null, wfMsgSc( "GotoSource" ), $t->gotoSourceStructure );
150132
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 );
152134 $t->collectionMembership = new Attribute( null, wfMsgSc( "CollectionMembership" ), $t->collectionMembershipStructure );
153135
154136 $t->classMembershipId = new Attribute( "class-membership-id", "Class membership id", "integer" );
155137 $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 );
157139 $t->classMembership = new Attribute( null, wfMsgSc( "ClassMembership" ), $t->classMembershipStructure );
158140
159141 global $relationTypeType;
160142
161143 $t->relationId = new Attribute( "relation-id", "Relation identifier", "object-id" );
162144 $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 );
164146
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 );
168150 $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 );
170152
171153 $t->definitionId = new Attribute( "definition-id", "Definition identifier", "integer" );
172154
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+ }
178160 $t->source = new Attribute( "source-id", wfMsgSc( "Source" ), $definedMeaningReferenceType );
179161
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 );
181163 $t->alternativeDefinitions = new Attribute( null, wfMsgSc( "AlternativeDefinitions" ), $t->alternativeDefinitionsStructure );
182164
183165 if ( $viewInformation->filterOnLanguage() )
@@ -185,7 +167,7 @@
186168 $synonymsAndTranslationsCaption = wfMsgSc( "SynonymsAndTranslations" );
187169
188170 $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 );
190172 $t->synonymsAndTranslations = new Attribute( null, "$synonymsAndTranslationsCaption", $t->synonymsTranslationsStructure );
191173 $t->translatedTextAttributeId = new Attribute( "translated-text-attribute-id", "Attribute identifier", "object-id" );
192174 $t->translatedTextAttribute = new Attribute( "translated-text-attribute", wfMsgSc( "TranslatedTextAttribute" ), $definedMeaningReferenceType );
@@ -205,7 +187,7 @@
206188 $t->textAttributeId = new Attribute( "text-attribute-id", "Attribute identifier", "object-id" );
207189 $t->textAttributeObject = new Attribute( "text-attribute-object-id", "Attribute object", "object-id" );
208190 $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 );
210192 $t->textAttributeValues = new Attribute( null, wfMsgSc( "TextAttributeValues" ), $t->textAttributeValuesStructure );
211193
212194 $t->linkLabel = new Attribute( "label", wfMsg( 'ow_Label' ), "short-text" );
@@ -213,38 +195,38 @@
214196 $t->link = new Attribute( "link", wfMsg( 'ow_Link' ), new Structure( $t->linkLabel, $t->linkURL ) );
215197 $t->linkAttributeId = new Attribute( "link-attribute-id", "Attribute identifier", "object-id" );
216198 $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 );
219201 $t->linkAttributeValues = new Attribute( null, wfMsgSc( "LinkAttributeValues" ), $t->linkAttributeValuesStructure );
220202
221203 $t->optionAttributeId = new Attribute( "option-attribute-id", "Attribute identifier", "object-id" );
222204 $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 );
226208 $t->optionAttributeValues = new Attribute( null, wfMsgSc( "OptionAttributeValues" ), $t->optionAttributeValuesStructure );
227209 $t->optionAttributeOptionId = new Attribute( "option-attribute-option-id", "Option identifier", "object-id" );
228210 $t->optionAttributeOptionsStructure = new Structure( "option-attribute-options", $t->optionAttributeOptionId, $t->optionAttribute, $t->optionAttributeOption, $t->language );
229211 $t->optionAttributeOptions = new Attribute( null, wfMsgSc( "OptionAttributeOptions" ), $t->optionAttributeOptionsStructure );
230212
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+ }
236218
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 ) );
238220
239221 $t->classAttributeId = new Attribute( "class-attribute-id", "Class attribute identifier", "object-id" );
240222 $t->classAttributeAttribute = new Attribute( "class-attribute-attribute", wfMsgSc( "ClassAttributeAttribute" ), $t->definedMeaningReferenceStructure );
241223 $t->classAttributeLevel = new Attribute( "class-attribute-level", wfMsgSc( "ClassAttributeLevel" ), $t->definedMeaningReferenceStructure );
242224 $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 );
244226 $t->classAttributes = new Attribute( null, wfMsgSc( "ClassAttributes" ), $t->classAttributesStructure );
245227
246228 $t->definedMeaning = new Attribute( null, wfMsgSc( "DefinedMeaning" ),
247229 new Structure(
248 - $wgDefinedMeaning,
 230+ WD_DEFINED_MEANING,
249231 $t->definedMeaningId,
250232 $t->definedMeaningCompleteDefiningExpression,
251233 $t->definition,
@@ -259,9 +241,9 @@
260242 );
261243
262244 $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 );
266248 $t->expressionMeanings = new Attribute( null, wfMsgSc( "ExpressionMeanings" ), $t->expressionMeaningsStructure );
267249 $t->expressionsStructure = new Structure( "expressions", $t->expressionId, $t->expression, $t->expressionMeanings );
268250 $t->expressions = new Attribute( null, wfMsgSc( "Expressions" ), $t->expressionsStructure );

Status & tagging log