r23038 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23037‎ | r23038 | r23039 >
Date:20:11, 16 June 2007
Author:erik
Status:old
Tags:
Comment:
refactor out RecordType, ScalarType and RecordSetType
cache language IDs and names
Modified paths:
  • /trunk/extensions/Wikidata/App.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Attribute.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Editor.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/HTMLtable.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWiki.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Record.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/RecordSet.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Search.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialDatasearch.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialTransaction.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Transaction.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/converter.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/languages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/App.php
@@ -29,6 +29,7 @@
3030
3131 # These are the user groups
3232 $wgGroupPermissions['wikidata-omega']['editwikidata-uw']=true;
 33+$wgGroupPermissions['wikidata-omega']['editwikidata-moo']=true;
3334 $wgGroupPermissions['wikidata-omega']['editwikidata-tt']=false;
3435 $wgGroupPermissions['wikidata-test']['editwikidata-tt']=true;
3536
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialDatasearch.php
@@ -51,13 +51,13 @@
5252 $this->languageAttribute = new Attribute("language", "Language", "language");
5353
5454 $this->expressionStructure = new Structure($this->spellingAttribute, $this->languageAttribute);
55 - $this->expressionAttribute = new Attribute("expression", "Expression", new RecordType($this->expressionStructure));
 55+ $this->expressionAttribute = new Attribute("expression", "Expression", $this->expressionStructure);
5656
5757 $this->definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", $definedMeaningReferenceType);
5858 $this->definitionAttribute = new Attribute("definition", "Definition", "definition");
5959
6060 $this->meaningStructure = new Structure($this->definedMeaningAttribute, $this->definitionAttribute);
61 - $this->meaningAttribute = new Attribute("meaning", "Meaning", new RecordSetType($this->meaningStructure));
 61+ $this->meaningAttribute = new Attribute("meaning", "Meaning", $this->meaningStructure);
