r24026 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24025‎ | r24026 | r24027 >
Date:07:20, 12 July 2007
Author:kim
Status:old
Tags:
Comment:
Some initial work on OmegaWikiAttributes, basically just to
show what I'm actually doing, and to test to make sure
I'm doing it right.

Still supports "legacy code"
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Controller.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/NeedsTranslationTo.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes2.php (deleted) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Record.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes2.php
@@ -1,372 +0,0 @@
2 -<?php
3 -
4 -require_once("Attribute.php");
5 -require_once("WikiDataGlobals.php");
6 -require_once("ViewInformation.php");
7 -
8 -/**
9 - * Replacement OmegaWikiAttributes.
10 - *
11 - * This file models the structure of the OmegaWiki database in a
12 - * database-independent fashion. To do so, it follows a simplified
13 - * relational model, consisting of Attribute objects which are hierarchically
14 - * grouped together using Structure objects. See Attribute.php for details.
15 - *
16 - * The actual data is stored in Records, grouped together as RecordSets.
17 - * See Record.php and RecordSet.php for details.
18 - *
19 - * TODO:
20 - * - The current model of a ton of hardcoded globals is highly inadequate
21 - * and should be replaced with a more abstract schema description.
22 - * - Replacing with a single associative array.
23 - *
24 - * - Attribute names are in WikidataGlobals.php, but should really be
25 - * localizable through MediaWiki's wfMsg() function.
26 - * -This is step 2
27 - * - Records and RecordSets are currently capable of storing most (not all)
28 - * data, but can't actually commit them to the database again. To achieve
29 - * proper separation of architectural layers, the Records should learn
30 - * to talk directly with the DB layer.
31 - * -This is potentially what RecordHelpers are for.
32 - *
33 - */
34 -function initializeOmegaWikiAttributes(ViewInformation $viewInformation) {
35 - global
36 - $omegaWikiAttributes;
37 - $omegaWikiAttributes= new OmegaWikiAttributes($viewInformation);
38 -}
39 -
40 -class OmegaWikiAttributes {
41 - protected $attributes = null;
42 - function __construct(ViewInformation $viewInformation) {
43 - $this->hardValues();
44 - }
45 -
46 - /** Hardcoded schema for now. Later refactor to load from file or DB
47 - *
48 - * Naming: keys are previous name minus -"Attribute"
49 - * (-"Structure" is retained)
50 - */
51 - private function hardValues() {
52 -
53 - $a=$this->attributes; # <- wrist/RSI protection
54 -
55 - # TODO these will be replaced with i18n
56 - global
57 - $wgLanguageAttributeName, $wgSpellingAttributeName, $wgTextAttributeName;
58 -
59 - $a["language"] = new Attribute("language", $wgLanguageAttributeName, "language");
60 - $a["spelling"] = new Attribute("spelling", $wgSpellingAttributeName, "spelling");
61 - $a["text"] = new Attribute("text", $wgTextAttributeName, "text");
62 -
63 - #TODO replace with i18n
64 - global
65 - $wgDefinedMeaningAttributesAttributeName,
66 - $wgDefinedMeaningAttributesAttributeName,
67 - $wgAnnotationAttributeName;
68 -
69 - $a["definedMeaningAttributes"] = new Attribute("defined-meaning-attributes", $wgDefinedMeaningAttributesAttributeName, "will-be-specified-below");
70 - $a["objectAttributes"] = new Attribute("object-attributes", $wgAnnotationAttributeName, "will-be-specified-below");
71 -
72 - # TODO replace with i18n
73 - global
74 - $expressionIdAttribute, $identicalMeaningAttribute;
75 -
76 - $a["expressionId"] = new Attribute("expression-id", "Expression Id", "expression-id");
77 - $a["identicalMeaning"] = new Attribute("indentical-meaning", $wgIdenticalMeaningAttributeName, "boolean");
78 -
79 - #TODO replace with i18n
80 - global
81 - $wgExpressionAttributeName;
82 -
83 - if ($viewInformation->filterOnLanguage())
84 - $a["expression"] = new Attribute("expression", $wgSpellingAttributeName, "spelling");
85 - else {
86 - $a["expressionStructure"] = new Structure("expression", $languageAttribute, $spellingAttribute);
87 - $a["expression"] = new Attribute(null, $wgExpressionAttributeName, $expressionStructure);
88 - }
89 -
90 - global
91 - $definedMeaningIdAttribute, $definedMeaningDefiningExpressionAttribute,
92 - $definedMeaningCompleteDefiningExpressionStructure,
93 - $definedMeaningCompleteDefiningExpressionAttribute;
94 -
95 - $a["definedMeaningId"] = new Attribute("defined-meaning-id", "Defined meaning identifier", "defined-meaning-id");
96 - $a["definedMeaningDefiningExpression"] = new Attribute("defined-meaning-defining-expression", "Defined meaning defining expression", "short-text");
97 -
98 - $a["definedMeaningCompleteDefiningExpressionStructure"] =
99 - new Structure("defined-meaning-full-defining-expression",
100 - $definedMeaningDefiningExpressionAttribute,
101 - $expressionIdAttribute,
102 - $languageAttribute
103 - );
104 - $a["definedMeaningCompleteDefiningExpression"]=new Attribute(null, "Defining expression", $definedMeaningCompleteDefiningExpressionStructure);
105 -
106 - #==============================================
107 - # Done refactoring up to here (to maintain sanity, will do a little every day
108 - # if you want to do a good deed, shift this line down please)
109 - # ===============================================
110 -
111 - global
112 - $definedMeaningReferenceStructure, $definedMeaningLabelAttribute, $definedMeaningReferenceType,
113 - $definedMeaningReferenceAttribute, $wgDefinedMeaningReferenceAttributeName;
114 -
115 - $definedMeaningLabelAttribute = new Attribute("defined-meaning-label", "Defined meaning label", "short-text");
116 - $definedMeaningReferenceStructure = new Structure("defined-meaning", $definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute);
117 -
118 - $definedMeaningReferenceType = $definedMeaningReferenceStructure;
119 - $definedMeaningReferenceAttribute = new Attribute(null, $wgDefinedMeaningReferenceAttributeName, $definedMeaningReferenceType);
120 -
121 - global
122 - $collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute,
123 - $gotoSourceStructure, $gotoSourceAttribute,
124 - $wgCollectionAttributeName, $wgSourceIdentifierAttributeName, $wgGotoSourceAttributeName;
125 -
126 - $collectionIdAttribute = new Attribute("collection", "Collection", "collection-id");
127 - $collectionMeaningAttribute = new Attribute("collection-meaning", $wgCollectionAttributeName, $definedMeaningReferenceStructure);
128 - $sourceIdentifierAttribute = new Attribute("source-identifier", $wgSourceIdentifierAttributeName, "short-text");
129 - $gotoSourceStructure = new Structure("goto-source",$collectionIdAttribute, $sourceIdentifierAttribute);
130 - $gotoSourceAttribute = new Attribute(null, $wgGotoSourceAttributeName, $gotoSourceStructure);
131 -
132 - global
133 - $collectionMembershipAttribute, $wgCollectionMembershipAttributeName, $wgCollectionMembershipAttributeId,
134 - $collectionMembershipStructure;
135 -
136 - $collectionMembershipStructure = new Structure("collection-membership",$collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute);
137 - $collectionMembershipAttribute = new Attribute(null, $wgCollectionMembershipAttributeName, $collectionMembershipStructure);
138 -
139 - global
140 - $classMembershipIdAttribute, $classAttribute;
141 -
142 - $classMembershipIdAttribute = new Attribute("class-membership-id", "Class membership id", "integer");
143 - $classAttribute = new Attribute("class", "Class", $definedMeaningReferenceStructure);
144 -
145 - global
146 - $classMembershipStructure, $classMembershipKeyStructure, $classMembershipAttribute,
147 - $wgClassMembershipAttributeName, $wgClassMembershipAttributeId;
148 -
149 - $classMembershipStructure = new Structure("class-membership", $classMembershipIdAttribute, $classAttribute);
150 - $classMembershipAttribute = new Attribute(null, $wgClassMembershipAttributeName, $classMembershipStructure);
151 -
152 - global
153 - $possiblySynonymousIdAttribute,
154 - $possibleSynonymAttribute,
155 - $wgPossibleSynonymAttributeName, $possiblySynonymousStructure, $possiblySynonymousAttribute,
156 - $wgPossiblySynonymousAttributeName, $wgPossiblySynonymousAttributeId;
157 -
158 - $possiblySynonymousIdAttribute = new Attribute("possibly-synonymous-id", "Possibly synonymous id", "integer");
159 - $possibleSynonymAttribute = new Attribute("possible-synonym", $wgPossibleSynonymAttributeName, $definedMeaningReferenceStructure);
160 - $possiblySynonymousStructure = new Structure("possibly-synonymous", $possiblySynonymousIdAttribute, $possiblySynonymousAttribute);
161 - $possiblySynonymousAttribute = new Attribute(null, $wgPossiblySynonymousAttributeName, $possiblySynonymousStructure);
162 -
163 - global
164 - $relationIdAttribute, $relationTypeAttribute, $relationTypeType, $otherDefinedMeaningAttribute,
165 - $wgRelationTypeAttributeName, $wgOtherDefinedMeaningAttributeName;
166 -
167 - $relationIdAttribute = new Attribute("relation-id", "Relation identifier", "object-id");
168 - $relationTypeAttribute = new Attribute("relation-type", $wgRelationTypeAttributeName, $definedMeaningReferenceStructure);
169 - $otherDefinedMeaningAttribute = new Attribute("other-defined-meaning", $wgOtherDefinedMeaningAttributeName, $definedMeaningReferenceType);
170 -
171 - global
172 - $relationsAttribute, $relationStructure, $reciprocalRelationsAttribute, $objectAttributesAttribute, $wgRelationsAttributeName, $wgIncomingRelationsAttributeName, $wgRelationsAttributeId, $wgIncomingRelationsAttributeId,
173 - $repRelStructure;
174 -
175 - $relationStructure = new Structure("relations", $relationIdAttribute, $relationTypeAttribute, $otherDefinedMeaningAttribute, $objectAttributesAttribute);
176 - $relationsAttribute = new Attribute(null, $wgRelationsAttributeName, $relationStructure);
177 - $reciprocalRelationsAttribute = new Attribute("reciprocal-relations", $wgIncomingRelationsAttributeName, $relationStructure);
178 -
179 - global
180 - $translatedTextIdAttribute, $translatedTextStructure;
181 -
182 - $translatedTextIdAttribute = new Attribute("translated-text-id", "Translated text ID", "integer");
183 - $translatedTextStructure = new Structure("translated-text", $languageAttribute, $textAttribute);
184 -
185 - global
186 - $definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute,
187 - $wgAlternativeDefinitionAttributeName, $wgSourceAttributeName;
188 -
189 - $definitionIdAttribute = new Attribute("definition-id", "Definition identifier", "integer");
190 -
191 - if ($viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes())
192 - $alternativeDefinitionAttribute = new Attribute("alternative-definition", $wgAlternativeDefinitionAttributeName, "text");
193 - else
194 - $alternativeDefinitionAttribute = new Attribute("alternative-definition", $wgAlternativeDefinitionAttributeName, $translatedTextStructure);
195 -
196 - $sourceAttribute = new Attribute("source-id", $wgSourceAttributeName, $definedMeaningReferenceType);
197 -
198 - global
199 - $alternativeDefinitionsAttribute, $wgAlternativeDefinitionsAttributeName, $wgAlternativeDefinitionsAttributeId,
200 - $alternativeDefinitionsStructure;
201 -
202 - $alternativeDefinitionsStructure = new Structure("alternative-definitions", $definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute);
203 -
204 - $alternativeDefinitionsAttribute = new Attribute(null, $wgAlternativeDefinitionsAttributeName, $alternativeDefinitionsStructure);
205 -
206 - global
207 - $synonymsAndTranslationsAttribute, $syntransIdAttribute,
208 - $wgSynonymsAttributeName, $wgSynonymsAndTranslationsAttributeName, $wgSynonymsAndTranslationsAttributeId,
209 - $synonymsTranslationsStructure;
210 -
211 - if ($viewInformation->filterOnLanguage())
212 - $synonymsAndTranslationsCaption = $wgSynonymsAttributeName;
213 - else
214 - $synonymsAndTranslationsCaption = $wgSynonymsAndTranslationsAttributeName;
215 -
216 - $syntransIdAttribute = new Attribute("syntrans-id", "$synonymsAndTranslationsCaption identifier", "integer");
217 - $synonymsTranslationsStructure = new Structure("synonyms-translations", $syntransIdAttribute, $expressionAttribute, $identicalMeaningAttribute, $objectAttributesAttribute);
218 - $synonymsAndTranslationsAttribute = new Attribute(null, "$synonymsAndTranslationsCaption", $synonymsTranslationsStructure);
219 -
220 - global
221 - $translatedTextAttributeIdAttribute, $translatedTextValueIdAttribute,
222 - $translatedTextAttributeObjectAttribute, $translatedTextAttributeAttribute, $translatedTextValueAttribute, $translatedTextAttributeValuesAttribute,
223 - $translatedTextAttributeValuesStructure, $wgTranslatedTextAttributeValuesAttributeName, $wgTranslatedTextAttributeAttributeName, $wgTranslatedTextAttributeValueAttributeName;
224 -
225 - $translatedTextAttributeIdAttribute = new Attribute("translated-text-attribute-id", "Attribute identifier", "object-id");
226 - $translatedTextAttributeObjectAttribute = new Attribute("translated-text-attribute-object-id", "Attribute object", "object-id");
227 - $translatedTextAttributeAttribute = new Attribute("translated-text-attribute", $wgTranslatedTextAttributeAttributeName, $definedMeaningReferenceType);
228 - $translatedTextValueIdAttribute = new Attribute("translated-text-value-id", "Translated text value identifier", "translated-text-value-id");
229 -
230 - if ($viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes())
231 - $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, "text");
232 - else
233 - $translatedTextValueAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeValueAttributeName, $translatedTextStructure);
234 -
235 - $translatedTextAttributeValuesStructure = new Structure("translated-text-attribute-values",$translatedTextAttributeIdAttribute, $translatedTextAttributeObjectAttribute, $translatedTextAttributeAttribute, $translatedTextValueIdAttribute, $translatedTextValueAttribute, $objectAttributesAttribute);
236 - $translatedTextAttributeValuesAttribute = new Attribute(null, $wgTranslatedTextAttributeValuesAttributeName, $translatedTextAttributeValuesStructure);
237 -
238 - global
239 - $textAttributeIdAttribute, $textAttributeObjectAttribute, $textAttributeAttribute, $textAttributeValuesStructure,
240 - $textAttributeValuesAttribute,
241 - $wgTextAttributeValuesAttributeName, $wgTextAttributeAttributeName;
242 -
243 - $textAttributeIdAttribute = new Attribute("text-attribute-id", "Attribute identifier", "object-id");
244 - $textAttributeObjectAttribute = new Attribute("text-attribute-object-id", "Attribute object", "object-id");
245 - $textAttributeAttribute = new Attribute("text-attribute", $wgTextAttributeAttributeName, $definedMeaningReferenceStructure);
246 - $textAttributeValuesStructure = new Structure("text-attribute-values", $textAttributeIdAttribute, $textAttributeObjectAttribute, $textAttributeAttribute, $textAttribute, $objectAttributesAttribute);
247 - $textAttributeValuesAttribute = new Attribute(null, $wgTextAttributeValuesAttributeName, $textAttributeValuesStructure);
248 -
249 - global
250 - $urlAttribute, $urlAttributeIdAttribute, $urlAttributeObjectAttribute, $urlAttributeAttribute, $urlAttributeValuesStructure, $urlAttributeValuesAttribute,
251 - $wgUrlAttributeValuesAttributeName, $wgUrlAttributeAttributeName;
252 -
253 - $urlAttribute = new Attribute("url", "URL", "url");
254 - $urlAttributeIdAttribute = new Attribute("url-attribute-id", "Attribute identifier", "object-id");
255 - $urlAttributeObjectAttribute = new Attribute("url-attribute-object-id", "Attribute object", "object-id");
256 - $urlAttributeAttribute = new Attribute("url-attribute", $wgUrlAttributeAttributeName, $definedMeaningReferenceStructure);
257 - $urlAttributeValuesStructure = new Structure("url-attribute-values", $urlAttributeIdAttribute, $urlAttributeObjectAttribute, $urlAttributeAttribute, $urlAttribute, $objectAttributesAttribute);
258 - $urlAttributeValuesAttribute = new Attribute(null, $wgUrlAttributeValuesAttributeName, $urlAttributeValuesStructure);
259 -
260 - global
261 - $optionAttributeIdAttribute, $optionAttributeAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionAttribute, $optionAttributeValuesAttribute,
262 - $wgOptionAttributeAttributeName, $wgOptionAttributeOptionAttributeName, $wgOptionAttributeValuesAttributeName, $optionAttributeValuesStructure;
263 -
264 - $optionAttributeIdAttribute = new Attribute('option-attribute-id', 'Attribute identifier', 'object-id');
265 - $optionAttributeObjectAttribute = new Attribute('option-attribute-object-id', 'Attribute object', 'object-id');
266 - $optionAttributeAttribute = new Attribute('option-attribute', $wgOptionAttributeAttributeName, $definedMeaningReferenceType);
267 - $optionAttributeOptionAttribute = new Attribute('option-attribute-option', $wgOptionAttributeOptionAttributeName, $definedMeaningReferenceType);
268 - $optionAttributeValuesStructure = new Structure('option-attribute-values', $optionAttributeIdAttribute, $optionAttributeAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionAttribute, $objectAttributesAttribute);
269 - $optionAttributeValuesAttribute = new Attribute(null, $wgOptionAttributeValuesAttributeName, $optionAttributeValuesStructure);
270 -
271 - global
272 - $optionAttributeOptionIdAttribute, $optionAttributeOptionsAttribute, $wgOptionAttributeOptionsAttributeName;
273 -
274 - $optionAttributeOptionIdAttribute = new Attribute('option-attribute-option-id', 'Option identifier', 'object-id');
275 - $optionAttributeOptionsStructure = new Structure('option-attribute-options', $optionAttributeOptionIdAttribute, $optionAttributeAttribute, $optionAttributeOptionAttribute, $languageAttribute);
276 - $optionAttributeOptionsAttribute = new Attribute(null, $wgOptionAttributeOptionsAttributeName, $optionAttributeOptionsStructure);
277 -
278 - global
279 - $definitionAttribute, $translatedTextAttribute, $classAttributesAttribute,
280 - $wgDefinitionAttributeName, $wgTranslatedTextAttributeName;
281 -
282 - if ($viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes())
283 - $translatedTextAttribute = new Attribute("translated-text", $wgTextAttributeName, "text");
284 - else
285 - $translatedTextAttribute = new Attribute(null, $wgTranslatedTextAttributeName, $translatedTextStructure);
286 -
287 - $definitionAttribute = new Attribute(null, $wgDefinitionAttributeName, new Structure("definition", $translatedTextAttribute, $objectAttributesAttribute));
288 -
289 - global
290 - $classAttributesStructure,
291 - // $classAttributeClassAttribute,
292 - $classAttributeIdAttribute, $classAttributeAttributeAttribute, $classAttributeLevelAttribute, $classAttributeTypeAttribute,
293 - $wgClassAttributeAttributeAttributeName, $wgClassAttributeLevelAttributeName,
294 - $wgClassAttributeTypeAttributeName, $wgClassAttributesAttributeName, $wgClassAttributesAttributeId;
295 -
296 - $classAttributeIdAttribute = new Attribute("class-attribute-id", "Class attribute identifier", "object-id");
297 - $classAttributeAttributeAttribute = new Attribute("class-attribute-attribute", $wgClassAttributeAttributeAttributeName, $definedMeaningReferenceStructure);
298 - $classAttributeLevelAttribute = new Attribute("class-attribute-level", $wgClassAttributeLevelAttributeName, $definedMeaningReferenceStructure);
299 - $classAttributeTypeAttribute = new Attribute("class-attribute-type", $wgClassAttributeTypeAttributeName, "short-text");
300 - $classAttributesStructure = new Structure("class-attributes", $classAttributeIdAttribute, $classAttributeAttributeAttribute, $classAttributeLevelAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute);
301 - $classAttributesAttribute = new Attribute(null, $wgClassAttributesAttributeName, $classAttributesStructure);
302 -
303 - global
304 - $definedMeaningAttribute, $wgDefinedMeaningAttributeName;
305 -
306 - $definedMeaningAttribute = new Attribute(null, $wgDefinedMeaningAttributeName,
307 - new Structure(
308 - "defined-meaning",
309 - $definitionAttribute,
310 - $classAttributesAttribute,
311 - $alternativeDefinitionsAttribute,
312 - $synonymsAndTranslationsAttribute,
313 - $relationsAttribute,
314 - $reciprocalRelationsAttribute,
315 - $classMembershipAttribute,
316 - $collectionMembershipAttribute,
317 - $definedMeaningAttributesAttribute)
318 - );
319 -
320 - global
321 - $expressionsAttribute, $expressionMeaningStructure, $expressionExactMeaningsAttribute, $expressionApproximateMeaningsAttribute,
322 - $wgExactMeaningsAttributeName, $wgApproximateMeaningsAttributeName;
323 -
324 - $expressionMeaningStructure = new Structure("expression-exact-meanings", $definedMeaningIdAttribute, $textAttribute, $definedMeaningAttribute);
325 - $expressionExactMeaningsAttribute = new Attribute(null, $wgExactMeaningsAttributeName, $expressionMeaningStructure);
326 - $expressionApproximateMeaningsAttribute = new Attribute("expression-approximate-meanings", $wgApproximateMeaningsAttributeName, $expressionMeaningStructure);
327 -
328 - global
329 - $expressionMeaningsAttribute, $expressionMeaningsStructure, $expressionApproximateMeaningAttribute,
330 - $wgExpressionMeaningsAttributeName, $wgExpressionsAttributeName,
331 - $expressionsStructure;
332 -
333 - $expressionMeaningsStructure = new Structure("expression-meanings", $expressionExactMeaningsAttribute, $expressionApproximateMeaningAttribute);
334 - $expressionMeaningsAttribute = new Attribute(null, $wgExpressionMeaningsAttributeName, $expressionMeaningsStructure);
335 -
336 - $expressionsStructure = new Structure("expressions", $expressionIdAttribute, $expressionAttribute, $expressionMeaningsAttribute);
337 - $expressionsAttribute = new Attribute(null, $wgExpressionsAttributeName, $expressionsStructure);
338 -
339 - global
340 - $objectIdAttribute, $objectAttributesStructure, $wgAnnotationAttributeName;
341 -
342 - $objectIdAttribute = new Attribute("object-id", "Object identifier", "object-id");
343 - $objectAttributesStructure = new Structure("object-attributes", $objectIdAttribute, $textAttributeValuesAttribute, $translatedTextAttributeValuesAttribute, $optionAttributeValuesAttribute);
344 - $objectAttributesAttribute->setAttributeType($objectAttributesStructure);
345 - $definedMeaningAttributesAttribute->setAttributeType($objectAttributesStructure);
346 -
347 - global $wdDefinedMeaningAttributesOrder;
348 -
349 - /**
350 - * This global determines the order of the different
351 - * attributes in the user interface.
352 - */
353 - $wdDefinedMeaningAttributesOrder=array(
354 - $definitionAttribute->id,
355 - $classAttributesAttribute->id,
356 - $alternativeDefinitionsAttribute->id,
357 - $synonymsAndTranslationsAttribute->id,
358 - $possiblySynonymousAttribute->id,
359 - $relationsAttribute->id,
360 - $reciprocalRelationsAttribute->id,
361 - $classMembershipAttribute->id,
362 - $collectionMembershipAttribute->id,
363 - $definedMeaningAttributesAttribute->id
364 - );
365 - }
366 -
367 - function getAttribute($key) {
368 - $attributes=$this->attributes;
369 - return $attributes[$key];
370 - }
371 -}
372 -
373 -
Index: trunk/extensions/Wikidata/OmegaWiki/NeedsTranslationTo.php
@@ -48,7 +48,7 @@
4949
5050 protected function showExpressionsNeedingTranslation($sourceLanguageId, $destinationLanguageId) {
5151 global
52 - $definedMeaningIdAttribute, $expressionIdAttribute, $expressionAttribute, $expressionStructure, $spellingAttribute, $languageAttribute;
 52+ $definedMeaningIdAttribute, $expressionIdAttribute, $expressionAttribute, $expressionStructure, $omegaWikiAttributes;
5353
5454 $dc=wdGetDataSetContext();
5555
@@ -72,14 +72,14 @@
7373
7474 while ($row = $dbr->fetchObject($queryResult)) {
7575 $expressionRecord = new ArrayRecord($expressionStructure);
76 - $expressionRecord->setAttributeValue($languageAttribute, $row->source_language_id);
77 - $expressionRecord->setAttributeValue($spellingAttribute, $row->source_spelling);
 76+ $expressionRecord->language = $row->source_language_id;
 77+ $expressionRecord->spelling = $row->source_spelling;
7878
7979 $recordSet->addRecord(array($row->source_defined_meaning_id, $row->source_expression_id, $expressionRecord, getDefinedMeaningDefinition($row->source_defined_meaning_id)));
8080 }
8181
8282 $expressionEditor = new RecordTableCellEditor($expressionAttribute);
83 - $expressionEditor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), false));
 83+ $expressionEditor->addEditor(new LanguageEditor($omegaWikiAttributes->language, new SimplePermissionController(false), false));
