r19812 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r19811‎ | r19812 | r19813 >
Date:09:47, 7 February 2007
Author:proes
Status:old
Tags:
Comment:
Made the order of the defined meaning sections configurable in LocalSettings.php via $wgDefinedMeaningAttributesOrder.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php
@@ -100,6 +100,45 @@
101101 $wgUrlAttributeAttributeName = "Property";
102102 $wgUrlAttributeValuesAttributeName = "URL properties";
103103
 104+global
 105+ $wgAlternativeDefinitionsAttributeId,
 106+ $wgClassAttributesAttributeId,
 107+ $wgClassMembershipAttributeId,
 108+ $wgCollectionMembershipAttributeId,
 109+ $wgDefinedMeaningAttributesAttributeId,
 110+ $wgDefinitionAttributeId,
 111+ $wgIncomingRelationsAttributeId,
 112+ $wgPossiblySynonymousAttributeId,
 113+ $wgRelationsAttributeId,
 114+ $wgSynonymsAndTranslationsAttributeId;
 115+
 116+$wgAlternativeDefinitionsAttributeId = "alternative-definitions";
 117+$wgClassAttributesAttributeId = "class-attributes";
 118+$wgClassMembershipAttributeId = "class-membership";
 119+$wgCollectionMembershipAttributeId = "collection-membership";
 120+$wgDefinedMeaningAttributesAttributeId = "defined-meaning-attributes";
 121+$wgDefinitionAttributeId = "definition";
 122+$wgIncomingRelationsAttributeId = "reciprocal-relations";
 123+$wgPossiblySynonymousAttributeId = "possibly-synonymous";
 124+$wgRelationsAttributeId = "relations";
 125+$wgSynonymsAndTranslationsAttributeId = "synonyms-translations";
 126+
 127+global
 128+ $wgDefinedMeaningAttributesOrder;
 129+
 130+$wgDefinedMeaningAttributesOrder = array(
 131+ $wgDefinitionAttributeId,
 132+ $wgClassAttributesAttributeId,
 133+ $wgAlternativeDefinitionsAttributeId,
 134+ $wgSynonymsAndTranslationsAttributeId,
 135+ $wgPossiblySynonymousAttributeId,
 136+ $wgRelationsAttributeId,
 137+ $wgIncomingRelationsAttributeId,
 138+ $wgClassMembershipAttributeId,
 139+ $wgCollectionMembershipAttributeId,
 140+ $wgDefinedMeaningAttributesAttributeId
 141+);
 142+
104143 require_once("GotoSourceTemplate.php");
105144
106145 global
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php
@@ -14,9 +14,10 @@
1515
1616 global
1717 $objectAttributesAttribute, $definedMeaningAttributesAttribute,
18 - $wgDefinedMeaningAttributesAttributeName, $wgAnnotationAttributeName;
 18+ $wgDefinedMeaningAttributesAttributeName,
 19+ $wgDefinedMeaningAttributesAttributeName, $wgDefinedMeaningAttributesAttributeId, $wgAnnotationAttributeName;
1920
20 - $definedMeaningAttributesAttribute = new Attribute("defined-meaning-attributes", $wgDefinedMeaningAttributesAttributeName, "will-be-specified-below");
 21+ $definedMeaningAttributesAttribute = new Attribute($wgDefinedMeaningAttributesAttributeId, $wgDefinedMeaningAttributesAttributeName, "will-be-specified-below");
2122 $objectAttributesAttribute = new Attribute("object-attributes", $wgAnnotationAttributeName, "will-be-specified-below");
2223
2324 global
@@ -64,9 +65,9 @@
6566 $gotoSourceAttribute = new Attribute("goto-source", $wgGotoSourceAttributeName, new RecordType($gotoSourceStructure));
6667
6768 global
68 - $collectionMembershipAttribute, $wgCollectionMembershipAttributeName;
 69+ $collectionMembershipAttribute, $wgCollectionMembershipAttributeName, $wgCollectionMembershipAttributeId;
6970
70 - $collectionMembershipAttribute = new Attribute("collection-membership", $wgCollectionMembershipAttributeName, new RecordSetType(new Structure($collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute)));
 71+ $collectionMembershipAttribute = new Attribute($wgCollectionMembershipAttributeId, $wgCollectionMembershipAttributeName, new RecordSetType(new Structure($collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute)));
