Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php |
— | — | @@ -2,8 +2,9 @@ |
3 | 3 | |
4 | 4 | require_once("Attribute.php"); |
5 | 5 | require_once("WikiDataGlobals.php"); |
| 6 | +require_once("ViewInformation.php"); |
6 | 7 | |
7 | | -function initializeOmegaWikiAttributes($filterOnLanguage, $hasMetaDataAttributes=false) { |
| 8 | +function initializeOmegaWikiAttributes(ViewInformation $viewInformation) { |
8 | 9 | global |
9 | 10 | $languageAttribute, $spellingAttribute, $textAttribute, |
10 | 11 | $wgLanguageAttributeName, $wgSpellingAttributeName, $wgTextAttributeName; |
— | — | @@ -29,7 +30,7 @@ |
30 | 31 | global |
31 | 32 | $expressionStructure, $expressionAttribute, $wgExpressionAttributeName; |
32 | 33 | |
33 | | - if ($filterOnLanguage) |
| 34 | + if ($viewInformation->filterOnLanguage()) |
34 | 35 | $expressionAttribute = new Attribute("expression", $wgSpellingAttributeName, "spelling"); |
35 | 36 | else { |
36 | 37 | $expressionStructure = new Structure("expression", $languageAttribute, $spellingAttribute); |
— | — | @@ -122,7 +123,7 @@ |
123 | 124 | |
124 | 125 | $definitionIdAttribute = new Attribute("definition-id", "Definition identifier", "integer"); |
125 | 126 | |
126 | | - if ($filterOnLanguage && !$hasMetaDataAttributes) |
| 127 | + if ($viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes()) |
127 | 128 | $alternativeDefinitionAttribute = new Attribute("alternative-definition", $wgAlternativeDefinitionAttributeName, "text"); |
128 | 129 | else |
129 | 130 | $alternativeDefinitionAttribute = new Attribute("alternative-definition", $wgAlternativeDefinitionAttributeName, $translatedTextStructure); |
— | — | @@ -142,7 +143,7 @@ |
143 | 144 | $wgSynonymsAttributeName, $wgSynonymsAndTranslationsAttributeName, $wgSynonymsAndTranslationsAttributeId, |
144 | 145 | $synonymsTranslationsStructure; |
145 | 146 | |
146 | | - if ($filterOnLanguage) |
| 147 | + if ($viewInformation->filterOnLanguage()) |
147 | 148 | $synonymsAndTranslationsCaption = $wgSynonymsAttributeName; |
148 | 149 | else |
149 | 150 | $synonymsAndTranslationsCaption = $wgSynonymsAndTranslationsAttributeName; |
— | — | @@ -161,7 +162,7 @@ |
162 | 163 | $translatedTextAttributeAttribute = new Attribute("translated-text-attribute", $wgTranslatedTextAttributeAttributeName, $definedMeaningReferenceType); |
163 | 164 | $translatedTextValueIdAttribute = new Attribute("translated-text-value-id", "Translated text value identifier", "translated-text-value-id"); |
164 | 165 | |
165 | | - if ($filterOnLanguage && !$hasMetaDataAttributes) |
| 166 | + if ($viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes()) |
166 | 167 | $translatedTextValueAttribute = new Attribute("translated-text-value", $wgTranslatedTextAttributeValueAttributeName, "text"); |
167 | 168 | else |
168 | 169 | $translatedTextValueAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeValueAttributeName, $translatedTextStructure); |
— | — | @@ -213,7 +214,7 @@ |
214 | 215 | $definitionAttribute, $translatedTextAttribute, $classAttributesAttribute, |
215 | 216 | $wgDefinitionAttributeName, $wgTranslatedTextAttributeName; |
216 | 217 | |
217 | | - if ($filterOnLanguage && !$hasMetaDataAttributes) |
| 218 | + if ($viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes()) |
218 | 219 | $translatedTextAttribute = new Attribute("translated-text", $wgTextAttributeName, "text"); |
219 | 220 | else |
220 | 221 | $translatedTextAttribute = new Attribute(null, $wgTranslatedTextAttributeName, $translatedTextStructure); |
— | — | @@ -292,9 +293,6 @@ |
293 | 294 | $collectionMembershipAttribute->id, |
294 | 295 | $definedMeaningAttributesAttribute->id |
295 | 296 | ); |
296 | | - |
297 | | - |
298 | | - |
299 | 297 | } |
300 | 298 | |
301 | 299 | |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -940,7 +940,7 @@ |
941 | 941 | protected $addText = ""; |
942 | 942 | protected $controller; |
943 | 943 | |
944 | | - public function __construct(Attribute $attribute = null, PermissionController $permissionController, $isAddField, $truncate=false, $truncateAt=0, UpdateController $controller = null) { |
| 944 | + public function __construct(Attribute $attribute = null, PermissionController $permissionController, $isAddField, $truncate=false, $truncateAt=0, UpdateAttributeController $controller = null) { |
945 | 945 | parent::__construct($attribute, $permissionController, $isAddField); |
946 | 946 | |
947 | 947 | $this->truncate = $truncate; |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | * Please check if it still works correctly. Peter-Jan Roes. |
52 | 52 | */ |
53 | 53 | public function save() { |
54 | | - initializeOmegaWikiAttributes($this->filterLanguageId != 0, false); |
| 54 | + initializeOmegaWikiAttributes($this->viewInformation); |
55 | 55 | initializeObjectAttributeEditors($this->viewInformation); |
56 | 56 | |
57 | 57 | $definedMeaningId = $this->getDefinedMeaningID(); |
Index: trunk/extensions/Wikidata/OmegaWiki/ViewInformation.php |
— | — | @@ -25,6 +25,14 @@ |
26 | 26 | $this->showRecordLifeSpan = false; |
27 | 27 | $this->showAuthority = false; |
28 | 28 | } |
| 29 | + |
| 30 | + public function hasMetaDataAttributes() { |
| 31 | + return $this->showRecordLifeSpan || $this->showAuthority; |
| 32 | + } |
| 33 | + |
| 34 | + public function filterOnLanguage() { |
| 35 | + return $this->filterOnLanguage != 0; |
| 36 | + } |
29 | 37 | } |
30 | 38 | |
31 | 39 | ?> |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialTransaction.php |
— | — | @@ -28,8 +28,9 @@ |
29 | 29 | require_once("Editor.php"); |
30 | 30 | require_once("Controller.php"); |
31 | 31 | require_once("type.php"); |
| 32 | + require_once("ViewInformation.php"); |
32 | 33 | |
33 | | - initializeOmegaWikiAttributes(false, false); |
| 34 | + initializeOmegaWikiAttributes(new ViewInformation()); |
34 | 35 | initializeAttributes(); |
35 | 36 | |
36 | 37 | @$fromTransactionId = (int) $_GET['from-transaction']; # FIXME - check parameter |
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | |
101 | 101 | $this->viewInformation = $viewInformation; |
102 | 102 | |
103 | | - initializeOmegaWikiAttributes($this->filterLanguageId != 0); |
| 103 | + initializeOmegaWikiAttributes($viewInformation); |
104 | 104 | initializeObjectAttributeEditors($viewInformation); |
105 | 105 | } |
106 | 106 | |
— | — | @@ -133,7 +133,7 @@ |
134 | 134 | |
135 | 135 | $this->viewInformation = $viewInformation; |
136 | 136 | |
137 | | - initializeOmegaWikiAttributes($this->filterLanguageId != 0, false); |
| 137 | + initializeOmegaWikiAttributes($this->viewInformation); |
138 | 138 | initializeObjectAttributeEditors($this->viewInformation); |
139 | 139 | } |
140 | 140 | |
— | — | @@ -188,7 +188,7 @@ |
189 | 189 | |
190 | 190 | $this->viewInformation = $viewInformation; |
191 | 191 | |
192 | | - initializeOmegaWikiAttributes($this->filterLanguageId != 0, false); |
| 192 | + initializeOmegaWikiAttributes($this->viewInformation); |
193 | 193 | initializeObjectAttributeEditors($this->viewInformation); |
194 | 194 | |
195 | 195 | return true; |
— | — | @@ -245,7 +245,7 @@ |
246 | 246 | |
247 | 247 | $this->viewInformation = $viewInformation; |
248 | 248 | |
249 | | - initializeOmegaWikiAttributes($this->filterLanguageId != 0, true); |
| 249 | + initializeOmegaWikiAttributes($this->viewInformation); |
250 | 250 | initializeObjectAttributeEditors($viewInformation); |
251 | 251 | } |
252 | 252 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialDatasearch.php |
— | — | @@ -19,6 +19,8 @@ |
20 | 20 | protected $externalIdentifierAttribute; |
21 | 21 | protected $collectionAttribute; |
22 | 22 | protected $collectionMemberAttribute; |
| 23 | + protected $externalIdentifierMatchStructure; |
| 24 | + |
23 | 25 | protected $spellingAttribute; |
24 | 26 | protected $languageAttribute; |
25 | 27 | |
— | — | @@ -37,12 +39,13 @@ |
38 | 40 | require_once("WikiDataGlobals.php"); |
39 | 41 | require_once("forms.php"); |
40 | 42 | require_once("type.php"); |
| 43 | + require_once("ViewInformation.php"); |
41 | 44 | require_once("WikiDataAPI.php"); |
42 | 45 | require_once("OmegaWikiAttributes.php"); |
43 | 46 | require_once("OmegaWikiRecordSets.php"); |
44 | 47 | require_once("OmegaWikiEditors.php"); |
45 | 48 | |
46 | | - initializeOmegaWikiAttributes(false, false); |
| 49 | + initializeOmegaWikiAttributes(new ViewInformation()); |
47 | 50 | |
48 | 51 | global |
49 | 52 | $definedMeaningReferenceType; |
— | — | @@ -62,6 +65,12 @@ |
63 | 66 | $this->externalIdentifierAttribute = new Attribute("external-identifier", "External identifier", "short-text"); |
64 | 67 | $this->collectionAttribute = new Attribute("collection", "Collection", $definedMeaningReferenceType); |
65 | 68 | $this->collectionMemberAttribute = new Attribute("collection-member", "Collection member", $definedMeaningReferenceType); |
| 69 | + |
| 70 | + $this->externalIdentifierMatchStructure = new Structure( |
| 71 | + $this->externalIdentifierAttribute, |
| 72 | + $this->collectionAttribute, |
| 73 | + $this->collectionMemberAttribute |
| 74 | + ); |
66 | 75 | } |
67 | 76 | |
68 | 77 | function execute($parameter) { |
— | — | @@ -221,10 +230,10 @@ |
222 | 231 | |
223 | 232 | function getWordsSearchResultAsRecordSet($queryResult) { |
224 | 233 | global |
225 | | - $idAttribute; |
| 234 | + $definedMeaningIdAttribute; |
226 | 235 | |
227 | 236 | $dbr =& wfGetDB(DB_SLAVE); |
228 | | - $recordSet = new ArrayRecordSet(new Structure($idAttribute, $this->expressionAttribute, $this->meaningAttribute), new Structure($idAttribute)); |
| 237 | + $recordSet = new ArrayRecordSet(new Structure($definedMeaningIdAttribute, $this->expressionAttribute, $this->meaningAttribute), new Structure($definedMeaningIdAttribute)); |
229 | 238 | |
230 | 239 | while ($row = $dbr->fetchObject($queryResult)) { |
231 | 240 | $expressionRecord = new ArrayRecord($this->expressionStructure); |
Index: trunk/extensions/Wikidata/OmegaWiki/Search.php |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | |
46 | 46 | function getSearchResultAsRecordSet($queryResult) { |
47 | 47 | global |
48 | | - $idAttribute, $definedMeaningReferenceType; |
| 48 | + $definedMeaningIdAttribute, $definedMeaningReferenceType; |
49 | 49 | |
50 | 50 | $dbr =& wfGetDB(DB_SLAVE); |
51 | 51 | $spellingAttribute = new Attribute("found-word", "Found word", "short-text"); |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | $meaningStructure = new Structure($definedMeaningAttribute, $definitionAttribute); |
61 | 61 | $meaningAttribute = new Attribute("meaning", "Meaning", $meaningStructure); |
62 | 62 | |
63 | | - $recordSet = new ArrayRecordSet(new Structure($idAttribute, $expressionAttribute, $meaningAttribute), new Structure($idAttribute)); |
| 63 | + $recordSet = new ArrayRecordSet(new Structure($definedMeaningIdAttribute, $expressionAttribute, $meaningAttribute), new Structure($definedMeaningIdAttribute)); |
64 | 64 | |
65 | 65 | while ($row = $dbr->fetchObject($queryResult)) { |
66 | 66 | $expressionRecord = new ArrayRecord($expressionStructure); |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php |
— | — | @@ -91,24 +91,24 @@ |
92 | 92 | global |
93 | 93 | $definitionAttribute, $translatedTextAttribute, $definitionObjectAttributesEditor, $wgPopupAnnotationName; |
94 | 94 | |
95 | | - if ($viewInformation->filterLanguageId == 0) |
96 | | - $controller = new DefinedMeaningDefinitionController(); |
97 | | - else |
98 | | - $controller = new DefinedMeaningFilteredDefinitionController($viewInformation->filterLanguageId); |
99 | | - |
100 | 95 | $editor = new RecordDivListEditor($definitionAttribute); |
101 | | - $editor->addEditor(getTranslatedTextEditor($translatedTextAttribute, $controller, $viewInformation)); |
| 96 | + $editor->addEditor(getTranslatedTextEditor( |
| 97 | + $translatedTextAttribute, |
| 98 | + new DefinedMeaningDefinitionController(), |
| 99 | + new DefinedMeaningFilteredDefinitionController($viewInformation->filterLanguageId), |
| 100 | + $viewInformation |
| 101 | + )); |
102 | 102 | $editor->addEditor(new PopUpEditor($definitionObjectAttributesEditor, $wgPopupAnnotationName)); |
103 | 103 | |
104 | 104 | return $editor; |
105 | 105 | } |
106 | 106 | |
107 | | -function getTranslatedTextEditor(Attribute $attribute, UpdateController $controller, ViewInformation $viewInformation) { |
| 107 | +function getTranslatedTextEditor(Attribute $attribute, UpdateController $updateController, UpdateAttributeController $updateAttributeController, ViewInformation $viewInformation) { |
108 | 108 | global |
109 | 109 | $languageAttribute, $textAttribute; |
110 | 110 | |
111 | 111 | if ($viewInformation->filterLanguageId == 0 || $viewInformation->showRecordLifeSpan) { |
112 | | - $editor = new RecordSetTableEditor($attribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, true, $controller); |
| 112 | + $editor = new RecordSetTableEditor($attribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, true, $updateController); |
113 | 113 | |
114 | 114 | if ($viewInformation->filterLanguageId == 0) |
115 | 115 | $editor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), true)); |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | addTableMetadataEditors($editor, $viewInformation); |
119 | 119 | } |
120 | 120 | else |
121 | | - $editor = new TextEditor($attribute, new SimplePermissionController(true), true, false, 0, $controller); |
| 121 | + $editor = new TextEditor($attribute, new SimplePermissionController(true), true, false, 0, $updateAttributeController); |
122 | 122 | |
123 | 123 | return $editor; |
124 | 124 | } |
— | — | @@ -133,11 +133,6 @@ |
134 | 134 | global |
135 | 135 | $alternativeDefinitionsAttribute, $alternativeDefinitionAttribute, $sourceAttribute; |
136 | 136 | |
137 | | - if ($viewInformation->filterLanguageId == 0) |
138 | | - $alternativeDefinitionController = new DefinedMeaningAlternativeDefinitionController(); |
139 | | - else |
140 | | - $alternativeDefinitionController = new DefinedMeaningFilteredAlternativeDefinitionController($viewInformation); |
141 | | - |
142 | 137 | $editor = new RecordSetTableEditor( |
143 | 138 | $alternativeDefinitionsAttribute, |
144 | 139 | new SimplePermissionController(true), |
— | — | @@ -148,7 +143,12 @@ |
149 | 144 | new DefinedMeaningAlternativeDefinitionsController($viewInformation->filterLanguageId) |
150 | 145 | ); |
151 | 146 | |
152 | | - $editor->addEditor(getTranslatedTextEditor($alternativeDefinitionAttribute, $alternativeDefinitionController, $viewInformation)); |
| 147 | + $editor->addEditor(getTranslatedTextEditor( |
| 148 | + $alternativeDefinitionAttribute, |
| 149 | + new DefinedMeaningAlternativeDefinitionController(), |
| 150 | + new DefinedMeaningFilteredAlternativeDefinitionController($viewInformation), |
| 151 | + $viewInformation) |
| 152 | + ); |
153 | 153 | $editor->addEditor(new DefinedMeaningReferenceEditor($sourceAttribute, new SimplePermissionController(false), true)); |
154 | 154 | |
155 | 155 | addTableMetadataEditors($editor, $viewInformation); |
— | — | @@ -328,14 +328,14 @@ |
329 | 329 | $translatedTextAttributeAttribute, $translatedTextValueAttribute, $translatedTextAttributeValuesAttribute, |
330 | 330 | $translatedTextValueObjectAttributesEditor, $wgPopupAnnotationName; |
331 | 331 | |
332 | | - if ($viewInformation->filterLanguageId == 0) |
333 | | - $translatedTextAttributeValueController = new TranslatedTextAttributeValueController(); |
334 | | - else |
335 | | - $translatedTextAttributeValueController = new FilteredTranslatedTextAttributeValueController($viewInformation->filterLanguageId); |
336 | | - |
337 | 332 | $editor = new RecordSetTableEditor($translatedTextAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller); |
338 | 333 | $editor->addEditor(new TranslatedTextAttributeEditor($translatedTextAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher)); |
339 | | - $editor->addEditor(getTranslatedTextEditor($translatedTextValueAttribute, $translatedTextAttributeValueController, $viewInformation)); |
| 334 | + $editor->addEditor(getTranslatedTextEditor( |
| 335 | + $translatedTextValueAttribute, |
| 336 | + new TranslatedTextAttributeValueController(), |
| 337 | + new FilteredTranslatedTextAttributeValueController($viewInformation->filterLanguageId), |
| 338 | + $viewInformation |
| 339 | + )); |
340 | 340 | $editor->addEditor(new PopUpEditor($translatedTextValueObjectAttributesEditor, $wgPopupAnnotationName)); |
341 | 341 | |
342 | 342 | addTableMetadataEditors($editor, $viewInformation); |
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php |
— | — | @@ -114,14 +114,14 @@ |
115 | 115 | $attributes = $structure->getAttributes(); |
116 | 116 | $i = 0; |
117 | 117 | |
118 | | - while($result && $i < count($attributes)) { |
| 118 | + while ($result && $i < count($attributes)) { |
119 | 119 | $attribute = $attributes[$i]; |
120 | 120 | $type = $attribute->type; |
121 | 121 | $lhsValue = $lhs->getAttributeValue($attribute); |
122 | 122 | $rhsValue = $rhs->getAttributeValue($attribute); |
123 | 123 | |
124 | 124 | if ($type instanceof Structure) |
125 | | - $result = equalRecords($type->getStructure(), $lhsValue, $rhsValue); |
| 125 | + $result = $lhsValue instanceof Record && $rhsValue instanceof Record && equalRecords($type, $lhsValue, $rhsValue); |
126 | 126 | else |
127 | 127 | $result = $lhsValue == $rhsValue; |
128 | 128 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialNeedsTranslation.php |
— | — | @@ -20,8 +20,9 @@ |
21 | 21 | require_once("forms.php"); |
22 | 22 | require_once("type.php"); |
23 | 23 | require_once("OmegaWikiAttributes.php"); |
| 24 | + require_once("ViewInformation.php"); |
24 | 25 | |
25 | | - initializeOmegaWikiAttributes(false, false); |
| 26 | + initializeOmegaWikiAttributes(new ViewInformation()); |
26 | 27 | $wgOut->setPageTitle('Expressions needing translation'); |
27 | 28 | |
28 | 29 | $sourceLanguageId = $_GET['from-lang']; |