6262
6363 $this->externalIdentifierAttribute = new Attribute("external-identifier", "External identifier", "short-text");
6464 $this->collectionAttribute = new Attribute("collection", "Collection", $definedMeaningReferenceType);
Index: trunk/extensions/Wikidata/OmegaWiki/converter.php
@@ -24,7 +24,7 @@
2525 public function convert($record) {
2626 $result = new ArrayRecord($this->structure);
2727
28 - foreach($this->structure->attributes as $attribute)
 28+ foreach($this->structure->getStructure() as $attribute)
2929 $result->setAttributeValue($attribute, $record->getAttributeValue($attribute));
3030
3131 return $result;
Index: trunk/extensions/Wikidata/OmegaWiki/HTMLtable.php
@@ -28,12 +28,13 @@
2929 function getTableHeaderNode($structure, &$currentColumn=0) {
3030 $tableHeaderNode = new TableHeaderNode();
3131
32 - foreach($structure->attributes as $attribute) {
 32+ foreach($structure->getAttributes() as $attribute) {
3333 $type = $attribute->type;
3434
35 - if ($type instanceof RecordType)
36 - $childNode = getTableHeaderNode($type->getStructure(), $currentColumn);
37 - else {
 35+ if ($type instanceof Structure) {
 36+ $atts=$type->getAttributes();
 37+ $childNode = getTableHeaderNode(new Structure($atts), $currentColumn);
 38+ } else {
3839 $childNode = new TableHeaderNode();
3940 $childNode->width = 1;
4041 $childNode->height = 1;
@@ -58,7 +59,7 @@
5960 $idPath->pushAttribute($attribute);
6061 $type = $attribute->type;
6162
62 - if (!$type instanceof RecordType && !$type instanceof RecordSetType) {
 63+ if (!$type instanceof Structure) {
6364 $skipRows=count($rows);
6465 $columnIndex=$childNode->column + $columnOffset;
6566 $sort = 'sortTable(this, '. $skipRows .', '. $columnIndex.')';
@@ -106,9 +107,7 @@
107108 }
108109
109110 function getHTMLClassForType($type,$attribute) {
110 - if ($type instanceof RecordSetType)
111 - return "relation";
112 - else if ($type instanceof RecordType)
 111+ if ($type instanceof Structure)
113112 return $attribute->id;
114113 else
115114 return $type;
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php
@@ -429,7 +429,7 @@
430430 $languageAttribute = new Attribute("language", "Language", "language");
431431
432432 $expressionStructure = new Structure($spellingAttribute, $languageAttribute);
433 - $definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", new RecordType($expressionStructure));
 433+ $definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", $expressionStructure);
434434 $definitionAttribute = new Attribute("definition", "Definition", "definition");
435435
436436 $recordSet = new ArrayRecordSet(new Structure($idAttribute, $definedMeaningAttribute, $definitionAttribute), new Structure($idAttribute));
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php
@@ -33,7 +33,7 @@
3434 $expressionAttribute = new Attribute("expression", $wgSpellingAttributeName, "spelling");
3535 else {
3636 $expressionStructure = new Structure($languageAttribute, $spellingAttribute);
37 - $expressionAttribute = new Attribute("expression", $wgExpressionAttributeName, new RecordType($expressionStructure));
 37+ $expressionAttribute = new Attribute("expression", $wgExpressionAttributeName, $expressionStructure);
3838 }
3939
4040 global
@@ -49,7 +49,7 @@
5050 $definedMeaningLabelAttribute = new Attribute("defined-meaning-label", "Defined meaning label", "short-text");
5151 $definedMeaningReferenceStructure = new Structure($definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute);
5252 $definedMeaningReferenceKeyStructure = new Structure($definedMeaningIdAttribute);
53 - $definedMeaningReferenceType = new RecordType($definedMeaningReferenceStructure);
 53+ $definedMeaningReferenceType = $definedMeaningReferenceStructure;
5454 $definedMeaningReferenceAttribute = new Attribute("defined-meaning", $wgDefinedMeaningReferenceAttributeName, $definedMeaningReferenceType);
5555
5656 global
@@ -58,22 +58,22 @@
5959 $wgCollectionAttributeName, $wgSourceIdentifierAttributeName, $wgGotoSourceAttributeName;
6060
6161 $collectionIdAttribute = new Attribute("collection", "Collection", "collection-id");
62 - $collectionMeaningType = new RecordType($definedMeaningReferenceStructure);
 62+ $collectionMeaningType = $definedMeaningReferenceStructure;
6363 $collectionMeaningAttribute = new Attribute("collection-meaning", $wgCollectionAttributeName, $collectionMeaningType);
6464 $sourceIdentifierAttribute = new Attribute("source-identifier", $wgSourceIdentifierAttributeName, "short-text");
6565 $gotoSourceStructure = new Structure($collectionIdAttribute, $sourceIdentifierAttribute);
66 - $gotoSourceAttribute = new Attribute("goto-source", $wgGotoSourceAttributeName, new RecordType($gotoSourceStructure));
 66+ $gotoSourceAttribute = new Attribute("goto-source", $wgGotoSourceAttributeName, $gotoSourceStructure);
6767
6868 global
6969 $collectionMembershipAttribute, $wgCollectionMembershipAttributeName, $wgCollectionMembershipAttributeId;
7070
71 - $collectionMembershipAttribute = new Attribute($wgCollectionMembershipAttributeId, $wgCollectionMembershipAttributeName, new RecordSetType(new Structure($collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute)));
 71+ $collectionMembershipAttribute = new Attribute($wgCollectionMembershipAttributeId, $wgCollectionMembershipAttributeName, new Structure($collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute));
7272
7373 global
7474 $classMembershipIdAttribute, $classAttribute;
7575
7676 $classMembershipIdAttribute = new Attribute("class-membership-id", "Class membership id", "integer");
77 - $classAttribute = new Attribute("class", "Class", new RecordType($definedMeaningReferenceStructure));
 77+ $classAttribute = new Attribute("class", "Class", $definedMeaningReferenceStructure);
7878
7979 global
8080 $classMembershipStructure, $classMembershipKeyStructure, $classMembershipAttribute,
@@ -81,13 +81,13 @@
8282
8383 $classMembershipStructure = new Structure($classMembershipIdAttribute, $classAttribute);
8484 $classMembershipKeyStructure = new Structure($classMembershipIdAttribute);
85 - $classMembershipAttribute = new Attribute($wgClassMembershipAttributeId, $wgClassMembershipAttributeName, new RecordSetType($classMembershipStructure));
 85+ $classMembershipAttribute = new Attribute($wgClassMembershipAttributeId, $wgClassMembershipAttributeName, $classMembershipStructure);
8686
8787 global
8888 $possiblySynonymousIdAttribute, $possibleSynonymAttribute, $wgPossibleSynonymAttributeName;
8989
9090 $possiblySynonymousIdAttribute = new Attribute("possibly-synonymous-id", "Possibly synonymous id", "integer");
91 - $possibleSynonymAttribute = new Attribute("possible-synonym", $wgPossibleSynonymAttributeName, new RecordType($definedMeaningReferenceStructure));
 91+ $possibleSynonymAttribute = new Attribute("possible-synonym", $wgPossibleSynonymAttributeName, $definedMeaningReferenceStructure);
9292
9393 global
9494 $possiblySynonymousStructure, $possiblySynonymousKeyStructure, $possiblySynonymousAttribute,
@@ -95,14 +95,14 @@
9696
9797 $possiblySynonymousStructure = new Structure($possiblySynonymousIdAttribute, $possiblySynonymousAttribute);
9898 $possiblySynonymousKeyStructure = new Structure($possiblySynonymousIdAttribute);
99 - $possiblySynonymousAttribute = new Attribute($wgPossiblySynonymousAttributeId, $wgPossiblySynonymousAttributeName, new RecordSetType($possiblySynonymousStructure));
 99+ $possiblySynonymousAttribute = new Attribute($wgPossiblySynonymousAttributeId, $wgPossiblySynonymousAttributeName, $possiblySynonymousStructure);
100100
101101 global
102102 $relationIdAttribute, $relationTypeAttribute, $relationTypeType, $otherDefinedMeaningAttribute,
103103 $wgRelationTypeAttributeName, $wgOtherDefinedMeaningAttributeName;
104104
105105 $relationIdAttribute = new Attribute("relation-id", "Relation identifier", "object-id");
106 - $relationTypeType = new RecordType($definedMeaningReferenceStructure);
 106+ $relationTypeType = $definedMeaningReferenceStructure;
107107 $relationTypeAttribute = new Attribute("relation-type", $wgRelationTypeAttributeName, $relationTypeType);
108108 $otherDefinedMeaningAttribute = new Attribute("other-defined-meaning", $wgOtherDefinedMeaningAttributeName, $definedMeaningReferenceType);
109109
@@ -112,8 +112,8 @@
113113
114114 $relationStructure = new Structure($relationIdAttribute, $relationTypeAttribute, $otherDefinedMeaningAttribute, $objectAttributesAttribute);
115115 $relationKeyStructure = new Structure($relationIdAttribute);
116 - $relationsAttribute = new Attribute($wgRelationsAttributeId, $wgRelationsAttributeName, new RecordSetType($relationStructure));
117 - $reciprocalRelationsAttribute = new Attribute($wgIncomingRelationsAttributeId, $wgIncomingRelationsAttributeName, new RecordSetType($relationStructure));
 116+ $relationsAttribute = new Attribute($wgRelationsAttributeId, $wgRelationsAttributeName, $relationStructure);
 117+ $reciprocalRelationsAttribute = new Attribute($wgIncomingRelationsAttributeId, $wgIncomingRelationsAttributeName, $relationStructure);
118118
119119 global
120120 $translatedTextIdAttribute, $translatedTextStructure;
@@ -130,14 +130,14 @@
131131 if ($filterOnLanguage && !$hasMetaDataAttributes)
132132 $alternativeDefinitionAttribute = new Attribute("alternative-definition", $wgAlternativeDefinitionAttributeName, "text");
133133 else
134 - $alternativeDefinitionAttribute = new Attribute("alternative-definition", $wgAlternativeDefinitionAttributeName, new RecordSetType($translatedTextStructure));
 134+ $alternativeDefinitionAttribute = new Attribute("alternative-definition", $wgAlternativeDefinitionAttributeName, $translatedTextStructure);
135135
136136 $sourceAttribute = new Attribute("source-id", $wgSourceAttributeName, $definedMeaningReferenceType);
137137
138138 global
139139 $alternativeDefinitionsAttribute, $wgAlternativeDefinitionsAttributeName, $wgAlternativeDefinitionsAttributeId;
140140
141 - $alternativeDefinitionsAttribute = new Attribute($wgAlternativeDefinitionsAttributeId, $wgAlternativeDefinitionsAttributeName, new RecordSetType(new Structure($definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute)));
 141+ $alternativeDefinitionsAttribute = new Attribute($wgAlternativeDefinitionsAttributeId, $wgAlternativeDefinitionsAttributeName, new Structure($definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute));
142142
143143 global
144144 $synonymsAndTranslationsAttribute, $syntransIdAttribute,
@@ -149,7 +149,7 @@
150150 $synonymsAndTranslationsCaption = $wgSynonymsAndTranslationsAttributeName;
151151
152152 $syntransIdAttribute = new Attribute("syntrans-id", "$synonymsAndTranslationsCaption identifier", "integer");
153 - $synonymsAndTranslationsAttribute = new Attribute($wgSynonymsAndTranslationsAttributeId, "$synonymsAndTranslationsCaption", new RecordSetType(new Structure($syntransIdAttribute, $expressionAttribute, $identicalMeaningAttribute, $objectAttributesAttribute)));
 153+ $synonymsAndTranslationsAttribute = new Attribute($wgSynonymsAndTranslationsAttributeId, "$synonymsAndTranslationsCaption", new Structure($syntransIdAttribute, $expressionAttribute, $identicalMeaningAttribute, $objectAttributesAttribute));
154154
155155 global
156156 $translatedTextAttributeIdAttribute, $translatedTextValueIdAttribute,
@@ -164,10 +164,10 @@
165165 if ($filterOnLanguage && !$hasMetaDataAttributes)
166166 $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, "text");
167167 else
168 - $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, new RecordSetType($translatedTextStructure));
 168+ $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, $translatedTextStructure);
169169
170170 $translatedTextAttributeValuesStructure = new Structure($translatedTextAttributeIdAttribute, $translatedTextAttributeObjectAttribute, $translatedTextAttributeAttribute, $translatedTextValueIdAttribute, $translatedTextValueAttribute, $objectAttributesAttribute);
171 - $translatedTextAttributeValuesAttribute = new Attribute("translated-text-attribute-values", $wgTranslatedTextAttributeValuesAttributeName, new RecordSetType($translatedTextAttributeValuesStructure));
 171+ $translatedTextAttributeValuesAttribute = new Attribute("translated-text-attribute-values", $wgTranslatedTextAttributeValuesAttributeName, $translatedTextAttributeValuesStructure);
172172
173173 global
174174 $textAttributeIdAttribute, $textAttributeObjectAttribute, $textAttributeAttribute, $textAttributeValuesStructure,
@@ -176,9 +176,9 @@
177177
178178 $textAttributeIdAttribute = new Attribute("text-attribute-id", "Attribute identifier", "object-id");
179179 $textAttributeObjectAttribute = new Attribute("text-attribute-object-id", "Attribute object", "object-id");
180 - $textAttributeAttribute = new Attribute("text-attribute", $wgTextAttributeAttributeName, new RecordSetType($definedMeaningReferenceStructure));
 180+ $textAttributeAttribute = new Attribute("text-attribute", $wgTextAttributeAttributeName, $definedMeaningReferenceStructure);
181181 $textAttributeValuesStructure = new Structure($textAttributeIdAttribute, $textAttributeObjectAttribute, $textAttributeAttribute, $textAttribute, $objectAttributesAttribute);
182 - $textAttributeValuesAttribute = new Attribute("text-attribute-values", $wgTextAttributeValuesAttributeName, new RecordSetType($textAttributeValuesStructure));
 182+ $textAttributeValuesAttribute = new Attribute("text-attribute-values", $wgTextAttributeValuesAttributeName, $textAttributeValuesStructure);
183183
184184 global
185185 $urlAttribute, $urlAttributeIdAttribute, $urlAttributeObjectAttribute, $urlAttributeAttribute, $urlAttributeValuesStructure, $urlAttributeValuesAttribute,
@@ -187,9 +187,9 @@
188188 $urlAttribute = new Attribute("url", "URL", "url");
189189 $urlAttributeIdAttribute = new Attribute("url-attribute-id", "Attribute identifier", "object-id");
190190 $urlAttributeObjectAttribute = new Attribute("url-attribute-object-id", "Attribute object", "object-id");
191 - $urlAttributeAttribute = new Attribute("url-attribute", $wgUrlAttributeAttributeName, new RecordSetType($definedMeaningReferenceStructure));
 191+ $urlAttributeAttribute = new Attribute("url-attribute", $wgUrlAttributeAttributeName, $definedMeaningReferenceStructure);
192192 $urlAttributeValuesStructure = new Structure($urlAttributeIdAttribute, $urlAttributeObjectAttribute, $urlAttributeAttribute, $urlAttribute, $objectAttributesAttribute);
193 - $urlAttributeValuesAttribute = new Attribute("url-attribute-values", $wgUrlAttributeValuesAttributeName, new RecordSetType($urlAttributeValuesStructure));
 193+ $urlAttributeValuesAttribute = new Attribute("url-attribute-values", $wgUrlAttributeValuesAttributeName, $urlAttributeValuesStructure);
194194
195195 global
196196 $optionAttributeIdAttribute, $optionAttributeAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionAttribute, $optionAttributeValuesAttribute,
@@ -200,14 +200,14 @@
201201 $optionAttributeAttribute = new Attribute('option-attribute', $wgOptionAttributeAttributeName, $definedMeaningReferenceType);
202202 $optionAttributeOptionAttribute = new Attribute('option-attribute-option', $wgOptionAttributeOptionAttributeName, $definedMeaningReferenceType);
203203 $optionAttributeValuesStructure = new Structure($optionAttributeIdAttribute, $optionAttributeAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionAttribute, $objectAttributesAttribute);
204 - $optionAttributeValuesAttribute = new Attribute('option-attribute-values', $wgOptionAttributeValuesAttributeName, new RecordSetType($optionAttributeValuesStructure));
 204+ $optionAttributeValuesAttribute = new Attribute('option-attribute-values', $wgOptionAttributeValuesAttributeName, $optionAttributeValuesStructure);
205205
206206 global
207207 $optionAttributeOptionIdAttribute, $optionAttributeOptionsAttribute, $wgOptionAttributeOptionsAttributeName;
208208
209209 $optionAttributeOptionIdAttribute = new Attribute('option-attribute-option-id', 'Option identifier', 'object-id');
210210 $optionAttributeOptionsStructure = new Structure($optionAttributeOptionIdAttribute, $optionAttributeAttribute, $optionAttributeOptionAttribute, $languageAttribute);
211 - $optionAttributeOptionsAttribute = new Attribute('option-attribute-options', $wgOptionAttributeOptionsAttributeName, new RecordSetType($optionAttributeOptionsStructure));
 211+ $optionAttributeOptionsAttribute = new Attribute('option-attribute-options', $wgOptionAttributeOptionsAttributeName, $optionAttributeOptionsStructure);
212212
213213 global
214214 $definitionAttribute, $translatedTextAttribute, $classAttributesAttribute,
@@ -216,9 +216,9 @@
217217 if ($filterOnLanguage && !$hasMetaDataAttributes)
218218 $translatedTextAttribute = new Attribute("translated-text", $wgTextAttributeName, "text");
219219 else
220 - $translatedTextAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeName, new RecordSetType($translatedTextStructure));
 220+ $translatedTextAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeName, $translatedTextStructure);
221221
222 - $definitionAttribute = new Attribute($wgDefinitionAttributeId, $wgDefinitionAttributeName, new RecordType(new Structure($translatedTextAttribute, $objectAttributesAttribute)));
 222+ $definitionAttribute = new Attribute($wgDefinitionAttributeId, $wgDefinitionAttributeName, new Structure($translatedTextAttribute, $objectAttributesAttribute));
223223
224224 global
225225 $classAttributesStructure,
@@ -228,17 +228,17 @@
229229 $wgClassAttributeTypeAttributeName, $wgClassAttributesAttributeName, $wgClassAttributesAttributeId;
230230
231231 $classAttributeIdAttribute = new Attribute("class-attribute-id", "Class attribute identifier", "object-id");
232 - $classAttributeAttributeAttribute = new Attribute("class-attribute-attribute", $wgClassAttributeAttributeAttributeName, new RecordType($definedMeaningReferenceStructure));
233 - $classAttributeLevelAttribute = new Attribute("class-attribute-level", $wgClassAttributeLevelAttributeName, new RecordType($definedMeaningReferenceStructure));
 232+ $classAttributeAttributeAttribute = new Attribute("class-attribute-attribute", $wgClassAttributeAttributeAttributeName, $definedMeaningReferenceStructure);
 233+ $classAttributeLevelAttribute = new Attribute("class-attribute-level", $wgClassAttributeLevelAttributeName, $definedMeaningReferenceStructure);
234234 $classAttributeTypeAttribute = new Attribute("class-attribute-type", $wgClassAttributeTypeAttributeName, "short-text");
235235 $classAttributesStructure = new Structure($classAttributeIdAttribute, $classAttributeAttributeAttribute, $classAttributeLevelAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute);
236 - $classAttributesAttribute = new Attribute($wgClassAttributesAttributeId, $wgClassAttributesAttributeName, new RecordSetType($classAttributesStructure));
 236+ $classAttributesAttribute = new Attribute($wgClassAttributesAttributeId, $wgClassAttributesAttributeName, $classAttributesStructure);
237237
238238 global
239239 $definedMeaningAttribute, $wgDefinedMeaningAttributeName;
240240
241241 $definedMeaningAttribute = new Attribute("defined-meaning", $wgDefinedMeaningAttributeName,
242 - new RecordType(new Structure(
 242+ new Structure(
243243 $definitionAttribute,
244244 $classAttributesAttribute,
245245 $alternativeDefinitionsAttribute,
@@ -248,7 +248,6 @@
249249 $classMembershipAttribute,
250250 $collectionMembershipAttribute,
251251 $definedMeaningAttributesAttribute)
252 - )
253252 );
254253
255254 global
@@ -256,25 +255,25 @@
257256 $wgExactMeaningsAttributeName, $wgApproximateMeaningsAttributeName;
258257
259258 $expressionMeaningStructure = new Structure($definedMeaningIdAttribute, $textAttribute, $definedMeaningAttribute);
260 - $expressionExactMeaningsAttribute = new Attribute("expression-exact-meanings", $wgExactMeaningsAttributeName, new RecordSetType($expressionMeaningStructure));
261 - $expressionApproximateMeaningsAttribute = new Attribute("expression-approximate-meanings", $wgApproximateMeaningsAttributeName, new RecordSetType($expressionMeaningStructure));
 259+ $expressionExactMeaningsAttribute = new Attribute("expression-exact-meanings", $wgExactMeaningsAttributeName, $expressionMeaningStructure);
 260+ $expressionApproximateMeaningsAttribute = new Attribute("expression-approximate-meanings", $wgApproximateMeaningsAttributeName, $expressionMeaningStructure);
262261
263262 global
264263 $expressionMeaningsAttribute, $expressionMeaningsStructure, $expressionApproximateMeaningAttribute,
265264 $wgExpressionMeaningsAttributeName, $wgExpressionsAttributeName;
266265
267266 $expressionMeaningsStructure = new Structure($expressionExactMeaningsAttribute, $expressionApproximateMeaningAttribute);
268 - $expressionMeaningsAttribute = new Attribute("expression-meanings", $wgExpressionMeaningsAttributeName, new RecordType($expressionMeaningsStructure));
 267+ $expressionMeaningsAttribute = new Attribute("expression-meanings", $wgExpressionMeaningsAttributeName, $expressionMeaningsStructure);
269268
270 - $expressionsAttribute = new Attribute("expressions", $wgExpressionsAttributeName, new RecordSetType(new Structure($expressionIdAttribute, $expressionAttribute, $expressionMeaningsAttribute)));
 269+ $expressionsAttribute = new Attribute("expressions", $wgExpressionsAttributeName, new Structure($expressionIdAttribute, $expressionAttribute, $expressionMeaningsAttribute));
271270
272271 global
273272 $objectIdAttribute, $objectAttributesStructure, $wgAnnotationAttributeName;
274273
275274 $objectIdAttribute = new Attribute("object-id", "Object identifier", "object-id");
276275 $objectAttributesStructure = new Structure($objectIdAttribute, $textAttributeValuesAttribute, $translatedTextAttributeValuesAttribute, $optionAttributeValuesAttribute);
277 - $objectAttributesAttribute->type = new RecordType($objectAttributesStructure);
278 - $definedMeaningAttributesAttribute->type = new RecordType($objectAttributesStructure);
 276+ $objectAttributesAttribute->type = $objectAttributesStructure;
 277+ $definedMeaningAttributesAttribute->type = $objectAttributesStructure;
279278 }
280279
281280 ?>
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialTransaction.php
@@ -134,7 +134,7 @@
135135 $isLatestAttribute = new Attribute('is-latest', 'Is latest', 'boolean');
136136
137137 $rollBackStructure = new Structure($isLatestAttribute, $operationAttribute);
138 - $rollBackAttribute = new Attribute('roll-back', 'Roll back', new RecordType($rollBackStructure));
 138+ $rollBackAttribute = new Attribute('roll-back', 'Roll back', $rollBackStructure);
139139
140140 global
141141 $translatedContentHistoryStructure, $translatedContentHistoryKeyStructure, $translatedContentHistoryAttribute,
@@ -144,14 +144,14 @@
145145
146146 $translatedContentHistoryStructure = new Structure($addTransactionIdAttribute, $textAttribute, $recordLifeSpanAttribute);
147147 $translatedContentHistoryKeyStructure = new Structure($addTransactionIdAttribute);
148 - $translatedContentHistoryAttribute = new Attribute('translated-content-history', 'History', new RecordSetType($translatedContentHistoryStructure));
 148+ $translatedContentHistoryAttribute = new Attribute('translated-content-history', 'History', $translatedContentHistoryStructure);
149149 $translatedContentIdAttribute = new Attribute('translated-content-id', 'Translated content ID', 'object-id');
150150
151151 global
152152 $rollBackTranslatedContentStructure, $rollBackTranslatedContentAttribute;
153153
154154 $rollBackTranslatedContentStructure = new Structure($isLatestAttribute, $operationAttribute, $translatedContentHistoryAttribute);
155 - $rollBackTranslatedContentAttribute = new Attribute('roll-back', 'Roll back', new RecordType($rollBackTranslatedContentStructure));
 155+ $rollBackTranslatedContentAttribute = new Attribute('roll-back', 'Roll back', $rollBackTranslatedContentStructure);
156156
157157 global
158158 $updatedDefinitionStructure, $updatedDefinitionAttribute;
@@ -167,7 +167,7 @@
168168 $isLatestAttribute
169169 );
170170
171 - $updatedDefinitionAttribute = new Attribute('updated-definition', 'Definition', new RecordSetType($updatedDefinitionStructure));
 171+ $updatedDefinitionAttribute = new Attribute('updated-definition', 'Definition', $updatedDefinitionStructure);
172172
173173 global
174174 $expressionAttribute, $expressionIdAttribute, $identicalMeaningAttribute, $syntransIdAttribute, $updatedSyntransesAttribute;
@@ -182,14 +182,14 @@
183183 $operationAttribute
184184 );
185185
186 - $updatedSyntransesAttribute = new Attribute('updated-syntranses', 'Synonyms and translations', new RecordSetType($updatedSyntransesStructure));
 186+ $updatedSyntransesAttribute = new Attribute('updated-syntranses', 'Synonyms and translations', $updatedSyntransesStructure);
187187
188188 global
189189 $relationIdAttribute, $firstMeaningAttribute, $secondMeaningAttribute, $relationTypeAttribute,
190190 $updatedRelationsStructure, $updatedRelationsAttribute;
191191
192 - $firstMeaningAttribute = new Attribute('first-meaning', "First defined meaning", new RecordType($definedMeaningReferenceStructure));
193 - $secondMeaningAttribute = new Attribute('second-meaning', "Second defined meaning", new RecordType($definedMeaningReferenceStructure));
 192+ $firstMeaningAttribute = new Attribute('first-meaning', "First defined meaning", $definedMeaningReferenceStructure);
 193+ $secondMeaningAttribute = new Attribute('second-meaning', "Second defined meaning", $definedMeaningReferenceStructure);
194194
195195 $updatedRelationsStructure = new Structure(
196196 $rollBackAttribute,
@@ -201,13 +201,13 @@
202202 $isLatestAttribute
203203 );
204204
205 - $updatedRelationsAttribute = new Attribute('updated-relations', 'Relations', new RecordSetType($updatedRelationsStructure));
 205+ $updatedRelationsAttribute = new Attribute('updated-relations', 'Relations', $updatedRelationsStructure);
206206
207207 global
208208 $classMembershipIdAttribute, $classAttribute, $classMemberAttribute,
209209 $updatedClassMembershipStructure, $updatedClassMembershipAttribute;
210210
211 - $classMemberAttribute = new Attribute('class-member', 'Class member', new RecordType($definedMeaningReferenceStructure));
 211+ $classMemberAttribute = new Attribute('class-member', 'Class member', $definedMeaningReferenceStructure);
212212
213213 $updatedClassMembershipStructure = new Structure(
214214 $rollBackAttribute,
@@ -218,13 +218,13 @@
219219 $isLatestAttribute
220220 );
221221
222 - $updatedClassMembershipAttribute = new Attribute('updated-class-membership', 'Class membership', new RecordSetType($updatedClassMembershipStructure));
 222+ $updatedClassMembershipAttribute = new Attribute('updated-class-membership', 'Class membership', $updatedClassMembershipStructure);
223223
224224 global
225225 $collectionIdAttribute, $collectionMeaningAttribute, $collectionMemberAttribute, $sourceIdentifierAttribute,
226226 $updatedCollectionMembershipStructure, $updatedCollectionMembershipAttribute, $collectionMemberIdAttribute;
227227
228 - $collectionMemberAttribute = new Attribute('collection-member', 'Collection member', new RecordType($definedMeaningReferenceStructure));
 228+ $collectionMemberAttribute = new Attribute('collection-member', 'Collection member', $definedMeaningReferenceStructure);
229229 $collectionMemberIdAttribute = new Attribute('collection-member-id', 'Collection member identifier', 'defined-meaning-id');
230230
231231 $updatedCollectionMembershipStructure = new Structure(
@@ -237,14 +237,14 @@
238238 $operationAttribute
239239 );
240240
241 - $updatedCollectionMembershipAttribute = new Attribute('updated-collection-membership', 'Collection membership', new RecordSetType($updatedCollectionMembershipStructure));
 241+ $updatedCollectionMembershipAttribute = new Attribute('updated-collection-membership', 'Collection membership', $updatedCollectionMembershipStructure);
242242
243243 global
244244 $objectIdAttribute, $valueIdAttribute, $attributeAttribute;
245245
246246 $objectIdAttribute = new Attribute('object-id', 'Object', 'object-id');
247247 $valueIdAttribute = new Attribute('value-id', 'Value identifier', 'object-id');
248 - $attributeAttribute = new Attribute('attribute', 'Attribute', new RecordType($definedMeaningReferenceStructure));
 248+ $attributeAttribute = new Attribute('attribute', 'Attribute', $definedMeaningReferenceStructure);
249249
250250 global
251251 $updatedURLAttribute, $updatedURLStructure, $URLAttribute;
@@ -261,7 +261,7 @@
262262 $isLatestAttribute
263263 );
264264
265 - $updatedURLAttribute = new Attribute('updated-url', 'URL properties', new RecordSetType($updatedURLStructure));
 265+ $updatedURLAttribute = new Attribute('updated-url', 'URL properties', $updatedURLStructure);