7172
7273 global
7374 $classMembershipIdAttribute, $classAttribute;
@@ -75,11 +76,12 @@
7677 $classAttribute = new Attribute("class", "Class", new RecordType($definedMeaningReferenceStructure));
7778
7879 global
79 - $classMembershipStructure, $classMembershipKeyStructure, $classMembershipAttribute, $wgClassMembershipAttributeName;
 80+ $classMembershipStructure, $classMembershipKeyStructure, $classMembershipAttribute,
 81+ $wgClassMembershipAttributeName, $wgClassMembershipAttributeId;
8082
8183 $classMembershipStructure = new Structure($classMembershipIdAttribute, $classAttribute);
8284 $classMembershipKeyStructure = new Structure($classMembershipIdAttribute);
83 - $classMembershipAttribute = new Attribute("class-membership", $wgClassMembershipAttributeName, new RecordSetType($classMembershipStructure));
 85+ $classMembershipAttribute = new Attribute($wgClassMembershipAttributeId, $wgClassMembershipAttributeName, new RecordSetType($classMembershipStructure));
8486
8587 global
8688 $possiblySynonymousIdAttribute, $possibleSynonymAttribute, $wgPossibleSynonymAttributeName;
@@ -89,11 +91,11 @@
9092
9193 global
9294 $possiblySynonymousStructure, $possiblySynonymousKeyStructure, $possiblySynonymousAttribute,
93 - $wgPossiblySynonymousAttributeName;
 95+ $wgPossiblySynonymousAttributeName, $wgPossiblySynonymousAttributeId;
9496
9597 $possiblySynonymousStructure = new Structure($possiblySynonymousIdAttribute, $possiblySynonymousAttribute);
9698 $possiblySynonymousKeyStructure = new Structure($possiblySynonymousIdAttribute);
97 - $possiblySynonymousAttribute = new Attribute("possibly-synonymous", $wgPossiblySynonymousAttributeName, new RecordSetType($possiblySynonymousStructure));
 99+ $possiblySynonymousAttribute = new Attribute($wgPossiblySynonymousAttributeId, $wgPossiblySynonymousAttributeName, new RecordSetType($possiblySynonymousStructure));
98100
99101 global
100102 $relationIdAttribute, $relationTypeAttribute, $relationTypeType, $otherDefinedMeaningAttribute,
@@ -106,12 +108,12 @@
107109
108110 global
109111 $relationsAttribute, $relationStructure, $relationKeyStructure, $reciprocalRelationsAttribute, $objectAttributesAttribute,
110 - $wgRelationsAttributeName, $wgIncomingRelationsAttributeName;
 112+ $wgRelationsAttributeName, $wgIncomingRelationsAttributeName, $wgRelationsAttributeId, $wgIncomingRelationsAttributeId;
111113
112114 $relationStructure = new Structure($relationIdAttribute, $relationTypeAttribute, $otherDefinedMeaningAttribute, $objectAttributesAttribute);
113115 $relationKeyStructure = new Structure($relationIdAttribute);
114 - $relationsAttribute = new Attribute("relations", $wgRelationsAttributeName, new RecordSetType($relationStructure));
115 - $reciprocalRelationsAttribute = new Attribute("reciprocal-relations", $wgIncomingRelationsAttributeName, new RecordSetType($relationStructure));
 116+ $relationsAttribute = new Attribute($wgRelationsAttributeId, $wgRelationsAttributeName, new RecordSetType($relationStructure));
 117+ $reciprocalRelationsAttribute = new Attribute($wgIncomingRelationsAttributeId, $wgIncomingRelationsAttributeName, new RecordSetType($relationStructure));
116118
117119 global
118120 $translatedTextIdAttribute, $translatedTextStructure;
@@ -133,13 +135,13 @@
134136 $sourceAttribute = new Attribute("source-id", $wgSourceAttributeName, $definedMeaningReferenceType);
135137
136138 global
137 - $alternativeDefinitionsAttribute, $wgAlternativeDefinitionsAttributeName;
 139+ $alternativeDefinitionsAttribute, $wgAlternativeDefinitionsAttributeName, $wgAlternativeDefinitionsAttributeId;
138140
139 - $alternativeDefinitionsAttribute = new Attribute("alternative-definitions", $wgAlternativeDefinitionsAttributeName, new RecordSetType(new Structure($definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute)));
 141+ $alternativeDefinitionsAttribute = new Attribute($wgAlternativeDefinitionsAttributeId, $wgAlternativeDefinitionsAttributeName, new RecordSetType(new Structure($definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute)));
