r23656 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23655‎ | r23656 | r23657 >
Date:22:52, 2 July 2007
Author:erik
Status:old
Tags:
Comment:
Refactoring:

1) Structure objects should generally know what data they describe.
Therefore, the structure class now has an optional type parameter.
(If not provided, the structure will try to guess its type from
the passed attribute, but if there are multiple ones, it will
be anonymous.)

This makes it easier to parse Records, as each one of them
will know what kind of data it contains.

It necessitates some changes throughout to ensure that
correctly named structures are associated with the Records.
(Still incomplete, but it should be sufficient for now, until
we completely refactor the Save & Transaction code.)

May still have bugs.

2) Reduce globals a bit. But really, the entire OmegaWikiAttributes
must die in favor of a schema definition that is parsed into
a single global.

3) Fix a minor dataset bug in Editor.php

4) Wrap view_as=raw in <pre> and serve as HTML to make sure that
any debug messages are shown correctly.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Attribute.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Editor.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php (modified) (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)
  • /trunk/extensions/Wikidata/OmegaWiki/RecordHelper.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/RecordSet.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/RecordSetQueries.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialTransaction.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php
@@ -17,9 +17,7 @@
1818
1919 if ($view_as=="raw") {
2020 $wgOut->disable();
21 -
22 - header("Content-Type: text/plain; charset=UTF-8");
23 - echo($this->raw());
 21+ echo("<pre>".$this->raw()."</pre>");
2422 return;
2523 }
2624 $this->outputViewHeader();
@@ -108,7 +106,6 @@
109107 $this->viewQueryTransactionInformation
110108 );
111109 $record=$dmModel->getRecord();
112 - $record->finish("DefinedMeaning");
113110 return $record;
114111 }
115112
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php
@@ -102,49 +102,6 @@
103103 $wgUrlAttributeAttributeName = "Property";
104104 $wgUrlAttributeValuesAttributeName = "URL properties";
105105
106 -// Attribute Ids
107 -
108 -global
109 - $wgAlternativeDefinitionsAttributeId,
110 - $wgClassAttributesAttributeId,
111 - $wgClassMembershipAttributeId,
112 - $wgCollectionMembershipAttributeId,
113 - $wgDefinedMeaningAttributesAttributeId,
114 - $wgDefinitionAttributeId,
115 - $wgIncomingRelationsAttributeId,
116 - $wgPossiblySynonymousAttributeId,
117 - $wgRelationsAttributeId,
118 - $wgSynonymsAndTranslationsAttributeId;
119 -
120 -$wgAlternativeDefinitionsAttributeId = "alternative-definitions";
121 -$wgClassAttributesAttributeId = "class-attributes";
122 -$wgClassMembershipAttributeId = "class-membership";
123 -$wgCollectionMembershipAttributeId = "collection-membership";
124 -$wgDefinedMeaningAttributesAttributeId = "defined-meaning-attributes";
125 -$wgDefinitionAttributeId = "definition";
126 -$wgIncomingRelationsAttributeId = "reciprocal-relations";
127 -$wgPossiblySynonymousAttributeId = "possibly-synonymous";
128 -$wgRelationsAttributeId = "relations";
129 -$wgSynonymsAndTranslationsAttributeId = "synonyms-translations";
130 -
131 -// Defined meaning editor
132 -
133 -global
134 - $wgDefinedMeaningAttributesOrder;
135 -
136 -$wgDefinedMeaningAttributesOrder = array(
137 - $wgDefinitionAttributeId,
138 - $wgClassAttributesAttributeId,
139 - $wgAlternativeDefinitionsAttributeId,
140 - $wgSynonymsAndTranslationsAttributeId,
141 - $wgPossiblySynonymousAttributeId,
142 - $wgRelationsAttributeId,
143 - $wgIncomingRelationsAttributeId,
144 - $wgClassMembershipAttributeId,
145 - $wgCollectionMembershipAttributeId,
146 - $wgDefinedMeaningAttributesAttributeId
147 -);
148 -
149106 // Go to source templates
150107
151108 require_once("GotoSourceTemplate.php");
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php
@@ -475,8 +475,8 @@
476476 $spellingAttribute = new Attribute("spelling", "Spelling", "short-text");
477477 $languageAttribute = new Attribute("language", "Language", "language");
478478
479 - $expressionStructure = new Structure($spellingAttribute, $languageAttribute);
480 - $definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", $expressionStructure);
 479+ $expressionStructure = new Structure("defined-meaning", $spellingAttribute, $languageAttribute);
 480+ $definedMeaningAttribute = new Attribute(null, "Defined meaning", $expressionStructure);
481481 $definitionAttribute = new Attribute("definition", "Definition", "definition");
482482
483483 $recordSet = new ArrayRecordSet(new Structure($idAttribute, $definedMeaningAttribute, $definitionAttribute), new Structure($idAttribute));
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php
@@ -17,7 +17,7 @@
1818 $wgDefinedMeaningAttributesAttributeName,
1919 $wgDefinedMeaningAttributesAttributeName, $wgDefinedMeaningAttributesAttributeId, $wgAnnotationAttributeName;
2020
21 - $definedMeaningAttributesAttribute = new Attribute($wgDefinedMeaningAttributesAttributeId, $wgDefinedMeaningAttributesAttributeName, "will-be-specified-below");
 21+ $definedMeaningAttributesAttribute = new Attribute("defined-meaning-attributes", $wgDefinedMeaningAttributesAttributeName, "will-be-specified-below");
2222 $objectAttributesAttribute = new Attribute("object-attributes", $wgAnnotationAttributeName, "will-be-specified-below");
2323
2424 global
@@ -32,8 +32,8 @@
3333 if ($filterOnLanguage)
3434 $expressionAttribute = new Attribute("expression", $wgSpellingAttributeName, "spelling");
3535 else {
36 - $expressionStructure = new Structure($languageAttribute, $spellingAttribute);
37 - $expressionAttribute = new Attribute("expression", $wgExpressionAttributeName, $expressionStructure);
 36+ $expressionStructure = new Structure("expression", $languageAttribute, $spellingAttribute);
 37+ $expressionAttribute = new Attribute(null, $wgExpressionAttributeName, $expressionStructure);
3838 }
3939
4040 global
@@ -43,31 +43,32 @@
4444 $definedMeaningDefiningExpressionAttribute = new Attribute("defined-meaning-defining-expression", "Defined meaning defining expression", "short-text");
4545
4646 global
47 - $definedMeaningReferenceStructure, $definedMeaningLabelAttribute, $definedMeaningReferenceKeyStructure, $definedMeaningReferenceType,
 47+ $definedMeaningReferenceStructure, $definedMeaningLabelAttribute, $definedMeaningReferenceType,
4848 $definedMeaningReferenceAttribute, $wgDefinedMeaningReferenceAttributeName;
4949
5050 $definedMeaningLabelAttribute = new Attribute("defined-meaning-label", "Defined meaning label", "short-text");
51 - $definedMeaningReferenceStructure = new Structure($definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute);
52 - $definedMeaningReferenceKeyStructure = new Structure($definedMeaningIdAttribute);
 51+ $definedMeaningReferenceStructure = new Structure("defined-meaning", $definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute);
 52+
5353 $definedMeaningReferenceType = $definedMeaningReferenceStructure;
54 - $definedMeaningReferenceAttribute = new Attribute("defined-meaning", $wgDefinedMeaningReferenceAttributeName, $definedMeaningReferenceType);
 54+ $definedMeaningReferenceAttribute = new Attribute(null, $wgDefinedMeaningReferenceAttributeName, $definedMeaningReferenceType);
5555
5656 global
57 - $collectionIdAttribute, $collectionMeaningType, $collectionMeaningAttribute, $sourceIdentifierAttribute,
 57+ $collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute,
5858 $gotoSourceStructure, $gotoSourceAttribute,
5959 $wgCollectionAttributeName, $wgSourceIdentifierAttributeName, $wgGotoSourceAttributeName;
6060
6161 $collectionIdAttribute = new Attribute("collection", "Collection", "collection-id");
62 - $collectionMeaningType = $definedMeaningReferenceStructure;
63 - $collectionMeaningAttribute = new Attribute("collection-meaning", $wgCollectionAttributeName, $collectionMeaningType);
 62+ $collectionMeaningAttribute = new Attribute("collection-meaning", $wgCollectionAttributeName, $definedMeaningReferenceStructure);