266266
267267 global
268268 $updatedTextAttribute, $updatedTextStructure, $textAttribute;
@@ -276,13 +276,13 @@
277277 $isLatestAttribute
278278 );
279279
280 - $updatedTextAttribute = new Attribute('updated-text', 'Unstructured text properties', new RecordSetType($updatedTextStructure));
 280+ $updatedTextAttribute = new Attribute('updated-text', 'Unstructured text properties', $updatedTextStructure);
281281
282282 global
283283 $translatedTextStructure,
284284 $updatedTranslatedTextPropertyAttribute, $updatedTranslatedTextPropertyStructure, $translatedTextTextAttribute;
285285
286 - $translatedTextTextAttribute = new Attribute('translated-text-property-text', 'Text', new RecordSetType($translatedTextStructure));
 286+ $translatedTextTextAttribute = new Attribute('translated-text-property-text', 'Text', $translatedTextStructure);
287287
288288 $updatedTranslatedTextPropertyStructure = new Structure(
289289 $rollBackAttribute,
@@ -295,7 +295,7 @@
296296 $isLatestAttribute
297297 );
298298
299 - $updatedTranslatedTextPropertyAttribute = new Attribute('updated-translated-text-property', 'Text properties', new RecordSetType($updatedTranslatedTextPropertyStructure));
 299+ $updatedTranslatedTextPropertyAttribute = new Attribute('updated-translated-text-property', 'Text properties', $updatedTranslatedTextPropertyStructure);
