r17070 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17069‎ | r17070 | r17071 >
Date:11:22, 17 October 2006
Author:proes
Status:old
Tags:
Comment:
Hide expandable/collapsable nodes when they have no data to show in view/history mode. Edit mode still shows these nodes to allow the addition of data.
Modified paths:
  • /trunk/extensions/Wikidata/WiktionaryZ/Editor.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/WiktionaryZ/Editor.php
@@ -89,6 +89,7 @@
9090 public function getUpdateAttribute();
9191 public function getAddAttribute();
9292
 93+ public function showsData($value);
9394 public function view($idPath, $value);
9495 public function edit($idPath, $value);
9596 public function add($idPath);
@@ -370,6 +371,10 @@
371372
372373 return $result;
373374 }
 375+
 376+ public function showsData($value) {
 377+ return $value->getRecordCount() > 0;
 378+ }
374379 }
375380
376381 class RecordSetTableEditor extends RecordSetEditor {
@@ -588,6 +593,10 @@
589594 $idPath->popAttribute();
590595 }
591596 }
 597+
 598+ public function showsData($value) {
 599+ return true;
 600+ }
592601 }
593602
594603 class RecordTableCellEditor extends RecordEditor {
@@ -662,6 +671,10 @@
663672 else
664673 return $this->getViewHTML($idPath, $value);
665674 }
 675+
 676+ public function showsData($value) {
 677+ return true;
 678+ }
666679 }
667680
668681 class LanguageEditor extends ScalarEditor {
@@ -954,10 +967,14 @@
955968 $attributeId = $idPath->getId();
956969 $expansionPrefix = $this->getExpansionPrefix($class, $attributeId);
957970 $this->setExpansionByEditor($editor, $class);
958 - $result .= '<li>'.
959 - '<h'. $this->headerLevel .'><span id="collapse-'. $attributeId .'" class="toggle '. addCollapsablePrefixToClass($class) .'" onclick="toggle(this, event);">' . $expansionPrefix . '&nbsp;' . $attribute->name . '</span></h'. $this->headerLevel .'>' .
960 - '<div id="collapsable-'. $attributeId . '" class="expand-' . $class . '">' . $editor->view($idPath, $value->getAttributeValue($attribute)) . '</div>' .
961 - '</li>';
 971+ $attributeValue = $value->getAttributeValue($attribute);
 972+
 973+ if ($editor->showsData($attributeValue))
 974+ $result .= '<li>'.
 975+ '<h'. $this->headerLevel .'><span id="collapse-'. $attributeId .'" class="toggle '. addCollapsablePrefixToClass($class) .'" onclick="toggle(this, event);">' . $expansionPrefix . '&nbsp;' . $attribute->name . '</span></h'. $this->headerLevel .'>' .
 976+ '<div id="collapsable-'. $attributeId . '" class="expand-' . $class . '">' . $editor->view($idPath, $attributeValue) . '</div>' .
 977+ '</li>';
 978+
962979 $idPath->popAttribute();
963980 }
964981
@@ -1176,6 +1193,10 @@
11771194 public function add($idPath) {
11781195 return "New " . strtolower($this->attribute->name);
11791196 }
 1197+
 1198+ public function showsData($value) {
 1199+ return true;
 1200+ }
11801201 }
11811202
11821203 class RecordSpanEditor extends RecordEditor {