6463 $sourceIdentifierAttribute = new Attribute("source-identifier", $wgSourceIdentifierAttributeName, "short-text");
65 - $gotoSourceStructure = new Structure($collectionIdAttribute, $sourceIdentifierAttribute);
66 - $gotoSourceAttribute = new Attribute("goto-source", $wgGotoSourceAttributeName, $gotoSourceStructure);
 64+ $gotoSourceStructure = new Structure("goto-source",$collectionIdAttribute, $sourceIdentifierAttribute);
 65+ $gotoSourceAttribute = new Attribute(null, $wgGotoSourceAttributeName, $gotoSourceStructure);
6766
6867 global
69 - $collectionMembershipAttribute, $wgCollectionMembershipAttributeName, $wgCollectionMembershipAttributeId;
 68+ $collectionMembershipAttribute, $wgCollectionMembershipAttributeName, $wgCollectionMembershipAttributeId,
 69+ $collectionMembershipStructure;
7070
71 - $collectionMembershipAttribute = new Attribute($wgCollectionMembershipAttributeId, $wgCollectionMembershipAttributeName, new Structure($collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute));
 71+ $collectionMembershipStructure = new Structure("collection-membership",$collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute);
 72+ $collectionMembershipAttribute = new Attribute(null, $wgCollectionMembershipAttributeName, $collectionMembershipStructure);
7273
7374 global
7475 $classMembershipIdAttribute, $classAttribute;
@@ -79,47 +80,38 @@
8081 $classMembershipStructure, $classMembershipKeyStructure, $classMembershipAttribute,
8182 $wgClassMembershipAttributeName, $wgClassMembershipAttributeId;
8283
83 - $classMembershipStructure = new Structure($classMembershipIdAttribute, $classAttribute);
84 - $classMembershipKeyStructure = new Structure($classMembershipIdAttribute);
85 - $classMembershipAttribute = new Attribute($wgClassMembershipAttributeId, $wgClassMembershipAttributeName, $classMembershipStructure);
 84+ $classMembershipStructure = new Structure("class-membership", $classMembershipIdAttribute, $classAttribute);
 85+ $classMembershipAttribute = new Attribute(null, $wgClassMembershipAttributeName, $classMembershipStructure);
8686
8787 global
88 - $possiblySynonymousIdAttribute, $possibleSynonymAttribute, $wgPossibleSynonymAttributeName;
 88+ $possiblySynonymousIdAttribute, $possiblySynonymousAttribute, $wgPossibleSynonymAttributeName, $possiblySynonymousStructure, $possiblySynonymousAttribute, $wgPossiblySynonymousAttributeName, $wgPossiblySynonymousAttributeId;
8989
9090 $possiblySynonymousIdAttribute = new Attribute("possibly-synonymous-id", "Possibly synonymous id", "integer");
91 - $possibleSynonymAttribute = new Attribute("possible-synonym", $wgPossibleSynonymAttributeName, $definedMeaningReferenceStructure);
92 -
93 - global
94 - $possiblySynonymousStructure, $possiblySynonymousKeyStructure, $possiblySynonymousAttribute,
95 - $wgPossiblySynonymousAttributeName, $wgPossiblySynonymousAttributeId;
96 -
97 - $possiblySynonymousStructure = new Structure($possiblySynonymousIdAttribute, $possiblySynonymousAttribute);
98 - $possiblySynonymousKeyStructure = new Structure($possiblySynonymousIdAttribute);
99 - $possiblySynonymousAttribute = new Attribute($wgPossiblySynonymousAttributeId, $wgPossiblySynonymousAttributeName, $possiblySynonymousStructure);
 91+ $possiblySynonymousAttribute = new Attribute("possible-synonym", $wgPossibleSynonymAttributeName, $definedMeaningReferenceStructure);
 92+ $possiblySynonymousStructure = new Structure("possibly-synonymous", $possiblySynonymousIdAttribute, $possiblySynonymousAttribute);
 93+ $possiblySynonymousAttribute = new Attribute(null, $wgPossiblySynonymousAttributeName, $possiblySynonymousStructure);
10094
10195 global
10296 $relationIdAttribute, $relationTypeAttribute, $relationTypeType, $otherDefinedMeaningAttribute,
10397 $wgRelationTypeAttributeName, $wgOtherDefinedMeaningAttributeName;
10498
10599 $relationIdAttribute = new Attribute("relation-id", "Relation identifier", "object-id");
106 - $relationTypeType = $definedMeaningReferenceStructure;
107 - $relationTypeAttribute = new Attribute("relation-type", $wgRelationTypeAttributeName, $relationTypeType);
 100+ $relationTypeAttribute = new Attribute("relation-type", $wgRelationTypeAttributeName, $definedMeaningReferenceStructure);
108101 $otherDefinedMeaningAttribute = new Attribute("other-defined-meaning", $wgOtherDefinedMeaningAttributeName, $definedMeaningReferenceType);
109102
110103 global
111 - $relationsAttribute, $relationStructure, $relationKeyStructure, $reciprocalRelationsAttribute, $objectAttributesAttribute,
112 - $wgRelationsAttributeName, $wgIncomingRelationsAttributeName, $wgRelationsAttributeId, $wgIncomingRelationsAttributeId;
 104+ $relationsAttribute, $relationStructure, $reciprocalRelationsAttribute, $objectAttributesAttribute, $wgRelationsAttributeName, $wgIncomingRelationsAttributeName, $wgRelationsAttributeId, $wgIncomingRelationsAttributeId,
 105+ $repRelStructure;
113106
114 - $relationStructure = new Structure($relationIdAttribute, $relationTypeAttribute, $otherDefinedMeaningAttribute, $objectAttributesAttribute);
115 - $relationKeyStructure = new Structure($relationIdAttribute);
116 - $relationsAttribute = new Attribute($wgRelationsAttributeId, $wgRelationsAttributeName, $relationStructure);
117 - $reciprocalRelationsAttribute = new Attribute($wgIncomingRelationsAttributeId, $wgIncomingRelationsAttributeName, $relationStructure);
 107+ $relationStructure = new Structure("relations", $relationIdAttribute, $relationTypeAttribute, $otherDefinedMeaningAttribute, $objectAttributesAttribute);
 108+ $relationsAttribute = new Attribute(null, $wgRelationsAttributeName, $relationStructure);
 109+ $reciprocalRelationsAttribute = new Attribute("reciprocal-relations", $wgIncomingRelationsAttributeName, $relationStructure);
118110
119111 global
120112 $translatedTextIdAttribute, $translatedTextStructure;
121113
122114 $translatedTextIdAttribute = new Attribute("translated-text-id", "Translated text ID", "integer");
123 - $translatedTextStructure = new Structure($languageAttribute, $textAttribute);
 115+ $translatedTextStructure = new Structure("translated-text", $languageAttribute, $textAttribute);
124116
125117 global
126118 $definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute,
@@ -135,21 +127,26 @@
136128 $sourceAttribute = new Attribute("source-id", $wgSourceAttributeName, $definedMeaningReferenceType);
137129
138130 global
139 - $alternativeDefinitionsAttribute, $wgAlternativeDefinitionsAttributeName, $wgAlternativeDefinitionsAttributeId;
 131+ $alternativeDefinitionsAttribute, $wgAlternativeDefinitionsAttributeName, $wgAlternativeDefinitionsAttributeId,
 132+ $alternativeDefinitionsStructure;
140133
141 - $alternativeDefinitionsAttribute = new Attribute($wgAlternativeDefinitionsAttributeId, $wgAlternativeDefinitionsAttributeName, new Structure($definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute));
 134+ $alternativeDefinitionsStructure = new Structure("alternative-definitions", $definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute);
 135+
 136+ $alternativeDefinitionsAttribute = new Attribute(null, $wgAlternativeDefinitionsAttributeName, $alternativeDefinitionsStructure);
