Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php |
— | — | @@ -17,9 +17,7 @@ |
18 | 18 | |
19 | 19 | if ($view_as=="raw") { |
20 | 20 | $wgOut->disable(); |
21 | | - |
22 | | - header("Content-Type: text/plain; charset=UTF-8"); |
23 | | - echo($this->raw()); |
| 21 | + echo("<pre>".$this->raw()."</pre>"); |
24 | 22 | return; |
25 | 23 | } |
26 | 24 | $this->outputViewHeader(); |
— | — | @@ -108,7 +106,6 @@ |
109 | 107 | $this->viewQueryTransactionInformation |
110 | 108 | ); |
111 | 109 | $record=$dmModel->getRecord(); |
112 | | - $record->finish("DefinedMeaning"); |
113 | 110 | return $record; |
114 | 111 | } |
115 | 112 | |
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php |
— | — | @@ -102,49 +102,6 @@ |
103 | 103 | $wgUrlAttributeAttributeName = "Property"; |
104 | 104 | $wgUrlAttributeValuesAttributeName = "URL properties"; |
105 | 105 | |
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 | | - |
149 | 106 | // Go to source templates |
150 | 107 | |
151 | 108 | require_once("GotoSourceTemplate.php"); |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php |
— | — | @@ -475,8 +475,8 @@ |
476 | 476 | $spellingAttribute = new Attribute("spelling", "Spelling", "short-text"); |
477 | 477 | $languageAttribute = new Attribute("language", "Language", "language"); |
478 | 478 | |
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); |
481 | 481 | $definitionAttribute = new Attribute("definition", "Definition", "definition"); |
482 | 482 | |
483 | 483 | $recordSet = new ArrayRecordSet(new Structure($idAttribute, $definedMeaningAttribute, $definitionAttribute), new Structure($idAttribute)); |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | $wgDefinedMeaningAttributesAttributeName, |
19 | 19 | $wgDefinedMeaningAttributesAttributeName, $wgDefinedMeaningAttributesAttributeId, $wgAnnotationAttributeName; |
20 | 20 | |
21 | | - $definedMeaningAttributesAttribute = new Attribute($wgDefinedMeaningAttributesAttributeId, $wgDefinedMeaningAttributesAttributeName, "will-be-specified-below"); |
| 21 | + $definedMeaningAttributesAttribute = new Attribute("defined-meaning-attributes", $wgDefinedMeaningAttributesAttributeName, "will-be-specified-below"); |
22 | 22 | $objectAttributesAttribute = new Attribute("object-attributes", $wgAnnotationAttributeName, "will-be-specified-below"); |
23 | 23 | |
24 | 24 | global |
— | — | @@ -32,8 +32,8 @@ |
33 | 33 | if ($filterOnLanguage) |
34 | 34 | $expressionAttribute = new Attribute("expression", $wgSpellingAttributeName, "spelling"); |
35 | 35 | 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); |
38 | 38 | } |
39 | 39 | |
40 | 40 | global |
— | — | @@ -43,31 +43,32 @@ |
44 | 44 | $definedMeaningDefiningExpressionAttribute = new Attribute("defined-meaning-defining-expression", "Defined meaning defining expression", "short-text"); |
45 | 45 | |
46 | 46 | global |
47 | | - $definedMeaningReferenceStructure, $definedMeaningLabelAttribute, $definedMeaningReferenceKeyStructure, $definedMeaningReferenceType, |
| 47 | + $definedMeaningReferenceStructure, $definedMeaningLabelAttribute, $definedMeaningReferenceType, |
48 | 48 | $definedMeaningReferenceAttribute, $wgDefinedMeaningReferenceAttributeName; |
49 | 49 | |
50 | 50 | $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 | + |
53 | 53 | $definedMeaningReferenceType = $definedMeaningReferenceStructure; |
54 | | - $definedMeaningReferenceAttribute = new Attribute("defined-meaning", $wgDefinedMeaningReferenceAttributeName, $definedMeaningReferenceType); |
| 54 | + $definedMeaningReferenceAttribute = new Attribute(null, $wgDefinedMeaningReferenceAttributeName, $definedMeaningReferenceType); |
55 | 55 | |
56 | 56 | global |
57 | | - $collectionIdAttribute, $collectionMeaningType, $collectionMeaningAttribute, $sourceIdentifierAttribute, |
| 57 | + $collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute, |
58 | 58 | $gotoSourceStructure, $gotoSourceAttribute, |
59 | 59 | $wgCollectionAttributeName, $wgSourceIdentifierAttributeName, $wgGotoSourceAttributeName; |
60 | 60 | |
61 | 61 | $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); |
64 | 63 | $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); |
67 | 66 | |
68 | 67 | global |
69 | | - $collectionMembershipAttribute, $wgCollectionMembershipAttributeName, $wgCollectionMembershipAttributeId; |
| 68 | + $collectionMembershipAttribute, $wgCollectionMembershipAttributeName, $wgCollectionMembershipAttributeId, |
| 69 | + $collectionMembershipStructure; |
70 | 70 | |
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); |
72 | 73 | |
73 | 74 | global |
74 | 75 | $classMembershipIdAttribute, $classAttribute; |
— | — | @@ -79,47 +80,38 @@ |
80 | 81 | $classMembershipStructure, $classMembershipKeyStructure, $classMembershipAttribute, |
81 | 82 | $wgClassMembershipAttributeName, $wgClassMembershipAttributeId; |
82 | 83 | |
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); |
86 | 86 | |
87 | 87 | global |
88 | | - $possiblySynonymousIdAttribute, $possibleSynonymAttribute, $wgPossibleSynonymAttributeName; |
| 88 | + $possiblySynonymousIdAttribute, $possiblySynonymousAttribute, $wgPossibleSynonymAttributeName, $possiblySynonymousStructure, $possiblySynonymousAttribute, $wgPossiblySynonymousAttributeName, $wgPossiblySynonymousAttributeId; |
89 | 89 | |
90 | 90 | $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); |
100 | 94 | |
101 | 95 | global |
102 | 96 | $relationIdAttribute, $relationTypeAttribute, $relationTypeType, $otherDefinedMeaningAttribute, |
103 | 97 | $wgRelationTypeAttributeName, $wgOtherDefinedMeaningAttributeName; |
104 | 98 | |
105 | 99 | $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); |
108 | 101 | $otherDefinedMeaningAttribute = new Attribute("other-defined-meaning", $wgOtherDefinedMeaningAttributeName, $definedMeaningReferenceType); |
109 | 102 | |
110 | 103 | global |
111 | | - $relationsAttribute, $relationStructure, $relationKeyStructure, $reciprocalRelationsAttribute, $objectAttributesAttribute, |
112 | | - $wgRelationsAttributeName, $wgIncomingRelationsAttributeName, $wgRelationsAttributeId, $wgIncomingRelationsAttributeId; |
| 104 | + $relationsAttribute, $relationStructure, $reciprocalRelationsAttribute, $objectAttributesAttribute, $wgRelationsAttributeName, $wgIncomingRelationsAttributeName, $wgRelationsAttributeId, $wgIncomingRelationsAttributeId, |
| 105 | + $repRelStructure; |
113 | 106 | |
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); |
118 | 110 | |
119 | 111 | global |
120 | 112 | $translatedTextIdAttribute, $translatedTextStructure; |
121 | 113 | |
122 | 114 | $translatedTextIdAttribute = new Attribute("translated-text-id", "Translated text ID", "integer"); |
123 | | - $translatedTextStructure = new Structure($languageAttribute, $textAttribute); |
| 115 | + $translatedTextStructure = new Structure("translated-text", $languageAttribute, $textAttribute); |
124 | 116 | |
125 | 117 | global |
126 | 118 | $definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute, |
— | — | @@ -135,21 +127,26 @@ |
136 | 128 | $sourceAttribute = new Attribute("source-id", $wgSourceAttributeName, $definedMeaningReferenceType); |
137 | 129 | |
138 | 130 | global |
139 | | - $alternativeDefinitionsAttribute, $wgAlternativeDefinitionsAttributeName, $wgAlternativeDefinitionsAttributeId; |
| 131 | + $alternativeDefinitionsAttribute, $wgAlternativeDefinitionsAttributeName, $wgAlternativeDefinitionsAttributeId, |
| 132 | + $alternativeDefinitionsStructure; |
140 | 133 | |
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); |
142 | 137 | |
143 | 138 | global |
144 | 139 | $synonymsAndTranslationsAttribute, $syntransIdAttribute, |
145 | | - $wgSynonymsAttributeName, $wgSynonymsAndTranslationsAttributeName, $wgSynonymsAndTranslationsAttributeId; |
| 140 | + $wgSynonymsAttributeName, $wgSynonymsAndTranslationsAttributeName, $wgSynonymsAndTranslationsAttributeId, |
| 141 | + $synonymsTranslationsStructure; |
146 | 142 | |
147 | 143 | if ($filterOnLanguage) |
148 | 144 | $synonymsAndTranslationsCaption = $wgSynonymsAttributeName; |
149 | 145 | else |
150 | | - $synonymsAndTranslationsCaption = $wgSynonymsAndTranslationsAttributeName; |
151 | | - |
| 146 | + $synonymsAndTranslationsCaption = $wgSynonymsAndTranslationsAttributeName; |
| 147 | + |
152 | 148 | $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); |
154 | 151 | |
155 | 152 | global |
156 | 153 | $translatedTextAttributeIdAttribute, $translatedTextValueIdAttribute, |
— | — | @@ -164,10 +161,10 @@ |
165 | 162 | if ($filterOnLanguage && !$hasMetaDataAttributes) |
166 | 163 | $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, "text"); |
167 | 164 | else |
168 | | - $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, $translatedTextStructure); |
| 165 | + $translatedTextValueAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeValueAttributeName, $translatedTextStructure); |
169 | 166 | |
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); |
172 | 169 | |
173 | 170 | global |
174 | 171 | $textAttributeIdAttribute, $textAttributeObjectAttribute, $textAttributeAttribute, $textAttributeValuesStructure, |
— | — | @@ -177,8 +174,8 @@ |
178 | 175 | $textAttributeIdAttribute = new Attribute("text-attribute-id", "Attribute identifier", "object-id"); |
179 | 176 | $textAttributeObjectAttribute = new Attribute("text-attribute-object-id", "Attribute object", "object-id"); |
180 | 177 | $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); |
183 | 180 | |
184 | 181 | global |
185 | 182 | $urlAttribute, $urlAttributeIdAttribute, $urlAttributeObjectAttribute, $urlAttributeAttribute, $urlAttributeValuesStructure, $urlAttributeValuesAttribute, |
— | — | @@ -188,37 +185,37 @@ |
189 | 186 | $urlAttributeIdAttribute = new Attribute("url-attribute-id", "Attribute identifier", "object-id"); |
190 | 187 | $urlAttributeObjectAttribute = new Attribute("url-attribute-object-id", "Attribute object", "object-id"); |
191 | 188 | $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); |
194 | 191 | |
195 | 192 | global |
196 | 193 | $optionAttributeIdAttribute, $optionAttributeAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionAttribute, $optionAttributeValuesAttribute, |
197 | | - $wgOptionAttributeAttributeName, $wgOptionAttributeOptionAttributeName, $wgOptionAttributeValuesAttributeName; |
| 194 | + $wgOptionAttributeAttributeName, $wgOptionAttributeOptionAttributeName, $wgOptionAttributeValuesAttributeName, $optionAttributeValuesStructure; |
198 | 195 | |
199 | 196 | $optionAttributeIdAttribute = new Attribute('option-attribute-id', 'Attribute identifier', 'object-id'); |
200 | 197 | $optionAttributeObjectAttribute = new Attribute('option-attribute-object-id', 'Attribute object', 'object-id'); |
201 | 198 | $optionAttributeAttribute = new Attribute('option-attribute', $wgOptionAttributeAttributeName, $definedMeaningReferenceType); |
202 | 199 | $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); |
205 | 202 | |
206 | 203 | global |
207 | 204 | $optionAttributeOptionIdAttribute, $optionAttributeOptionsAttribute, $wgOptionAttributeOptionsAttributeName; |
208 | 205 | |
209 | 206 | $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); |
212 | 209 | |
213 | 210 | global |
214 | 211 | $definitionAttribute, $translatedTextAttribute, $classAttributesAttribute, |
215 | | - $wgDefinitionAttributeName, $wgDefinitionAttributeId, $wgTranslatedTextAttributeName; |
| 212 | + $wgDefinitionAttributeName, $wgTranslatedTextAttributeName; |
216 | 213 | |
217 | 214 | if ($filterOnLanguage && !$hasMetaDataAttributes) |
218 | 215 | $translatedTextAttribute = new Attribute("translated-text", $wgTextAttributeName, "text"); |
219 | 216 | else |
220 | | - $translatedTextAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeName, $translatedTextStructure); |
| 217 | + $translatedTextAttribute = new Attribute(null, $wgTranslatedTextAttributeName, $translatedTextStructure); |
221 | 218 | |
222 | | - $definitionAttribute = new Attribute($wgDefinitionAttributeId, $wgDefinitionAttributeName, new Structure($translatedTextAttribute, $objectAttributesAttribute)); |
| 219 | + $definitionAttribute = new Attribute(null, $wgDefinitionAttributeName, new Structure("definition", $translatedTextAttribute, $objectAttributesAttribute)); |
223 | 220 | |
224 | 221 | global |
225 | 222 | $classAttributesStructure, |
— | — | @@ -231,14 +228,15 @@ |
232 | 229 | $classAttributeAttributeAttribute = new Attribute("class-attribute-attribute", $wgClassAttributeAttributeAttributeName, $definedMeaningReferenceStructure); |
233 | 230 | $classAttributeLevelAttribute = new Attribute("class-attribute-level", $wgClassAttributeLevelAttributeName, $definedMeaningReferenceStructure); |
234 | 231 | $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); |
237 | 234 | |
238 | 235 | global |
239 | 236 | $definedMeaningAttribute, $wgDefinedMeaningAttributeName; |
240 | | - |
241 | | - $definedMeaningAttribute = new Attribute("defined-meaning", $wgDefinedMeaningAttributeName, |
| 237 | + |
| 238 | + $definedMeaningAttribute = new Attribute(null, $wgDefinedMeaningAttributeName, |
242 | 239 | new Structure( |
| 240 | + "defined-meaning", |
243 | 241 | $definitionAttribute, |
244 | 242 | $classAttributesAttribute, |
245 | 243 | $alternativeDefinitionsAttribute, |
— | — | @@ -249,31 +247,51 @@ |
250 | 248 | $collectionMembershipAttribute, |
251 | 249 | $definedMeaningAttributesAttribute) |
252 | 250 | ); |
253 | | - |
| 251 | + |
254 | 252 | global |
255 | 253 | $expressionsAttribute, $expressionMeaningStructure, $expressionExactMeaningsAttribute, $expressionApproximateMeaningsAttribute, |
256 | 254 | $wgExactMeaningsAttributeName, $wgApproximateMeaningsAttributeName; |
257 | 255 | |
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); |
260 | 258 | $expressionApproximateMeaningsAttribute = new Attribute("expression-approximate-meanings", $wgApproximateMeaningsAttributeName, $expressionMeaningStructure); |
261 | 259 | |
262 | 260 | global |
263 | 261 | $expressionMeaningsAttribute, $expressionMeaningsStructure, $expressionApproximateMeaningAttribute, |
264 | | - $wgExpressionMeaningsAttributeName, $wgExpressionsAttributeName; |
| 262 | + $wgExpressionMeaningsAttributeName, $wgExpressionsAttributeName, |
| 263 | + $expressionsStructure; |
265 | 264 | |
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); |
268 | 267 | |
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); |
270 | 270 | |
271 | 271 | global |
272 | 272 | $objectIdAttribute, $objectAttributesStructure, $wgAnnotationAttributeName; |
273 | 273 | |
274 | 274 | $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 | + |
278 | 296 | } |
279 | 297 | |
280 | 298 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialTransaction.php |
— | — | @@ -170,7 +170,8 @@ |
171 | 171 | $updatedDefinitionAttribute = new Attribute('updated-definition', 'Definition', $updatedDefinitionStructure); |
172 | 172 | |
173 | 173 | global |
174 | | - $expressionAttribute, $expressionIdAttribute, $identicalMeaningAttribute, $syntransIdAttribute, $updatedSyntransesAttribute; |
| 174 | + $expressionAttribute, $expressionIdAttribute, $identicalMeaningAttribute, $syntransIdAttribute, $updatedSyntransesAttribute, |
| 175 | + $updatedSyntransesStructure; |
175 | 176 | |
176 | 177 | $updatedSyntransesStructure = new Structure( |
177 | 178 | $syntransIdAttribute, |
— | — | @@ -401,6 +402,7 @@ |
402 | 403 | $restrictions[] = "EXISTS (SELECT user_name FROM user WHERE user.user_id={$dc}_transactions.user_id AND user.user_name='" . $userName . "')"; |
403 | 404 | |
404 | 405 | $recordSet = queryRecordSet( |
| 406 | + 'transaction-id', |
405 | 407 | $queryTransactionInformation, |
406 | 408 | $transactionIdAttribute, |
407 | 409 | array( |
— | — | @@ -477,7 +479,7 @@ |
478 | 480 | $updatedAlternativeDefinitionsAttribute, $updatedAlternativeDefinitionTextAttribute, |
479 | 481 | $updatedTranslatedTextPropertyAttribute; |
480 | 482 | |
481 | | - $record = new ArrayRecord($updatesInTransactionAttribute->type->getAttributes()); |
| 483 | + $record = new ArrayRecord($updatesInTransactionAttribute->type); |
482 | 484 | $record->setAttributeValue($updatedDefinitionAttribute, getUpdatedDefinedMeaningDefinitionRecordSet($transactionId)); |
483 | 485 | $record->setAttributeValue($updatedAlternativeDefinitionsAttribute, getUpdatedAlternativeDefinitionsRecordSet($transactionId)); |
484 | 486 | $record->setAttributeValue($updatedAlternativeDefinitionTextAttribute, getUpdatedAlternativeDefinitionTextRecordSet($transactionId)); |
Index: trunk/extensions/Wikidata/OmegaWiki/RecordSetQueries.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | return $query; |
33 | 33 | } |
34 | 34 | |
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) { |
36 | 36 | $dbr =& wfGetDB(DB_SLAVE); |
37 | 37 | |
38 | 38 | $selectFields = array_keys($fieldAttributeMapping); |
— | — | @@ -44,8 +44,11 @@ |
45 | 45 | |
46 | 46 | $query = getTransactedSQL($transactionInformation, $selectFields, $table, $restrictions, $orderBy, $count, $offset); |
47 | 47 | $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 | + } |
50 | 53 | $recordSet = new ArrayRecordSet($structure, new Structure($keyAttribute)); |
51 | 54 | |
52 | 55 | while ($row = $dbr->fetchRow($queryResult)) { |
Index: trunk/extensions/Wikidata/OmegaWiki/RecordSet.php |
— | — | @@ -10,7 +10,6 @@ |
11 | 11 | public abstract function getKey(); |
12 | 12 | public abstract function getRecordCount(); |
13 | 13 | public abstract function getRecord($index); |
14 | | - protected $type=null; |
15 | 14 | protected $records; |
16 | 15 | # public function save(); # <- we first need to implement, then uncomment |
17 | 16 | /** |
— | — | @@ -22,7 +21,8 @@ |
23 | 22 | |
24 | 23 | public function tostring_indent($depth=0,$key="",$myname="RecordSet") { |
25 | 24 | $rv="\n".str_pad("",$depth*8); |
26 | | - $type=$this->type; |
| 25 | + $str=$this->getStructure(); |
| 26 | + $type=$str->getStructureType(); |
27 | 27 | $rv.="$key:$myname(... $type) {"; |
28 | 28 | $rv2=$rv; |
29 | 29 | foreach ($this->records as $value) { |
— | — | @@ -43,37 +43,6 @@ |
44 | 44 | return $rv; |
45 | 45 | } |
46 | 46 | |
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 | | - } |
78 | 47 | } |
79 | 48 | |
80 | 49 | class ArrayRecordSet extends RecordSet { |
— | — | @@ -81,7 +50,7 @@ |
82 | 51 | protected $key; |
83 | 52 | protected $records = array(); |
84 | 53 | |
85 | | - public function __construct($structure, $key) { |
| 54 | + public function __construct(Structure $structure, $key) { |
86 | 55 | $this->structure = $structure; |
87 | 56 | $this->key = $key; |
88 | 57 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/Attribute.php |
— | — | @@ -1,28 +1,50 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class Attribute { |
5 | | - public $id = ""; |
| 5 | + public $id = null; |
6 | 6 | public $name = ""; |
7 | 7 | public $type = ""; |
8 | 8 | |
9 | 9 | /** |
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. |
15 | 18 | */ |
16 | 19 | public function __construct($id, $name, $type) { |
17 | | - $this->id = $id; |
| 20 | + $this->id = $id; |
18 | 21 | $this->name = $name; |
19 | | - $this->type = $type; |
| 22 | + $this->setAttributeType($type); |
20 | 23 | } |
21 | 24 | |
| 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 | + |
22 | 43 | } |
23 | 44 | |
24 | 45 | class Structure { |
25 | 46 | |
26 | | - private $structure; # Array of attributes |
| 47 | + private $structure; |
| 48 | + private $type; |
27 | 49 | |
28 | 50 | public function getAttributes() { |
29 | 51 | return $this->structure; |
— | — | @@ -32,12 +54,64 @@ |
33 | 55 | $this->structure[]=$attribute; |
34 | 56 | } |
35 | 57 | |
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; |
41 | 60 | } |
| 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 | + } |
42 | 116 | } |
43 | 117 | |
44 | 118 | |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php |
— | — | @@ -415,7 +415,7 @@ |
416 | 416 | |
417 | 417 | function getDefinedMeaningEditor($filterLanguageId, $possiblySynonymousRelationTypeId, $showRecordLifeSpan, $showAuthority) { |
418 | 418 | global |
419 | | - $wgDefinedMeaningAttributesOrder, |
| 419 | + $wdDefinedMeaningAttributesOrder, |
420 | 420 | $definedMeaningAttribute, $possiblySynonymousIdAttribute, $possiblySynonymousAttribute, |
421 | 421 | $possibleSynonymAttribute, $definedMeaningObjectAttributesEditor, $possiblySynonymousObjectAttributesEditor; |
422 | 422 | |
— | — | @@ -453,7 +453,7 @@ |
454 | 454 | |
455 | 455 | $definedMeaningEditor = new RecordUnorderedListEditor($definedMeaningAttribute, 4); |
456 | 456 | |
457 | | - foreach ($wgDefinedMeaningAttributesOrder as $attributeId) { |
| 457 | + foreach ($wdDefinedMeaningAttributesOrder as $attributeId) { |
458 | 458 | $editor = $availableEditors->getEditorForAttributeId($attributeId); |
459 | 459 | |
460 | 460 | if ($editor != null) |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | " GROUP BY {$dc}_defined_meaning.defined_meaning_id"; |
65 | 65 | } |
66 | 66 | |
67 | | -function fetchDefinedMeaningReferenceRecords($sql, &$definedMeaningIds, &$definedMeaningReferenceRecords) { |
| 67 | +function fetchDefinedMeaningReferenceRecords($sql, &$definedMeaningIds, &$definedMeaningReferenceRecords, $usedAs='defined-meaning') { |
68 | 68 | |
69 | 69 | $dc=wdGetDataSetContext(); |
70 | 70 | |
— | — | @@ -78,8 +78,10 @@ |
79 | 79 | |
80 | 80 | while ($row = $dbr->fetchObject($queryResult)) { |
81 | 81 | $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); |
84 | 86 | $record->setAttributeValue($definedMeaningIdAttribute, $definedMeaningId); |
85 | 87 | $record->setAttributeValue($definedMeaningLabelAttribute, $row->label); |
86 | 88 | |
— | — | @@ -134,7 +136,7 @@ |
135 | 137 | return $record; |
136 | 138 | } |
137 | 139 | |
138 | | -function getDefinedMeaningReferenceRecords($definedMeaningIds) { |
| 140 | +function getDefinedMeaningReferenceRecords($definedMeaningIds, $usedAs) { |
139 | 141 | global |
140 | 142 | $wgUser; |
141 | 143 | |
— | — | @@ -154,7 +156,8 @@ |
155 | 157 | fetchDefinedMeaningReferenceRecords( |
156 | 158 | getDefiningSQLForLanguage($definingLanguage, $definedMeaningIds), |
157 | 159 | $definedMeaningIds, |
158 | | - $result |
| 160 | + $result, |
| 161 | + $usedAs |
159 | 162 | ); |
160 | 163 | |
161 | 164 | if (count($definedMeaningIds) > 0) { |
— | — | @@ -162,21 +165,25 @@ |
163 | 166 | fetchDefinedMeaningReferenceRecords( |
164 | 167 | getSynonymSQLForLanguage($userLanguage, $definedMeaningIds), |
165 | 168 | $definedMeaningIds, |
166 | | - $result |
| 169 | + $result, |
| 170 | + $usedAs |
| 171 | + |
167 | 172 | ); |
168 | 173 | |
169 | 174 | if (count($definedMeaningIds) > 0) { |
170 | 175 | fetchDefinedMeaningReferenceRecords( |
171 | 176 | getSynonymSQLForLanguage(85, $definedMeaningIds), |
172 | 177 | $definedMeaningIds, |
173 | | - $result |
| 178 | + $result, |
| 179 | + $usedAs |
174 | 180 | ); |
175 | 181 | |
176 | 182 | if (count($definedMeaningIds) > 0) { |
177 | 183 | fetchDefinedMeaningReferenceRecords( |
178 | 184 | getSynonymSQLForAnyLanguage($definedMeaningIds), |
179 | 185 | $definedMeaningIds, |
180 | | - $result |
| 186 | + $result, |
| 187 | + $usedAs |
181 | 188 | ); |
182 | 189 | } |
183 | 190 | } |
— | — | @@ -193,11 +200,17 @@ |
194 | 201 | } |
195 | 202 | |
196 | 203 | function expandDefinedMeaningReferencesInRecordSet($recordSet, $definedMeaningAttributes) { |
197 | | - $definedMeaningReferenceRecords = getDefinedMeaningReferenceRecords(getUniqueIdsInRecordSet($recordSet, $definedMeaningAttributes)); |
198 | 204 | |
| 205 | + $definedMeaningReferenceRecords=array(); |
| 206 | + |
| 207 | + foreach($definedMeaningAttributes as $dmatt) { |
| 208 | + $tmpArray = getDefinedMeaningReferenceRecords(getUniqueIdsInRecordSet($recordSet, array($dmatt)), $dmatt->id); |
| 209 | + $definedMeaningReferenceRecords+=$tmpArray; |
| 210 | + |
| 211 | + } |
| 212 | + |
199 | 213 | for ($i = 0; $i < $recordSet->getRecordCount(); $i++) { |
200 | 214 | $record = $recordSet->getRecord($i); |
201 | | - |
202 | 215 | foreach($definedMeaningAttributes as $definedMeaningAttribute) |
203 | 216 | $record->setAttributeValue( |
204 | 217 | $definedMeaningAttribute, |
— | — | @@ -383,7 +396,7 @@ |
384 | 397 | |
385 | 398 | function getExpressionsRecordSet($spelling, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation) { |
386 | 399 | global |
387 | | - $expressionIdAttribute, $expressionAttribute, $languageAttribute, $expressionMeaningsAttribute; |
| 400 | + $expressionIdAttribute, $expressionAttribute, $languageAttribute, $expressionMeaningsAttribute, $expressionsStructure; |
388 | 401 | |
389 | 402 | $dc=wdGetDataSetContext(); |
390 | 403 | |
— | — | @@ -407,11 +420,11 @@ |
408 | 421 | .")" |
409 | 422 | ); |
410 | 423 | |
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); |
413 | 426 | |
414 | 427 | while($expression = $dbr->fetchObject($queryResult)) { |
415 | | - $expressionRecord = new ArrayRecord($expressionStructure); |
| 428 | + $expressionRecord = new ArrayRecord($languageStructure); |
416 | 429 | $expressionRecord->setAttributeValue($languageAttribute, $expression->language_id); |
417 | 430 | |
418 | 431 | $result->addRecord(array( |
— | — | @@ -451,9 +464,11 @@ |
452 | 465 | |
453 | 466 | function getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation) { |
454 | 467 | global |
455 | | - $classAttributesTable, $classAttributeIdAttribute, $classAttributeLevelAttribute, $classAttributeAttributeAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute; |
| 468 | + $classAttributesTable, $classAttributeIdAttribute, $classAttributeLevelAttribute, $classAttributeAttributeAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute, |
| 469 | + $classAttributesStructure; |
456 | 470 | |
457 | 471 | $recordSet = queryRecordSet( |
| 472 | + $classAttributesStructure->getStructureType(), |
458 | 473 | $queryTransactionInformation, |
459 | 474 | $classAttributeIdAttribute, |
460 | 475 | array( |
— | — | @@ -485,9 +500,11 @@ |
486 | 501 | |
487 | 502 | function getAlternativeDefinitionsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation) { |
488 | 503 | global |
489 | | - $alternativeDefinitionsTable, $definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute; |
| 504 | + $alternativeDefinitionsTable, $definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute, |
| 505 | + $alternativeDefinitionsStructure; |
490 | 506 | |
491 | 507 | $recordSet = queryRecordSet( |
| 508 | + $alternativeDefinitionsStructure->getStructureType(), |
492 | 509 | $queryTransactionInformation, |
493 | 510 | $definitionIdAttribute, |
494 | 511 | array( |
— | — | @@ -511,20 +528,25 @@ |
512 | 529 | $definitionAttribute, $translatedTextAttribute, $objectAttributesAttribute; |
513 | 530 | |
514 | 531 | $definitionId = getDefinedMeaningDefinitionId($definedMeaningId); |
515 | | - $record = new ArrayRecord($definitionAttribute->type->getAttributes()); |
| 532 | + $record = new ArrayRecord(new Structure($definitionAttribute)); |
516 | 533 | $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)); |
518 | 535 | |
519 | 536 | return $record; |
520 | 537 | } |
521 | 538 | |
522 | | -function getObjectAttributesRecord($objectId, $filterLanguageId, $queryTransactionInformation) { |
| 539 | +function getObjectAttributesRecord($objectId, $filterLanguageId, $queryTransactionInformation, $structuralOverride=null) { |
523 | 540 | global |
524 | 541 | $objectAttributesAttribute, $objectIdAttribute, |
525 | 542 | $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 | + } |
529 | 551 | |
530 | 552 | $record->setAttributeValue($objectIdAttribute, $objectId); |
531 | 553 | $record->setAttributeValue($textAttributeValuesAttribute, getTextAttributesValuesRecordSet(array($objectId), $filterLanguageId, $queryTransactionInformation)); |
— | — | @@ -557,9 +579,11 @@ |
558 | 580 | |
559 | 581 | function getTranslatedContentRecordSet($translatedContentId, $queryTransactionInformation) { |
560 | 582 | global |
561 | | - $translatedContentTable, $languageAttribute, $textAttribute; |
| 583 | + $translatedContentTable, $languageAttribute, $textAttribute, |
| 584 | + $translatedTextStructure; |
562 | 585 | |
563 | 586 | $recordSet = queryRecordSet( |
| 587 | + $translatedTextStructure->getStructureType(), |
564 | 588 | $queryTransactionInformation, |
565 | 589 | $languageAttribute, |
566 | 590 | array( |
— | — | @@ -580,6 +604,7 @@ |
581 | 605 | $translatedContentTable, $languageAttribute, $textAttribute; |
582 | 606 | |
583 | 607 | $recordSet = queryRecordSet( |
| 608 | + null, |
584 | 609 | $queryTransactionInformation, |
585 | 610 | $languageAttribute, |
586 | 611 | array( |
— | — | @@ -600,7 +625,8 @@ |
601 | 626 | |
602 | 627 | function getSynonymAndTranslationRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation) { |
603 | 628 | global |
604 | | - $syntransTable, $syntransIdAttribute, $expressionAttribute, $identicalMeaningAttribute, $objectAttributesAttribute; |
| 629 | + $syntransTable, $syntransIdAttribute, $expressionAttribute, $identicalMeaningAttribute, $objectAttributesAttribute, |
| 630 | + $synonymsTranslationsStructure; |
605 | 631 | |
606 | 632 | $dc=wdGetDataSetContext(); |
607 | 633 | $restrictions = array("defined_meaning_id=$definedMeaningId"); |
— | — | @@ -616,6 +642,7 @@ |
617 | 643 | ")"; |
618 | 644 | |
619 | 645 | $recordSet = queryRecordSet( |
| 646 | + $synonymsTranslationsStructure->getStructureType(), |
620 | 647 | $queryTransactionInformation, |
621 | 648 | $syntransIdAttribute, |
622 | 649 | array( |
— | — | @@ -647,7 +674,7 @@ |
648 | 675 | $urlAttributeObjectAttribute, $urlAttributeValuesAttribute, |
649 | 676 | $optionAttributeObjectAttribute, $optionAttributeValuesAttribute; |
650 | 677 | |
651 | | - $objectAttributesRecordStructure = $objectAttributesAttribute->type->getAttributes(); |
| 678 | + $objectAttributesRecordStructure = $objectAttributesAttribute->type; |
652 | 679 | $objectIds = getUniqueIdsInRecordSet($recordSet, array($objectIdAttribute)); |
653 | 680 | |
654 | 681 | if (count($objectIds) > 0) { |
— | — | @@ -755,7 +782,8 @@ |
756 | 783 | function getDefinedMeaningRelationsRecordSet($definedMeaningId, $filterLanguageId, $filterRelationTypes, $queryTransactionInformation) { |
757 | 784 | global |
758 | 785 | $meaningRelationsTable, $relationIdAttribute, $relationTypeAttribute, |
759 | | - $objectAttributesAttribute, $otherDefinedMeaningAttribute; |
| 786 | + $objectAttributesAttribute, $otherDefinedMeaningAttribute, |
| 787 | + $relationStructure; |
760 | 788 | |
761 | 789 | $restrictions = array("meaning1_mid=$definedMeaningId"); |
762 | 790 | |
— | — | @@ -763,6 +791,7 @@ |
764 | 792 | $restrictions[] = "relationtype_mid NOT IN (". implode(", ", $filterRelationTypes) .")"; |
765 | 793 | |
766 | 794 | $recordSet = queryRecordSet( |
| 795 | + $relationStructure->getStructureType(), |
767 | 796 | $queryTransactionInformation, |
768 | 797 | $relationIdAttribute, |
769 | 798 | array( |
— | — | @@ -789,9 +818,11 @@ |
790 | 819 | function getDefinedMeaningReciprocalRelationsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation) { |
791 | 820 | global |
792 | 821 | $meaningRelationsTable, $relationIdAttribute, $relationTypeAttribute, |
793 | | - $otherDefinedMeaningAttribute, $objectAttributesAttribute; |
| 822 | + $otherDefinedMeaningAttribute, $objectAttributesAttribute, |
| 823 | + $reciprocalRelationsAttribute; |
794 | 824 | |
795 | 825 | $recordSet = queryRecordSet( |
| 826 | + $reciprocalRelationsAttribute->id, |
796 | 827 | $queryTransactionInformation, |
797 | 828 | $relationIdAttribute, |
798 | 829 | array( |
— | — | @@ -821,6 +852,7 @@ |
822 | 853 | $objectAttributesAttribute, $otherDefinedMeaningAttribute; |
823 | 854 | |
824 | 855 | $recordSet = queryRecordSet( |
| 856 | + null, |
825 | 857 | $queryTransactionInformation, |
826 | 858 | $possiblySynonymousIdAttribute, |
827 | 859 | array( |
— | — | @@ -860,9 +892,10 @@ |
861 | 893 | function getDefinedMeaningCollectionMembershipRecordSet($definedMeaningId, $queryTransactionInformation) { |
862 | 894 | global |
863 | 895 | $collectionMembershipsTable, $collectionIdAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute, |
864 | | - $gotoSourceAttribute; |
| 896 | + $gotoSourceAttribute, $collectionMembershipStructure; |
865 | 897 | |
866 | 898 | $recordSet = queryRecordSet( |
| 899 | + $collectionMembershipStructure->getStructureType(), |
867 | 900 | $queryTransactionInformation, |
868 | 901 | $collectionIdAttribute, |
869 | 902 | array( |
— | — | @@ -889,9 +922,11 @@ |
890 | 923 | function getTextAttributesValuesRecordSet($objectIds, $filterLanguageId, $queryTransactionInformation) { |
891 | 924 | global |
892 | 925 | $textAttributeValuesTable, $textAttributeIdAttribute, $textAttributeObjectAttribute, |
893 | | - $textAttributeAttribute, $textAttribute, $objectAttributesAttribute; |
| 926 | + $textAttributeAttribute, $textAttribute, $objectAttributesAttribute, |
| 927 | + $textAttributeValuesStructure; |
894 | 928 | |
895 | 929 | $recordSet = queryRecordSet( |
| 930 | + $textAttributeValuesStructure->getStructureType(), |
896 | 931 | $queryTransactionInformation, |
897 | 932 | $textAttributeIdAttribute, |
898 | 933 | array( |
— | — | @@ -917,9 +952,11 @@ |
918 | 953 | function getURLAttributeValuesRecordSet($objectIds, $filterLanguageId, $queryTransactionInformation) { |
919 | 954 | global |
920 | 955 | $urlAttributeValuesTable, $urlAttributeIdAttribute, $urlAttributeObjectAttribute, |
921 | | - $urlAttributeAttribute, $urlAttribute, $objectAttributesAttribute; |
| 956 | + $urlAttributeAttribute, $urlAttribute, $objectAttributesAttribute, |
| 957 | + $urlAttributeValuesStructure; |
922 | 958 | |
923 | 959 | $recordSet = queryRecordSet( |
| 960 | + $urlAttributeValuesStructure->getStructureType(), |
924 | 961 | $queryTransactionInformation, |
925 | 962 | $urlAttributeIdAttribute, |
926 | 963 | array( |
— | — | @@ -945,9 +982,11 @@ |
946 | 983 | function getTranslatedTextAttributeValuesRecordSet($objectIds, $filterLanguageId, $queryTransactionInformation) { |
947 | 984 | global |
948 | 985 | $translatedTextAttributeIdAttribute, $translatedContentAttributeValuesTable, $translatedTextAttributeAttribute, |
949 | | - $objectAttributesAttribute, $translatedTextAttributeObjectAttribute, $translatedTextValueAttribute, $translatedTextValueIdAttribute; |
| 986 | + $objectAttributesAttribute, $translatedTextAttributeObjectAttribute, $translatedTextValueAttribute, $translatedTextValueIdAttribute, |
| 987 | + $translatedTextAttributeValuesStructure; |
950 | 988 | |
951 | 989 | $recordSet = queryRecordSet( |
| 990 | + $translatedTextAttributeValuesStructure->getStructureType(), |
952 | 991 | $queryTransactionInformation, |
953 | 992 | $translatedTextAttributeIdAttribute, |
954 | 993 | array( |
— | — | @@ -977,6 +1016,7 @@ |
978 | 1017 | $optionAttributeOptionIdAttribute, $optionAttributeAttribute, $optionAttributeOptionAttribute, $languageAttribute, $optionAttributeOptionsTable; |
979 | 1018 | |
980 | 1019 | $recordSet = queryRecordSet( |
| 1020 | + null, |
981 | 1021 | $queryTransactionInformation, |
982 | 1022 | $optionAttributeOptionIdAttribute, |
983 | 1023 | array( |
— | — | @@ -996,9 +1036,11 @@ |
997 | 1037 | |
998 | 1038 | function getOptionAttributeValuesRecordSet($objectIds, $filterLanguageId, $queryTransactionInformation) { |
999 | 1039 | global |
1000 | | - $optionAttributeIdAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionIdAttribute, $optionAttributeAttribute,$optionAttributeOptionAttribute, $optionAttributeValuesTable, $objectAttributesAttribute; |
| 1040 | + $optionAttributeIdAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionIdAttribute, $optionAttributeAttribute,$optionAttributeOptionAttribute, $optionAttributeValuesTable, $objectAttributesAttribute, |
| 1041 | + $optionAttributeValuesStructure; |
1001 | 1042 | |
1002 | 1043 | $recordSet = queryRecordSet( |
| 1044 | + $optionAttributeValuesStructure->getStructureType(), |
1003 | 1045 | $queryTransactionInformation, |
1004 | 1046 | $optionAttributeIdAttribute, |
1005 | 1047 | array( |
— | — | @@ -1030,6 +1072,7 @@ |
1031 | 1073 | $record = $recordSet->getRecord($i); |
1032 | 1074 | |
1033 | 1075 | $optionRecordSet = queryRecordSet( |
| 1076 | + null, |
1034 | 1077 | $queryTransactionInformation, |
1035 | 1078 | $optionAttributeOptionIdAttribute, |
1036 | 1079 | array( |
— | — | @@ -1047,6 +1090,7 @@ |
1048 | 1091 | ); |
1049 | 1092 | |
1050 | 1093 | $optionRecordSet = queryRecordSet( |
| 1094 | + null, |
1051 | 1095 | $queryTransactionInformation, |
1052 | 1096 | $optionAttributeIdAttribute, |
1053 | 1097 | array('attribute_mid' => $optionAttributeAttribute), |
— | — | @@ -1064,9 +1108,11 @@ |
1065 | 1109 | |
1066 | 1110 | function getDefinedMeaningClassMembershipRecordSet($definedMeaningId, $queryTransactionInformation) { |
1067 | 1111 | global |
1068 | | - $classMembershipsTable, $classMembershipIdAttribute, $classAttribute; |
| 1112 | + $classMembershipsTable, $classMembershipIdAttribute, $classAttribute, |
| 1113 | + $classMembershipStructure; |
1069 | 1114 | |
1070 | 1115 | $recordSet = queryRecordSet( |
| 1116 | + $classMembershipStructure->getStructureType(), |
1071 | 1117 | $queryTransactionInformation, |
1072 | 1118 | $classMembershipIdAttribute, |
1073 | 1119 | array( |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -1,5 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | +require_once('OmegaWikiAttributes.php'); |
4 | 5 | require_once('OmegaWikiRecordSets.php'); |
5 | 6 | require_once('OmegaWikiAttributes.php'); |
6 | 7 | require_once("Transaction.php"); |
— | — | @@ -22,7 +23,7 @@ |
23 | 24 | $possiblySynonymousAttribute; |
24 | 25 | |
25 | 26 | $this->setDefinedMeaningID($definedMeaningId); |
26 | | - $record = new ArrayRecord($definedMeaningAttribute->type->getAttributes()); |
| 27 | + $record = new ArrayRecord($definedMeaningAttribute->type); |
27 | 28 | $record->setAttributeValue($definitionAttribute, getDefinedMeaningDefinitionRecord($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
28 | 29 | $record->setAttributeValue($classAttributesAttribute, getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation)); |
29 | 30 | $record->setAttributeValue($alternativeDefinitionsAttribute, getAlternativeDefinitionsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php |
— | — | @@ -12,11 +12,11 @@ |
13 | 13 | class ArrayRecord implements Record { |
14 | 14 | protected $structure; |
15 | 15 | protected $values = array(); |
16 | | - protected $type = null; |
17 | 16 | protected $helper=null; |
18 | 17 | |
19 | | - public function __construct($structure) { |
| 18 | + public function __construct(Structure $structure) { |
20 | 19 | $this->structure = $structure; |
| 20 | + $this->helper=RecordHelperFactory::getRecordHelper($this); |
21 | 21 | } |
22 | 22 | |
23 | 23 | public function getStructure() { |
— | — | @@ -39,49 +39,6 @@ |
40 | 40 | @$this->values[$attribute->id] = $value; |
41 | 41 | } |
42 | 42 | |
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 | | - } |
86 | 43 | /** |
87 | 44 | * |
88 | 45 | * @param $values Array to write into the record, by order of the structure |
— | — | @@ -112,7 +69,8 @@ |
113 | 70 | |
114 | 71 | public function tostring_indent($depth=0,$key="") { |
115 | 72 | $rv="\n".str_pad("",$depth*8); |
116 | | - $type=$this->type; |
| 73 | + $str=$this->getStructure(); |
| 74 | + $type=$str->getStructureType(); |
117 | 75 | $rv.="$key:ArrayRecord(..., $type) {"; |
118 | 76 | $rv2=$rv; |
119 | 77 | foreach ($this->values as $key=>$value) { |
Index: trunk/extensions/Wikidata/OmegaWiki/RecordHelper.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | class RecordHelperFactory { |
5 | 5 | |
6 | 6 | public static function getRecordHelper($record) { |
7 | | - $type=$record->getType(); |
| 7 | + $type=$record->getStructure()->getStructureType(); |
8 | 8 | if (empty($type)) |
9 | 9 | return null; |
10 | 10 | switch($type) { |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | return new TranslatedTextHelper($record); |
15 | 15 | case "object-attributes": |
16 | 16 | return new ObjectAttributesHelper($record); |
17 | | - case "synonyms-translations": |
| 17 | + case "syntrans-id": |
18 | 18 | return new SynonymsTranslationsHelper($record); |
19 | 19 | break; |
20 | 20 | case "expression": |
— | — | @@ -43,8 +43,17 @@ |
44 | 44 | case "defined-meaning-attributes": |
45 | 45 | return new DefinedMeaningAttributesHelper($record); |
46 | 46 | break; |
| 47 | + case "defined-meaning-id": |
| 48 | + // Relax |
| 49 | + break; |
| 50 | + case "defined-meaning": |
| 51 | + // ... |
| 52 | + break; |
| 53 | + case "language": |
| 54 | + break; |
47 | 55 | 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'"); |
49 | 58 | break; |
50 | 59 | } |
51 | 60 | |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -2080,7 +2080,7 @@ |
2081 | 2081 | $dbr = &wfGetDB(DB_SLAVE); |
2082 | 2082 | $queryResult = $dbr->query( |
2083 | 2083 | "SELECT spelling, defined_meaning_id" . |
2084 | | - " FROM {$dc}_syntrans, _expression_ns" . |
| 2084 | + " FROM {$dc}_syntrans, {$dc}_expression_ns" . |
2085 | 2085 | " WHERE syntrans_sid=$objectId" . |
2086 | 2086 | " AND {$dc}_syntrans.expression_id={$dc}_expression_ns.expression_id" |
2087 | 2087 | ); |