140142
141143 global
142144 $synonymsAndTranslationsAttribute, $syntransIdAttribute,
143 - $wgSynonymsAttributeName, $wgSynonymsAndTranslationsAttributeName;
 145+ $wgSynonymsAttributeName, $wgSynonymsAndTranslationsAttributeName, $wgSynonymsAndTranslationsAttributeId;
144146
145147 if ($filterOnLanguage)
146148 $synonymsAndTranslationsCaption = $wgSynonymsAttributeName;
@@ -147,7 +149,7 @@
148150 $synonymsAndTranslationsCaption = $wgSynonymsAndTranslationsAttributeName;
149151
150152 $syntransIdAttribute = new Attribute("syntrans-id", "$synonymsAndTranslationsCaption identifier", "integer");
151 - $synonymsAndTranslationsAttribute = new Attribute("synonyms-translations", "$synonymsAndTranslationsCaption", new RecordSetType(new Structure($syntransIdAttribute, $expressionAttribute, $identicalMeaningAttribute, $objectAttributesAttribute)));
 153+ $synonymsAndTranslationsAttribute = new Attribute($wgSynonymsAndTranslationsAttributeId, "$synonymsAndTranslationsCaption", new RecordSetType(new Structure($syntransIdAttribute, $expressionAttribute, $identicalMeaningAttribute, $objectAttributesAttribute)));
152154
153155 global
154156 $translatedTextAttributeIdAttribute, $translatedTextValueIdAttribute, $translatedTextAttributeAttribute, $translatedTextValueAttribute, $translatedTextAttributeValuesAttribute,
@@ -205,18 +207,48 @@
206208 $optionAttributeOptionsAttribute = new Attribute('option-attribute-options', $wgOptionAttributeOptionsAttributeName, new RecordSetType($optionAttributeOptionsStructure));
207209
208210 global
209 - $definitionAttribute, $definedMeaningAttribute, $translatedTextAttribute, $classAttributesAttribute,
210 - $wgDefinitionAttributeName, $wgDefinedMeaningAttributeName, $wgTranslatedTextAttributeName;
 211+ $definitionAttribute, $translatedTextAttribute, $classAttributesAttribute,
 212+ $wgDefinitionAttributeName, $wgDefinitionAttributeId, $wgTranslatedTextAttributeName;
211213
212214 if ($filterOnLanguage && !$hasMetaDataAttributes)
213215 $translatedTextAttribute = new Attribute("translated-text", $wgTextAttributeName, "text");
214216 else
215217 $translatedTextAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeName, new RecordSetType($translatedTextStructure));
216218
217 - $definitionAttribute = new Attribute("definition", $wgDefinitionAttributeName, new RecordType(new Structure($translatedTextAttribute, $objectAttributesAttribute)));
218 - $definedMeaningAttribute = new Attribute("defined-meaning", $wgDefinedMeaningAttributeName, new RecordType(new Structure($definitionAttribute, $classAttributesAttribute, $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute, $relationsAttribute, $classMembershipAttribute, $collectionMembershipAttribute, $objectAttributesAttribute)));
 219+ $definitionAttribute = new Attribute($wgDefinitionAttributeId, $wgDefinitionAttributeName, new RecordType(new Structure($translatedTextAttribute, $objectAttributesAttribute)));
 220+
 221+ global
 222+ $classAttributesStructure,
 223+ // $classAttributeClassAttribute,
 224+ $classAttributeIdAttribute, $classAttributeAttributeAttribute, $classAttributeLevelAttribute, $classAttributeTypeAttribute,
 225+ $wgClassAttributeAttributeAttributeName, $wgClassAttributeLevelAttributeName,
 226+ $wgClassAttributeTypeAttributeName, $wgClassAttributesAttributeName, $wgClassAttributesAttributeId;
219227
 228+ $classAttributeIdAttribute = new Attribute("class-attribute-id", "Class attribute identifier", "object-id");
 229+ $classAttributeAttributeAttribute = new Attribute("class-attribute-attribute", $wgClassAttributeAttributeAttributeName, new RecordType($definedMeaningReferenceStructure));
 230+ $classAttributeLevelAttribute = new Attribute("class-attribute-level", $wgClassAttributeLevelAttributeName, new RecordType($definedMeaningReferenceStructure));
 231+ $classAttributeTypeAttribute = new Attribute("class-attribute-type", $wgClassAttributeTypeAttributeName, "short-text");
 232+ $classAttributesStructure = new Structure($classAttributeIdAttribute, $classAttributeAttributeAttribute, $classAttributeLevelAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute);
 233+ $classAttributesAttribute = new Attribute($wgClassAttributesAttributeId, $wgClassAttributesAttributeName, new RecordSetType($classAttributesStructure));
 234+