300300
301301 global
302302 $updatedTranslatedTextStructure, $updatedTranslatedTextAttribute;
@@ -312,14 +312,14 @@
313313 $isLatestAttribute
314314 );
315315
316 - $updatedTranslatedTextAttribute = new Attribute('updated-translated-text', 'Texts', new RecordSetType($updatedTranslatedTextStructure));
 316+ $updatedTranslatedTextAttribute = new Attribute('updated-translated-text', 'Texts', $updatedTranslatedTextStructure);
317317
318318 global
319319 $updatedClassAttributesAttribute, $updatedClassAttributesStructure, $classAttributeId, $levelAttribute,
320320 $typeAttribute;
321321
322322 $classAttributeId = new Attribute('class-attribute-id', 'Class attribute id', 'object-id');
323 - $levelAttribute = new Attribute('level', 'Level', new RecordType($definedMeaningReferenceStructure));
 323+ $levelAttribute = new Attribute('level', 'Level', $definedMeaningReferenceStructure);
324324 $typeAttribute = new Attribute('type', 'Type', 'text');
325325
326326 $updatedClassAttributesStructure = new Structure(
@@ -333,14 +333,14 @@
334334 $isLatestAttribute
335335 );
336336
337 - $updatedClassAttributesAttribute = new Attribute('updated-class-attributes', 'Class attributes', new RecordSetType($updatedClassAttributesStructure));
 337+ $updatedClassAttributesAttribute = new Attribute('updated-class-attributes', 'Class attributes', $updatedClassAttributesStructure);