142137
143138 global
144139 $synonymsAndTranslationsAttribute, $syntransIdAttribute,
145 - $wgSynonymsAttributeName, $wgSynonymsAndTranslationsAttributeName, $wgSynonymsAndTranslationsAttributeId;
 140+ $wgSynonymsAttributeName, $wgSynonymsAndTranslationsAttributeName, $wgSynonymsAndTranslationsAttributeId,
 141+ $synonymsTranslationsStructure;
146142
147143 if ($filterOnLanguage)
148144 $synonymsAndTranslationsCaption = $wgSynonymsAttributeName;
149145 else
150 - $synonymsAndTranslationsCaption = $wgSynonymsAndTranslationsAttributeName;
151 -
 146+ $synonymsAndTranslationsCaption = $wgSynonymsAndTranslationsAttributeName;
 147+
152148 $syntransIdAttribute = new Attribute("syntrans-id", "$synonymsAndTranslationsCaption identifier", "integer");
153 - $synonymsAndTranslationsAttribute = new Attribute($wgSynonymsAndTranslationsAttributeId, "$synonymsAndTranslationsCaption", new Structure($syntransIdAttribute, $expressionAttribute, $identicalMeaningAttribute, $objectAttributesAttribute));
 149+ $synonymsTranslationsStructure = new Structure("synonyms-translations", $syntransIdAttribute, $expressionAttribute, $identicalMeaningAttribute, $objectAttributesAttribute);
 150+ $synonymsAndTranslationsAttribute = new Attribute(null, "$synonymsAndTranslationsCaption", $synonymsTranslationsStructure);
154151
155152 global
156153 $translatedTextAttributeIdAttribute, $translatedTextValueIdAttribute,
@@ -164,10 +161,10 @@
165162 if ($filterOnLanguage && !$hasMetaDataAttributes)
166163 $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, "text");
167164 else
168 - $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, $translatedTextStructure);
 165+ $translatedTextValueAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeValueAttributeName, $translatedTextStructure);
169166
170 - $translatedTextAttributeValuesStructure = new Structure($translatedTextAttributeIdAttribute, $translatedTextAttributeObjectAttribute, $translatedTextAttributeAttribute, $translatedTextValueIdAttribute, $translatedTextValueAttribute, $objectAttributesAttribute);
171 - $translatedTextAttributeValuesAttribute = new Attribute("translated-text-attribute-values", $wgTranslatedTextAttributeValuesAttributeName, $translatedTextAttributeValuesStructure);
 167+ $translatedTextAttributeValuesStructure = new Structure("translated-text-attribute-values",$translatedTextAttributeIdAttribute, $translatedTextAttributeObjectAttribute, $translatedTextAttributeAttribute, $translatedTextValueIdAttribute, $translatedTextValueAttribute, $objectAttributesAttribute);
 168+ $translatedTextAttributeValuesAttribute = new Attribute(null, $wgTranslatedTextAttributeValuesAttributeName, $translatedTextAttributeValuesStructure);
172169
173170 global
174171 $textAttributeIdAttribute, $textAttributeObjectAttribute, $textAttributeAttribute, $textAttributeValuesStructure,
@@ -177,8 +174,8 @@
178175 $textAttributeIdAttribute = new Attribute("text-attribute-id", "Attribute identifier", "object-id");
179176 $textAttributeObjectAttribute = new Attribute("text-attribute-object-id", "Attribute object", "object-id");
180177 $textAttributeAttribute = new Attribute("text-attribute", $wgTextAttributeAttributeName, $definedMeaningReferenceStructure);
181 - $textAttributeValuesStructure = new Structure($textAttributeIdAttribute, $textAttributeObjectAttribute, $textAttributeAttribute, $textAttribute, $objectAttributesAttribute);
182 - $textAttributeValuesAttribute = new Attribute("text-attribute-values", $wgTextAttributeValuesAttributeName, $textAttributeValuesStructure);
 178+ $textAttributeValuesStructure = new Structure("text-attribute-values", $textAttributeIdAttribute, $textAttributeObjectAttribute, $textAttributeAttribute, $textAttribute, $objectAttributesAttribute);
 179+ $textAttributeValuesAttribute = new Attribute(null, $wgTextAttributeValuesAttributeName, $textAttributeValuesStructure);
183180
184181 global
185182 $urlAttribute, $urlAttributeIdAttribute, $urlAttributeObjectAttribute, $urlAttributeAttribute, $urlAttributeValuesStructure, $urlAttributeValuesAttribute,
@@ -188,37 +185,37 @@
189186 $urlAttributeIdAttribute = new Attribute("url-attribute-id", "Attribute identifier", "object-id");
190187 $urlAttributeObjectAttribute = new Attribute("url-attribute-object-id", "Attribute object", "object-id");
191188 $urlAttributeAttribute = new Attribute("url-attribute", $wgUrlAttributeAttributeName, $definedMeaningReferenceStructure);
192 - $urlAttributeValuesStructure = new Structure($urlAttributeIdAttribute, $urlAttributeObjectAttribute, $urlAttributeAttribute, $urlAttribute, $objectAttributesAttribute);
193 - $urlAttributeValuesAttribute = new Attribute("url-attribute-values", $wgUrlAttributeValuesAttributeName, $urlAttributeValuesStructure);
 189+ $urlAttributeValuesStructure = new Structure("url-attribute-values", $urlAttributeIdAttribute, $urlAttributeObjectAttribute, $urlAttributeAttribute, $urlAttribute, $objectAttributesAttribute);
 190+ $urlAttributeValuesAttribute = new Attribute(null, $wgUrlAttributeValuesAttributeName, $urlAttributeValuesStructure);
194191
195192 global
196193 $optionAttributeIdAttribute, $optionAttributeAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionAttribute, $optionAttributeValuesAttribute,
197 - $wgOptionAttributeAttributeName, $wgOptionAttributeOptionAttributeName, $wgOptionAttributeValuesAttributeName;
 194+ $wgOptionAttributeAttributeName, $wgOptionAttributeOptionAttributeName, $wgOptionAttributeValuesAttributeName, $optionAttributeValuesStructure;
198195
199196 $optionAttributeIdAttribute = new Attribute('option-attribute-id', 'Attribute identifier', 'object-id');
200197 $optionAttributeObjectAttribute = new Attribute('option-attribute-object-id', 'Attribute object', 'object-id');
201198 $optionAttributeAttribute = new Attribute('option-attribute', $wgOptionAttributeAttributeName, $definedMeaningReferenceType);
202199 $optionAttributeOptionAttribute = new Attribute('option-attribute-option', $wgOptionAttributeOptionAttributeName, $definedMeaningReferenceType);
203 - $optionAttributeValuesStructure = new Structure($optionAttributeIdAttribute, $optionAttributeAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionAttribute, $objectAttributesAttribute);
204 - $optionAttributeValuesAttribute = new Attribute('option-attribute-values', $wgOptionAttributeValuesAttributeName, $optionAttributeValuesStructure);
 200+ $optionAttributeValuesStructure = new Structure('option-attribute-values', $optionAttributeIdAttribute, $optionAttributeAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionAttribute, $objectAttributesAttribute);
 201+ $optionAttributeValuesAttribute = new Attribute(null, $wgOptionAttributeValuesAttributeName, $optionAttributeValuesStructure);
205202
206203 global
207204 $optionAttributeOptionIdAttribute, $optionAttributeOptionsAttribute, $wgOptionAttributeOptionsAttributeName;
208205
209206 $optionAttributeOptionIdAttribute = new Attribute('option-attribute-option-id', 'Option identifier', 'object-id');
210 - $optionAttributeOptionsStructure = new Structure($optionAttributeOptionIdAttribute, $optionAttributeAttribute, $optionAttributeOptionAttribute, $languageAttribute);
211 - $optionAttributeOptionsAttribute = new Attribute('option-attribute-options', $wgOptionAttributeOptionsAttributeName, $optionAttributeOptionsStructure);
 207+ $optionAttributeOptionsStructure = new Structure('option-attribute-options', $optionAttributeOptionIdAttribute, $optionAttributeAttribute, $optionAttributeOptionAttribute, $languageAttribute);
 208+ $optionAttributeOptionsAttribute = new Attribute(null, $wgOptionAttributeOptionsAttributeName, $optionAttributeOptionsStructure);