220235 global
 236+ $definedMeaningAttribute, $wgDefinedMeaningAttributeName;
 237+
 238+ $definedMeaningAttribute = new Attribute("defined-meaning", $wgDefinedMeaningAttributeName,
 239+ new RecordType(new Structure(
 240+ $definitionAttribute,
 241+ $classAttributesAttribute,
 242+ $alternativeDefinitionsAttribute,
 243+ $synonymsAndTranslationsAttribute,
 244+ $relationsAttribute,
 245+ $reciprocalRelationsAttribute,
 246+ $classMembershipAttribute,
 247+ $collectionMembershipAttribute,
 248+ $definedMeaningAttributesAttribute)
 249+ )
 250+ );
 251+
 252+ global
221253 $expressionsAttribute, $expressionMeaningStructure, $expressionExactMeaningsAttribute, $expressionApproximateMeaningsAttribute,
222254 $wgExactMeaningsAttributeName, $wgApproximateMeaningsAttributeName;
223255
@@ -240,20 +272,6 @@
241273 $objectAttributesStructure = new Structure($objectIdAttribute, $textAttributeValuesAttribute, $translatedTextAttributeValuesAttribute, $optionAttributeValuesAttribute);
242274 $objectAttributesAttribute->type = new RecordType($objectAttributesStructure);
243275 $definedMeaningAttributesAttribute->type = new RecordType($objectAttributesStructure);
244 -
245 - global
246 - $classAttributesStructure,
247 - // $classAttributeClassAttribute,
248 - $classAttributeIdAttribute, $classAttributeAttributeAttribute, $classAttributeLevelAttribute, $classAttributeTypeAttribute,
249 - $wgClassAttributeAttributeAttributeName, $wgClassAttributeLevelAttributeName,
250 - $wgClassAttributeTypeAttributeName, $wgClassAttributesAttributeName;
251 -
252 - $classAttributeIdAttribute = new Attribute("class-attribute-id", "Class attribute identifier", "object-id");
253 - $classAttributeAttributeAttribute = new Attribute("class-attribute-attribute", $wgClassAttributeAttributeAttributeName, new RecordType($definedMeaningReferenceStructure));
254 - $classAttributeLevelAttribute = new Attribute("class-attribute-level", $wgClassAttributeLevelAttributeName, new RecordType($definedMeaningReferenceStructure));
255 - $classAttributeTypeAttribute = new Attribute("class-attribute-type", $wgClassAttributeTypeAttributeName, "short-text");
256 - $classAttributesStructure = new Structure($classAttributeIdAttribute, $classAttributeAttributeAttribute, $classAttributeLevelAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute);
257 - $classAttributesAttribute = new Attribute("class-attributes", $wgClassAttributesAttributeName, new RecordSetType($classAttributesStructure));
258276 }
259277
260278 ?>
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php
@@ -4,6 +4,7 @@
55 require_once('OmegaWikiAttributes.php');
66 require_once('WikiDataBootstrappedMeanings.php');
77 require_once('Fetcher.php');
 8+require_once('WikiDataGlobals.php');
89 require_once('GotoSourceTemplate.php');
910
1011 function initializeObjectAttributeEditors($filterLanguageId, $showRecordLifeSpan, $showAuthority) {
@@ -398,43 +399,65 @@
399400 return $expressionsEditor;
400401 }
401402
 403+class AttributeEditorMap {
 404+ protected $attributeEditorMap = array();
 405+
 406+ public function addEditor($editor) {
 407+ $attributeId = $editor->getAttribute()->id;
 408+ $this->attributeEditorMap[$attributeId] = $editor;
 409+ }
 410+
 411+ public function getEditorForAttributeId($attributeId) {
 412+ return $this->attributeEditorMap[$attributeId];
 413+ }
 414+}
 415+