338338
339339 global
340340 $updatedAlternativeDefinitionsStructure, $updatedAlternativeDefinitionsAttribute, $sourceAttribute,
341341 $alternativeDefinitionTextAttribute;
342342
343 - $alternativeDefinitionTextAttribute = new Attribute('alternative-definition-text', 'Definition', new RecordSetType($translatedTextStructure));
344 - $sourceAttribute = new Attribute('source', 'Source', new RecordType($definedMeaningReferenceStructure));
 343+ $alternativeDefinitionTextAttribute = new Attribute('alternative-definition-text', 'Definition', $translatedTextStructure);
 344+ $sourceAttribute = new Attribute('source', 'Source', $definedMeaningReferenceStructure);
345345
346346 $updatedAlternativeDefinitionsStructure = new Structure(
347347 $rollBackAttribute,
@@ -353,7 +353,7 @@
354354 $isLatestAttribute
355355 );
356356
357 - $updatedAlternativeDefinitionsAttribute = new Attribute('updated-alternative-definitions', 'Alternative definitions', new RecordSetType($updatedAlternativeDefinitionsStructure));
 357+ $updatedAlternativeDefinitionsAttribute = new Attribute('updated-alternative-definitions', 'Alternative definitions', $updatedAlternativeDefinitionsStructure);
358358
359359 global
360360 $updatedAlternativeDefinitionTextAttribute, $updatedAlternativeDefinitionTextStructure;
@@ -370,7 +370,7 @@
371371 $isLatestAttribute
372372 );
373373
374 - $updatedAlternativeDefinitionTextAttribute = new Attribute('updated-alternative-definition-text', 'Alternative definition text', new RecordSetType($updatedAlternativeDefinitionTextStructure));
 374+ $updatedAlternativeDefinitionTextAttribute = new Attribute('updated-alternative-definition-text', 'Alternative definition text', $updatedAlternativeDefinitionTextStructure);
375375
376376 global
377377 $updatesInTransactionAttribute;
@@ -386,7 +386,7 @@
387387 $updatedAlternativeDefinitionsAttribute
388388 );
389389
390 - $updatesInTransactionAttribute = new Attribute('updates-in-transaction', 'Updates in transaction', new RecordType($updatesInTransactionStructure));
 390+ $updatesInTransactionAttribute = new Attribute('updates-in-transaction', 'Updates in transaction', $updatesInTransactionStructure);