8484 $expressionEditor->addEditor(new SpellingEditor($spellingAttribute, new SimplePermissionController(false), false));
8585
8686 $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new AllowAddController(false), false, false, null);
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php
@@ -14,18 +14,38 @@
1515 * The actual data is stored in Records, grouped together as RecordSets.
1616 * See Record.php and RecordSet.php for details.
1717 *
 18+ * OmegawikiAttributes2.php was running out of date already, so
 19+ * merging here.
 20+ *
1821 * TODO:
1922 * - The current model of a ton of hardcoded globals is highly inadequate
2023 * and should be replaced with a more abstract schema description.
 24+ * -replacing with a single associative array.
2125 * - Attribute names are in WikidataGlobals.php, but should really be
2226 * localizable through MediaWiki's wfMsg() function.
 27+ * -this is step 2
2328 * - Records and RecordSets are currently capable of storing most (not all)
2429 * data, but can't actually commit them to the database again. To achieve
2530 * proper separation of architectural layers, the Records should learn
2631 * to talk directly with the DB layer.
27 - *
 32+ * -this is what RecordHelpers are for.
2833 */
29 -function initializeOmegaWikiAttributes(ViewInformation $viewInformation) {
 34+
 35+function initializeOmegaWikiAttributes(ViewInformation $viewInformation){
 36+ global
 37+ $omegaWikiAttributes; // It would be even better if this was
 38+ // passed to objects explicitly
 39+ // but one step at a time...
 40+ $omegaWikiAttributes= new OmegaWikiAttributes($viewInformation);
 41+ initializeOmegaWikiAttributesOld($viewInformation); //backward compatibility, will be removed.
 42+}
 43+
 44+
 45+/**
 46+ * Original initializeOmegaWikiAttributes, Do not call.
 47+ * @deprecated use/update OmegaWikiAttributes->hardValues instead for now.
 48+ */
 49+function initializeOmegaWikiAttributesOld(ViewInformation $viewInformation) {
3050 global
3151 $languageAttribute, $spellingAttribute, $textAttribute,
3252 $wgLanguageAttributeName, $wgSpellingAttributeName, $wgTextAttributeName;
@@ -72,6 +92,8 @@
7393 $expressionIdAttribute,
7494 $languageAttribute
7595 );
 96+
 97+ # ====== refactored up to this point, do not make changes above this line ====
7698 $definedMeaningCompleteDefiningExpressionAttribute=new Attribute(null, "Defining expression", $definedMeaningCompleteDefiningExpressionStructure);
7799
78100
@@ -333,3 +355,86 @@
334356 }
335357
336358
 359+class OmegaWikiAttributes {
 360+ protected $attributes = array();
 361+
 362+ function __construct(ViewInformation $viewInformation) {
 363+ $this->hardValues($viewInformation);
 364+ }
 365+
 366+ /** Hardcoded schema for now. Later refactor to load from file or DB
 367+ *
 368+ * Naming: keys are previous name minus -"Attribute"
 369+ * (-"Structure" is retained, -"Attributes" is retained)
 370+ */
 371+ private function hardValues($viewInformation) {
 372+
 373+ $a=&$this->attributes; # <- wrist/RSI protection
 374+ $t=$this; #<-idem
 375+
 376+ global
 377+ $wgLanguageAttributeName, $wgSpellingAttributeName, $wgTextAttributeName;
 378+
 379+ $t->language = new Attribute("language", $wgLanguageAttributeName, "language");
 380+ $t->spelling = new Attribute("spelling", $wgSpellingAttributeName, "spelling");
 381+ $t->text= new Attribute("text", $wgTextAttributeName, "text");
 382+
 383+ /*
 384+ $a->definedMeaningAttributes = new Attribute("defined-meaning-attributes", $wgDefinedMeaningAttributesAttributeName, "will-be-specified-below");
 385+ $a["objectAttributes"] = new Attribute("object-attributes", $wgAnnotationAttributeName, "will-be-specified-below");
 386+
 387+ # TODO replace with i18n
 388+ global
 389+ $expressionIdAttribute, $identicalMeaningAttribute;
 390+
 391+ $a["expressionId"] = new Attribute("expression-id", "Expression Id", "expression-id");
 392+ $a["identicalMeaning"] = new Attribute("indentical-meaning", $wgIdenticalMeaningAttributeName, "boolean");
 393+
 394+ #TODO replace with i18n
 395+ global
 396+ $wgExpressionAttributeName;
 397+
 398+ if ($viewInformation->filterOnLanguage())
 399+ $a["expression"] = new Attribute("expression", $wgSpellingAttributeName, "spelling");
 400+ else {
 401+ $a["expressionStructure"] = new Structure("expression", $this->language, $this->spelling);
 402+ $a["expression"] = new Attribute(null, $wgExpressionAttributeName, $expressionStructure);
 403+ }
 404+
 405+ global
 406+ $definedMeaningIdAttribute, $definedMeaningDefiningExpressionAttribute,
 407+ $definedMeaningCompleteDefiningExpressionStructure,
 408+ $definedMeaningCompleteDefiningExpressionAttribute;
 409+
 410+ $a["definedMeaningId"] = new Attribute("defined-meaning-id", "Defined meaning identifier", "defined-meaning-id");
 411+ $a["definedMeaningDefiningExpression"] = new Attribute("defined-meaning-defining-expression", "Defined meaning defining expression", "short-text");
 412+
 413+ $a["definedMeaningCompleteDefiningExpressionStructure"] =
 414+ new Structure("defined-meaning-full-defining-expression",
 415+ $definedMeaningDefiningExpressionAttribute,
 416+ $expressionIdAttribute,
 417+ $
 418+ );
 419+ $a["definedMeaningCompleteDefiningExpression"]=new Attribute(null, "Defining expression", $definedMeaningCompleteDefiningExpressionStructure);
 420+ );
 421+ */
 422+ }
 423+
 424+
 425+ protected function __set($key,$value) {
 426+ $attributes=&$this->attributes;
 427+ $attributes[$key]=$value;
 428+
 429+ }
 430+
 431+ public function __get($key) {
 432+ $attributes=&$this->attributes;
 433+ if (!array_key_exists($key, $attributes)) {
 434+ throw new Exception("Key does not exist");
 435+ }
 436+ return $attributes[$key];
 437+ }
 438+}
 439+
 440+
 441+