212209
213210 global
214211 $definitionAttribute, $translatedTextAttribute, $classAttributesAttribute,
215 - $wgDefinitionAttributeName, $wgDefinitionAttributeId, $wgTranslatedTextAttributeName;
 212+ $wgDefinitionAttributeName, $wgTranslatedTextAttributeName;
216213
217214 if ($filterOnLanguage && !$hasMetaDataAttributes)
218215 $translatedTextAttribute = new Attribute("translated-text", $wgTextAttributeName, "text");
219216 else
220 - $translatedTextAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeName, $translatedTextStructure);
 217+ $translatedTextAttribute = new Attribute(null, $wgTranslatedTextAttributeName, $translatedTextStructure);
221218
222 - $definitionAttribute = new Attribute($wgDefinitionAttributeId, $wgDefinitionAttributeName, new Structure($translatedTextAttribute, $objectAttributesAttribute));
 219+ $definitionAttribute = new Attribute(null, $wgDefinitionAttributeName, new Structure("definition", $translatedTextAttribute, $objectAttributesAttribute));
223220
224221 global
225222 $classAttributesStructure,
@@ -231,14 +228,15 @@
232229 $classAttributeAttributeAttribute = new Attribute("class-attribute-attribute", $wgClassAttributeAttributeAttributeName, $definedMeaningReferenceStructure);
233230 $classAttributeLevelAttribute = new Attribute("class-attribute-level", $wgClassAttributeLevelAttributeName, $definedMeaningReferenceStructure);
234231 $classAttributeTypeAttribute = new Attribute("class-attribute-type", $wgClassAttributeTypeAttributeName, "short-text");
235 - $classAttributesStructure = new Structure($classAttributeIdAttribute, $classAttributeAttributeAttribute, $classAttributeLevelAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute);
236 - $classAttributesAttribute = new Attribute($wgClassAttributesAttributeId, $wgClassAttributesAttributeName, $classAttributesStructure);
 232+ $classAttributesStructure = new Structure("class-attributes", $classAttributeIdAttribute, $classAttributeAttributeAttribute, $classAttributeLevelAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute);
 233+ $classAttributesAttribute = new Attribute(null, $wgClassAttributesAttributeName, $classAttributesStructure);
237234
238235 global
239236 $definedMeaningAttribute, $wgDefinedMeaningAttributeName;
240 -
241 - $definedMeaningAttribute = new Attribute("defined-meaning", $wgDefinedMeaningAttributeName,
 237+
 238+ $definedMeaningAttribute = new Attribute(null, $wgDefinedMeaningAttributeName,
242239 new Structure(
 240+ "defined-meaning",
243241 $definitionAttribute,
244242 $classAttributesAttribute,
245243 $alternativeDefinitionsAttribute,
@@ -249,31 +247,51 @@
250248 $collectionMembershipAttribute,
251249 $definedMeaningAttributesAttribute)
252250 );
253 -
 251+
254252 global
255253 $expressionsAttribute, $expressionMeaningStructure, $expressionExactMeaningsAttribute, $expressionApproximateMeaningsAttribute,
256254 $wgExactMeaningsAttributeName, $wgApproximateMeaningsAttributeName;
257255
258 - $expressionMeaningStructure = new Structure($definedMeaningIdAttribute, $textAttribute, $definedMeaningAttribute);
259 - $expressionExactMeaningsAttribute = new Attribute("expression-exact-meanings", $wgExactMeaningsAttributeName, $expressionMeaningStructure);
 256+ $expressionMeaningStructure = new Structure("expression-exact-meanings", $definedMeaningIdAttribute, $textAttribute, $definedMeaningAttribute);
 257+ $expressionExactMeaningsAttribute = new Attribute(null, $wgExactMeaningsAttributeName, $expressionMeaningStructure);
260258 $expressionApproximateMeaningsAttribute = new Attribute("expression-approximate-meanings", $wgApproximateMeaningsAttributeName, $expressionMeaningStructure);
261259
262260 global
263261 $expressionMeaningsAttribute, $expressionMeaningsStructure, $expressionApproximateMeaningAttribute,
264 - $wgExpressionMeaningsAttributeName, $wgExpressionsAttributeName;
 262+ $wgExpressionMeaningsAttributeName, $wgExpressionsAttributeName,
 263+ $expressionsStructure;
265264
266 - $expressionMeaningsStructure = new Structure($expressionExactMeaningsAttribute, $expressionApproximateMeaningAttribute);
267 - $expressionMeaningsAttribute = new Attribute("expression-meanings", $wgExpressionMeaningsAttributeName, $expressionMeaningsStructure);
 265+ $expressionMeaningsStructure = new Structure("expression-meanings", $expressionExactMeaningsAttribute, $expressionApproximateMeaningAttribute);
 266+ $expressionMeaningsAttribute = new Attribute(null, $wgExpressionMeaningsAttributeName, $expressionMeaningsStructure);
268267
269 - $expressionsAttribute = new Attribute("expressions", $wgExpressionsAttributeName, new Structure($expressionIdAttribute, $expressionAttribute, $expressionMeaningsAttribute));
 268+ $expressionsStructure = new Structure("expressions", $expressionIdAttribute, $expressionAttribute, $expressionMeaningsAttribute);
 269+ $expressionsAttribute = new Attribute(null, $wgExpressionsAttributeName, $expressionsStructure);
270270
271271 global
272272 $objectIdAttribute, $objectAttributesStructure, $wgAnnotationAttributeName;
273273
274274 $objectIdAttribute = new Attribute("object-id", "Object identifier", "object-id");
275 - $objectAttributesStructure = new Structure($objectIdAttribute, $textAttributeValuesAttribute, $translatedTextAttributeValuesAttribute, $optionAttributeValuesAttribute);
276 - $objectAttributesAttribute->type = $objectAttributesStructure;
277 - $definedMeaningAttributesAttribute->type = $objectAttributesStructure;
 275+ $objectAttributesStructure = new Structure("object-attributes", $objectIdAttribute, $textAttributeValuesAttribute, $translatedTextAttributeValuesAttribute, $optionAttributeValuesAttribute);
 276+ $objectAttributesAttribute->setAttributeType($objectAttributesStructure);
 277+ $definedMeaningAttributesAttribute->setAttributeType($objectAttributesStructure);
 278+
 279+ global $wdDefinedMeaningAttributesOrder;
 280+
 281+ $wdDefinedMeaningAttributesOrder=array(
 282+ $definitionAttribute->id,
 283+ $classAttributesAttribute->id,
 284+ $alternativeDefinitionsAttribute->id,
 285+ $synonymsAndTranslationsAttribute->id,
 286+ $possiblySynonymousAttribute->id,
 287+ $relationsAttribute->id,
 288+ $reciprocalRelationsAttribute->id,
 289+ $classMembershipAttribute->id,
 290+ $collectionMembershipAttribute->id,
 291+ $definedMeaningAttributesAttribute->id
 292+ );
 293+
 294+
 295+
278296 }
279297
280298
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialTransaction.php
@@ -170,7 +170,8 @@
171171 $updatedDefinitionAttribute = new Attribute('updated-definition', 'Definition', $updatedDefinitionStructure);
172172
173173 global
174 - $expressionAttribute, $expressionIdAttribute, $identicalMeaningAttribute, $syntransIdAttribute, $updatedSyntransesAttribute;
 174+ $expressionAttribute, $expressionIdAttribute, $identicalMeaningAttribute, $syntransIdAttribute, $updatedSyntransesAttribute,
 175+ $updatedSyntransesStructure;
