Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php |
— | — | @@ -8,11 +8,20 @@ |
9 | 9 | require_once('GotoSourceTemplate.php'); |
10 | 10 | require_once('ViewInformation.php'); |
11 | 11 | |
| 12 | +class DummyViewer extends Viewer { |
| 13 | + public function view(IdStack $idPath, $value) { |
| 14 | + return ""; |
| 15 | + } |
| 16 | + |
| 17 | + public function showsData($value) { |
| 18 | + return true; |
| 19 | + } |
| 20 | +} |
| 21 | + |
12 | 22 | class ObjectAttributeValuesEditor extends WrappingEditor { |
13 | 23 | protected $recordSetTableEditor; |
14 | 24 | protected $propertyAttribute; |
15 | 25 | protected $valueAttribute; |
16 | | - protected $suffixAttributes; |
17 | 26 | |
18 | 27 | public function __construct(Attribute $attribute, ViewInformation $viewInformation) { |
19 | 28 | parent::__construct(new RecordUnorderedListEditor($attribute, 5)); |
— | — | @@ -30,18 +39,14 @@ |
31 | 40 | $this->propertyAttribute = new Attribute("property", "Property", "short-text"); |
32 | 41 | $this->valueAttribute = new Attribute("value", "Value", "short-text"); |
33 | 42 | |
34 | | - $this->suffixAttributes = array(); |
35 | | - |
36 | | -// foreach ($viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter) |
37 | | -// $this->suffixAttributes[] = $propertyToColumnFilter->getAttribute(); |
| 43 | + foreach ($viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter) |
| 44 | + $this->recordSetTableEditor->addEditor(new DummyViewer($propertyToColumnFilter->getAttribute())); |
38 | 45 | |
39 | 46 | global |
40 | | - $wgRequest, $objectAttributesAttribute, $recordLifeSpanAttribute; |
| 47 | + $objectAttributesAttribute; |
41 | 48 | |
42 | | -// $this->suffixAttributes[] = $objectAttributesAttribute; |
43 | | - |
44 | | - if ($wgRequest->getText('action') == 'history' && $viewInformation->showRecordLifeSpan) |
45 | | - $this->suffixAttributes[] = $recordLifeSpanAttribute; |
| 49 | + $this->recordSetTableEditor->addEditor(new DummyViewer($objectAttributesAttribute)); |
| 50 | + addTableMetadataEditors($this->recordSetTableEditor, $viewInformation); |
46 | 51 | } |
47 | 52 | |
48 | 53 | protected function attributeInStructure(Attribute $attribute, Structure $structure) { |
— | — | @@ -53,7 +58,6 @@ |
54 | 59 | $result = $attribute->id == $attributes[$i]->id; |
55 | 60 | $i++; |
56 | 61 | } |
57 | | - |
58 | 62 | |
59 | 63 | return $result; |
60 | 64 | } |
— | — | @@ -120,10 +124,17 @@ |
121 | 125 | public function determineVisibleSuffixAttributes($value) { |
122 | 126 | $visibleStructures = array(); |
123 | 127 | |
124 | | - foreach ($this->getEditors() as $editor) |
125 | | - $visibleStructures[] = $editor->getTableStructureForView($value->getAttributeValue($editor->getAttribute())); |
| 128 | + foreach ($this->getEditors() as $editor) { |
| 129 | + $visibleStructure = $editor->getTableStructureForView($value->getAttributeValue($editor->getAttribute())); |
| 130 | + |
| 131 | + if (count($visibleStructure->getAttributes()) > 0) |
| 132 | + $visibleStructures[] = $visibleStructure; |
| 133 | + } |
126 | 134 | |
127 | | - return $this->filterAttributesByStructures($this->suffixAttributes, $visibleStructures); |
| 135 | + return $this->filterAttributesByStructures( |
| 136 | + $this->recordSetTableEditor->getTableStructure($this->recordSetTableEditor)->getAttributes(), |
| 137 | + $visibleStructures |
| 138 | + ); |
128 | 139 | } |
129 | 140 | |
130 | 141 | public function addEditor(Editor $editor) { |
— | — | @@ -170,20 +181,39 @@ |
171 | 182 | function initializeObjectAttributeEditors(ViewInformation $viewInformation) { |
172 | 183 | global |
173 | 184 | $objectAttributesAttribute, $definedMeaningIdAttribute, |
174 | | - $textValueObjectAttributesEditor, $textAttributeIdAttribute, |
175 | | - $linkValueObjectAttributesEditor, $linkAttributeIdAttribute, |
176 | | - $translatedTextValueObjectAttributesEditor, $translatedTextAttributeIdAttribute, |
177 | | - $optionValueObjectAttributesEditor, $optionAttributeIdAttribute, $annotationMeaningName, $omegaWikiAttributes; |
| 185 | + $textValueObjectAttributesEditors, $textAttributeIdAttribute, |
| 186 | + $linkValueObjectAttributesEditors, $linkAttributeIdAttribute, |
| 187 | + $translatedTextValueObjectAttributesEditors, $translatedTextAttributeIdAttribute, |
| 188 | + $optionValueObjectAttributesEditors, $optionAttributeIdAttribute, $annotationMeaningName, $omegaWikiAttributes; |
178 | 189 | |
179 | | - $textValueObjectAttributesEditor = new RecordUnorderedListEditor($objectAttributesAttribute, 5); |
180 | | - $linkValueObjectAttributesEditor = new RecordUnorderedListEditor($objectAttributesAttribute, 5); |
181 | | - $translatedTextValueObjectAttributesEditor = new RecordUnorderedListEditor($objectAttributesAttribute, 5); |
182 | | - $optionValueObjectAttributesEditor = new RecordUnorderedListEditor($objectAttributesAttribute, 5); |
| 190 | + $linkValueObjectAttributesEditors = array(); |
| 191 | + $textValueObjectAttributesEditors = array(); |
183 | 192 | |
184 | | - addObjectAttributesEditors($textValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $textAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute)); |
185 | | - addObjectAttributesEditors($linkValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $linkAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute)); |
186 | | - addObjectAttributesEditors($translatedTextValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $translatedTextAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute)); |
187 | | - addObjectAttributesEditors($optionValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $optionAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute)); |
| 193 | + foreach ($viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter) { |
| 194 | + $attribute = $propertyToColumnFilter->getAttribute(); |
| 195 | + |
| 196 | + $textValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $viewInformation); |
| 197 | + $linkValueObjectAttributeEditors[] = new ObjectAttributeValuesEditor($attribute, $viewInformation); |
| 198 | + $translatedTextValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $viewInformation); |
| 199 | + $optionValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $viewInformation); |
| 200 | + } |
| 201 | + |
| 202 | + $textValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($objectAttributesAttribute, $viewInformation); |
| 203 | + $linkValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($objectAttributesAttribute, $viewInformation); |
| 204 | + $translatedTextValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($objectAttributesAttribute, $viewInformation); |
| 205 | + $optionValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($objectAttributesAttribute, $viewInformation); |
| 206 | + |
| 207 | + foreach ($textValueObjectAttributesEditors as $textValueObjectAttributesEditor) |
| 208 | + addObjectAttributesEditors($textValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $textAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute)); |
| 209 | + |
| 210 | + foreach ($linkValueObjectAttributesEditors as $linkValueObjectAttributesEditor) |
| 211 | + addObjectAttributesEditors($linkValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $linkAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute)); |
| 212 | + |
| 213 | + foreach ($translatedTextValueObjectAttributesEditors as $translatedTextValueObjectAttributesEditor) |
| 214 | + addObjectAttributesEditors($translatedTextValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $translatedTextAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute)); |
| 215 | + |
| 216 | + foreach ($optionValueObjectAttributesEditors as $optionValueObjectAttributesEditor) |
| 217 | + addObjectAttributesEditors($optionValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $optionAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute)); |
188 | 218 | } |
189 | 219 | |
190 | 220 | function getTransactionEditor(Attribute $attribute) { |
— | — | @@ -279,8 +309,9 @@ |
280 | 310 | } |
281 | 311 | |
282 | 312 | function getTranslatedTextEditor(Attribute $attribute, UpdateController $updateController, UpdateAttributeController $updateAttributeController, ViewInformation $viewInformation) { |
283 | | - |
284 | | - global $omegaWikiAttributes; |
| 313 | + global |
| 314 | + $omegaWikiAttributes; |
| 315 | + |
285 | 316 | if ($viewInformation->filterLanguageId == 0 || $viewInformation->showRecordLifeSpan) { |
286 | 317 | $editor = new RecordSetTableEditor($attribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, true, $updateController); |
287 | 318 | |
— | — | @@ -520,16 +551,20 @@ |
521 | 552 | return $editor; |
522 | 553 | } |
523 | 554 | |
| 555 | +function addPopupEditors(Editor $editor, array &$columnEditors) { |
| 556 | + foreach ($columnEditors as $columnEditor) |
| 557 | + $editor->addEditor(new PopUpEditor($columnEditor, $columnEditor->getAttribute()->name)); |
| 558 | +} |
| 559 | + |
524 | 560 | function getTextAttributeValuesEditor(ViewInformation $viewInformation, $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) { |
525 | 561 | global |
526 | | - $textAttributeAttribute, $textAttribute, $textAttributeValuesAttribute, $textValueObjectAttributesEditor, |
527 | | - $wgPopupAnnotationName; |
| 562 | + $textAttributeAttribute, $textAttribute, $textAttributeValuesAttribute, $textValueObjectAttributesEditors; |
528 | 563 | |
529 | 564 | $editor = new RecordSetTableEditor($textAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller); |
530 | 565 | $editor->addEditor(new TextAttributeEditor($textAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher)); |
531 | 566 | $editor->addEditor(new TextEditor($textAttribute, new SimplePermissionController(true), true)); |
532 | | - $editor->addEditor(new PopUpEditor($textValueObjectAttributesEditor, $wgPopupAnnotationName)); |
533 | | - |
| 567 | + |
| 568 | + addPopupEditors($editor, $textValueObjectAttributesEditors); |
534 | 569 | addTableMetadataEditors($editor, $viewInformation); |
535 | 570 | |
536 | 571 | return $editor; |
— | — | @@ -537,8 +572,8 @@ |
538 | 573 | |
539 | 574 | function getLinkAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) { |
540 | 575 | global |
541 | | - $linkAttributeAttribute, $linkAttribute, $linkAttributeValuesAttribute, $linkValueObjectAttributesEditor, |
542 | | - $wgPopupAnnotationName, $linkLabelAttribute, $linkURLAttribute; |
| 576 | + $linkAttributeAttribute, $linkAttribute, $linkAttributeValuesAttribute, $linkValueObjectAttributesEditors, |
| 577 | + $linkLabelAttribute, $linkURLAttribute; |
543 | 578 | |
544 | 579 | $editor = new RecordSetTableEditor($linkAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller); |
545 | 580 | $editor->addEditor(new LinkAttributeEditor($linkAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher)); |
— | — | @@ -552,8 +587,8 @@ |
553 | 588 | } |
554 | 589 | |
555 | 590 | $editor->addEditor($linkEditor); |
556 | | - $editor->addEditor(new PopUpEditor($linkValueObjectAttributesEditor, $wgPopupAnnotationName)); |
557 | 591 | |
| 592 | + addPopupEditors($editor, $linkValueObjectAttributesEditors); |
558 | 593 | addTableMetadataEditors($editor, $viewInformation); |
559 | 594 | |
560 | 595 | return $editor; |
— | — | @@ -562,7 +597,7 @@ |
563 | 598 | function getTranslatedTextAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) { |
564 | 599 | global |
565 | 600 | $translatedTextAttributeAttribute, $translatedTextValueAttribute, $translatedTextAttributeValuesAttribute, |
566 | | - $translatedTextValueObjectAttributesEditor, $wgPopupAnnotationName; |
| 601 | + $translatedTextValueObjectAttributesEditors; |
567 | 602 | |
568 | 603 | $editor = new RecordSetTableEditor($translatedTextAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller); |
569 | 604 | $editor->addEditor(new TranslatedTextAttributeEditor($translatedTextAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher)); |
— | — | @@ -572,8 +607,8 @@ |
573 | 608 | new FilteredTranslatedTextAttributeValueController($viewInformation->filterLanguageId), |
574 | 609 | $viewInformation |
575 | 610 | )); |
576 | | - $editor->addEditor(new PopUpEditor($translatedTextValueObjectAttributesEditor, $wgPopupAnnotationName)); |
577 | | - |
| 611 | + |
| 612 | + addPopupEditors($editor, $translatedTextValueObjectAttributesEditors); |
578 | 613 | addTableMetadataEditors($editor, $viewInformation); |
579 | 614 | |
580 | 615 | return $editor; |
— | — | @@ -582,14 +617,14 @@ |
583 | 618 | function getOptionAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) { |
584 | 619 | global |
585 | 620 | $optionAttributeAttribute, $optionAttributeOptionAttribute, $optionAttributeValuesAttribute, |
586 | | - $optionValueObjectAttributesEditor, $wgPopupAnnotationName; |
| 621 | + $optionValueObjectAttributesEditors; |
587 | 622 | |
588 | 623 | $editor = new RecordSetTableEditor($optionAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller); |
589 | 624 | |
590 | 625 | $editor->addEditor(new OptionAttributeEditor($optionAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher)); |
591 | 626 | $editor->addEditor(new OptionSelectEditor($optionAttributeOptionAttribute, new SimplePermissionController(false), true)); |
592 | | - $editor->addEditor(new PopUpEditor($optionValueObjectAttributesEditor, $wgPopupAnnotationName)); |
593 | | - |
| 627 | + |
| 628 | + addPopupEditors($editor, $optionValueObjectAttributesEditors); |
594 | 629 | addTableMetadataEditors($editor, $viewInformation); |
595 | 630 | |
596 | 631 | return $editor; |