r24034 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24033‎ | r24034 | r24035 >
Date:15:32, 12 July 2007
Author:proes
Status:old
Tags:
Comment:
Now recursive annotation can be filtered to independent columns properly
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php
@@ -8,11 +8,20 @@
99 require_once('GotoSourceTemplate.php');
1010 require_once('ViewInformation.php');
1111
 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+
1222 class ObjectAttributeValuesEditor extends WrappingEditor {
1323 protected $recordSetTableEditor;
1424 protected $propertyAttribute;
1525 protected $valueAttribute;
16 - protected $suffixAttributes;
1726
1827 public function __construct(Attribute $attribute, ViewInformation $viewInformation) {
1928 parent::__construct(new RecordUnorderedListEditor($attribute, 5));
@@ -30,18 +39,14 @@
3140 $this->propertyAttribute = new Attribute("property", "Property", "short-text");
3241 $this->valueAttribute = new Attribute("value", "Value", "short-text");
3342
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()));
3845
3946 global
40 - $wgRequest, $objectAttributesAttribute, $recordLifeSpanAttribute;
 47+ $objectAttributesAttribute;
4148
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);
4651 }
4752
4853 protected function attributeInStructure(Attribute $attribute, Structure $structure) {
@@ -53,7 +58,6 @@
5459 $result = $attribute->id == $attributes[$i]->id;
5560 $i++;
5661 }
57 -
5862
5963 return $result;
6064 }
@@ -120,10 +124,17 @@
121125 public function determineVisibleSuffixAttributes($value) {
122126 $visibleStructures = array();
123127
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+ }
126134
127 - return $this->filterAttributesByStructures($this->suffixAttributes, $visibleStructures);
 135+ return $this->filterAttributesByStructures(
 136+ $this->recordSetTableEditor->getTableStructure($this->recordSetTableEditor)->getAttributes(),
 137+ $visibleStructures
 138+ );
128139 }
129140
130141 public function addEditor(Editor $editor) {
@@ -170,20 +181,39 @@
171182 function initializeObjectAttributeEditors(ViewInformation $viewInformation) {
172183 global
173184 $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;
178189
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();
183192
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));
188218 }
189219
190220 function getTransactionEditor(Attribute $attribute) {
@@ -279,8 +309,9 @@
280310 }
281311
282312 function getTranslatedTextEditor(Attribute $attribute, UpdateController $updateController, UpdateAttributeController $updateAttributeController, ViewInformation $viewInformation) {
283 -
284 - global $omegaWikiAttributes;
 313+ global
 314+ $omegaWikiAttributes;
 315+
285316 if ($viewInformation->filterLanguageId == 0 || $viewInformation->showRecordLifeSpan) {
286317 $editor = new RecordSetTableEditor($attribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, true, $updateController);
287318
@@ -520,16 +551,20 @@
521552 return $editor;
522553 }
523554
 555+function addPopupEditors(Editor $editor, array &$columnEditors) {
 556+ foreach ($columnEditors as $columnEditor)
 557+ $editor->addEditor(new PopUpEditor($columnEditor, $columnEditor->getAttribute()->name));
 558+}
 559+
524560 function getTextAttributeValuesEditor(ViewInformation $viewInformation, $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) {
525561 global
526 - $textAttributeAttribute, $textAttribute, $textAttributeValuesAttribute, $textValueObjectAttributesEditor,
527 - $wgPopupAnnotationName;
 562+ $textAttributeAttribute, $textAttribute, $textAttributeValuesAttribute, $textValueObjectAttributesEditors;
528563
529564 $editor = new RecordSetTableEditor($textAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller);
530565 $editor->addEditor(new TextAttributeEditor($textAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher));
531566 $editor->addEditor(new TextEditor($textAttribute, new SimplePermissionController(true), true));
532 - $editor->addEditor(new PopUpEditor($textValueObjectAttributesEditor, $wgPopupAnnotationName));
533 -
 567+
 568+ addPopupEditors($editor, $textValueObjectAttributesEditors);
534569 addTableMetadataEditors($editor, $viewInformation);
535570
536571 return $editor;
@@ -537,8 +572,8 @@
538573
539574 function getLinkAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) {
540575 global
541 - $linkAttributeAttribute, $linkAttribute, $linkAttributeValuesAttribute, $linkValueObjectAttributesEditor,
542 - $wgPopupAnnotationName, $linkLabelAttribute, $linkURLAttribute;
 576+ $linkAttributeAttribute, $linkAttribute, $linkAttributeValuesAttribute, $linkValueObjectAttributesEditors,
 577+ $linkLabelAttribute, $linkURLAttribute;
543578
544579 $editor = new RecordSetTableEditor($linkAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller);
545580 $editor->addEditor(new LinkAttributeEditor($linkAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher));
@@ -552,8 +587,8 @@
553588 }
554589
555590 $editor->addEditor($linkEditor);
556 - $editor->addEditor(new PopUpEditor($linkValueObjectAttributesEditor, $wgPopupAnnotationName));
557591
 592+ addPopupEditors($editor, $linkValueObjectAttributesEditors);
558593 addTableMetadataEditors($editor, $viewInformation);
559594
560595 return $editor;
@@ -562,7 +597,7 @@
563598 function getTranslatedTextAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) {
564599 global
565600 $translatedTextAttributeAttribute, $translatedTextValueAttribute, $translatedTextAttributeValuesAttribute,
566 - $translatedTextValueObjectAttributesEditor, $wgPopupAnnotationName;
 601+ $translatedTextValueObjectAttributesEditors;
567602
568603 $editor = new RecordSetTableEditor($translatedTextAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller);
569604 $editor->addEditor(new TranslatedTextAttributeEditor($translatedTextAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher));
@@ -572,8 +607,8 @@
573608 new FilteredTranslatedTextAttributeValueController($viewInformation->filterLanguageId),
574609 $viewInformation
575610 ));
576 - $editor->addEditor(new PopUpEditor($translatedTextValueObjectAttributesEditor, $wgPopupAnnotationName));
577 -
 611+
 612+ addPopupEditors($editor, $translatedTextValueObjectAttributesEditors);
578613 addTableMetadataEditors($editor, $viewInformation);
579614
580615 return $editor;
@@ -582,14 +617,14 @@
583618 function getOptionAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) {
584619 global
585620 $optionAttributeAttribute, $optionAttributeOptionAttribute, $optionAttributeValuesAttribute,
586 - $optionValueObjectAttributesEditor, $wgPopupAnnotationName;
 621+ $optionValueObjectAttributesEditors;
587622
588623 $editor = new RecordSetTableEditor($optionAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller);
589624
590625 $editor->addEditor(new OptionAttributeEditor($optionAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher));
591626 $editor->addEditor(new OptionSelectEditor($optionAttributeOptionAttribute, new SimplePermissionController(false), true));
592 - $editor->addEditor(new PopUpEditor($optionValueObjectAttributesEditor, $wgPopupAnnotationName));
593 -
 627+
 628+ addPopupEditors($editor, $optionValueObjectAttributesEditors);
594629 addTableMetadataEditors($editor, $viewInformation);
595630
596631 return $editor;

Status & tagging log