175176
176177 $updatedSyntransesStructure = new Structure(
177178 $syntransIdAttribute,
@@ -401,6 +402,7 @@
402403 $restrictions[] = "EXISTS (SELECT user_name FROM user WHERE user.user_id={$dc}_transactions.user_id AND user.user_name='" . $userName . "')";
403404
404405 $recordSet = queryRecordSet(
 406+ 'transaction-id',
405407 $queryTransactionInformation,
406408 $transactionIdAttribute,
407409 array(
@@ -477,7 +479,7 @@
478480 $updatedAlternativeDefinitionsAttribute, $updatedAlternativeDefinitionTextAttribute,
479481 $updatedTranslatedTextPropertyAttribute;
480482
481 - $record = new ArrayRecord($updatesInTransactionAttribute->type->getAttributes());
 483+ $record = new ArrayRecord($updatesInTransactionAttribute->type);
482484 $record->setAttributeValue($updatedDefinitionAttribute, getUpdatedDefinedMeaningDefinitionRecordSet($transactionId));
483485 $record->setAttributeValue($updatedAlternativeDefinitionsAttribute, getUpdatedAlternativeDefinitionsRecordSet($transactionId));
484486 $record->setAttributeValue($updatedAlternativeDefinitionTextAttribute, getUpdatedAlternativeDefinitionTextRecordSet($transactionId));
Index: trunk/extensions/Wikidata/OmegaWiki/RecordSetQueries.php
@@ -31,7 +31,7 @@
3232 return $query;
3333 }
3434
35 -function queryRecordSet($transactionInformation, $keyAttribute, $fieldAttributeMapping, $table, $restrictions, $orderBy = array(), $count = -1, $offset = 0) {
 35+function queryRecordSet($recordSetStructureId, $transactionInformation, $keyAttribute, $fieldAttributeMapping, Table $table, $restrictions, $orderBy = array(), $count = -1, $offset = 0) {
3636 $dbr =& wfGetDB(DB_SLAVE);
3737
3838 $selectFields = array_keys($fieldAttributeMapping);
@@ -44,8 +44,11 @@
4545
4646 $query = getTransactedSQL($transactionInformation, $selectFields, $table, $restrictions, $orderBy, $count, $offset);
4747 $queryResult = $dbr->query($query);
48 -
49 - $structure = new Structure($allAttributes);
 48+ if(!is_null($recordSetStructureId)) {
 49+ $structure = new Structure($recordSetStructureId, $allAttributes);
 50+ } else {
 51+ $structure = new Structure($allAttributes);
 52+ }
5053 $recordSet = new ArrayRecordSet($structure, new Structure($keyAttribute));
5154
5255 while ($row = $dbr->fetchRow($queryResult)) {
Index: trunk/extensions/Wikidata/OmegaWiki/RecordSet.php
@@ -10,7 +10,6 @@
1111 public abstract function getKey();
1212 public abstract function getRecordCount();
1313 public abstract function getRecord($index);
14 - protected $type=null;
1514 protected $records;
1615 # public function save(); # <- we first need to implement, then uncomment
1716 /**
@@ -22,7 +21,8 @@
2322
2423 public function tostring_indent($depth=0,$key="",$myname="RecordSet") {
2524 $rv="\n".str_pad("",$depth*8);
26 - $type=$this->type;
 25+ $str=$this->getStructure();
 26+ $type=$str->getStructureType();
2727 $rv.="$key:$myname(... $type) {";
2828 $rv2=$rv;
2929 foreach ($this->records as $value) {
@@ -43,37 +43,6 @@
4444 return $rv;
4545 }
4646
47 - public function getType(){
48 - return $this->type;
49 - }
50 -
51 - public function setType($type) {
52 - $this->type=$type;
53 - }
54 -
55 - /**only setType if it wasn't set yet
56 - * @param the type you would like to suggest
57 - * @returns the type this arrayset finally got
58 - */
59 - public function suggestType($type) {
60 - if(is_null($this->type))
61 - $this->setType($type);
62 - return $this->getType();
63 - }
64 -
65 - public function finish($type) {
66 - $type=$this->suggestType($type);
67 -
68 -
69 - foreach ($this->records as $key=>$value) {
70 - $methods=get_class_methods(get_class($value));
71 - if (!is_null($methods)) {
72 - if (in_array("finish",$methods)) {
73 - $value->finish($this->type);
74 - }
75 - }
76 - }
77 - }
7847 }
7948
8049 class ArrayRecordSet extends RecordSet {
@@ -81,7 +50,7 @@
8251 protected $key;
8352 protected $records = array();
8453
85 - public function __construct($structure, $key) {
 54+ public function __construct(Structure $structure, $key) {
8655 $this->structure = $structure;
8756 $this->key = $key;
8857 }
Index: trunk/extensions/Wikidata/OmegaWiki/Attribute.php
@@ -1,28 +1,50 @@
22 <?php
33
44 class Attribute {
5 - public $id = "";
 5+ public $id = null;
66 public $name = "";
77 public $type = "";
88
99 /**
10 - * @param $name (String)
11 - * @param $id (String)
12 - * @param $type (String) "language", "spelling", "boolean", "defined-meaning",
13 - * "defining-expression", "relation-type", "attribute", "collection", "short-text",
14 - * "text"..?
 10+ * @param $id (String) or null if
 11+ * @param $name (String)
 12+ * @param $type (String or Structure)
 13+ * If String, can be "language", "spelling", "boolean",
 14+ * "defined-meaning", "defining-expression", "relation-type", "attribute",
 15+ * "collection", "short-text", "text"
 16+ *
 17+ * If Structure, see below.
1518 */
1619 public function __construct($id, $name, $type) {
17 - $this->id = $id;
 20+ $this->id = $id;
1821 $this->name = $name;
19 - $this->type = $type;
 22+ $this->setAttributeType($type);
2023 }
2124
 25+ public function setAttributeType($type) {
 26+ # Copy the structure since we might modify it
 27+ if($type instanceof Structure) {
 28+ $this->type=clone $type;
 29+ } else {
 30+ $this->type=$type;
 31+ }
 32+
 33+ // Since the attribute is a structure and unnamed, we use
 34+ // the default label associated with it.
 35+ if(is_null($this->id) && ($this->type instanceof Structure)) {
 36+ $this->id = $this->type->getStructureType();
 37+ // Override structure label with a more specific one
 38+ } elseif(!is_null($this->id) && ($this->type instanceof Structure)) {
 39+ $this->type->setStructureType($this->id);
 40+ }
 41+ }
 42+
2243 }
2344
2445 class Structure {
2546
26 - private $structure; # Array of attributes
 47+ private $structure;
 48+ private $type;
2749
2850 public function getAttributes() {
2951 return $this->structure;
@@ -32,12 +54,64 @@
3355 $this->structure[]=$attribute;
3456 }
3557
36 - public function __construct($structure) {
37 - if (is_array($structure))
38 - $this->structure = $structure;
39 - else
40 - $this->structure = func_get_args();
 58+ public function getStructureType() {
 59+ return $this->type;
4160 }
 61+
 62+ public function setStructureType($type) {
 63+ $this->type=$type;
 64+ }
 65+
 66+
 67+ /**
 68+ * Construct named Structure which contains Attribute objects
 69+ *
 70+ * @param $type (String) Identifying string that describes the structure.
 71+ * Optional; if not specified, will be considered
 72+ * 'anonymous-structure' unless there is only a
 73+ * a single Attribute object, in which case the structure
 74+ * will inherit its ID. Do not pass null.
 75+ * @param $structure (Array or Parameter list) One or more Attribute objects.
 76+ *
 77+ */
 78+ public function __construct($argumentList) {
 79+
 80+ # We're trying to be clever.
 81+ $args=func_get_args();
 82+ $this->structure=null;
 83+
 84+ if($args[0] instanceof Attribute) {
 85+ $this->structure=$args;
 86+ } elseif(is_array($args[0])) {
 87+ $this->structure=$args[0];
 88+ }
 89+
 90+ if(is_array($this->structure)) {
 91+ # We don't know what to call an unnamed
 92+ # structure with multiple attributes.
 93+ if(sizeof($this->structure)>1) {
 94+ $this->type='anonymous-structure';
 95+ # Meh, just one Attribute. Let's eat it.
 96+ } elseif(sizeof($this->structure)==1) {
 97+ $this->type=$this->structure[0]->id;
 98+ } else {
 99+ $this->type='empty-structure';
 100+ }
 101+
 102+ # First parameter is the structure's name.
 103+ } elseif(is_string($args[0]) && !empty($args[0])) {
 104+ $this->type=$args[0];
 105+ if(is_array($args[1])) {
 106+ $this->structure=$args[1];
 107+ } else {
 108+ array_shift($args);
 109+ $this->structure=$args;
 110+ }
 111+ } else {
 112+ # WTF?
 113+ throw new Exception("Invalid structure constructor: ".print_r($args,true));
 114+ }
 115+ }
42116 }
43117
44118
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php
@@ -415,7 +415,7 @@
416416
417417 function getDefinedMeaningEditor($filterLanguageId, $possiblySynonymousRelationTypeId, $showRecordLifeSpan, $showAuthority) {
418418 global
419 - $wgDefinedMeaningAttributesOrder,
 419+ $wdDefinedMeaningAttributesOrder,
420420 $definedMeaningAttribute, $possiblySynonymousIdAttribute, $possiblySynonymousAttribute,
421421 $possibleSynonymAttribute, $definedMeaningObjectAttributesEditor, $possiblySynonymousObjectAttributesEditor;
422422
@@ -453,7 +453,7 @@
454454
455455 $definedMeaningEditor = new RecordUnorderedListEditor($definedMeaningAttribute, 4);
456456
457 - foreach ($wgDefinedMeaningAttributesOrder as $attributeId) {
 457+ foreach ($wdDefinedMeaningAttributesOrder as $attributeId) {
458458 $editor = $availableEditors->getEditorForAttributeId($attributeId);
459459
460460 if ($editor != null)
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php
@@ -63,7 +63,7 @@
6464 " GROUP BY {$dc}_defined_meaning.defined_meaning_id";
6565 }
6666
67 -function fetchDefinedMeaningReferenceRecords($sql, &$definedMeaningIds, &$definedMeaningReferenceRecords) {
 67+function fetchDefinedMeaningReferenceRecords($sql, &$definedMeaningIds, &$definedMeaningReferenceRecords, $usedAs='defined-meaning') {
6868
6969 $dc=wdGetDataSetContext();
7070
@@ -78,8 +78,10 @@
7979
8080 while ($row = $dbr->fetchObject($queryResult)) {
8181 $definedMeaningId = $row->defined_meaning_id;
82 -
83 - $record = new ArrayRecord($definedMeaningReferenceStructure);
 82+
 83+ $specificStructure=clone $definedMeaningReferenceStructure;
 84+ $specificStructure->setStructureType($usedAs);
 85+ $record = new ArrayRecord($specificStructure);
8486 $record->setAttributeValue($definedMeaningIdAttribute, $definedMeaningId);
8587 $record->setAttributeValue($definedMeaningLabelAttribute, $row->label);
8688
@@ -134,7 +136,7 @@
135137 return $record;
136138 }
137139
138 -function getDefinedMeaningReferenceRecords($definedMeaningIds) {
 140+function getDefinedMeaningReferenceRecords($definedMeaningIds, $usedAs) {
139141 global
140142 $wgUser;
141143
@@ -154,7 +156,8 @@
155157 fetchDefinedMeaningReferenceRecords(
156158 getDefiningSQLForLanguage($definingLanguage, $definedMeaningIds),
157159 $definedMeaningIds,
158 - $result
 160+ $result,
 161+ $usedAs
159162 );
160163
161164 if (count($definedMeaningIds) > 0) {
@@ -162,21 +165,25 @@
163166 fetchDefinedMeaningReferenceRecords(
164167 getSynonymSQLForLanguage($userLanguage, $definedMeaningIds),
165168 $definedMeaningIds,
166 - $result
 169+ $result,
 170+ $usedAs
 171+
167172 );
168173
169174 if (count($definedMeaningIds) > 0) {
170175 fetchDefinedMeaningReferenceRecords(
171176 getSynonymSQLForLanguage(85, $definedMeaningIds),
172177 $definedMeaningIds,
173 - $result
 178+ $result,
 179+ $usedAs
174180 );
175181
176182 if (count($definedMeaningIds) > 0) {
177183 fetchDefinedMeaningReferenceRecords(
178184 getSynonymSQLForAnyLanguage($definedMeaningIds),
179185 $definedMeaningIds,
180 - $result
 186+ $result,
 187+ $usedAs
181188 );
182189 }
183190 }
@@ -193,11 +200,17 @@
194201 }
195202
196203 function expandDefinedMeaningReferencesInRecordSet($recordSet, $definedMeaningAttributes) {
197 - $definedMeaningReferenceRecords = getDefinedMeaningReferenceRecords(getUniqueIdsInRecordSet($recordSet, $definedMeaningAttributes));
198204
 205+ $definedMeaningReferenceRecords=array();
 206+
 207+ foreach($definedMeaningAttributes as $dmatt) {
 208+ $tmpArray = getDefinedMeaningReferenceRecords(getUniqueIdsInRecordSet($recordSet, array($dmatt)), $dmatt->id);
 209+ $definedMeaningReferenceRecords+=$tmpArray;
 210+
 211+ }
 212+
199213 for ($i = 0; $i < $recordSet->getRecordCount(); $i++) {
200214 $record = $recordSet->getRecord($i);
201 -
202215 foreach($definedMeaningAttributes as $definedMeaningAttribute)
203216 $record->setAttributeValue(
204217 $definedMeaningAttribute,
@@ -383,7 +396,7 @@
384397
385398 function getExpressionsRecordSet($spelling, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation) {
386399 global
387 - $expressionIdAttribute, $expressionAttribute, $languageAttribute, $expressionMeaningsAttribute;
 400+ $expressionIdAttribute, $expressionAttribute, $languageAttribute, $expressionMeaningsAttribute, $expressionsStructure;
388401
389402 $dc=wdGetDataSetContext();
390403
@@ -407,11 +420,11 @@
408421 .")"
409422 );
410423
411 - $result = new ArrayRecordSet(new Structure($expressionIdAttribute, $expressionAttribute, $expressionMeaningsAttribute), new Structure($expressionIdAttribute));
412 - $expressionStructure = new Structure($languageAttribute);
 424+ $result = new ArrayRecordSet($expressionsStructure, new Structure("expression-id", $expressionIdAttribute));
 425+ $languageStructure = new Structure("language", $languageAttribute);
413426
414427 while($expression = $dbr->fetchObject($queryResult)) {
415 - $expressionRecord = new ArrayRecord($expressionStructure);
 428+ $expressionRecord = new ArrayRecord($languageStructure);
416429 $expressionRecord->setAttributeValue($languageAttribute, $expression->language_id);
417430
418431 $result->addRecord(array(
@@ -451,9 +464,11 @@
452465
453466 function getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation) {
454467 global
455 - $classAttributesTable, $classAttributeIdAttribute, $classAttributeLevelAttribute, $classAttributeAttributeAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute;
 468+ $classAttributesTable, $classAttributeIdAttribute, $classAttributeLevelAttribute, $classAttributeAttributeAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute,
 469+ $classAttributesStructure;
456470
457471 $recordSet = queryRecordSet(
 472+ $classAttributesStructure->getStructureType(),
458473 $queryTransactionInformation,
459474 $classAttributeIdAttribute,
460475 array(
@@ -485,9 +500,11 @@
486501
487502 function getAlternativeDefinitionsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation) {
488503 global
489 - $alternativeDefinitionsTable, $definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute;
 504+ $alternativeDefinitionsTable, $definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute,
 505+ $alternativeDefinitionsStructure;
490506
491507 $recordSet = queryRecordSet(
 508+ $alternativeDefinitionsStructure->getStructureType(),
492509 $queryTransactionInformation,
493510 $definitionIdAttribute,
494511 array(
@@ -511,20 +528,25 @@
512529 $definitionAttribute, $translatedTextAttribute, $objectAttributesAttribute;
513530
514531 $definitionId = getDefinedMeaningDefinitionId($definedMeaningId);
515 - $record = new ArrayRecord($definitionAttribute->type->getAttributes());
 532+ $record = new ArrayRecord(new Structure($definitionAttribute));
516533 $record->setAttributeValue($translatedTextAttribute, getTranslatedContentValue($definitionId, $filterLanguageId, $queryTransactionInformation));
517 - $record->setAttributeValue($objectAttributesAttribute, getObjectAttributesRecord($definitionId, $filterLanguageId, $queryTransactionInformation));
 534+ $record->setAttributeValue($objectAttributesAttribute, getObjectAttributesRecord($definitionId, $filterLanguageId, $queryTransactionInformation,$objectAttributesAttribute->id));
518535
519536 return $record;
520537 }
521538
522 -function getObjectAttributesRecord($objectId, $filterLanguageId, $queryTransactionInformation) {
 539+function getObjectAttributesRecord($objectId, $filterLanguageId, $queryTransactionInformation, $structuralOverride=null) {
523540 global
524541 $objectAttributesAttribute, $objectIdAttribute,
525542 $urlAttributeValuesAttribute, $textAttributeValuesAttribute,
526 - $translatedTextAttributeValuesAttribute, $optionAttributeValuesAttribute;
527 -
528 - $record = new ArrayRecord($objectAttributesAttribute->type->getAttributes());
 543+ $translatedTextAttributeValuesAttribute, $optionAttributeValuesAttribute,
 544+ $definedMeaningAttributesAttribute;
 545+
 546+ if($structuralOverride) {
 547+ $record = new ArrayRecord(new Structure($structuralOverride,$definedMeaningAttributesAttribute));
 548+ } else {
 549+ $record = new ArrayRecord(new Structure($definedMeaningAttributesAttribute));
 550+ }
529551
530552 $record->setAttributeValue($objectIdAttribute, $objectId);
531553 $record->setAttributeValue($textAttributeValuesAttribute, getTextAttributesValuesRecordSet(array($objectId), $filterLanguageId, $queryTransactionInformation));
@@ -557,9 +579,11 @@
558580
559581 function getTranslatedContentRecordSet($translatedContentId, $queryTransactionInformation) {
560582 global
561 - $translatedContentTable, $languageAttribute, $textAttribute;
 583+ $translatedContentTable, $languageAttribute, $textAttribute,
 584+ $translatedTextStructure;
562585
563586 $recordSet = queryRecordSet(
 587+ $translatedTextStructure->getStructureType(),
564588 $queryTransactionInformation,
565589 $languageAttribute,
566590 array(
@@ -580,6 +604,7 @@
581605 $translatedContentTable, $languageAttribute, $textAttribute;
582606
583607 $recordSet = queryRecordSet(
 608+ null,
584609 $queryTransactionInformation,
585610 $languageAttribute,
586611 array(
@@ -600,7 +625,8 @@
601626
602627 function getSynonymAndTranslationRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation) {
603628 global
604 - $syntransTable, $syntransIdAttribute, $expressionAttribute, $identicalMeaningAttribute, $objectAttributesAttribute;
 629+ $syntransTable, $syntransIdAttribute, $expressionAttribute, $identicalMeaningAttribute, $objectAttributesAttribute,
 630+ $synonymsTranslationsStructure;
605631
606632 $dc=wdGetDataSetContext();
607633 $restrictions = array("defined_meaning_id=$definedMeaningId");
@@ -616,6 +642,7 @@
617643 ")";
618644
619645 $recordSet = queryRecordSet(
 646+ $synonymsTranslationsStructure->getStructureType(),
620647 $queryTransactionInformation,
621648 $syntransIdAttribute,
622649 array(
@@ -647,7 +674,7 @@
648675 $urlAttributeObjectAttribute, $urlAttributeValuesAttribute,
649676 $optionAttributeObjectAttribute, $optionAttributeValuesAttribute;
650677
651 - $objectAttributesRecordStructure = $objectAttributesAttribute->type->getAttributes();
 678+ $objectAttributesRecordStructure = $objectAttributesAttribute->type;
652679 $objectIds = getUniqueIdsInRecordSet($recordSet, array($objectIdAttribute));
653680
654681 if (count($objectIds) > 0) {
@@ -755,7 +782,8 @@
756783 function getDefinedMeaningRelationsRecordSet($definedMeaningId, $filterLanguageId, $filterRelationTypes, $queryTransactionInformation) {
757784 global
758785 $meaningRelationsTable, $relationIdAttribute, $relationTypeAttribute,
759 - $objectAttributesAttribute, $otherDefinedMeaningAttribute;
 786+ $objectAttributesAttribute, $otherDefinedMeaningAttribute,
 787+ $relationStructure;
760788
761789 $restrictions = array("meaning1_mid=$definedMeaningId");
762790
@@ -763,6 +791,7 @@
764792 $restrictions[] = "relationtype_mid NOT IN (". implode(", ", $filterRelationTypes) .")";
765793
766794 $recordSet = queryRecordSet(
 795+ $relationStructure->getStructureType(),
767796 $queryTransactionInformation,
768797 $relationIdAttribute,
769798 array(
@@ -789,9 +818,11 @@
790819 function getDefinedMeaningReciprocalRelationsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation) {
791820 global
792821 $meaningRelationsTable, $relationIdAttribute, $relationTypeAttribute,
793 - $otherDefinedMeaningAttribute, $objectAttributesAttribute;
 822+ $otherDefinedMeaningAttribute, $objectAttributesAttribute,
 823+ $reciprocalRelationsAttribute;
794824
795825 $recordSet = queryRecordSet(
 826+ $reciprocalRelationsAttribute->id,
796827 $queryTransactionInformation,
797828 $relationIdAttribute,
798829 array(
@@ -821,6 +852,7 @@
822853 $objectAttributesAttribute, $otherDefinedMeaningAttribute;
823854
824855 $recordSet = queryRecordSet(
 856+ null,
825857 $queryTransactionInformation,
826858 $possiblySynonymousIdAttribute,
827859 array(
@@ -860,9 +892,10 @@
861893 function getDefinedMeaningCollectionMembershipRecordSet($definedMeaningId, $queryTransactionInformation) {
862894 global
863895 $collectionMembershipsTable, $collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute,
864 - $gotoSourceAttribute;
 896+ $gotoSourceAttribute, $collectionMembershipStructure;
865897
866898 $recordSet = queryRecordSet(
 899+ $collectionMembershipStructure->getStructureType(),
867900 $queryTransactionInformation,
868901 $collectionIdAttribute,
869902 array(
@@ -889,9 +922,11 @@
890923 function getTextAttributesValuesRecordSet($objectIds, $filterLanguageId, $queryTransactionInformation) {
891924 global
892925 $textAttributeValuesTable, $textAttributeIdAttribute, $textAttributeObjectAttribute,
893 - $textAttributeAttribute, $textAttribute, $objectAttributesAttribute;
 926+ $textAttributeAttribute, $textAttribute, $objectAttributesAttribute,
 927+ $textAttributeValuesStructure;
894928
895929 $recordSet = queryRecordSet(
 930+ $textAttributeValuesStructure->getStructureType(),
896931 $queryTransactionInformation,
897932 $textAttributeIdAttribute,
898933 array(
@@ -917,9 +952,11 @@
918953 function getURLAttributeValuesRecordSet($objectIds, $filterLanguageId, $queryTransactionInformation) {
919954 global
920955 $urlAttributeValuesTable, $urlAttributeIdAttribute, $urlAttributeObjectAttribute,
921 - $urlAttributeAttribute, $urlAttribute, $objectAttributesAttribute;
 956+ $urlAttributeAttribute, $urlAttribute, $objectAttributesAttribute,
 957+ $urlAttributeValuesStructure;
922958
923959 $recordSet = queryRecordSet(
 960+ $urlAttributeValuesStructure->getStructureType(),
924961 $queryTransactionInformation,
925962 $urlAttributeIdAttribute,
926963 array(
@@ -945,9 +982,11 @@
946983 function getTranslatedTextAttributeValuesRecordSet($objectIds, $filterLanguageId, $queryTransactionInformation) {
947984 global
948985 $translatedTextAttributeIdAttribute, $translatedContentAttributeValuesTable, $translatedTextAttributeAttribute,
949 - $objectAttributesAttribute, $translatedTextAttributeObjectAttribute, $translatedTextValueAttribute, $translatedTextValueIdAttribute;
 986+ $objectAttributesAttribute, $translatedTextAttributeObjectAttribute, $translatedTextValueAttribute, $translatedTextValueIdAttribute,
 987+ $translatedTextAttributeValuesStructure;
950988
951989 $recordSet = queryRecordSet(
 990+ $translatedTextAttributeValuesStructure->getStructureType(),
952991 $queryTransactionInformation,
953992 $translatedTextAttributeIdAttribute,
954993 array(
@@ -977,6 +1016,7 @@
9781017 $optionAttributeOptionIdAttribute, $optionAttributeAttribute, $optionAttributeOptionAttribute, $languageAttribute, $optionAttributeOptionsTable;
9791018
9801019 $recordSet = queryRecordSet(
 1020+ null,
9811021 $queryTransactionInformation,
9821022 $optionAttributeOptionIdAttribute,
9831023 array(
@@ -996,9 +1036,11 @@
9971037
9981038 function getOptionAttributeValuesRecordSet($objectIds, $filterLanguageId, $queryTransactionInformation) {
9991039 global
1000 - $optionAttributeIdAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionIdAttribute, $optionAttributeAttribute,$optionAttributeOptionAttribute, $optionAttributeValuesTable, $objectAttributesAttribute;
 1040+ $optionAttributeIdAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionIdAttribute, $optionAttributeAttribute,$optionAttributeOptionAttribute, $optionAttributeValuesTable, $objectAttributesAttribute,
 1041+ $optionAttributeValuesStructure;
10011042
10021043 $recordSet = queryRecordSet(
 1044+ $optionAttributeValuesStructure->getStructureType(),
10031045 $queryTransactionInformation,
10041046 $optionAttributeIdAttribute,
10051047 array(
@@ -1030,6 +1072,7 @@
10311073 $record = $recordSet->getRecord($i);
10321074
10331075 $optionRecordSet = queryRecordSet(
 1076+ null,
10341077 $queryTransactionInformation,
10351078 $optionAttributeOptionIdAttribute,
10361079 array(
@@ -1047,6 +1090,7 @@
10481091 );
10491092
10501093 $optionRecordSet = queryRecordSet(
 1094+ null,
10511095 $queryTransactionInformation,
10521096 $optionAttributeIdAttribute,
10531097 array('attribute_mid' => $optionAttributeAttribute),
@@ -1064,9 +1108,11 @@
10651109
10661110 function getDefinedMeaningClassMembershipRecordSet($definedMeaningId, $queryTransactionInformation) {
10671111 global
1068 - $classMembershipsTable, $classMembershipIdAttribute, $classAttribute;
 1112+ $classMembershipsTable, $classMembershipIdAttribute, $classAttribute,
 1113+ $classMembershipStructure;
10691114
10701115 $recordSet = queryRecordSet(
 1116+ $classMembershipStructure->getStructureType(),
10711117 $queryTransactionInformation,
10721118 $classMembershipIdAttribute,
10731119 array(
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php
@@ -1,5 +1,6 @@
22 <?php
33
 4+require_once('OmegaWikiAttributes.php');
45 require_once('OmegaWikiRecordSets.php');
56 require_once('OmegaWikiAttributes.php');
67 require_once("Transaction.php");
@@ -22,7 +23,7 @@
2324 $possiblySynonymousAttribute;
2425
2526 $this->setDefinedMeaningID($definedMeaningId);
26 - $record = new ArrayRecord($definedMeaningAttribute->type->getAttributes());
 27+ $record = new ArrayRecord($definedMeaningAttribute->type);
2728 $record->setAttributeValue($definitionAttribute, getDefinedMeaningDefinitionRecord($definedMeaningId, $filterLanguageId, $queryTransactionInformation));
2829 $record->setAttributeValue($classAttributesAttribute, getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation));
2930 $record->setAttributeValue($alternativeDefinitionsAttribute, getAlternativeDefinitionsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation));
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php
@@ -12,11 +12,11 @@
1313 class ArrayRecord implements Record {
1414 protected $structure;
1515 protected $values = array();
16 - protected $type = null;
1716 protected $helper=null;
1817
19 - public function __construct($structure) {
 18+ public function __construct(Structure $structure) {
2019 $this->structure = $structure;
 20+ $this->helper=RecordHelperFactory::getRecordHelper($this);
2121 }
2222
2323 public function getStructure() {
@@ -39,49 +39,6 @@
4040 @$this->values[$attribute->id] = $value;
4141 }
4242
43 - public function getType() {
44 - return $this->type;
45 - }
46 -
47 - public function setType($type) {
48 - $this->type=$type;
49 - $this->helper=RecordHelperFactory::getRecordHelper($this);
50 - }
51 -
52 - /**only setType if it wasn't set yet.
53 - *@param $type the type to set
54 - *@return the type that is actually used now.
55 - */
56 - public function suggestType($type) {
57 - if(is_null($this->type))
58 - $this->setType($type);
59 - return $this->getType();
60 - }
61 -
62 - /** temporary hack to complete an arrayrecord structure
63 - * Uses knowlege already present in our Record based structure
64 - * to explain to records what they are. (ie, finish completes the
65 - * building of the structure, to leave it in a usable state)
66 - * @param $type the type that this record should have.
67 - * (if you have no idea, use some random but readily
68 - * recognisable string, other records should still get
69 - * correct types)
70 - * The brokenness of the system ends here, and only pretty code
71 - * should run beyond this point. (One day ). Erik Moeller is working
72 - * on eliminating this function which would be excellent.
73 - */
74 - public function finish($type) {
75 - $type=$this->suggestType($type);
76 -
77 - foreach ($this->values as $key=>$value) {
78 - $methods=get_class_methods(get_class($value));
79 - if (!is_null($methods)) {
80 - if (in_array("finish",$methods)) {
81 - $value->finish($key);
82 - }
83 - }
84 - }
85 - }
8643 /**
8744 *
8845 * @param $values Array to write into the record, by order of the structure
@@ -112,7 +69,8 @@
11370
11471 public function tostring_indent($depth=0,$key="") {
11572 $rv="\n".str_pad("",$depth*8);
116 - $type=$this->type;
 73+ $str=$this->getStructure();
 74+ $type=$str->getStructureType();
11775 $rv.="$key:ArrayRecord(..., $type) {";
11876 $rv2=$rv;
11977 foreach ($this->values as $key=>$value) {
Index: trunk/extensions/Wikidata/OmegaWiki/RecordHelper.php
@@ -3,7 +3,7 @@
44 class RecordHelperFactory {
55
66 public static function getRecordHelper($record) {
7 - $type=$record->getType();
 7+ $type=$record->getStructure()->getStructureType();
88 if (empty($type))
99 return null;
1010 switch($type) {
@@ -13,7 +13,7 @@
1414 return new TranslatedTextHelper($record);
1515 case "object-attributes":
1616 return new ObjectAttributesHelper($record);
17 - case "synonyms-translations":
 17+ case "syntrans-id":
1818 return new SynonymsTranslationsHelper($record);
1919 break;
2020 case "expression":
@@ -43,8 +43,17 @@
4444 case "defined-meaning-attributes":
4545 return new DefinedMeaningAttributesHelper($record);
4646 break;
 47+ case "defined-meaning-id":
 48+ // Relax
 49+ break;
 50+ case "defined-meaning":
 51+ // ...
 52+ break;
 53+ case "language":
 54+ break;
4755 default :
48 - echo "IGIVEUP ($type) I Give Up! \n";
 56+ # Need to do more checks here
 57+# throw new Exception("Record with unknown type: '$type'");
4958 break;
5059 }
5160
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php
@@ -2080,7 +2080,7 @@
20812081 $dbr = &wfGetDB(DB_SLAVE);
20822082 $queryResult = $dbr->query(
20832083 "SELECT spelling, defined_meaning_id" .
2084 - " FROM {$dc}_syntrans, _expression_ns" .
 2084+ " FROM {$dc}_syntrans, {$dc}_expression_ns" .
20852085 " WHERE syntrans_sid=$objectId" .
20862086 " AND {$dc}_syntrans.expression_id={$dc}_expression_ns.expression_id"
20872087 );

Status & tagging log