Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php |
— | — | @@ -133,11 +133,11 @@ |
134 | 134 | return $result; |
135 | 135 | } |
136 | 136 | |
137 | | - public function determineVisibleSuffixAttributes($value) { |
| 137 | + public function determineVisibleSuffixAttributes(IdStack $idPath, $value) { |
138 | 138 | $visibleStructures = array(); |
139 | 139 | |
140 | 140 | foreach ($this->getEditors() as $editor) { |
141 | | - $visibleStructure = $editor->getTableStructureForView($value->getAttributeValue($editor->getAttribute())); |
| 141 | + $visibleStructure = $editor->getTableStructureForView($idPath, $value->getAttributeValue($editor->getAttribute())); |
142 | 142 | |
143 | 143 | if (count($visibleStructure->getAttributes()) > 0) |
144 | 144 | $visibleStructures[] = $visibleStructure; |
— | — | @@ -165,7 +165,7 @@ |
166 | 166 | |
167 | 167 | public function view(IdStack $idPath, $value) { |
168 | 168 | $idPath->pushAnnotationAttribute($this->getAttribute()); |
169 | | - $visibleSuffixAttributes = $this->determineVisibleSuffixAttributes($value); |
| 169 | + $visibleSuffixAttributes = $this->determineVisibleSuffixAttributes($idPath, $value); |
170 | 170 | |
171 | 171 | $visibleStructure = new Structure(array_merge( |
172 | 172 | array($this->propertyAttribute, $this->valueAttribute), |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -548,7 +548,7 @@ |
549 | 549 | $this->rowHTMLAttributes = $rowHTMLAttributes; |
550 | 550 | } |
551 | 551 | |
552 | | - protected function columnShowsData(Editor $columnEditor, $value, $attributePath) { |
| 552 | + protected function columnShowsData(Editor $columnEditor, RecordSet $value, $attributePath) { |
553 | 553 | $result = false; |
554 | 554 | $recordCount = $value->getRecordCount(); |
555 | 555 | $i = 0; |
— | — | @@ -583,7 +583,7 @@ |
584 | 584 | return new Structure($attributes); |
585 | 585 | } |
586 | 586 | |
587 | | - protected function getTableStructureShowingData(Editor $editor, $value, $attributePath = array()) { |
| 587 | + protected function getTableStructureShowingData($viewOrEdit, Editor $editor, IdStack $idPath, RecordSet $value, $attributePath = array()) { |
588 | 588 | $attributes = array(); |
589 | 589 | |
590 | 590 | foreach ($editor->getEditors() as $childEditor) { |
— | — | @@ -591,12 +591,13 @@ |
592 | 592 | array_push($attributePath, $childAttribute); |
593 | 593 | |
594 | 594 | if ($childEditor instanceof RecordTableCellEditor) { |
595 | | - $type = $this->getTableStructureShowingData($childEditor, $value, $attributePath); |
| 595 | + $type = $this->getTableStructureShowingData($viewOrEdit, $childEditor, $idPath, $value, $attributePath); |
596 | 596 | |
597 | 597 | if (count($type->getAttributes()) > 0) |
598 | 598 | $attributes[] = new Attribute($childAttribute->id, $childAttribute->name, $type); |
599 | 599 | } |
600 | | - else if ($this->columnShowsData($childEditor, $value, $attributePath)) |
| 600 | + else if (($viewOrEdit == "view" && $this->columnShowsData($childEditor, $value, $attributePath)) || |
| 601 | + ($viewOrEdit == "edit") && $childEditor->showEditField($idPath)) |
601 | 602 | $attributes[] = new Attribute($childAttribute->id, $childAttribute->name, 'short-text'); |
602 | 603 | |
603 | 604 | array_pop($attributePath); |
— | — | @@ -614,7 +615,7 @@ |
615 | 616 | return $result; |
616 | 617 | } |
617 | 618 | |
618 | | - public function viewRows(IdStack $idPath, $value, Structure $visibleStructure) { |
| 619 | + public function viewRows(IdStack $idPath, RecordSet $value, Structure $visibleStructure) { |
619 | 620 | $result = ""; |
620 | 621 | $rowAttributes = $this->getRowAttributesText(); |
621 | 622 | $key = $value->getKey(); |
— | — | @@ -638,15 +639,19 @@ |
639 | 640 | return '</table>' . EOL; |
640 | 641 | } |
641 | 642 | |
642 | | - public function getTableStructureForView($value) { |
| 643 | + public function getTableStructureForView(IdStack $idPath, RecordSet $value) { |
643 | 644 | if ($this->hideEmptyColumns) |
644 | | - return $this->getTableStructureShowingData($this, $value); |
| 645 | + return $this->getTableStructureShowingData("view", $this, $idPath, $value); |
645 | 646 | else |
646 | 647 | return $this->getTableStructure($this); |
647 | 648 | } |
| 649 | + |
| 650 | + public function getTableStructureForEdit(IdStack $idPath, RecordSet $value) { |
| 651 | + return $this->getTableStructureShowingData("edit", $this, $idPath, $value); |
| 652 | + } |
648 | 653 | |
649 | 654 | public function view(IdStack $idPath, $value) { |
650 | | - $visibleStructure = $this->getTableStructureForView($value); |
| 655 | + $visibleStructure = $this->getTableStructureForView($idPath, $value); |
651 | 656 | |
652 | 657 | $result = |
653 | 658 | $this->viewHeader($idPath, $visibleStructure) . |
— | — | @@ -663,9 +668,10 @@ |
664 | 669 | $result = '<table id="'. $idPath->getId() .'" class="wiki-data-table">'; |
665 | 670 | $key = $value->getKey(); |
666 | 671 | $rowAttributes = $this->getRowAttributesText(); |
667 | | - $visibleStructure = $this->getTableStructure($this); |
| 672 | + $visibleStructure = $this->getTableStructureForEdit($idPath, $value); |
| 673 | + |
668 | 674 | $columnOffset = $this->allowRemove ? 1 : 0; |
669 | | - $headerRows = getStructureAsTableHeaderRows($this->getTableStructure($this), $columnOffset, $idPath); |
| 675 | + $headerRows = getStructureAsTableHeaderRows($visibleStructure, $columnOffset, $idPath); |
670 | 676 | |
671 | 677 | if ($this->allowRemove) |
672 | 678 | $headerRows[0] = '<th class="remove" rowspan="' . count($headerRows) . '"><img src="'.$wgStylePath.'/amethyst/delete.png" title="Mark rows to remove" alt="Remove"/></th>' . $headerRows[0]; |