r25585 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25584‎ | r25585 | r25586 >
Date:13:53, 6 September 2007
Author:proes
Status:old
Tags:
Comment:
Hide table columns on edit page that don't allow editing
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,11 +133,11 @@
134134 return $result;
135135 }
136136
137 - public function determineVisibleSuffixAttributes($value) {
 137+ public function determineVisibleSuffixAttributes(IdStack $idPath, $value) {
138138 $visibleStructures = array();
139139
140140 foreach ($this->getEditors() as $editor) {
141 - $visibleStructure = $editor->getTableStructureForView($value->getAttributeValue($editor->getAttribute()));
 141+ $visibleStructure = $editor->getTableStructureForView($idPath, $value->getAttributeValue($editor->getAttribute()));
142142
143143 if (count($visibleStructure->getAttributes()) > 0)
144144 $visibleStructures[] = $visibleStructure;
@@ -165,7 +165,7 @@
166166
167167 public function view(IdStack $idPath, $value) {
168168 $idPath->pushAnnotationAttribute($this->getAttribute());
169 - $visibleSuffixAttributes = $this->determineVisibleSuffixAttributes($value);
 169+ $visibleSuffixAttributes = $this->determineVisibleSuffixAttributes($idPath, $value);
170170
171171 $visibleStructure = new Structure(array_merge(
172172 array($this->propertyAttribute, $this->valueAttribute),
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php
@@ -548,7 +548,7 @@
549549 $this->rowHTMLAttributes = $rowHTMLAttributes;
550550 }
551551
552 - protected function columnShowsData(Editor $columnEditor, $value, $attributePath) {
 552+ protected function columnShowsData(Editor $columnEditor, RecordSet $value, $attributePath) {
553553 $result = false;
554554 $recordCount = $value->getRecordCount();
555555 $i = 0;
@@ -583,7 +583,7 @@
584584 return new Structure($attributes);
585585 }
586586
587 - protected function getTableStructureShowingData(Editor $editor, $value, $attributePath = array()) {
 587+ protected function getTableStructureShowingData($viewOrEdit, Editor $editor, IdStack $idPath, RecordSet $value, $attributePath = array()) {
588588 $attributes = array();
589589
590590 foreach ($editor->getEditors() as $childEditor) {
@@ -591,12 +591,13 @@
592592 array_push($attributePath, $childAttribute);
593593
594594 if ($childEditor instanceof RecordTableCellEditor) {
595 - $type = $this->getTableStructureShowingData($childEditor, $value, $attributePath);
 595+ $type = $this->getTableStructureShowingData($viewOrEdit, $childEditor, $idPath, $value, $attributePath);
596596
597597 if (count($type->getAttributes()) > 0)
598598 $attributes[] = new Attribute($childAttribute->id, $childAttribute->name, $type);
599599 }
600 - else if ($this->columnShowsData($childEditor, $value, $attributePath))
 600+ else if (($viewOrEdit == "view" && $this->columnShowsData($childEditor, $value, $attributePath)) ||
 601+ ($viewOrEdit == "edit") && $childEditor->showEditField($idPath))
601602 $attributes[] = new Attribute($childAttribute->id, $childAttribute->name, 'short-text');
602603
603604 array_pop($attributePath);
@@ -614,7 +615,7 @@
615616 return $result;
616617 }
617618
618 - public function viewRows(IdStack $idPath, $value, Structure $visibleStructure) {
 619+ public function viewRows(IdStack $idPath, RecordSet $value, Structure $visibleStructure) {
619620 $result = "";
620621 $rowAttributes = $this->getRowAttributesText();
621622 $key = $value->getKey();
@@ -638,15 +639,19 @@
639640 return '</table>' . EOL;
640641 }
641642
642 - public function getTableStructureForView($value) {
 643+ public function getTableStructureForView(IdStack $idPath, RecordSet $value) {
643644 if ($this->hideEmptyColumns)
644 - return $this->getTableStructureShowingData($this, $value);
 645+ return $this->getTableStructureShowingData("view", $this, $idPath, $value);
645646 else
646647 return $this->getTableStructure($this);
647648 }
 649+
 650+ public function getTableStructureForEdit(IdStack $idPath, RecordSet $value) {
 651+ return $this->getTableStructureShowingData("edit", $this, $idPath, $value);
 652+ }
648653
649654 public function view(IdStack $idPath, $value) {
650 - $visibleStructure = $this->getTableStructureForView($value);
 655+ $visibleStructure = $this->getTableStructureForView($idPath, $value);
651656
652657 $result =
653658 $this->viewHeader($idPath, $visibleStructure) .
@@ -663,9 +668,10 @@
664669 $result = '<table id="'. $idPath->getId() .'" class="wiki-data-table">';
665670 $key = $value->getKey();
666671 $rowAttributes = $this->getRowAttributesText();
667 - $visibleStructure = $this->getTableStructure($this);
 672+ $visibleStructure = $this->getTableStructureForEdit($idPath, $value);
 673+
668674 $columnOffset = $this->allowRemove ? 1 : 0;
669 - $headerRows = getStructureAsTableHeaderRows($this->getTableStructure($this), $columnOffset, $idPath);
 675+ $headerRows = getStructureAsTableHeaderRows($visibleStructure, $columnOffset, $idPath);
670676
671677 if ($this->allowRemove)
672678 $headerRows[0] = '<th class="remove" rowspan="' . count($headerRows) . '"><img src="'.$wgStylePath.'/amethyst/delete.png" title="Mark rows to remove" alt="Remove"/></th>' . $headerRows[0];

Status & tagging log