Index: trunk/extensions/Wikidata/OmegaWiki/Controller.php
@@ -43,10 +43,10 @@
4444 class DefinedMeaningDefinitionController implements UpdateController {
4545 public function add($keyPath, $record) {
4646 global
47 - $definedMeaningIdAttribute, $languageAttribute, $textAttribute;
 47+ $definedMeaningIdAttribute;
4848 $definedMeaningId = $keyPath->peek(0)->getAttributeValue($definedMeaningIdAttribute);
49 - $languageId = $record->getAttributeValue($languageAttribute);
50 - $text = $record->getAttributeValue($textAttribute);
 49+ $languageId = $record->language;
 50+ $text = $record->text;
5151
5252 if ($languageId != 0 && $text != "")
5353 addDefinedMeaningDefinition($definedMeaningId, $languageId, $text);
@@ -54,20 +54,20 @@
5555
5656 public function remove($keyPath) {
5757 global
58 - $definedMeaningIdAttribute, $languageAttribute;
 58+ $definedMeaningIdAttribute;
5959
6060 $definedMeaningId = $keyPath->peek(1)->getAttributeValue($definedMeaningIdAttribute);
61 - $languageId = $keyPath->peek(0)->getAttributeValue($languageAttribute);
 61+ $languageId = $keyPath->peek(0)->language;
6262 removeDefinedMeaningDefinition($definedMeaningId, $languageId);
6363 }
6464
6565 public function update($keyPath, $record) {
6666 global
67 - $definedMeaningIdAttribute, $languageAttribute, $textAttribute;
 67+ $definedMeaningIdAttribute;
6868
6969 $definedMeaningId = $keyPath->peek(1)->getAttributeValue($definedMeaningIdAttribute);
70 - $languageId = $keyPath->peek(0)->getAttributeValue($languageAttribute);
71 - $text = $record->getAttributeValue($textAttribute);
 70+ $languageId = $keyPath->peek(0)->language;
 71+ $text = $record->text;
7272
7373 if ($text != "")
7474 updateDefinedMeaningDefinition($definedMeaningId, $languageId, $text);
@@ -101,7 +101,7 @@
102102
103103 public function add($keyPath, $record) {
104104 global
105 - $definedMeaningIdAttribute, $alternativeDefinitionAttribute, $languageAttribute, $textAttribute,
 105+ $definedMeaningIdAttribute, $alternativeDefinitionAttribute,
106106 $sourceAttribute;
107107
108108 $definedMeaningId = $keyPath->peek(0)->getAttributeValue($definedMeaningIdAttribute);
@@ -112,8 +112,8 @@
113113 if ($alternativeDefinition->getRecordCount() > 0) {
114114 $definitionRecord = $alternativeDefinition->getRecord(0);
115115
116 - $languageId = $definitionRecord->getAttributeValue($languageAttribute);
117 - $text = $definitionRecord->getAttributeValue($textAttribute);
 116+ $languageId = $definitionRecord->language;
 117+ $text = $definitionRecord->text;
118118
119119 if ($languageId != 0 && $text != '')
120120 addDefinedMeaningAlternativeDefinition($definedMeaningId, $languageId, $text, $sourceId);
@@ -139,11 +139,11 @@
140140 class DefinedMeaningAlternativeDefinitionController implements UpdateController {
141141 public function add($keyPath, $record) {
142142 global
143 - $expressionIdAttribute, $definitionIdAttribute, $languageAttribute, $textAttribute;
 143+ $expressionIdAttribute, $definitionIdAttribute ;
144144
145145 $definitionId = $keyPath->peek(0)->getAttributeValue($definitionIdAttribute);
146 - $languageId = $record->getAttributeValue($languageAttribute);
147 - $text = $record->getAttributeValue($textAttribute);
 146+ $languageId = $record->language;
 147+ $text = $record->text;
148148
149149 if ($languageId != 0 && $text != "")
150150 addTranslatedTextIfNotPresent($definitionId, $languageId, $text);
@@ -151,21 +151,21 @@
152152
153153 public function remove($keyPath) {
154154 global
155 - $definitionIdAttribute, $languageAttribute;
 155+ $definitionIdAttribute;
156156
157157 $definitionId = $keyPath->peek(1)->getAttributeValue($definitionIdAttribute);
158 - $languageId = $keyPath->peek(0)->getAttributeValue($languageAttribute);
 158+ $languageId = $keyPath->peek(0)->$language;
159159
160160 removeTranslatedText($definitionId, $languageId);
161161 }
162162
163163 public function update($keyPath, $record) {
164164 global
165 - $definitionIdAttribute, $languageAttribute, $textAttribute;
 165+ $definitionIdAttribute;
166166
167167 $definitionId = $keyPath->peek(1)->getAttributeValue($definitionIdAttribute);
168 - $languageId = $keyPath->peek(0)->getAttributeValue($languageAttribute);
169 - $text = $record->getAttributeValue($textAttribute);
 168+ $languageId = $keyPath->peek(0)->language;
 169+ $text = $record->text;
170170
171171 if ($text != "")
172172 updateTranslatedText($definitionId, $languageId, $text);
@@ -181,7 +181,7 @@
182182
183183 public function update($keyPath, $value) {
184184 global
185 - $definitionIdAttribute, $languageAttribute, $textAttribute;
 185+ $definitionIdAttribute;
186186
187187 $definitionId = $keyPath->peek(0)->getAttributeValue($definitionIdAttribute);
188188
@@ -199,13 +199,13 @@
200200
201201 public function add($keyPath, $record) {
202202 global
203 - $definedMeaningIdAttribute, $expressionAttribute, $languageAttribute, $spellingAttribute, $identicalMeaningAttribute;
 203+ $definedMeaningIdAttribute, $expressionAttribute, $spellingAttribute, $identicalMeaningAttribute;
204204
205205 $definedMeaningId = $keyPath->peek(0)->getAttributeValue($definedMeaningIdAttribute);
206206 $expressionValue = $record->getAttributeValue($expressionAttribute);
207207
208208 if ($this->filterLanguageId == 0) {
209 - $languageId = $expressionValue->getAttributeValue($languageAttribute);
 209+ $languageId = $expressionValue->$language;
210210 $spelling = $expressionValue->getAttributeValue($spellingAttribute);
211211 }
212212 else {
@@ -398,7 +398,7 @@
399399
400400 public function add($keyPath, $record) {
401401 global
402 - $expressionIdAttribute, $definedMeaningAttribute, $definitionAttribute, $translatedTextAttribute, $languageAttribute, $textAttribute;
 402+ $expressionIdAttribute, $definedMeaningAttribute, $definitionAttribute, $translatedTextAttribute;
403403
404404 $definition = $record->getAttributeValue($definedMeaningAttribute)->getAttributeValue($definitionAttribute);
405405 $translatedContent = $definition->getAttributeValue($translatedTextAttribute);
@@ -408,8 +408,8 @@
409409 if ($translatedContent->getRecordCount() > 0) {
410410 $definitionRecord = $translatedContent->getRecord(0);
411411
412 - $text = $definitionRecord->getAttributeValue($textAttribute);
413 - $languageId = $definitionRecord->getAttributeValue($languageAttribute);
 412+ $text = $definitionRecord->text;
 413+ $languageId = $definitionRecord->language;
414414
415415 if ($languageId != 0 && $text != "")
416416 createNewDefinedMeaning($expressionId, $languageId, $text);
@@ -439,10 +439,10 @@
440440 global
441441 $expressionAttribute, $expressionMeaningsAttribute, $expressionExactMeaningsAttribute,
442442 $definedMeaningAttribute, $definitionAttribute,
443 - $languageAttribute, $textAttribute, $translatedTextAttribute;
 443+ $translatedTextAttribute;
444444
445445 if ($this->filterLanguageId == 0)
446 - $expressionLanguageId = $record->getAttributeValue($expressionAttribute)->getAttributeValue($languageAttribute);
 446+ $expressionLanguageId = $record->getAttributeValue($expressionAttribute)->languageAttribute;
447447 else
448448 $expressionLanguageId = $this->filterLanguageId;
449449
@@ -458,8 +458,8 @@
459459 if ($translatedContent->getRecordCount() > 0) {
460460 $definitionRecord = $translatedContent->getRecord(0);
461461
462 - $text = $definitionRecord->getAttributeValue($textAttribute);
463 - $languageId = $definitionRecord->getAttributeValue($languageAttribute);
 462+ $text = $definitionRecord->text;
 463+ $languageId = $definitionRecord->language;
464464
465465 if ($languageId != 0 && $text != "") {
466466 $expression = findOrCreateExpression($this->spelling, $expressionLanguageId);
@@ -492,10 +492,10 @@
493493 class TextAttributeValuesController extends ObjectAttributeValuesController {
494494 public function add($keyPath, $record) {
495495 global
496 - $textAttribute, $textAttributeAttribute;
 496+ $textAttributeAttribute;
497497 $objectId = $this->objectIdFetcher->fetch($keyPath);
498498 $textAttributeId = $record->getAttributeValue($textAttributeAttribute);
499 - $text = $record->getAttributeValue($textAttribute);
 499+ $text = $record->text;
500500 if ($textAttributeId != 0 && $text != '')
501501 addTextAttributeValue($objectId, $textAttributeId, $text);
502502 }
@@ -512,7 +512,7 @@
513513 $textAttributeIdAttribute, $textAttribute;
514514
515515 $textId = $keyPath->peek(0)->getAttributeValue($textAttributeIdAttribute);
516 - $text = $record->getAttributeValue($textAttribute);
 516+ $text = $record->text;
517517
518518 updateTextAttributeValue($text, $textId);
519519 }
@@ -566,8 +566,8 @@
567567
568568 public function add($keyPath, $record) {
569569 global
570 - $translatedTextValueAttribute, $languageAttribute,
571 - $textAttribute, $translatedTextAttributeAttribute;
 570+ $translatedTextValueAttribute,
 571+ $translatedTextAttributeAttribute;
572572
573573 $objectId = $this->objectIdFetcher->fetch($keyPath);
574574 $textValue = $record->getAttributeValue($translatedTextValueAttribute);
@@ -578,8 +578,8 @@
579579 if ($textValue->getRecordCount() > 0) {
580580 $textValueRecord = $textValue->getRecord(0);
581581
582 - $languageId = $textValueRecord->getAttributeValue($languageAttribute);
583 - $text = $textValueRecord->getAttributeValue($textAttribute);
 582+ $languageId = $textValueRecord->languageAttribute;
 583+ $text = $textValueRecord->textAttribute;
584584
585585 if ($languageId != 0 && $text != '')
586586 addTranslatedTextAttributeValue($objectId, $textAttributeId, $languageId, $text);
@@ -605,11 +605,11 @@
606606 class TranslatedTextAttributeValueController implements UpdateController {
607607 public function add($keyPath, $record) {
608608 global
609 - $translatedTextAttributeIdAttribute, $languageAttribute, $textAttribute;
 609+ $translatedTextAttributeIdAttribute;
610610
611611 $valueId = $keyPath->peek(0)->getAttributeValue($translatedTextAttributeIdAttribute);
612 - $languageId = $record->getAttributeValue($languageAttribute);
613 - $text = $record->getAttributeValue($textAttribute);
 612+ $languageId = $record->language;
 613+ $text = $record->text;
614614 $translatedTextAttribute = getTranslatedTextAttribute($valueId);
615615
616616 if ($languageId != 0 && $text != "")
@@ -618,10 +618,10 @@
619619
620620 public function remove($keyPath) {
621621 global
622 - $translatedTextAttributeIdAttribute, $languageAttribute;
 622+ $translatedTextAttributeIdAttribute;
623623
624624 $valueId = $keyPath->peek(1)->getAttributeValue($translatedTextAttributeIdAttribute);
625 - $languageId = $keyPath->peek(0)->getAttributeValue($languageAttribute);
 625+ $languageId = $keyPath->peek(0)->language;
626626 $translatedTextAttribute = getTranslatedTextAttribute($valueId);
627627
628628 removeTranslatedText($translatedTextAttribute->value_tcid, $languageId);
@@ -629,11 +629,11 @@
630630
631631 public function update($keyPath, $record) {
632632 global
633 - $translatedTextAttributeIdAttribute, $languageAttribute, $textAttribute;
 633+ $translatedTextAttributeIdAttribute;
634634
635635 $valueId = $keyPath->peek(1)->getAttributeValue($translatedTextAttributeIdAttribute);
636 - $languageId = $keyPath->peek(0)->getAttributeValue($languageAttribute);
637 - $text = $record->getAttributeValue($textAttribute);
 636+ $languageId = $keyPath->peek(0)->language;
 637+ $text = $record->text;
638638 $translatedTextAttribute = getTranslatedTextAttribute($valueId);
639639
640640 if ($text != "")
@@ -650,7 +650,7 @@
651651
652652 public function update($keyPath, $value) {
653653 global
654 - $translatedTextAttributeIdAttribute, $languageAttribute, $textAttribute;
 654+ $translatedTextAttributeIdAttribute ;
655655
656656 $valueId = $keyPath->peek(0)->getAttributeValue($translatedTextAttributeIdAttribute);
657657 $translatedTextAttribute = getTranslatedTextAttribute($valueId);
@@ -686,11 +686,11 @@
687687 class OptionAttributeOptionsController implements UpdateController {
688688 public function add($keyPath, $record) {
689689 global
690 - $classAttributeIdAttribute, $optionAttributeOptionAttribute, $languageAttribute;
 690+ $classAttributeIdAttribute, $optionAttributeOptionAttribute;
691691
692692 $attributeId = $keyPath->peek(0)->getAttributeValue($classAttributeIdAttribute);
693693 $optionMeaningId = $record->getAttributeValue($optionAttributeOptionAttribute);
694 - $languageId = $record->getAttributeValue($languageAttribute);
 694+ $languageId = $record->language;
695695
696696 if ($optionMeaningId)
697697 addOptionAttributeOption($attributeId, $optionMeaningId, $languageId);
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php
@@ -14,7 +14,7 @@
1515 $textValueObjectAttributesEditor, $textAttributeIdAttribute,
1616 $linkValueObjectAttributesEditor, $linkAttributeIdAttribute,
1717 $translatedTextValueObjectAttributesEditor, $translatedTextAttributeIdAttribute,
18 - $optionValueObjectAttributesEditor, $optionAttributeIdAttribute, $annotationMeaningName;
 18+ $optionValueObjectAttributesEditor, $optionAttributeIdAttribute, $annotationMeaningName, $omegaWikiAttributes;
1919
2020 $textValueObjectAttributesEditor = new RecordUnorderedListEditor($objectAttributesAttribute, 5);
2121 $linkValueObjectAttributesEditor = new RecordUnorderedListEditor($objectAttributesAttribute, 5);
@@ -109,16 +109,15 @@
110110 }
111111
112112 function getTranslatedTextEditor(Attribute $attribute, UpdateController $updateController, UpdateAttributeController $updateAttributeController, ViewInformation $viewInformation) {
113 - global
114 - $languageAttribute, $textAttribute;
115113
 114+ global $omegaWikiAttributes;
116115 if ($viewInformation->filterLanguageId == 0 || $viewInformation->showRecordLifeSpan) {
117116 $editor = new RecordSetTableEditor($attribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, true, $updateController);
118117
119118 if ($viewInformation->filterLanguageId == 0)
120 - $editor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), true));
 119+ $editor->addEditor(new LanguageEditor($omegaWikiAttributes->language, new SimplePermissionController(false), true));
121120
122 - $editor->addEditor(new TextEditor($textAttribute, new SimplePermissionController(true), true));
 121+ $editor->addEditor(new TextEditor($omegaWikiAttributes->text, new SimplePermissionController(true), true));
123122 addTableMetadataEditors($editor, $viewInformation);
124123 }
125124 else
@@ -197,12 +196,12 @@
198197
199198 function getExpressionTableCellEditor(Attribute $attribute, ViewInformation $viewInformation) {
200199 global
201 - $languageAttribute, $spellingAttribute;
 200+ $omegaWikiAttributes;
202201
203202 if ($viewInformation->filterLanguageId == 0) {
204203 $editor = new RecordTableCellEditor($attribute);
205 - $editor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), true));
206 - $editor->addEditor(new SpellingEditor($spellingAttribute, new SimplePermissionController(false), true));
 204+ $editor->addEditor(new LanguageEditor($omegaWikiAttributes->language, new SimplePermissionController(false), true));
 205+ $editor->addEditor(new SpellingEditor($omegaWikiAttributes->spelling, new SimplePermissionController(false), true));
207206 }
208207 else
209208 $editor = new SpellingEditor($attribute, new SimplePermissionController(false), true);
@@ -428,11 +427,12 @@
429428
430429 function getOptionAttributeOptionsEditor() {
431430 global
432 - $optionAttributeAttribute, $optionAttributeOptionAttribute, $languageAttribute, $optionAttributeOptionsAttribute;
 431+ $optionAttributeAttribute, $optionAttributeOptionAttribute, $optionAttributeOptionsAttribute, $omegaWikiAttributes;
 432+ $o=$omegaWikiAttributes;
433433
434434 $editor = new RecordSetTableEditor($optionAttributeOptionsAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new OptionAttributeOptionsController());
435435 $editor->addEditor(new DefinedMeaningReferenceEditor($optionAttributeOptionAttribute, new SimplePermissionController(false), true));
436 - $editor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), true));
 436+ $editor->addEditor(new LanguageEditor($o->language, new SimplePermissionController(false), true));
437437
438438 return $editor;
439439 }
@@ -455,7 +455,7 @@
456456
457457 function getExpressionsEditor($spelling, ViewInformation $viewInformation) {
458458 global
459 - $expressionMeaningsAttribute, $expressionExactMeaningsAttribute, $expressionApproximateMeaningsAttribute, $expressionAttribute, $languageAttribute, $expressionsAttribute;
 459+ $expressionMeaningsAttribute, $expressionExactMeaningsAttribute, $expressionApproximateMeaningsAttribute, $expressionAttribute, $expressionsAttribute, $omegaWikiAttributes;
460460
461461 $expressionMeaningsRecordEditor = new RecordUnorderedListEditor($expressionMeaningsAttribute, 3);
462462
@@ -467,7 +467,7 @@
468468
469469 if ($viewInformation->filterLanguageId == 0) {
470470 $expressionEditor = new RecordSpanEditor($expressionAttribute, ': ', ' - ');
471 - $expressionEditor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), true));
 471+ $expressionEditor->addEditor(new LanguageEditor($omegaWikiAttributes->language, new SimplePermissionController(false), true));
472472
473473 $expressionsEditor = new RecordSetListEditor(
474474 $expressionsAttribute,
@@ -629,13 +629,13 @@
630630
631631 function createTranslatedTextViewer($attribute) {
632632 global
633 - $languageAttribute, $textAttribute;
 633+ $textAttribute,$omegaWikiAttributes;
634634
635635 $result = createTableViewer($attribute);
636 - $result->addEditor(createLanguageViewer($languageAttribute));
 636+ $result->addEditor(createLanguageViewer($omegaWikiAttributes->language));
637637 $result->addEditor(createLongTextViewer($textAttribute));
638638
639639 return $result;
640640 }
641641
642 -?>
\ No newline at end of file
 642+?>
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php
@@ -229,7 +229,7 @@
230230
231231 function getExpressionReferenceRecords($expressionIds) {
232232 global
233 - $expressionStructure, $languageAttribute, $spellingAttribute;
 233+ $expressionStructure;
234234
235235 $dc=wdGetDataSetContext();
236236
@@ -246,8 +246,8 @@
247247
248248 while ($row = $dbr->fetchObject($queryResult)) {
249249 $record = new ArrayRecord($expressionStructure);
250 - $record->setAttributeValue($languageAttribute, $row->language_id);
251 - $record->setAttributeValue($spellingAttribute, $row->spelling);
 250+ $record->language = $row->language_id;
 251+ $record->spelling = $row->spelling;
252252
253253 $result[$row->expression_id] = $record;
254254 }
@@ -396,7 +396,7 @@
397397
398398 function getExpressionsRecordSet($spelling, ViewInformation $viewInformation) {
399399 global
400 - $expressionIdAttribute, $expressionAttribute, $languageAttribute, $expressionMeaningsAttribute, $expressionsStructure;
 400+ $omegaWikiAttributes, $expressionIdAttribute, $expressionAttribute, $expressionMeaningsAttribute, $expressionsStructure;
401401
402402 $dc=wdGetDataSetContext();
403403
@@ -418,11 +418,11 @@
419419 );
420420
421421 $result = new ArrayRecordSet($expressionsStructure, new Structure("expression-id", $expressionIdAttribute));
422 - $languageStructure = new Structure("language", $languageAttribute);
 422+ $languageStructure = new Structure("language", $omegaWikiAttributes->language);
423423
424424 while($expression = $dbr->fetchObject($queryResult)) {
425425 $expressionRecord = new ArrayRecord($languageStructure);
426 - $expressionRecord->setAttributeValue($languageAttribute, $expression->language_id);
 426+ $expressionRecord->language = $expression->language_id;
427427
428428 $result->addRecord(array(
429429 $expression->expression_id,
@@ -656,37 +656,41 @@
657657
658658 function getTranslatedContentRecordSet($translatedContentId, ViewInformation $viewInformation) {
659659 global
660 - $translatedContentTable, $languageAttribute, $textAttribute,
661 - $translatedTextStructure;
 660+ $translatedContentTable,
 661+ $translatedTextStructure, $omegaWikiAttributes;
662662
 663+ $o=$omegaWikiAttributes;
 664+
663665 $recordSet = queryRecordSet(
664666 $translatedTextStructure->getStructureType(),
665667 $viewInformation->queryTransactionInformation,
666 - $languageAttribute,
 668+ $o->language,
667669 new TableColumnsToAttributesMapping(
668 - new TableColumnsToAttribute(array('language_id'), $languageAttribute),
669 - new TableColumnsToAttribute(array('text_id'), $textAttribute)
 670+ new TableColumnsToAttribute(array('language_id'), $o->language),
 671+ new TableColumnsToAttribute(array('text_id'), $o->text)
670672 ),
671673 $translatedContentTable,
672674 array("translated_content_id=$translatedContentId")
673675 );
674676
675 - expandTextReferencesInRecordSet($recordSet, array($textAttribute));
 677+ expandTextReferencesInRecordSet($recordSet, array($o->text));
676678
677679 return $recordSet;
678680 }
679681
680682 function getFilteredTranslatedContentRecordSet($translatedContentId, ViewInformation $viewInformation) {
681683 global
682 - $translatedContentTable, $languageAttribute, $textAttribute;
 684+ $translatedContentTable, $omegaWikiAttributes ;
 685+
 686+ $o=$omegaWikiAttributes;
683687
684688 $recordSet = queryRecordSet(
685689 null,
686690 $viewInformation->queryTransactionInformation,
687 - $languageAttribute,
 691+ $o->language,
688692 new TableColumnsToAttributesMapping(
689 - new TableColumnsToAttribute(array('language_id'), $languageAttribute),
690 - new TableColumnsToAttribute(array('text_id'), $textAttribute)
 693+ new TableColumnsToAttribute(array('language_id'), $o->language),
 694+ new TableColumnsToAttribute(array('text_id'), $o->text)
691695 ),
692696 $translatedContentTable,
693697 array(
@@ -1061,8 +1065,9 @@
10621066
10631067 function getOptionAttributeOptionsRecordSet($attributeId, ViewInformation $viewInformation) {
10641068 global
1065 - $optionAttributeOptionIdAttribute, $optionAttributeAttribute, $optionAttributeOptionAttribute, $languageAttribute, $optionAttributeOptionsTable;
 1069+ $optionAttributeOptionIdAttribute, $optionAttributeAttribute, $optionAttributeOptionAttribute, $omegaWikiAttributes, $optionAttributeOptionsTable;
10661070
 1071+ $o=$omegaWikiAttributes;
10671072 $recordSet = queryRecordSet(
10681073 null,
10691074 $viewInformation->queryTransactionInformation,
@@ -1071,7 +1076,7 @@
10721077 new TableColumnsToAttribute(array('option_id'), $optionAttributeOptionIdAttribute),
10731078 new TableColumnsToAttribute(array('attribute_id'), $optionAttributeAttribute),
10741079 new TableColumnsToAttribute(array('option_mid'), $optionAttributeOptionAttribute),
1075 - new TableColumnsToAttribute(array('language_id'), $languageAttribute)
 1080+ new TableColumnsToAttribute(array('language_id'), $o->language)
10761081 ),
10771082 $optionAttributeOptionsTable,
10781083 array('attribute_id = ' . $attributeId)
@@ -1178,13 +1183,15 @@
11791184 $definedMeaningCompleteDefiningExpressionAttribute,
11801185 $definedMeaningDefiningExpressionAttribute,
11811186 $expressionIdAttribute,
1182 - $languageAttribute;
 1187+ $omegaWikiAttributes;
11831188
 1189+ $o=$omegaWikiAttributes;
 1190+
11841191 $definingExpression=definingExpressionRow($definedMeaningId);
11851192 $definingExpressionRecord = new ArrayRecord($definedMeaningCompleteDefiningExpressionAttribute->type);
11861193 $definingExpressionRecord->setAttributeValue($expressionIdAttribute, $definingExpression[0]);
11871194 $definingExpressionRecord->setAttributeValue($definedMeaningDefiningExpressionAttribute, $definingExpression[1]);
1188 - $definingExpressionRecord->setAttributeValue($languageAttribute, $definingExpression[2]);
 1195+ $definingExpressionRecord->setAttributeValue($o->language, $definingExpression[2]);
11891196 return $definingExpressionRecord;
11901197
1191 -}
\ No newline at end of file
 1198+}
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php
@@ -2,6 +2,7 @@
33
44 require_once('Attribute.php');
55 require_once('RecordHelper.php');
 6+require_once('OmegaWikiAttributes.php');
67
78 interface Record {
89 public function getStructure();
@@ -13,7 +14,8 @@
1415 protected $structure;
1516 protected $values = array();
1617 protected $helper=null;
17 -
 18+ #possibly associate an OmegaWikiAttributes instance (singleton?) here
 19+
1820 public function __construct(Structure $structure) {
1921 $this->structure = $structure;
2022 $this->helper=RecordHelperFactory::getRecordHelper($this);
@@ -28,11 +30,30 @@
2931 return @$this->values[$attribute->id];
3032 }
3133
 34+
 35+ /**
 36+ * Look up the correct attribute using omegaWikiAttributes
 37+ * and return its value
 38+ */
 39+ public function __get($attribute_name){
 40+ global $omegaWikiAttributes;
 41+ return $this->getAttributeValue($omegaWikiAttributes->$attribute_name);
 42+ }
 43+
 44+ /**
 45+ * Look up the correct attribute using omegaWikiAttributes
 46+ * and set its value
 47+ */
 48+ public function __set($attribute_name, $value){
 49+ global $omegaWikiAttributes;
 50+ return $this->setAttributeValue ($omegaWikiAttributes->$attribute_name, $value);
 51+ }
3252 /**
3353 * Obtains a value based on the provided key.
3454 * In future, this should check against an attributes global with string
3555 * lookup, and might even be smart.
3656 * For now, this just does a direct lookup.
 57+ * @deprecated use __get and __set instead
3758 */
3859 public function getValue ($key) {
3960 return @$this->values[$key];
@@ -86,6 +107,7 @@
87108 $rv=$comma;
88109 $repr="$key:$value";
89110 #Duck typing (should refactor this to a has_attr() function);
 111+ # ( might be replacable by property_exists() in php 5.1+ )
90112 $methods=get_class_methods(get_class($value));
91113 if (!is_null($methods)) {
92114 if (in_array("tostring_indent",$methods)) {

Status & tagging log