391391 }
392392
393393 function getTransactionRecordSet($fromTransactionId, $transactionCount, $userName) {
@@ -412,10 +412,10 @@
413413 $transactionCount
414414 );
415415
416 - $recordSet->getStructure()->attributes[] = $transactionIdAttribute;
 416+ $recordSet->getStructure()->addAttribute($transactionIdAttribute);
417417 expandTransactionIDsInRecordSet($recordSet, $transactionIdAttribute, $transactionAttribute);
418418
419 - $recordSet->getStructure()->attributes[] = $updatesInTransactionAttribute;
 419+ $recordSet->getStructure()->addAttribute($updatesInTransactionAttribute);
420420 expandUpdatesInTransactionInRecordSet($recordSet);
421421
422422 return $recordSet;
@@ -1248,7 +1248,7 @@
12491249 }
12501250
12511251 function simpleRecord($structure, $values) {
1252 - $attributes = $structure->attributes;
 1252+ $attributes = $structure->getAttributes();
12531253 $result = new ArrayRecord($structure);
12541254
12551255 for ($i = 0; $i < count($attributes); $i++)
Index: trunk/extensions/Wikidata/OmegaWiki/RecordSet.php
@@ -156,7 +156,7 @@
157157 $attributes = array();
158158
159159 foreach ($this->converters as $converter)
160 - $attributes = array_merge($attributes, $converter->getStructure()->attributes);
 160+ $attributes = array_merge($attributes, $converter->getStructure()->getAttributes());
161161
162162 return new Structure($attributes);
163163 }
@@ -186,7 +186,7 @@
187187 function getStructureAsListStructure($structure) {
188188 $result = '<h5>';
189189
190 - foreach($structure->attributes as $attribute) {
 190+ foreach($structure->getAttributes() as $attribute) {
191191 $result .= getAttributeAsText($attribute);
192192 $result .= ' - ';
193193 }
@@ -197,9 +197,9 @@
198198
199199 function getAttributeAsText($attribute){
200200 $type = $attribute->type;
201 - if (is_a($type, RecordType)) {
 201+ if (is_a($type, Structure)) {
202202 $structure = $type->getStructure();
203 - foreach($structure->attributes as $innerAttribute) {
 203+ foreach($structure->getAttributes() as $innerAttribute) {
204204 $result .= getAttributeAsText($innerAttribute);
205205 $result .= ' - ';
206206 }
@@ -214,11 +214,11 @@
215215 function getRecordAsListItem($structure, $record) {
216216 $result = '';
217217
218 - foreach($structure->attributes as $attribute) {
 218+ foreach($structure->getAttributes() as $attribute) {
219219 $type = $attribute->type;
220220 $value = $record->getAttributeValue($attribute);
221221
222 - if (is_a($type, RecordType)) {
 222+ if (is_a($type, Structure)) {
223223 $result .= getRecordAsListItem($type->getStructure(), $value);
224224 }
225225 else {
@@ -248,7 +248,7 @@
249249 for ($i = 0; $i < $recordSet->getRecordCount(); $i++) {
250250 $record = $recordSet->getRecord($i);
251251 $groupAttributeValue = $record->getAttributeValue($groupAttribute);
252 - $groupRecordSet = $result[$groupAttributeValue];
 252+ @$groupRecordSet = $result[$groupAttributeValue]; # FIXME - check existence in array
253253
254254 if ($groupRecordSet == null) {
255255 $groupRecordSet = new ArrayRecordSet($structure, $key);
Index: trunk/extensions/Wikidata/OmegaWiki/Attribute.php
@@ -1,37 +1,5 @@
22 <?php
33
4 -class ScalarType {
5 - protected $id;
6 -
7 - public function __construct($id) {
8 - $this->id = $id;
9 - }
10 -}
11 -
12 -class RecordType {
13 - protected $structure;
14 -
15 - public function __construct($structure) {
16 - $this->structure = $structure;
17 - }
18 -
19 - public function getStructure() {
20 - return $this->structure;
21 - }
22 -}
23 -
24 -class RecordSetType {
25 - protected $structure;
26 -
27 - public function __construct($structure) {
28 - $this->structure = $structure;
29 - }
30 -
31 - public function getStructure() {
32 - return $this->structure;
33 - }
34 -}
35 -
364 class Attribute {
375 public $id = "";
386 public $name = "";
@@ -53,13 +21,22 @@
5422 }
5523
5624 class Structure {
57 - public $attributes;
5825
59 - public function __construct($attributes) {
60 - if (is_array($attributes))
61 - $this->attributes = $attributes;
 26+ private $structure; # Array of attributes
 27+
 28+ public function getAttributes() {
 29+ return $this->structure;
 30+ }
 31+
 32+ public function addAttribute($attribute) {
 33+ $this->structure[]=$attribute;
 34+ }
 35+
 36+ public function __construct($structure) {
 37+ if (is_array($structure))
 38+ $this->structure = $structure;
6239 else
63 - $this->attributes = func_get_args();
 40+ $this->structure = func_get_args();
6441 }
6542 }
6643
Index: trunk/extensions/Wikidata/OmegaWiki/Search.php
@@ -51,13 +51,13 @@
5252 $languageAttribute = new Attribute("language", "Language", "language");
5353
5454 $expressionStructure = new Structure($spellingAttribute, $languageAttribute);
55 - $expressionAttribute = new Attribute("expression", "Expression", new RecordType($expressionStructure));
 55+ $expressionAttribute = new Attribute("expression", "Expression", $expressionStructure);
5656
5757 $definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", $definedMeaningReferenceType);
5858 $definitionAttribute = new Attribute("definition", "Definition", "definition");
5959
6060 $meaningStructure = new Structure($definedMeaningAttribute, $definitionAttribute);
61 - $meaningAttribute = new Attribute("meaning", "Meaning", new RecordSetType($meaningStructure));
 61+ $meaningAttribute = new Attribute("meaning", "Meaning", $meaningStructure);
6262
6363 $recordSet = new ArrayRecordSet(new Structure($idAttribute, $expressionAttribute, $meaningAttribute), new Structure($idAttribute));
6464
Index: trunk/extensions/Wikidata/OmegaWiki/languages.php
@@ -1,9 +1,17 @@
22 <?php
33
4 -function getOwLanguageNames() {
 4+/**
 5+ * @param $purge purge cache
 6+ * @return array of language names for the user's language preference
 7+ **/
 8+function getOwLanguageNames($purge=false) {
59 global $wgUser;
6 - $owLanguageNames = getLangNames($wgUser->getOption('language'));
 10+ static $owLanguageNames=null;
 11+ if(is_null($owLanguageNames) && !$purge) {
 12+ $owLanguageNames = getLangNames($wgUser->getOption('language'));
 13+ }
714 return $owLanguageNames;
 15+
816 }
917
1018 /* Return an array containing all language names translated into the language
@@ -20,10 +28,21 @@
2129 }
2230
2331 function getLanguageIdForCode($code) {
24 - $dbr =& wfGetDB( DB_SLAVE );
25 - $id_res=$dbr->query("select language_id from language where wikimedia_key='".$code."'");
26 - $id_row=$dbr->fetchObject($id_res);
27 - return $id_row->language_id;
 32+
 33+ static $languages=null;
 34+ if(is_null($languages)) {
 35+ $dbr =& wfGetDB( DB_SLAVE );
 36+ $id_res=$dbr->query("select language_id,wikimedia_key from language");
 37+ while($id_row=$dbr->fetchObject($id_res)) {
 38+ $languages[$id_row->wikimedia_key]=$id_row->language_id;
 39+ }
 40+ }
 41+ if(is_array($languages) && array_key_exists($code,$languages)) {
 42+ return $languages[$code];
 43+ } else {
 44+ return null;
 45+ }
 46+
2847 }
2948
3049 /* Return SQL query string for fetching language names. */
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php
@@ -501,7 +501,7 @@
502502 array("meaning_mid=$definedMeaningId")
503503 );
504504
505 - $recordSet->getStructure()->attributes[] = $alternativeDefinitionAttribute;
 505+ $recordSet->getStructure()->addAttribute($alternativeDefinitionAttribute);
506506
507507 expandTranslatedContentsInRecordSet($recordSet, $definitionIdAttribute, $alternativeDefinitionAttribute, $filterLanguageId, $queryTransactionInformation);
508508 expandDefinedMeaningReferencesInRecordSet($recordSet, array($sourceAttribute));
@@ -514,7 +514,7 @@
515515 $definitionAttribute, $translatedTextAttribute, $objectAttributesAttribute;
516516
517517 $definitionId = getDefinedMeaningDefinitionId($definedMeaningId);
518 - $record = new ArrayRecord($definitionAttribute->type->getStructure());
 518+ $record = new ArrayRecord($definitionAttribute->type->getAttributes());
519519 $record->setAttributeValue($translatedTextAttribute, getTranslatedContentValue($definitionId, $filterLanguageId, $queryTransactionInformation));
520520 $record->setAttributeValue($objectAttributesAttribute, getObjectAttributesRecord($definitionId, $filterLanguageId, $queryTransactionInformation));
521521
@@ -527,7 +527,7 @@
528528 $urlAttributeValuesAttribute, $textAttributeValuesAttribute,
529529 $translatedTextAttributeValuesAttribute, $optionAttributeValuesAttribute;
530530
531 - $record = new ArrayRecord($objectAttributesAttribute->type->getStructure());
 531+ $record = new ArrayRecord($objectAttributesAttribute->type->getAttributes());
532532
533533 $record->setAttributeValue($objectIdAttribute, $objectId);
534534 $record->setAttributeValue($textAttributeValuesAttribute, getTextAttributesValuesRecordSet(array($objectId), $filterLanguageId, $queryTransactionInformation));
@@ -637,7 +637,7 @@
638638
639639 //add object attributes attribute to the generated structure
640640 //and expand the records
641 - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute;
 641+ $recordSet->getStructure()->addAttribute($objectAttributesAttribute);
642642 expandObjectAttributesAttribute($recordSet, $syntransIdAttribute, $filterLanguageId, $queryTransactionInformation);
643643 return $recordSet;
644644 }
@@ -650,7 +650,7 @@
651651 $urlAttributeObjectAttribute, $urlAttributeValuesAttribute,
652652 $optionAttributeObjectAttribute, $optionAttributeValuesAttribute;
653653
654 - $objectAttributesRecordStructure = $objectAttributesAttribute->type->getStructure();
 654+ $objectAttributesRecordStructure = $objectAttributesAttribute->type->getAttributes();
655655 $objectIds = getUniqueIdsInRecordSet($recordSet, array($objectIdAttribute));
656656
657657 if (count($objectIds) > 0) {
@@ -782,7 +782,8 @@
783783
784784 //add object attributes attribute to the generated structure
785785 //and expand the records
786 - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute;
 786+ $struct=$recordSet->getStructure();
 787+ $struct->addAttribute($objectAttributesAttribute);
787788 expandObjectAttributesAttribute($recordSet, $relationIdAttribute, $filterLanguageId, $queryTransactionInformation);
788789
789790 return $recordSet;
@@ -810,7 +811,8 @@
811812
812813 //add object attributes attribute to the generated structure
813814 //and expand the records
814 - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute;
 815+ $struct=$recordSet->getStructure();
 816+ $struct->addAttribute($objectAttributesAttribute);
815817 expandObjectAttributesAttribute($recordSet, $relationIdAttribute, $filterLanguageId, $queryTransactionInformation);
816818
817819 return $recordSet;
@@ -840,7 +842,8 @@
841843
842844 //add object attributes attribute to the generated structure
843845 //and expand the records
844 - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute;
 846+ $struct=$recordSet->getStructure();
 847+ $struct->addAttribute($objectAttributesAttribute);
845848 expandObjectAttributesAttribute($recordSet, $possiblySynonymousIdAttribute, $filterLanguageId, $queryTransactionInformation);
846849
847850 return $recordSet;
@@ -873,7 +876,7 @@
874877 array("member_mid=$definedMeaningId")
875878 );
876879
877 - $recordSet->getStructure()->atttributes[] = $collectionMeaningAttribute;
 880+ $recordSet->getStructure()->addAttribute($collectionMeaningAttribute);
878881
879882 for ($i = 0; $i < $recordSet->getRecordCount(); $i++) {
880883 $record = $recordSet->getRecord($i);
@@ -908,7 +911,7 @@
909912
910913 //add object attributes attribute to the generated structure
911914 //and expand the records
912 - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute;
 915+ $recordSet->getStructure()->addAttribute($objectAttributesAttribute);
913916 expandObjectAttributesAttribute($recordSet, $textAttributeIdAttribute, $filterLanguageId, $queryTransactionInformation);
914917
915918 return $recordSet;
@@ -936,7 +939,7 @@
937940
938941 //add object attributes attribute to the generated structure
939942 //and expand the records
940 - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute;
 943+ $recordSet->getStructure()->addAttribute($objectAttributesAttribute);
941944 expandObjectAttributesAttribute($recordSet, $urlAttributeIdAttribute, $filterLanguageId, $queryTransactionInformation);
942945
943946 return $recordSet;
@@ -960,14 +963,14 @@
961964 array("object_id IN (" . implode(", ", $objectIds) . ")")
962965 );
963966
964 - $recordSet->getStructure()->attributes[] = $translatedTextValueAttribute;
 967+ $recordSet->getStructure()->addAttribute($translatedTextValueAttribute);
965968
966969 expandTranslatedContentsInRecordSet($recordSet, $translatedTextValueIdAttribute, $translatedTextValueAttribute, $filterLanguageId, $queryTransactionInformation);
967970 expandDefinedMeaningReferencesInRecordSet($recordSet, array($translatedTextAttributeAttribute));
968971
969972 //add object attributes attribute to the generated structure
970973 //and expand the records
971 - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute;
 974+ $recordSet->getStructure()->addAttribute($objectAttributesAttribute);
972975 expandObjectAttributesAttribute($recordSet, $translatedTextAttributeIdAttribute, $filterLanguageId, $queryTransactionInformation);
973976 return $recordSet;
974977 }
@@ -1015,7 +1018,7 @@
10161019
10171020 /* Add object attributes attribute to the generated structure
10181021 and expand the records. */
1019 - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute;
 1022+ $recordSet->getStructure()->addAttribute($objectAttributesAttribute);
10201023 expandObjectAttributesAttribute($recordSet, $optionAttributeIdAttribute, $filterLanguageId, $queryTransactionInformation);
10211024
10221025 return $recordSet;
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWiki.php
@@ -23,7 +23,6 @@
2424 $wgOut, $wgTitle;
2525
2626 parent::view();
27 -
2827 $this->outputViewHeader();
2928
3029 $spelling = $wgTitle->getText();
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php
@@ -15,7 +15,7 @@
1616 $classMembershipAttribute, $collectionMembershipAttribute, $definedMeaningAttributesAttribute,
1717 $possiblySynonymousAttribute;
1818
19 - $record = new ArrayRecord($definedMeaningAttribute->type->getStructure());
 19+ $record = new ArrayRecord($definedMeaningAttribute->type->getAttributes());
2020 $record->setAttributeValue($definitionAttribute, getDefinedMeaningDefinitionRecord($definedMeaningId, $filterLanguageId, $queryTransactionInformation));
2121 $record->setAttributeValue($classAttributesAttribute, getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation));
2222 $record->setAttributeValue($alternativeDefinitionsAttribute, getAlternativeDefinitionsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation));
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php
@@ -75,8 +75,9 @@
7676 *
7777 */
7878 public function setAttributeValuesByOrder($values) {
79 - for ($i = 0; $i < count($this->structure->attributes); $i++)
80 - $this->values[$this->structure->attributes[$i]->id] = $values[$i];
 79+ $atts=$this->structure->getAttributes();
 80+ for ($i = 0; $i < count($atts); $i++)
 81+ $this->values[$atts[$i]->id] = $values[$i];
8182 }
8283
8384 /*
@@ -85,7 +86,7 @@
8687 *
8788 */
8889 public function setSubRecord($record) {
89 - foreach($record->getStructure()->attributes as $attribute)
 90+ foreach($record->getStructure()->getAttributes() as $attribute)
9091 $this->values[$attribute->id] = $record->getAttributeValue($attribute);
9192 }
9293
@@ -124,11 +125,11 @@
125126 function project($record, $structure) {
126127 $result = new ArrayRecord($structure);
127128
128 - foreach ($structure->attributes as $attribute) {
 129+ foreach ($structure->getAttributes() as $attribute) {
129130 $type = $attribute->type;
130131 $value = $record->getAttributeValue($attribute);
131132
132 - if ($type instanceof RecordType)
 133+ if ($type instanceof Structure)
133134 $result->setAttributeValue($attribute, project($record, $type->getStructure()));
134135 else
135136 $result->setAttributeValue($attribute, $value);
@@ -139,7 +140,7 @@
140141
141142 function equalRecords($structure, $lhs, $rhs) {
142143 $result = true;
143 - $attributes = $structure->attributes;
 144+ $attributes = $structure->getAttributes();
144145 $i = 0;
145146
146147 while($result && $i < count($attributes)) {
@@ -148,7 +149,7 @@
149150 $lhsValue = $lhs->getAttributeValue($attribute);
150151 $rhsValue = $rhs->getAttributeValue($attribute);
151152
152 - if ($type instanceof RecordType)
 153+ if ($type instanceof Structure)
153154 $result = equalRecords($type->getStructure(), $lhsValue, $rhsValue);
154155 else
155156 $result = $lhsValue == $rhsValue;
Index: trunk/extensions/Wikidata/OmegaWiki/Transaction.php
@@ -346,11 +346,11 @@
347347 $summaryAttribute = new Attribute('summary', 'Summary', 'text');
348348 $transactionStructure = new Structure($transactionIdAttribute, $userAttribute, $userIPAttribute, $timestampAttribute, $summaryAttribute);
349349
350 -$addTransactionAttribute = new Attribute('add-transaction', 'Added', new RecordType($transactionStructure));
351 -$removeTransactionAttribute = new Attribute('remove-transaction', 'Removed', new RecordType($transactionStructure));
 350+$addTransactionAttribute = new Attribute('add-transaction', 'Added', $transactionStructure);
 351+$removeTransactionAttribute = new Attribute('remove-transaction', 'Removed', $transactionStructure);
352352
353353 $recordLifeSpanStructure = new Structure($addTransactionAttribute, $removeTransactionAttribute);
354 -$recordLifeSpanAttribute = new Attribute('record-life-span', 'Record life span', new RecordType($recordLifeSpanStructure));
 354+$recordLifeSpanAttribute = new Attribute('record-life-span', 'Record life span', $recordLifeSpanStructure);
355355
356356 function getUserName($userId) {
357357 $dbr =& wfGetDB(DB_SLAVE);
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php
@@ -31,7 +31,7 @@
3232 protected function getKeyIds($record) {
3333 $ids = array();
3434
35 - foreach($record->getStructure()->attributes as $attribute)
 35+ foreach($record->getStructure() as $attribute)
3636 $ids[] = $record->getAttributeValue($attribute);
3737
3838 return $ids;
@@ -209,7 +209,7 @@
210210 public function getAddValue($idPath) {
211211 $addStructure = $this->getAddStructure();
212212
213 - if (count($addStructure->attributes) > 0) {
 213+ if (count($addStructure->getAttributes()) > 0) {
214214 $relation = new ArrayRecordSet($addStructure, $addStructure); // TODO Determine real key
215215 $values = array();
216216
@@ -342,7 +342,7 @@
343343 if ($this->allowAddController->check($idPath) && $this->controller != null) {
344344 $addStructure = $this->getAddStructure();
345345
346 - if (count($addStructure->attributes) > 0) {
 346+ if (count($addStructure->getAttributes()) > 0) {
347347 $addEditors = $this->getAddEditors();
348348 $record = $this->getAddRecord($idPath, $addStructure, $addEditors);
349349 $this->controller->add($idPath->getKeyStack(), $record);
@@ -377,8 +377,8 @@
378378 if ($this->isAddField) {
379379 $addStructure = $this->getAddStructure();
380380
381 - if (count($addStructure->attributes) > 0)
382 - $result = new Attribute($this->attribute->id, $this->attribute->name, new RecordSetType($addStructure));
 381+ if (count($addStructure->getAttributes()) > 0)
 382+ $result = new Attribute($this->attribute->id, $this->attribute->name, $addStructure);
383383 }
384384
385385 return $result;
@@ -544,7 +544,7 @@
545545 $childAttribute = $childEditor->getAttribute();
546546
547547 if ($childEditor instanceof RecordTableCellEditor)
548 - $type = new RecordType($this->getTableStructure($childEditor));
 548+ $type = $this->getTableStructure($childEditor);
549549 else
550550 $type = 'short-text';
551551
@@ -605,8 +605,8 @@
606606 public function getUpdateAttribute() {
607607 $updateStructure = $this->getUpdateStructure();
608608
609 - if (count($updateStructure->attributes) > 0)
610 - return new Attribute($this->attribute->id, $this->attribute->name, new RecordType($updateStructure));
 609+ if (count($updateStructure->getAttributes()) > 0)
 610+ return new Attribute($this->attribute->id, $this->attribute->name, $updateStructure);
611611 else
612612 return null;
613613 }
@@ -614,8 +614,8 @@
615615 public function getAddAttribute() {
616616 $addStructure = $this->getAddStructure();
617617
618 - if (count($addStructure->attributes) > 0)
619 - return new Attribute($this->attribute->id, $this->attribute->name, new RecordType($addStructure));
 618+ if (count($addStructure->getAttributes()) > 0)
 619+ return new Attribute($this->attribute->id, $this->attribute->name, $addStructure);
620620 else
621621 return null;
622622 }
@@ -967,7 +967,6 @@
968968 public function getViewHTML($idPath, $value) {
969969 global
970970 $definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute;
971 -
972971 $definedMeaningId = $value->getAttributeValue($definedMeaningIdAttribute);
973972 $definedMeaningLabel = $value->getAttributeValue($definedMeaningLabelAttribute);
974973 $definedMeaningDefiningExpression = $value->getAttributeValue($definedMeaningDefiningExpressionAttribute);

Status & tagging log