Index: trunk/extensions/Wikidata/App.php |
— | — | @@ -29,6 +29,7 @@ |
30 | 30 | |
31 | 31 | # These are the user groups |
32 | 32 | $wgGroupPermissions['wikidata-omega']['editwikidata-uw']=true; |
| 33 | +$wgGroupPermissions['wikidata-omega']['editwikidata-moo']=true; |
33 | 34 | $wgGroupPermissions['wikidata-omega']['editwikidata-tt']=false; |
34 | 35 | $wgGroupPermissions['wikidata-test']['editwikidata-tt']=true; |
35 | 36 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialDatasearch.php |
— | — | @@ -51,13 +51,13 @@ |
52 | 52 | $this->languageAttribute = new Attribute("language", "Language", "language"); |
53 | 53 | |
54 | 54 | $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); |
56 | 56 | |
57 | 57 | $this->definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", $definedMeaningReferenceType); |
58 | 58 | $this->definitionAttribute = new Attribute("definition", "Definition", "definition"); |
59 | 59 | |
60 | 60 | $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); |
62 | 62 | |
63 | 63 | $this->externalIdentifierAttribute = new Attribute("external-identifier", "External identifier", "short-text"); |
64 | 64 | $this->collectionAttribute = new Attribute("collection", "Collection", $definedMeaningReferenceType); |
Index: trunk/extensions/Wikidata/OmegaWiki/converter.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | public function convert($record) { |
26 | 26 | $result = new ArrayRecord($this->structure); |
27 | 27 | |
28 | | - foreach($this->structure->attributes as $attribute) |
| 28 | + foreach($this->structure->getStructure() as $attribute) |
29 | 29 | $result->setAttributeValue($attribute, $record->getAttributeValue($attribute)); |
30 | 30 | |
31 | 31 | return $result; |
Index: trunk/extensions/Wikidata/OmegaWiki/HTMLtable.php |
— | — | @@ -28,12 +28,13 @@ |
29 | 29 | function getTableHeaderNode($structure, &$currentColumn=0) { |
30 | 30 | $tableHeaderNode = new TableHeaderNode(); |
31 | 31 | |
32 | | - foreach($structure->attributes as $attribute) { |
| 32 | + foreach($structure->getAttributes() as $attribute) { |
33 | 33 | $type = $attribute->type; |
34 | 34 | |
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 { |
38 | 39 | $childNode = new TableHeaderNode(); |
39 | 40 | $childNode->width = 1; |
40 | 41 | $childNode->height = 1; |
— | — | @@ -58,7 +59,7 @@ |
59 | 60 | $idPath->pushAttribute($attribute); |
60 | 61 | $type = $attribute->type; |
61 | 62 | |
62 | | - if (!$type instanceof RecordType && !$type instanceof RecordSetType) { |
| 63 | + if (!$type instanceof Structure) { |
63 | 64 | $skipRows=count($rows); |
64 | 65 | $columnIndex=$childNode->column + $columnOffset; |
65 | 66 | $sort = 'sortTable(this, '. $skipRows .', '. $columnIndex.')'; |
— | — | @@ -106,9 +107,7 @@ |
107 | 108 | } |
108 | 109 | |
109 | 110 | function getHTMLClassForType($type,$attribute) { |
110 | | - if ($type instanceof RecordSetType) |
111 | | - return "relation"; |
112 | | - else if ($type instanceof RecordType) |
| 111 | + if ($type instanceof Structure) |
113 | 112 | return $attribute->id; |
114 | 113 | else |
115 | 114 | return $type; |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php |
— | — | @@ -429,7 +429,7 @@ |
430 | 430 | $languageAttribute = new Attribute("language", "Language", "language"); |
431 | 431 | |
432 | 432 | $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); |
434 | 434 | $definitionAttribute = new Attribute("definition", "Definition", "definition"); |
435 | 435 | |
436 | 436 | $recordSet = new ArrayRecordSet(new Structure($idAttribute, $definedMeaningAttribute, $definitionAttribute), new Structure($idAttribute)); |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | $expressionAttribute = new Attribute("expression", $wgSpellingAttributeName, "spelling"); |
35 | 35 | else { |
36 | 36 | $expressionStructure = new Structure($languageAttribute, $spellingAttribute); |
37 | | - $expressionAttribute = new Attribute("expression", $wgExpressionAttributeName, new RecordType($expressionStructure)); |
| 37 | + $expressionAttribute = new Attribute("expression", $wgExpressionAttributeName, $expressionStructure); |
38 | 38 | } |
39 | 39 | |
40 | 40 | global |
— | — | @@ -49,7 +49,7 @@ |
50 | 50 | $definedMeaningLabelAttribute = new Attribute("defined-meaning-label", "Defined meaning label", "short-text"); |
51 | 51 | $definedMeaningReferenceStructure = new Structure($definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute); |
52 | 52 | $definedMeaningReferenceKeyStructure = new Structure($definedMeaningIdAttribute); |
53 | | - $definedMeaningReferenceType = new RecordType($definedMeaningReferenceStructure); |
| 53 | + $definedMeaningReferenceType = $definedMeaningReferenceStructure; |
54 | 54 | $definedMeaningReferenceAttribute = new Attribute("defined-meaning", $wgDefinedMeaningReferenceAttributeName, $definedMeaningReferenceType); |
55 | 55 | |
56 | 56 | global |
— | — | @@ -58,22 +58,22 @@ |
59 | 59 | $wgCollectionAttributeName, $wgSourceIdentifierAttributeName, $wgGotoSourceAttributeName; |
60 | 60 | |
61 | 61 | $collectionIdAttribute = new Attribute("collection", "Collection", "collection-id"); |
62 | | - $collectionMeaningType = new RecordType($definedMeaningReferenceStructure); |
| 62 | + $collectionMeaningType = $definedMeaningReferenceStructure; |
63 | 63 | $collectionMeaningAttribute = new Attribute("collection-meaning", $wgCollectionAttributeName, $collectionMeaningType); |
64 | 64 | $sourceIdentifierAttribute = new Attribute("source-identifier", $wgSourceIdentifierAttributeName, "short-text"); |
65 | 65 | $gotoSourceStructure = new Structure($collectionIdAttribute, $sourceIdentifierAttribute); |
66 | | - $gotoSourceAttribute = new Attribute("goto-source", $wgGotoSourceAttributeName, new RecordType($gotoSourceStructure)); |
| 66 | + $gotoSourceAttribute = new Attribute("goto-source", $wgGotoSourceAttributeName, $gotoSourceStructure); |
67 | 67 | |
68 | 68 | global |
69 | 69 | $collectionMembershipAttribute, $wgCollectionMembershipAttributeName, $wgCollectionMembershipAttributeId; |
70 | 70 | |
71 | | - $collectionMembershipAttribute = new Attribute($wgCollectionMembershipAttributeId, $wgCollectionMembershipAttributeName, new RecordSetType(new Structure($collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute))); |
| 71 | + $collectionMembershipAttribute = new Attribute($wgCollectionMembershipAttributeId, $wgCollectionMembershipAttributeName, new Structure($collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute)); |
72 | 72 | |
73 | 73 | global |
74 | 74 | $classMembershipIdAttribute, $classAttribute; |
75 | 75 | |
76 | 76 | $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); |
78 | 78 | |
79 | 79 | global |
80 | 80 | $classMembershipStructure, $classMembershipKeyStructure, $classMembershipAttribute, |
— | — | @@ -81,13 +81,13 @@ |
82 | 82 | |
83 | 83 | $classMembershipStructure = new Structure($classMembershipIdAttribute, $classAttribute); |
84 | 84 | $classMembershipKeyStructure = new Structure($classMembershipIdAttribute); |
85 | | - $classMembershipAttribute = new Attribute($wgClassMembershipAttributeId, $wgClassMembershipAttributeName, new RecordSetType($classMembershipStructure)); |
| 85 | + $classMembershipAttribute = new Attribute($wgClassMembershipAttributeId, $wgClassMembershipAttributeName, $classMembershipStructure); |
86 | 86 | |
87 | 87 | global |
88 | 88 | $possiblySynonymousIdAttribute, $possibleSynonymAttribute, $wgPossibleSynonymAttributeName; |
89 | 89 | |
90 | 90 | $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); |
92 | 92 | |
93 | 93 | global |
94 | 94 | $possiblySynonymousStructure, $possiblySynonymousKeyStructure, $possiblySynonymousAttribute, |
— | — | @@ -95,14 +95,14 @@ |
96 | 96 | |
97 | 97 | $possiblySynonymousStructure = new Structure($possiblySynonymousIdAttribute, $possiblySynonymousAttribute); |
98 | 98 | $possiblySynonymousKeyStructure = new Structure($possiblySynonymousIdAttribute); |
99 | | - $possiblySynonymousAttribute = new Attribute($wgPossiblySynonymousAttributeId, $wgPossiblySynonymousAttributeName, new RecordSetType($possiblySynonymousStructure)); |
| 99 | + $possiblySynonymousAttribute = new Attribute($wgPossiblySynonymousAttributeId, $wgPossiblySynonymousAttributeName, $possiblySynonymousStructure); |
100 | 100 | |
101 | 101 | global |
102 | 102 | $relationIdAttribute, $relationTypeAttribute, $relationTypeType, $otherDefinedMeaningAttribute, |
103 | 103 | $wgRelationTypeAttributeName, $wgOtherDefinedMeaningAttributeName; |
104 | 104 | |
105 | 105 | $relationIdAttribute = new Attribute("relation-id", "Relation identifier", "object-id"); |
106 | | - $relationTypeType = new RecordType($definedMeaningReferenceStructure); |
| 106 | + $relationTypeType = $definedMeaningReferenceStructure; |
107 | 107 | $relationTypeAttribute = new Attribute("relation-type", $wgRelationTypeAttributeName, $relationTypeType); |
108 | 108 | $otherDefinedMeaningAttribute = new Attribute("other-defined-meaning", $wgOtherDefinedMeaningAttributeName, $definedMeaningReferenceType); |
109 | 109 | |
— | — | @@ -112,8 +112,8 @@ |
113 | 113 | |
114 | 114 | $relationStructure = new Structure($relationIdAttribute, $relationTypeAttribute, $otherDefinedMeaningAttribute, $objectAttributesAttribute); |
115 | 115 | $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); |
118 | 118 | |
119 | 119 | global |
120 | 120 | $translatedTextIdAttribute, $translatedTextStructure; |
— | — | @@ -130,14 +130,14 @@ |
131 | 131 | if ($filterOnLanguage && !$hasMetaDataAttributes) |
132 | 132 | $alternativeDefinitionAttribute = new Attribute("alternative-definition", $wgAlternativeDefinitionAttributeName, "text"); |
133 | 133 | else |
134 | | - $alternativeDefinitionAttribute = new Attribute("alternative-definition", $wgAlternativeDefinitionAttributeName, new RecordSetType($translatedTextStructure)); |
| 134 | + $alternativeDefinitionAttribute = new Attribute("alternative-definition", $wgAlternativeDefinitionAttributeName, $translatedTextStructure); |
135 | 135 | |
136 | 136 | $sourceAttribute = new Attribute("source-id", $wgSourceAttributeName, $definedMeaningReferenceType); |
137 | 137 | |
138 | 138 | global |
139 | 139 | $alternativeDefinitionsAttribute, $wgAlternativeDefinitionsAttributeName, $wgAlternativeDefinitionsAttributeId; |
140 | 140 | |
141 | | - $alternativeDefinitionsAttribute = new Attribute($wgAlternativeDefinitionsAttributeId, $wgAlternativeDefinitionsAttributeName, new RecordSetType(new Structure($definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute))); |
| 141 | + $alternativeDefinitionsAttribute = new Attribute($wgAlternativeDefinitionsAttributeId, $wgAlternativeDefinitionsAttributeName, new Structure($definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute)); |
142 | 142 | |
143 | 143 | global |
144 | 144 | $synonymsAndTranslationsAttribute, $syntransIdAttribute, |
— | — | @@ -149,7 +149,7 @@ |
150 | 150 | $synonymsAndTranslationsCaption = $wgSynonymsAndTranslationsAttributeName; |
151 | 151 | |
152 | 152 | $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)); |
154 | 154 | |
155 | 155 | global |
156 | 156 | $translatedTextAttributeIdAttribute, $translatedTextValueIdAttribute, |
— | — | @@ -164,10 +164,10 @@ |
165 | 165 | if ($filterOnLanguage && !$hasMetaDataAttributes) |
166 | 166 | $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, "text"); |
167 | 167 | else |
168 | | - $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, new RecordSetType($translatedTextStructure)); |
| 168 | + $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, $translatedTextStructure); |
169 | 169 | |
170 | 170 | $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); |
172 | 172 | |
173 | 173 | global |
174 | 174 | $textAttributeIdAttribute, $textAttributeObjectAttribute, $textAttributeAttribute, $textAttributeValuesStructure, |
— | — | @@ -176,9 +176,9 @@ |
177 | 177 | |
178 | 178 | $textAttributeIdAttribute = new Attribute("text-attribute-id", "Attribute identifier", "object-id"); |
179 | 179 | $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); |
181 | 181 | $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); |
183 | 183 | |
184 | 184 | global |
185 | 185 | $urlAttribute, $urlAttributeIdAttribute, $urlAttributeObjectAttribute, $urlAttributeAttribute, $urlAttributeValuesStructure, $urlAttributeValuesAttribute, |
— | — | @@ -187,9 +187,9 @@ |
188 | 188 | $urlAttribute = new Attribute("url", "URL", "url"); |
189 | 189 | $urlAttributeIdAttribute = new Attribute("url-attribute-id", "Attribute identifier", "object-id"); |
190 | 190 | $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); |
192 | 192 | $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); |
194 | 194 | |
195 | 195 | global |
196 | 196 | $optionAttributeIdAttribute, $optionAttributeAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionAttribute, $optionAttributeValuesAttribute, |
— | — | @@ -200,14 +200,14 @@ |
201 | 201 | $optionAttributeAttribute = new Attribute('option-attribute', $wgOptionAttributeAttributeName, $definedMeaningReferenceType); |
202 | 202 | $optionAttributeOptionAttribute = new Attribute('option-attribute-option', $wgOptionAttributeOptionAttributeName, $definedMeaningReferenceType); |
203 | 203 | $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); |
205 | 205 | |
206 | 206 | global |
207 | 207 | $optionAttributeOptionIdAttribute, $optionAttributeOptionsAttribute, $wgOptionAttributeOptionsAttributeName; |
208 | 208 | |
209 | 209 | $optionAttributeOptionIdAttribute = new Attribute('option-attribute-option-id', 'Option identifier', 'object-id'); |
210 | 210 | $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); |
212 | 212 | |
213 | 213 | global |
214 | 214 | $definitionAttribute, $translatedTextAttribute, $classAttributesAttribute, |
— | — | @@ -216,9 +216,9 @@ |
217 | 217 | if ($filterOnLanguage && !$hasMetaDataAttributes) |
218 | 218 | $translatedTextAttribute = new Attribute("translated-text", $wgTextAttributeName, "text"); |
219 | 219 | else |
220 | | - $translatedTextAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeName, new RecordSetType($translatedTextStructure)); |
| 220 | + $translatedTextAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeName, $translatedTextStructure); |
221 | 221 | |
222 | | - $definitionAttribute = new Attribute($wgDefinitionAttributeId, $wgDefinitionAttributeName, new RecordType(new Structure($translatedTextAttribute, $objectAttributesAttribute))); |
| 222 | + $definitionAttribute = new Attribute($wgDefinitionAttributeId, $wgDefinitionAttributeName, new Structure($translatedTextAttribute, $objectAttributesAttribute)); |
223 | 223 | |
224 | 224 | global |
225 | 225 | $classAttributesStructure, |
— | — | @@ -228,17 +228,17 @@ |
229 | 229 | $wgClassAttributeTypeAttributeName, $wgClassAttributesAttributeName, $wgClassAttributesAttributeId; |
230 | 230 | |
231 | 231 | $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); |
234 | 234 | $classAttributeTypeAttribute = new Attribute("class-attribute-type", $wgClassAttributeTypeAttributeName, "short-text"); |
235 | 235 | $classAttributesStructure = new Structure($classAttributeIdAttribute, $classAttributeAttributeAttribute, $classAttributeLevelAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute); |
236 | | - $classAttributesAttribute = new Attribute($wgClassAttributesAttributeId, $wgClassAttributesAttributeName, new RecordSetType($classAttributesStructure)); |
| 236 | + $classAttributesAttribute = new Attribute($wgClassAttributesAttributeId, $wgClassAttributesAttributeName, $classAttributesStructure); |
237 | 237 | |
238 | 238 | global |
239 | 239 | $definedMeaningAttribute, $wgDefinedMeaningAttributeName; |
240 | 240 | |
241 | 241 | $definedMeaningAttribute = new Attribute("defined-meaning", $wgDefinedMeaningAttributeName, |
242 | | - new RecordType(new Structure( |
| 242 | + new Structure( |
243 | 243 | $definitionAttribute, |
244 | 244 | $classAttributesAttribute, |
245 | 245 | $alternativeDefinitionsAttribute, |
— | — | @@ -248,7 +248,6 @@ |
249 | 249 | $classMembershipAttribute, |
250 | 250 | $collectionMembershipAttribute, |
251 | 251 | $definedMeaningAttributesAttribute) |
252 | | - ) |
253 | 252 | ); |
254 | 253 | |
255 | 254 | global |
— | — | @@ -256,25 +255,25 @@ |
257 | 256 | $wgExactMeaningsAttributeName, $wgApproximateMeaningsAttributeName; |
258 | 257 | |
259 | 258 | $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); |
262 | 261 | |
263 | 262 | global |
264 | 263 | $expressionMeaningsAttribute, $expressionMeaningsStructure, $expressionApproximateMeaningAttribute, |
265 | 264 | $wgExpressionMeaningsAttributeName, $wgExpressionsAttributeName; |
266 | 265 | |
267 | 266 | $expressionMeaningsStructure = new Structure($expressionExactMeaningsAttribute, $expressionApproximateMeaningAttribute); |
268 | | - $expressionMeaningsAttribute = new Attribute("expression-meanings", $wgExpressionMeaningsAttributeName, new RecordType($expressionMeaningsStructure)); |
| 267 | + $expressionMeaningsAttribute = new Attribute("expression-meanings", $wgExpressionMeaningsAttributeName, $expressionMeaningsStructure); |
269 | 268 | |
270 | | - $expressionsAttribute = new Attribute("expressions", $wgExpressionsAttributeName, new RecordSetType(new Structure($expressionIdAttribute, $expressionAttribute, $expressionMeaningsAttribute))); |
| 269 | + $expressionsAttribute = new Attribute("expressions", $wgExpressionsAttributeName, new Structure($expressionIdAttribute, $expressionAttribute, $expressionMeaningsAttribute)); |
271 | 270 | |
272 | 271 | global |
273 | 272 | $objectIdAttribute, $objectAttributesStructure, $wgAnnotationAttributeName; |
274 | 273 | |
275 | 274 | $objectIdAttribute = new Attribute("object-id", "Object identifier", "object-id"); |
276 | 275 | $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; |
279 | 278 | } |
280 | 279 | |
281 | 280 | ?> |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialTransaction.php |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | $isLatestAttribute = new Attribute('is-latest', 'Is latest', 'boolean'); |
136 | 136 | |
137 | 137 | $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); |
139 | 139 | |
140 | 140 | global |
141 | 141 | $translatedContentHistoryStructure, $translatedContentHistoryKeyStructure, $translatedContentHistoryAttribute, |
— | — | @@ -144,14 +144,14 @@ |
145 | 145 | |
146 | 146 | $translatedContentHistoryStructure = new Structure($addTransactionIdAttribute, $textAttribute, $recordLifeSpanAttribute); |
147 | 147 | $translatedContentHistoryKeyStructure = new Structure($addTransactionIdAttribute); |
148 | | - $translatedContentHistoryAttribute = new Attribute('translated-content-history', 'History', new RecordSetType($translatedContentHistoryStructure)); |
| 148 | + $translatedContentHistoryAttribute = new Attribute('translated-content-history', 'History', $translatedContentHistoryStructure); |
149 | 149 | $translatedContentIdAttribute = new Attribute('translated-content-id', 'Translated content ID', 'object-id'); |
150 | 150 | |
151 | 151 | global |
152 | 152 | $rollBackTranslatedContentStructure, $rollBackTranslatedContentAttribute; |
153 | 153 | |
154 | 154 | $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); |
156 | 156 | |
157 | 157 | global |
158 | 158 | $updatedDefinitionStructure, $updatedDefinitionAttribute; |
— | — | @@ -167,7 +167,7 @@ |
168 | 168 | $isLatestAttribute |
169 | 169 | ); |
170 | 170 | |
171 | | - $updatedDefinitionAttribute = new Attribute('updated-definition', 'Definition', new RecordSetType($updatedDefinitionStructure)); |
| 171 | + $updatedDefinitionAttribute = new Attribute('updated-definition', 'Definition', $updatedDefinitionStructure); |
172 | 172 | |
173 | 173 | global |
174 | 174 | $expressionAttribute, $expressionIdAttribute, $identicalMeaningAttribute, $syntransIdAttribute, $updatedSyntransesAttribute; |
— | — | @@ -182,14 +182,14 @@ |
183 | 183 | $operationAttribute |
184 | 184 | ); |
185 | 185 | |
186 | | - $updatedSyntransesAttribute = new Attribute('updated-syntranses', 'Synonyms and translations', new RecordSetType($updatedSyntransesStructure)); |
| 186 | + $updatedSyntransesAttribute = new Attribute('updated-syntranses', 'Synonyms and translations', $updatedSyntransesStructure); |
187 | 187 | |
188 | 188 | global |
189 | 189 | $relationIdAttribute, $firstMeaningAttribute, $secondMeaningAttribute, $relationTypeAttribute, |
190 | 190 | $updatedRelationsStructure, $updatedRelationsAttribute; |
191 | 191 | |
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); |
194 | 194 | |
195 | 195 | $updatedRelationsStructure = new Structure( |
196 | 196 | $rollBackAttribute, |
— | — | @@ -201,13 +201,13 @@ |
202 | 202 | $isLatestAttribute |
203 | 203 | ); |
204 | 204 | |
205 | | - $updatedRelationsAttribute = new Attribute('updated-relations', 'Relations', new RecordSetType($updatedRelationsStructure)); |
| 205 | + $updatedRelationsAttribute = new Attribute('updated-relations', 'Relations', $updatedRelationsStructure); |
206 | 206 | |
207 | 207 | global |
208 | 208 | $classMembershipIdAttribute, $classAttribute, $classMemberAttribute, |
209 | 209 | $updatedClassMembershipStructure, $updatedClassMembershipAttribute; |
210 | 210 | |
211 | | - $classMemberAttribute = new Attribute('class-member', 'Class member', new RecordType($definedMeaningReferenceStructure)); |
| 211 | + $classMemberAttribute = new Attribute('class-member', 'Class member', $definedMeaningReferenceStructure); |
212 | 212 | |
213 | 213 | $updatedClassMembershipStructure = new Structure( |
214 | 214 | $rollBackAttribute, |
— | — | @@ -218,13 +218,13 @@ |
219 | 219 | $isLatestAttribute |
220 | 220 | ); |
221 | 221 | |
222 | | - $updatedClassMembershipAttribute = new Attribute('updated-class-membership', 'Class membership', new RecordSetType($updatedClassMembershipStructure)); |
| 222 | + $updatedClassMembershipAttribute = new Attribute('updated-class-membership', 'Class membership', $updatedClassMembershipStructure); |
223 | 223 | |
224 | 224 | global |
225 | 225 | $collectionIdAttribute, $collectionMeaningAttribute, $collectionMemberAttribute, $sourceIdentifierAttribute, |
226 | 226 | $updatedCollectionMembershipStructure, $updatedCollectionMembershipAttribute, $collectionMemberIdAttribute; |
227 | 227 | |
228 | | - $collectionMemberAttribute = new Attribute('collection-member', 'Collection member', new RecordType($definedMeaningReferenceStructure)); |
| 228 | + $collectionMemberAttribute = new Attribute('collection-member', 'Collection member', $definedMeaningReferenceStructure); |
229 | 229 | $collectionMemberIdAttribute = new Attribute('collection-member-id', 'Collection member identifier', 'defined-meaning-id'); |
230 | 230 | |
231 | 231 | $updatedCollectionMembershipStructure = new Structure( |
— | — | @@ -237,14 +237,14 @@ |
238 | 238 | $operationAttribute |
239 | 239 | ); |
240 | 240 | |
241 | | - $updatedCollectionMembershipAttribute = new Attribute('updated-collection-membership', 'Collection membership', new RecordSetType($updatedCollectionMembershipStructure)); |
| 241 | + $updatedCollectionMembershipAttribute = new Attribute('updated-collection-membership', 'Collection membership', $updatedCollectionMembershipStructure); |
242 | 242 | |
243 | 243 | global |
244 | 244 | $objectIdAttribute, $valueIdAttribute, $attributeAttribute; |
245 | 245 | |
246 | 246 | $objectIdAttribute = new Attribute('object-id', 'Object', 'object-id'); |
247 | 247 | $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); |
249 | 249 | |
250 | 250 | global |
251 | 251 | $updatedURLAttribute, $updatedURLStructure, $URLAttribute; |
— | — | @@ -261,7 +261,7 @@ |
262 | 262 | $isLatestAttribute |
263 | 263 | ); |
264 | 264 | |
265 | | - $updatedURLAttribute = new Attribute('updated-url', 'URL properties', new RecordSetType($updatedURLStructure)); |
| 265 | + $updatedURLAttribute = new Attribute('updated-url', 'URL properties', $updatedURLStructure); |
266 | 266 | |
267 | 267 | global |
268 | 268 | $updatedTextAttribute, $updatedTextStructure, $textAttribute; |
— | — | @@ -276,13 +276,13 @@ |
277 | 277 | $isLatestAttribute |
278 | 278 | ); |
279 | 279 | |
280 | | - $updatedTextAttribute = new Attribute('updated-text', 'Unstructured text properties', new RecordSetType($updatedTextStructure)); |
| 280 | + $updatedTextAttribute = new Attribute('updated-text', 'Unstructured text properties', $updatedTextStructure); |
281 | 281 | |
282 | 282 | global |
283 | 283 | $translatedTextStructure, |
284 | 284 | $updatedTranslatedTextPropertyAttribute, $updatedTranslatedTextPropertyStructure, $translatedTextTextAttribute; |
285 | 285 | |
286 | | - $translatedTextTextAttribute = new Attribute('translated-text-property-text', 'Text', new RecordSetType($translatedTextStructure)); |
| 286 | + $translatedTextTextAttribute = new Attribute('translated-text-property-text', 'Text', $translatedTextStructure); |
287 | 287 | |
288 | 288 | $updatedTranslatedTextPropertyStructure = new Structure( |
289 | 289 | $rollBackAttribute, |
— | — | @@ -295,7 +295,7 @@ |
296 | 296 | $isLatestAttribute |
297 | 297 | ); |
298 | 298 | |
299 | | - $updatedTranslatedTextPropertyAttribute = new Attribute('updated-translated-text-property', 'Text properties', new RecordSetType($updatedTranslatedTextPropertyStructure)); |
| 299 | + $updatedTranslatedTextPropertyAttribute = new Attribute('updated-translated-text-property', 'Text properties', $updatedTranslatedTextPropertyStructure); |
300 | 300 | |
301 | 301 | global |
302 | 302 | $updatedTranslatedTextStructure, $updatedTranslatedTextAttribute; |
— | — | @@ -312,14 +312,14 @@ |
313 | 313 | $isLatestAttribute |
314 | 314 | ); |
315 | 315 | |
316 | | - $updatedTranslatedTextAttribute = new Attribute('updated-translated-text', 'Texts', new RecordSetType($updatedTranslatedTextStructure)); |
| 316 | + $updatedTranslatedTextAttribute = new Attribute('updated-translated-text', 'Texts', $updatedTranslatedTextStructure); |
317 | 317 | |
318 | 318 | global |
319 | 319 | $updatedClassAttributesAttribute, $updatedClassAttributesStructure, $classAttributeId, $levelAttribute, |
320 | 320 | $typeAttribute; |
321 | 321 | |
322 | 322 | $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); |
324 | 324 | $typeAttribute = new Attribute('type', 'Type', 'text'); |
325 | 325 | |
326 | 326 | $updatedClassAttributesStructure = new Structure( |
— | — | @@ -333,14 +333,14 @@ |
334 | 334 | $isLatestAttribute |
335 | 335 | ); |
336 | 336 | |
337 | | - $updatedClassAttributesAttribute = new Attribute('updated-class-attributes', 'Class attributes', new RecordSetType($updatedClassAttributesStructure)); |
| 337 | + $updatedClassAttributesAttribute = new Attribute('updated-class-attributes', 'Class attributes', $updatedClassAttributesStructure); |
338 | 338 | |
339 | 339 | global |
340 | 340 | $updatedAlternativeDefinitionsStructure, $updatedAlternativeDefinitionsAttribute, $sourceAttribute, |
341 | 341 | $alternativeDefinitionTextAttribute; |
342 | 342 | |
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); |
345 | 345 | |
346 | 346 | $updatedAlternativeDefinitionsStructure = new Structure( |
347 | 347 | $rollBackAttribute, |
— | — | @@ -353,7 +353,7 @@ |
354 | 354 | $isLatestAttribute |
355 | 355 | ); |
356 | 356 | |
357 | | - $updatedAlternativeDefinitionsAttribute = new Attribute('updated-alternative-definitions', 'Alternative definitions', new RecordSetType($updatedAlternativeDefinitionsStructure)); |
| 357 | + $updatedAlternativeDefinitionsAttribute = new Attribute('updated-alternative-definitions', 'Alternative definitions', $updatedAlternativeDefinitionsStructure); |
358 | 358 | |
359 | 359 | global |
360 | 360 | $updatedAlternativeDefinitionTextAttribute, $updatedAlternativeDefinitionTextStructure; |
— | — | @@ -370,7 +370,7 @@ |
371 | 371 | $isLatestAttribute |
372 | 372 | ); |
373 | 373 | |
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); |
375 | 375 | |
376 | 376 | global |
377 | 377 | $updatesInTransactionAttribute; |
— | — | @@ -386,7 +386,7 @@ |
387 | 387 | $updatedAlternativeDefinitionsAttribute |
388 | 388 | ); |
389 | 389 | |
390 | | - $updatesInTransactionAttribute = new Attribute('updates-in-transaction', 'Updates in transaction', new RecordType($updatesInTransactionStructure)); |
| 390 | + $updatesInTransactionAttribute = new Attribute('updates-in-transaction', 'Updates in transaction', $updatesInTransactionStructure); |
391 | 391 | } |
392 | 392 | |
393 | 393 | function getTransactionRecordSet($fromTransactionId, $transactionCount, $userName) { |
— | — | @@ -412,10 +412,10 @@ |
413 | 413 | $transactionCount |
414 | 414 | ); |
415 | 415 | |
416 | | - $recordSet->getStructure()->attributes[] = $transactionIdAttribute; |
| 416 | + $recordSet->getStructure()->addAttribute($transactionIdAttribute); |
417 | 417 | expandTransactionIDsInRecordSet($recordSet, $transactionIdAttribute, $transactionAttribute); |
418 | 418 | |
419 | | - $recordSet->getStructure()->attributes[] = $updatesInTransactionAttribute; |
| 419 | + $recordSet->getStructure()->addAttribute($updatesInTransactionAttribute); |
420 | 420 | expandUpdatesInTransactionInRecordSet($recordSet); |
421 | 421 | |
422 | 422 | return $recordSet; |
— | — | @@ -1248,7 +1248,7 @@ |
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | function simpleRecord($structure, $values) { |
1252 | | - $attributes = $structure->attributes; |
| 1252 | + $attributes = $structure->getAttributes(); |
1253 | 1253 | $result = new ArrayRecord($structure); |
1254 | 1254 | |
1255 | 1255 | for ($i = 0; $i < count($attributes); $i++) |
Index: trunk/extensions/Wikidata/OmegaWiki/RecordSet.php |
— | — | @@ -156,7 +156,7 @@ |
157 | 157 | $attributes = array(); |
158 | 158 | |
159 | 159 | foreach ($this->converters as $converter) |
160 | | - $attributes = array_merge($attributes, $converter->getStructure()->attributes); |
| 160 | + $attributes = array_merge($attributes, $converter->getStructure()->getAttributes()); |
161 | 161 | |
162 | 162 | return new Structure($attributes); |
163 | 163 | } |
— | — | @@ -186,7 +186,7 @@ |
187 | 187 | function getStructureAsListStructure($structure) { |
188 | 188 | $result = '<h5>'; |
189 | 189 | |
190 | | - foreach($structure->attributes as $attribute) { |
| 190 | + foreach($structure->getAttributes() as $attribute) { |
191 | 191 | $result .= getAttributeAsText($attribute); |
192 | 192 | $result .= ' - '; |
193 | 193 | } |
— | — | @@ -197,9 +197,9 @@ |
198 | 198 | |
199 | 199 | function getAttributeAsText($attribute){ |
200 | 200 | $type = $attribute->type; |
201 | | - if (is_a($type, RecordType)) { |
| 201 | + if (is_a($type, Structure)) { |
202 | 202 | $structure = $type->getStructure(); |
203 | | - foreach($structure->attributes as $innerAttribute) { |
| 203 | + foreach($structure->getAttributes() as $innerAttribute) { |
204 | 204 | $result .= getAttributeAsText($innerAttribute); |
205 | 205 | $result .= ' - '; |
206 | 206 | } |
— | — | @@ -214,11 +214,11 @@ |
215 | 215 | function getRecordAsListItem($structure, $record) { |
216 | 216 | $result = ''; |
217 | 217 | |
218 | | - foreach($structure->attributes as $attribute) { |
| 218 | + foreach($structure->getAttributes() as $attribute) { |
219 | 219 | $type = $attribute->type; |
220 | 220 | $value = $record->getAttributeValue($attribute); |
221 | 221 | |
222 | | - if (is_a($type, RecordType)) { |
| 222 | + if (is_a($type, Structure)) { |
223 | 223 | $result .= getRecordAsListItem($type->getStructure(), $value); |
224 | 224 | } |
225 | 225 | else { |
— | — | @@ -248,7 +248,7 @@ |
249 | 249 | for ($i = 0; $i < $recordSet->getRecordCount(); $i++) { |
250 | 250 | $record = $recordSet->getRecord($i); |
251 | 251 | $groupAttributeValue = $record->getAttributeValue($groupAttribute); |
252 | | - $groupRecordSet = $result[$groupAttributeValue]; |
| 252 | + @$groupRecordSet = $result[$groupAttributeValue]; # FIXME - check existence in array |
253 | 253 | |
254 | 254 | if ($groupRecordSet == null) { |
255 | 255 | $groupRecordSet = new ArrayRecordSet($structure, $key); |
Index: trunk/extensions/Wikidata/OmegaWiki/Attribute.php |
— | — | @@ -1,37 +1,5 @@ |
2 | 2 | <?php |
3 | 3 | |
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 | | - |
36 | 4 | class Attribute { |
37 | 5 | public $id = ""; |
38 | 6 | public $name = ""; |
— | — | @@ -53,13 +21,22 @@ |
54 | 22 | } |
55 | 23 | |
56 | 24 | class Structure { |
57 | | - public $attributes; |
58 | 25 | |
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; |
62 | 39 | else |
63 | | - $this->attributes = func_get_args(); |
| 40 | + $this->structure = func_get_args(); |
64 | 41 | } |
65 | 42 | } |
66 | 43 | |
Index: trunk/extensions/Wikidata/OmegaWiki/Search.php |
— | — | @@ -51,13 +51,13 @@ |
52 | 52 | $languageAttribute = new Attribute("language", "Language", "language"); |
53 | 53 | |
54 | 54 | $expressionStructure = new Structure($spellingAttribute, $languageAttribute); |
55 | | - $expressionAttribute = new Attribute("expression", "Expression", new RecordType($expressionStructure)); |
| 55 | + $expressionAttribute = new Attribute("expression", "Expression", $expressionStructure); |
56 | 56 | |
57 | 57 | $definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", $definedMeaningReferenceType); |
58 | 58 | $definitionAttribute = new Attribute("definition", "Definition", "definition"); |
59 | 59 | |
60 | 60 | $meaningStructure = new Structure($definedMeaningAttribute, $definitionAttribute); |
61 | | - $meaningAttribute = new Attribute("meaning", "Meaning", new RecordSetType($meaningStructure)); |
| 61 | + $meaningAttribute = new Attribute("meaning", "Meaning", $meaningStructure); |
62 | 62 | |
63 | 63 | $recordSet = new ArrayRecordSet(new Structure($idAttribute, $expressionAttribute, $meaningAttribute), new Structure($idAttribute)); |
64 | 64 | |
Index: trunk/extensions/Wikidata/OmegaWiki/languages.php |
— | — | @@ -1,9 +1,17 @@ |
2 | 2 | <?php |
3 | 3 | |
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) { |
5 | 9 | 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 | + } |
7 | 14 | return $owLanguageNames; |
| 15 | + |
8 | 16 | } |
9 | 17 | |
10 | 18 | /* Return an array containing all language names translated into the language |
— | — | @@ -20,10 +28,21 @@ |
21 | 29 | } |
22 | 30 | |
23 | 31 | 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 | + |
28 | 47 | } |
29 | 48 | |
30 | 49 | /* Return SQL query string for fetching language names. */ |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php |
— | — | @@ -501,7 +501,7 @@ |
502 | 502 | array("meaning_mid=$definedMeaningId") |
503 | 503 | ); |
504 | 504 | |
505 | | - $recordSet->getStructure()->attributes[] = $alternativeDefinitionAttribute; |
| 505 | + $recordSet->getStructure()->addAttribute($alternativeDefinitionAttribute); |
506 | 506 | |
507 | 507 | expandTranslatedContentsInRecordSet($recordSet, $definitionIdAttribute, $alternativeDefinitionAttribute, $filterLanguageId, $queryTransactionInformation); |
508 | 508 | expandDefinedMeaningReferencesInRecordSet($recordSet, array($sourceAttribute)); |
— | — | @@ -514,7 +514,7 @@ |
515 | 515 | $definitionAttribute, $translatedTextAttribute, $objectAttributesAttribute; |
516 | 516 | |
517 | 517 | $definitionId = getDefinedMeaningDefinitionId($definedMeaningId); |
518 | | - $record = new ArrayRecord($definitionAttribute->type->getStructure()); |
| 518 | + $record = new ArrayRecord($definitionAttribute->type->getAttributes()); |
519 | 519 | $record->setAttributeValue($translatedTextAttribute, getTranslatedContentValue($definitionId, $filterLanguageId, $queryTransactionInformation)); |
520 | 520 | $record->setAttributeValue($objectAttributesAttribute, getObjectAttributesRecord($definitionId, $filterLanguageId, $queryTransactionInformation)); |
521 | 521 | |
— | — | @@ -527,7 +527,7 @@ |
528 | 528 | $urlAttributeValuesAttribute, $textAttributeValuesAttribute, |
529 | 529 | $translatedTextAttributeValuesAttribute, $optionAttributeValuesAttribute; |
530 | 530 | |
531 | | - $record = new ArrayRecord($objectAttributesAttribute->type->getStructure()); |
| 531 | + $record = new ArrayRecord($objectAttributesAttribute->type->getAttributes()); |
532 | 532 | |
533 | 533 | $record->setAttributeValue($objectIdAttribute, $objectId); |
534 | 534 | $record->setAttributeValue($textAttributeValuesAttribute, getTextAttributesValuesRecordSet(array($objectId), $filterLanguageId, $queryTransactionInformation)); |
— | — | @@ -637,7 +637,7 @@ |
638 | 638 | |
639 | 639 | //add object attributes attribute to the generated structure |
640 | 640 | //and expand the records |
641 | | - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute; |
| 641 | + $recordSet->getStructure()->addAttribute($objectAttributesAttribute); |
642 | 642 | expandObjectAttributesAttribute($recordSet, $syntransIdAttribute, $filterLanguageId, $queryTransactionInformation); |
643 | 643 | return $recordSet; |
644 | 644 | } |
— | — | @@ -650,7 +650,7 @@ |
651 | 651 | $urlAttributeObjectAttribute, $urlAttributeValuesAttribute, |
652 | 652 | $optionAttributeObjectAttribute, $optionAttributeValuesAttribute; |
653 | 653 | |
654 | | - $objectAttributesRecordStructure = $objectAttributesAttribute->type->getStructure(); |
| 654 | + $objectAttributesRecordStructure = $objectAttributesAttribute->type->getAttributes(); |
655 | 655 | $objectIds = getUniqueIdsInRecordSet($recordSet, array($objectIdAttribute)); |
656 | 656 | |
657 | 657 | if (count($objectIds) > 0) { |
— | — | @@ -782,7 +782,8 @@ |
783 | 783 | |
784 | 784 | //add object attributes attribute to the generated structure |
785 | 785 | //and expand the records |
786 | | - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute; |
| 786 | + $struct=$recordSet->getStructure(); |
| 787 | + $struct->addAttribute($objectAttributesAttribute); |
787 | 788 | expandObjectAttributesAttribute($recordSet, $relationIdAttribute, $filterLanguageId, $queryTransactionInformation); |
788 | 789 | |
789 | 790 | return $recordSet; |
— | — | @@ -810,7 +811,8 @@ |
811 | 812 | |
812 | 813 | //add object attributes attribute to the generated structure |
813 | 814 | //and expand the records |
814 | | - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute; |
| 815 | + $struct=$recordSet->getStructure(); |
| 816 | + $struct->addAttribute($objectAttributesAttribute); |
815 | 817 | expandObjectAttributesAttribute($recordSet, $relationIdAttribute, $filterLanguageId, $queryTransactionInformation); |
816 | 818 | |
817 | 819 | return $recordSet; |
— | — | @@ -840,7 +842,8 @@ |
841 | 843 | |
842 | 844 | //add object attributes attribute to the generated structure |
843 | 845 | //and expand the records |
844 | | - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute; |
| 846 | + $struct=$recordSet->getStructure(); |
| 847 | + $struct->addAttribute($objectAttributesAttribute); |
845 | 848 | expandObjectAttributesAttribute($recordSet, $possiblySynonymousIdAttribute, $filterLanguageId, $queryTransactionInformation); |
846 | 849 | |
847 | 850 | return $recordSet; |
— | — | @@ -873,7 +876,7 @@ |
874 | 877 | array("member_mid=$definedMeaningId") |
875 | 878 | ); |
876 | 879 | |
877 | | - $recordSet->getStructure()->atttributes[] = $collectionMeaningAttribute; |
| 880 | + $recordSet->getStructure()->addAttribute($collectionMeaningAttribute); |
878 | 881 | |
879 | 882 | for ($i = 0; $i < $recordSet->getRecordCount(); $i++) { |
880 | 883 | $record = $recordSet->getRecord($i); |
— | — | @@ -908,7 +911,7 @@ |
909 | 912 | |
910 | 913 | //add object attributes attribute to the generated structure |
911 | 914 | //and expand the records |
912 | | - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute; |
| 915 | + $recordSet->getStructure()->addAttribute($objectAttributesAttribute); |
913 | 916 | expandObjectAttributesAttribute($recordSet, $textAttributeIdAttribute, $filterLanguageId, $queryTransactionInformation); |
914 | 917 | |
915 | 918 | return $recordSet; |
— | — | @@ -936,7 +939,7 @@ |
937 | 940 | |
938 | 941 | //add object attributes attribute to the generated structure |
939 | 942 | //and expand the records |
940 | | - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute; |
| 943 | + $recordSet->getStructure()->addAttribute($objectAttributesAttribute); |
941 | 944 | expandObjectAttributesAttribute($recordSet, $urlAttributeIdAttribute, $filterLanguageId, $queryTransactionInformation); |
942 | 945 | |
943 | 946 | return $recordSet; |
— | — | @@ -960,14 +963,14 @@ |
961 | 964 | array("object_id IN (" . implode(", ", $objectIds) . ")") |
962 | 965 | ); |
963 | 966 | |
964 | | - $recordSet->getStructure()->attributes[] = $translatedTextValueAttribute; |
| 967 | + $recordSet->getStructure()->addAttribute($translatedTextValueAttribute); |
965 | 968 | |
966 | 969 | expandTranslatedContentsInRecordSet($recordSet, $translatedTextValueIdAttribute, $translatedTextValueAttribute, $filterLanguageId, $queryTransactionInformation); |
967 | 970 | expandDefinedMeaningReferencesInRecordSet($recordSet, array($translatedTextAttributeAttribute)); |
968 | 971 | |
969 | 972 | //add object attributes attribute to the generated structure |
970 | 973 | //and expand the records |
971 | | - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute; |
| 974 | + $recordSet->getStructure()->addAttribute($objectAttributesAttribute); |
972 | 975 | expandObjectAttributesAttribute($recordSet, $translatedTextAttributeIdAttribute, $filterLanguageId, $queryTransactionInformation); |
973 | 976 | return $recordSet; |
974 | 977 | } |
— | — | @@ -1015,7 +1018,7 @@ |
1016 | 1019 | |
1017 | 1020 | /* Add object attributes attribute to the generated structure |
1018 | 1021 | and expand the records. */ |
1019 | | - $recordSet->getStructure()->attributes[] = $objectAttributesAttribute; |
| 1022 | + $recordSet->getStructure()->addAttribute($objectAttributesAttribute); |
1020 | 1023 | expandObjectAttributesAttribute($recordSet, $optionAttributeIdAttribute, $filterLanguageId, $queryTransactionInformation); |
1021 | 1024 | |
1022 | 1025 | return $recordSet; |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWiki.php |
— | — | @@ -23,7 +23,6 @@ |
24 | 24 | $wgOut, $wgTitle; |
25 | 25 | |
26 | 26 | parent::view(); |
27 | | - |
28 | 27 | $this->outputViewHeader(); |
29 | 28 | |
30 | 29 | $spelling = $wgTitle->getText(); |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | $classMembershipAttribute, $collectionMembershipAttribute, $definedMeaningAttributesAttribute, |
17 | 17 | $possiblySynonymousAttribute; |
18 | 18 | |
19 | | - $record = new ArrayRecord($definedMeaningAttribute->type->getStructure()); |
| 19 | + $record = new ArrayRecord($definedMeaningAttribute->type->getAttributes()); |
20 | 20 | $record->setAttributeValue($definitionAttribute, getDefinedMeaningDefinitionRecord($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
21 | 21 | $record->setAttributeValue($classAttributesAttribute, getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation)); |
22 | 22 | $record->setAttributeValue($alternativeDefinitionsAttribute, getAlternativeDefinitionsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php |
— | — | @@ -75,8 +75,9 @@ |
76 | 76 | * |
77 | 77 | */ |
78 | 78 | 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]; |
81 | 82 | } |
82 | 83 | |
83 | 84 | /* |
— | — | @@ -85,7 +86,7 @@ |
86 | 87 | * |
87 | 88 | */ |
88 | 89 | public function setSubRecord($record) { |
89 | | - foreach($record->getStructure()->attributes as $attribute) |
| 90 | + foreach($record->getStructure()->getAttributes() as $attribute) |
90 | 91 | $this->values[$attribute->id] = $record->getAttributeValue($attribute); |
91 | 92 | } |
92 | 93 | |
— | — | @@ -124,11 +125,11 @@ |
125 | 126 | function project($record, $structure) { |
126 | 127 | $result = new ArrayRecord($structure); |
127 | 128 | |
128 | | - foreach ($structure->attributes as $attribute) { |
| 129 | + foreach ($structure->getAttributes() as $attribute) { |
129 | 130 | $type = $attribute->type; |
130 | 131 | $value = $record->getAttributeValue($attribute); |
131 | 132 | |
132 | | - if ($type instanceof RecordType) |
| 133 | + if ($type instanceof Structure) |
133 | 134 | $result->setAttributeValue($attribute, project($record, $type->getStructure())); |
134 | 135 | else |
135 | 136 | $result->setAttributeValue($attribute, $value); |
— | — | @@ -139,7 +140,7 @@ |
140 | 141 | |
141 | 142 | function equalRecords($structure, $lhs, $rhs) { |
142 | 143 | $result = true; |
143 | | - $attributes = $structure->attributes; |
| 144 | + $attributes = $structure->getAttributes(); |
144 | 145 | $i = 0; |
145 | 146 | |
146 | 147 | while($result && $i < count($attributes)) { |
— | — | @@ -148,7 +149,7 @@ |
149 | 150 | $lhsValue = $lhs->getAttributeValue($attribute); |
150 | 151 | $rhsValue = $rhs->getAttributeValue($attribute); |
151 | 152 | |
152 | | - if ($type instanceof RecordType) |
| 153 | + if ($type instanceof Structure) |
153 | 154 | $result = equalRecords($type->getStructure(), $lhsValue, $rhsValue); |
154 | 155 | else |
155 | 156 | $result = $lhsValue == $rhsValue; |
Index: trunk/extensions/Wikidata/OmegaWiki/Transaction.php |
— | — | @@ -346,11 +346,11 @@ |
347 | 347 | $summaryAttribute = new Attribute('summary', 'Summary', 'text'); |
348 | 348 | $transactionStructure = new Structure($transactionIdAttribute, $userAttribute, $userIPAttribute, $timestampAttribute, $summaryAttribute); |
349 | 349 | |
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); |
352 | 352 | |
353 | 353 | $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); |
355 | 355 | |
356 | 356 | function getUserName($userId) { |
357 | 357 | $dbr =& wfGetDB(DB_SLAVE); |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | protected function getKeyIds($record) { |
33 | 33 | $ids = array(); |
34 | 34 | |
35 | | - foreach($record->getStructure()->attributes as $attribute) |
| 35 | + foreach($record->getStructure() as $attribute) |
36 | 36 | $ids[] = $record->getAttributeValue($attribute); |
37 | 37 | |
38 | 38 | return $ids; |
— | — | @@ -209,7 +209,7 @@ |
210 | 210 | public function getAddValue($idPath) { |
211 | 211 | $addStructure = $this->getAddStructure(); |
212 | 212 | |
213 | | - if (count($addStructure->attributes) > 0) { |
| 213 | + if (count($addStructure->getAttributes()) > 0) { |
214 | 214 | $relation = new ArrayRecordSet($addStructure, $addStructure); // TODO Determine real key |
215 | 215 | $values = array(); |
216 | 216 | |
— | — | @@ -342,7 +342,7 @@ |
343 | 343 | if ($this->allowAddController->check($idPath) && $this->controller != null) { |
344 | 344 | $addStructure = $this->getAddStructure(); |
345 | 345 | |
346 | | - if (count($addStructure->attributes) > 0) { |
| 346 | + if (count($addStructure->getAttributes()) > 0) { |
347 | 347 | $addEditors = $this->getAddEditors(); |
348 | 348 | $record = $this->getAddRecord($idPath, $addStructure, $addEditors); |
349 | 349 | $this->controller->add($idPath->getKeyStack(), $record); |
— | — | @@ -377,8 +377,8 @@ |
378 | 378 | if ($this->isAddField) { |
379 | 379 | $addStructure = $this->getAddStructure(); |
380 | 380 | |
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); |
383 | 383 | } |
384 | 384 | |
385 | 385 | return $result; |
— | — | @@ -544,7 +544,7 @@ |
545 | 545 | $childAttribute = $childEditor->getAttribute(); |
546 | 546 | |
547 | 547 | if ($childEditor instanceof RecordTableCellEditor) |
548 | | - $type = new RecordType($this->getTableStructure($childEditor)); |
| 548 | + $type = $this->getTableStructure($childEditor); |
549 | 549 | else |
550 | 550 | $type = 'short-text'; |
551 | 551 | |
— | — | @@ -605,8 +605,8 @@ |
606 | 606 | public function getUpdateAttribute() { |
607 | 607 | $updateStructure = $this->getUpdateStructure(); |
608 | 608 | |
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); |
611 | 611 | else |
612 | 612 | return null; |
613 | 613 | } |
— | — | @@ -614,8 +614,8 @@ |
615 | 615 | public function getAddAttribute() { |
616 | 616 | $addStructure = $this->getAddStructure(); |
617 | 617 | |
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); |
620 | 620 | else |
621 | 621 | return null; |
622 | 622 | } |
— | — | @@ -967,7 +967,6 @@ |
968 | 968 | public function getViewHTML($idPath, $value) { |
969 | 969 | global |
970 | 970 | $definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute; |
971 | | - |
972 | 971 | $definedMeaningId = $value->getAttributeValue($definedMeaningIdAttribute); |
973 | 972 | $definedMeaningLabel = $value->getAttributeValue($definedMeaningLabelAttribute); |
974 | 973 | $definedMeaningDefiningExpression = $value->getAttributeValue($definedMeaningDefiningExpressionAttribute); |