r23956 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23955‎ | r23956 | r23957 >
Date:14:07, 10 July 2007
Author:proes
Status:old
Tags:
Comment:
On the view and history page object attribute values are now shown in one table instead of per-type tables.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Editor.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php
@@ -133,7 +133,7 @@
134134 global
135135 $objectAttributesAttribute, $definedMeaningIdAttribute;
136136
137 - $result = new RecordUnorderedListEditor($attribute, 5);
 137+ $result = new ObjectAttributeValuesEditor($attribute);
138138
139139 addObjectAttributesEditors(
140140 $result,
@@ -150,7 +150,7 @@
151151 global
152152 $objectAttributesAttribute, $definedMeaningIdAttribute;
153153
154 - $result = new RecordUnorderedListEditor($attribute, 5);
 154+ $result = new ObjectAttributeValuesEditor($attribute);
155155
156156 addObjectAttributesEditors(
157157 $result,
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php
@@ -210,6 +210,7 @@
211211 }
212212
213213 public function add(IdStack $idPath) {
 214+ return "";
214215 }
215216
216217 public function save(IdStack $idPath, $value) {
@@ -493,13 +494,13 @@
494495 return $result;
495496 }
496497
497 - protected function getAllColumnEditors(Editor $editor, $value) {
 498+ public function getAllColumnEditors(Editor $editor) {
498499 $result = array();
499500
500501 foreach ($editor->getEditors() as $childEditor) {
501502 if ($childEditor instanceof RecordTableCellEditor) {
502503 $result[] = $childEditor;
503 - $result = array_merge($result, $this->getAllColumnEditors($childEditor, $value));
 504+ $result = array_merge($result, $this->getAllColumnEditors($childEditor));
504505 }
505506 else
506507 $result[] = $childEditor;
@@ -541,15 +542,15 @@
542543 return '</table>' . EOL;
543544 }
544545
545 - public function getVisibleColumnHeadersForView($value) {
 546+ public function getVisibleColumnEditorsForView($value) {
546547 if ($this->hideEmptyColumns)
547548 return $this->getColumnEditorsShowingData($this, $value);
548549 else
549 - return $this->getAllColumnEditors($this, $value);
 550+ return $this->getAllColumnEditors($this);
550551 }
551552
552553 public function view(IdStack $idPath, $value) {
553 - $visibleColumnEditors = $this->getVisibleColumnHeadersForView($value);
 554+ $visibleColumnEditors = $this->getVisibleColumnEditorsForView($value);
554555
555556 $result =
556557 $this->viewHeader($idPath, $visibleColumnEditors) .
@@ -566,7 +567,7 @@
567568 $result = '<table id="'. $idPath->getId() .'" class="wiki-data-table">';
568569 $key = $value->getKey();
569570 $rowAttributes = $this->getRowAttributesText();
570 - $visibleColumnEditors = $this->getAllColumnEditors($this, $value);
 571+ $visibleColumnEditors = $this->getAllColumnEditors($this);
571572 $columnOffset = $this->allowRemove ? 1 : 0;
572573 $headerRows = getStructureAsTableHeaderRows($this->getTableStructure($this, $visibleColumnEditors), $columnOffset, $idPath);
573574
@@ -2170,4 +2171,73 @@
21712172 }
21722173 }
21732174
 2175+class ObjectAttributeValuesEditor extends WrappingEditor {
 2176+ protected $recordSetTableEditor;
 2177+ protected $propertyEditor;
 2178+ protected $vslueEditor;
 2179+
 2180+ public function __construct(Attribute $attribute = null) {
 2181+ parent::__construct(new RecordUnorderedListEditor($attribute, 5));
 2182+
 2183+ $this->recordSetTableEditor = new RecordSetTableEditor(
 2184+ $attribute,
 2185+ new SimplePermissionController(false),
 2186+ new ShowEditFieldChecker(true),
 2187+ new AllowAddController(false),
 2188+ false,
 2189+ false,
 2190+ null
 2191+ );
 2192+
 2193+ $propertyAttribute = new Attribute("property", "Property", "short-text");
 2194+ $valueAttribute = new Attribute("value", "Value", "short-text");
 2195+
 2196+ $this->propertyEditor = new ShortTextEditor($propertyAttribute, new SimplePermissionController(false), false);
 2197+ $this->valueEditor = new ShortTextEditor($valueAttribute, new SimplePermissionController(false), false);
 2198+
 2199+ $this->recordSetTableEditor->addEditor($this->propertyEditor);
 2200+ $this->recordSetTableEditor->addEditor($this->valueEditor);
 2201+ }
 2202+
 2203+ public function addEditor(Editor $editor) {
 2204+ $this->wrappedEditor->addEditor($editor);
 2205+ $childEditors = $editor->getEditors();
 2206+
 2207+ for ($i = count($this->recordSetTableEditor->getEditors()); $i < count($childEditors); $i++)
 2208+ $this->recordSetTableEditor->addEditor($childEditors[$i]);
 2209+ }
 2210+
 2211+ public function determineVisibleHeaders($value) {
 2212+ $result = array($this->propertyEditor, $this->valueEditor);
 2213+
 2214+ foreach ($this->wrappedEditor->getEditors() as $editor) {
 2215+ $visibleEditors = $editor->getVisibleColumnEditorsForView($value->getAttributeValue($editor->getAttribute()));
 2216+
 2217+ foreach ($visibleEditors as $visibleEditor)
 2218+ if (!in_array($visibleEditor, $result, true))
 2219+ $result[] = $visibleEditor;
 2220+ }
 2221+
 2222+ return $result;
 2223+ }
21742224
 2225+ public function view(IdStack $idPath, $value) {
 2226+ $visibleColumnEditors = $this->determineVisibleHeaders($value);
 2227+ $result = $this->recordSetTableEditor->viewHeader($idPath, $visibleColumnEditors);
 2228+
 2229+ foreach ($this->wrappedEditor->getEditors() as $editor) {
 2230+ $attribute = $editor->getAttribute();
 2231+ $idPath->pushAttribute($attribute);
 2232+ $result .= $editor->viewRows(
 2233+ $idPath,
 2234+ $value->getAttributeValue($attribute),
 2235+ $visibleColumnEditors
 2236+ );
 2237+ $idPath->popAttribute();
 2238+ }
 2239+
 2240+ $result .= $this->recordSetTableEditor->viewFooter($idPath, $visibleColumnEditors);
 2241+
 2242+ return $result;
 2243+ }
 2244+}

Status & tagging log