402416 function getDefinedMeaningEditor($filterLanguageId, $possiblySynonymousRelationTypeId, $showRecordLifeSpan, $showAuthority) {
403417 global
 418+ $wgDefinedMeaningAttributesOrder,
404419 $definedMeaningAttribute, $possiblySynonymousIdAttribute, $possiblySynonymousAttribute,
405420 $possibleSynonymAttribute, $definedMeaningObjectAttributesEditor, $possiblySynonymousObjectAttributesEditor;
406421
407422 $definitionEditor = getDefinitionEditor($filterLanguageId, $showRecordLifeSpan, $showAuthority);
 423+ $alternativeDefinitionsEditor = getAlternativeDefinitionsEditor($filterLanguageId, $showRecordLifeSpan, $showAuthority);
408424 $classAttributesEditor = getClassAttributesEditor($showRecordLifeSpan, $showAuthority);
409425 $synonymsAndTranslationsEditor = getSynonymsAndTranslationsEditor($filterLanguageId, $showRecordLifeSpan, $showAuthority);
410426 $relationsEditor = getDefinedMeaningRelationsEditor($showRecordLifeSpan, $showAuthority);
411427 $reciprocalRelationsEditor = getDefinedMeaningReciprocalRelationsEditor($showRecordLifeSpan, $showAuthority);
412428 $classMembershipEditor = getDefinedMeaningClassMembershipEditor($showRecordLifeSpan, $showAuthority);
413429 $collectionMembershipEditor = getDefinedMeaningCollectionMembershipEditor($showRecordLifeSpan, $showAuthority);
 430+ $possiblySynonymousEditor = getGroupedRelationTypeEditor(
 431+ $possiblySynonymousAttribute,
 432+ $possiblySynonymousIdAttribute,
 433+ $possibleSynonymAttribute,
 434+ $possiblySynonymousRelationTypeId,
 435+ $showRecordLifeSpan,
 436+ $showAuthority,
 437+ $possiblySynonymousObjectAttributesEditor
 438+ );
414439
415 - $definedMeaningEditor = new RecordUnorderedListEditor($definedMeaningAttribute, 4);
416 - $definedMeaningEditor->addEditor($definitionEditor);
417 - $definedMeaningEditor->addEditor($classAttributesEditor);
418 - $definedMeaningEditor->addEditor(getAlternativeDefinitionsEditor($filterLanguageId, $showRecordLifeSpan, $showAuthority));
419 - $definedMeaningEditor->addEditor($synonymsAndTranslationsEditor);
 440+ $availableEditors = new AttributeEditorMap();
 441+ $availableEditors->addEditor($definitionEditor);
 442+ $availableEditors->addEditor($alternativeDefinitionsEditor);
 443+ $availableEditors->addEditor($classAttributesEditor);
 444+ $availableEditors->addEditor($synonymsAndTranslationsEditor);
 445+ $availableEditors->addEditor($relationsEditor);
 446+ $availableEditors->addEditor($reciprocalRelationsEditor);
 447+ $availableEditors->addEditor($classMembershipEditor);
 448+ $availableEditors->addEditor($collectionMembershipEditor);
 449+ $availableEditors->addEditor($definedMeaningObjectAttributesEditor);
420450
421451 if ($possiblySynonymousRelationTypeId != 0)
422 - $definedMeaningEditor->addEditor(
423 - getGroupedRelationTypeEditor(
424 - $possiblySynonymousAttribute,
425 - $possiblySynonymousIdAttribute,
426 - $possibleSynonymAttribute,
427 - $possiblySynonymousRelationTypeId,
428 - $showRecordLifeSpan,
429 - $showAuthority,
430 - $possiblySynonymousObjectAttributesEditor
431 - )
432 - );
 452+ $availableEditors->addEditor($possiblySynonymousEditor);
 453+
 454+ $definedMeaningEditor = new RecordUnorderedListEditor($definedMeaningAttribute, 4);
 455+
 456+ foreach ($wgDefinedMeaningAttributesOrder as $attributeId) {
 457+ $editor = $availableEditors->getEditorForAttributeId($attributeId);
433458
434 - $definedMeaningEditor->addEditor($relationsEditor);
435 - $definedMeaningEditor->addEditor($reciprocalRelationsEditor);
436 - $definedMeaningEditor->addEditor($classMembershipEditor);
437 - $definedMeaningEditor->addEditor($collectionMembershipEditor);
438 - $definedMeaningEditor->addEditor($definedMeaningObjectAttributesEditor);
 459+ if ($editor != null)
 460+ $definedMeaningEditor->addEditor($editor);
 461+ }
439462
440463 $definedMeaningEditor->expandEditor($definitionEditor);
441464 $definedMeaningEditor->expandEditor($synonymsAndTranslationsEditor);