Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | $this->currentClass = $prefix; |
30 | 30 | } |
31 | 31 | |
32 | | - protected function getKeyIds($record) { |
| 32 | + protected function getKeyIds(Record $record) { |
33 | 33 | $ids = array(); |
34 | 34 | |
35 | 35 | foreach($record->getStructure()->getAttributes() as $attribute) |
— | — | @@ -55,12 +55,12 @@ |
56 | 56 | $this->currentClass = array_pop($this->classStack); |
57 | 57 | } |
58 | 58 | |
59 | | - public function pushKey($record) { |
| 59 | + public function pushKey(Record $record) { |
60 | 60 | $this->keyStack->push($record); |
61 | 61 | $this->pushId(implode("-", $this->getKeyIds($record))); |
62 | 62 | } |
63 | 63 | |
64 | | - public function pushAttribute($attribute) { |
| 64 | + public function pushAttribute(Attribute $attribute) { |
65 | 65 | # FIXME: check attribute id existence |
66 | 66 | @$id=$attribute->id; |
67 | 67 | $this->pushId($id); |
— | — | @@ -90,20 +90,59 @@ |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
| 94 | +//added the "allow add controller" to be able to control the usage of the add field in different circumstances |
| 95 | +//instances of this class are used instead of the boolean "allowAdd" in the editors |
| 96 | +class AllowAddController { |
| 97 | + protected $value; |
| 98 | + |
| 99 | + public function __construct($value){ |
| 100 | + $this->value = $value; |
| 101 | + } |
| 102 | + public function check($idPath){ |
| 103 | + return $this->value; |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | +class ShowEditFieldChecker { |
| 108 | + protected $value; |
| 109 | + |
| 110 | + public function __construct($value) { |
| 111 | + $this->value = $value; |
| 112 | + } |
| 113 | + |
| 114 | + public function check(IdStack $idPath) { |
| 115 | + return $this->value; |
| 116 | + } |
| 117 | +} |
| 118 | + |
| 119 | +class ShowEditFieldForClassesChecker extends ShowEditFieldChecker{ |
| 120 | + protected $objectIdAttributeLevel; |
| 121 | + protected $objectIdAttribute; |
| 122 | + |
| 123 | + public function __construct($objectIdAttributeLevel, Attribute $objectIdAttribute) { |
| 124 | + $this->objectIdAttributeLevel = $objectIdAttributeLevel; |
| 125 | + $this->objectIdAttribute = $objectIdAttribute; |
| 126 | + } |
| 127 | + public function check(IdStack $idPath) { |
| 128 | + $objectId = $idPath->getKeyStack()->peek($this->objectIdAttributeLevel)->getAttributeValue($this->objectIdAttribute); |
| 129 | + return isClass($objectId); |
| 130 | + } |
| 131 | +} |
| 132 | + |
94 | 133 | interface Editor { |
95 | 134 | public function getAttribute(); |
96 | 135 | public function getUpdateAttribute(); |
97 | 136 | public function getAddAttribute(); |
98 | 137 | |
99 | 138 | public function showsData($value); |
100 | | - public function view($idPath, $value); |
101 | | - public function showEditField($idPath); |
102 | | - public function edit($idPath, $value); |
103 | | - public function add($idPath); |
104 | | - public function save($idPath, $value); |
| 139 | + public function view(IdStack $idPath, $value); |
| 140 | + public function showEditField(IdStack $idPath); |
| 141 | + public function edit(IdStack $idPath, $value); |
| 142 | + public function add(IdStack $idPath); |
| 143 | + public function save(IdStack $idPath, $value); |
105 | 144 | |
106 | | - public function getUpdateValue($idPath); |
107 | | - public function getAddValue($idPath); |
| 145 | + public function getUpdateValue(IdStack $idPath); |
| 146 | + public function getAddValue(IdStack $idPath); |
108 | 147 | |
109 | 148 | public function getEditors(); |
110 | 149 | } |
— | — | @@ -113,11 +152,11 @@ |
114 | 153 | protected $editors = array(); |
115 | 154 | protected $attribute; |
116 | 155 | |
117 | | - public function __construct($attribute) { |
| 156 | + public function __construct(Attribute $attribute = null) { |
118 | 157 | $this->attribute = $attribute; |
119 | 158 | } |
120 | 159 | |
121 | | - public function addEditor($editor) { |
| 160 | + public function addEditor(Editor $editor) { |
122 | 161 | $this->editors[] = $editor; |
123 | 162 | } |
124 | 163 | |
— | — | @@ -166,25 +205,25 @@ |
167 | 206 | return null; |
168 | 207 | } |
169 | 208 | |
170 | | - public function edit($idPath, $value) { |
| 209 | + public function edit(IdStack $idPath, $value) { |
171 | 210 | return $this->view($idPath, $value); |
172 | 211 | } |
173 | 212 | |
174 | | - public function add($idPath) { |
| 213 | + public function add(IdStack $idPath) { |
175 | 214 | } |
176 | 215 | |
177 | | - public function save($idPath, $value) { |
| 216 | + public function save(IdStack $idPath, $value) { |
178 | 217 | } |
179 | 218 | |
180 | | - public function getUpdateValue($idPath) { |
| 219 | + public function getUpdateValue(IdStack $idPath) { |
181 | 220 | return null; |
182 | 221 | } |
183 | 222 | |
184 | | - public function getAddValue($idPath) { |
| 223 | + public function getAddValue(IdStack $idPath) { |
185 | 224 | return null; |
186 | 225 | } |
187 | 226 | |
188 | | - public function showEditField($idPath) { |
| 227 | + public function showEditField(IdStack $idPath) { |
189 | 228 | return true; |
190 | 229 | } |
191 | 230 | } |
— | — | @@ -197,7 +236,7 @@ |
198 | 237 | protected $isAddField; |
199 | 238 | protected $controller; |
200 | 239 | |
201 | | - public function __construct($attribute, $permissionController, $showEditFieldChecker, $allowAddController, $allowRemove, $isAddField, $controller) { |
| 240 | + public function __construct(Attribute $attribute = null, PermissionController $permissionController, ShowEditFieldChecker $showEditFieldChecker, AllowAddController $allowAddController, $allowRemove, $isAddField, UpdateController $controller = null) { |
202 | 241 | parent::__construct($attribute); |
203 | 242 | |
204 | 243 | $this->permissionController = $permissionController; |
— | — | @@ -208,7 +247,7 @@ |
209 | 248 | $this->controller = $controller; |
210 | 249 | } |
211 | 250 | |
212 | | - public function getAddValue($idPath) { |
| 251 | + public function getAddValue(IdStack $idPath) { |
213 | 252 | $addStructure = $this->getAddStructure(); |
214 | 253 | |
215 | 254 | if (count($addStructure->getAttributes()) > 0) { |
— | — | @@ -230,7 +269,7 @@ |
231 | 270 | return null; |
232 | 271 | } |
233 | 272 | |
234 | | - protected function saveRecord($idPath, $record) { |
| 273 | + protected function saveRecord(IdStack $idPath, Record $record) { |
235 | 274 | foreach($this->editors as $editor) { |
236 | 275 | $attribute = $editor->getAttribute(); |
237 | 276 | $value = $record->getAttributeValue($attribute); |
— | — | @@ -240,7 +279,7 @@ |
241 | 280 | } |
242 | 281 | } |
243 | 282 | |
244 | | - protected function updateRecord($idPath, $record, $structure, $editors) { |
| 283 | + protected function updateRecord(IdStack $idPath, Record $record, Structure $structure, $editors) { |
245 | 284 | if (count($editors) > 0) { |
246 | 285 | $updateRecord = $this->getUpdateRecord($idPath, $structure, $editors); |
247 | 286 | |
— | — | @@ -249,7 +288,7 @@ |
250 | 289 | } |
251 | 290 | } |
252 | 291 | |
253 | | - protected function removeRecord($idPath) { |
| 292 | + protected function removeRecord(IdStack $idPath) { |
254 | 293 | global |
255 | 294 | $wgRequest; |
256 | 295 | |
— | — | @@ -270,7 +309,7 @@ |
271 | 310 | return new Structure($attributes); |
272 | 311 | } |
273 | 312 | |
274 | | - public function getUpdateValue($idPath) { |
| 313 | + public function getUpdateValue(IdStack $idPath) { |
275 | 314 | return null; |
276 | 315 | } |
277 | 316 | |
— | — | @@ -314,7 +353,7 @@ |
315 | 354 | return $addEditors; |
316 | 355 | } |
317 | 356 | |
318 | | - public function getAddRecord($idPath, $structure, $editors) { |
| 357 | + public function getAddRecord(IdStack $idPath, Structure $structure, $editors) { |
319 | 358 | $result = new ArrayRecord($structure); |
320 | 359 | |
321 | 360 | foreach($editors as $editor) |
— | — | @@ -327,7 +366,7 @@ |
328 | 367 | return $result; |
329 | 368 | } |
330 | 369 | |
331 | | - public function getUpdateRecord($idPath, $structure, $editors) { |
| 370 | + public function getUpdateRecord(IdStack $idPath, Structure $structure, $editors) { |
332 | 371 | $result = new ArrayRecord($structure); |
333 | 372 | |
334 | 373 | foreach($editors as $editor) |
— | — | @@ -340,7 +379,7 @@ |
341 | 380 | return $result; |
342 | 381 | } |
343 | 382 | |
344 | | - public function save($idPath, $value) { |
| 383 | + public function save(IdStack $idPath, $value) { |
345 | 384 | if ($this->allowAddController->check($idPath) && $this->controller != null) { |
346 | 385 | $addStructure = $this->getAddStructure(); |
347 | 386 | |
— | — | @@ -390,7 +429,7 @@ |
391 | 430 | return $value->getRecordCount() > 0; |
392 | 431 | } |
393 | 432 | |
394 | | - public function showEditField($idPath) { |
| 433 | + public function showEditField(IdStack $idPath) { |
395 | 434 | return $this->showEditFieldChecker->check($idPath); |
396 | 435 | } |
397 | 436 | } |
— | — | @@ -413,7 +452,7 @@ |
414 | 453 | $this->rowHTMLAttributes = $rowHTMLAttributes; |
415 | 454 | } |
416 | 455 | |
417 | | - protected function columnShowsData($columnEditor, $value, $attributePath) { |
| 456 | + protected function columnShowsData(Editor $columnEditor, $value, $attributePath) { |
418 | 457 | $result = false; |
419 | 458 | $recordCount = $value->getRecordCount(); |
420 | 459 | $i = 0; |
— | — | @@ -431,7 +470,7 @@ |
432 | 471 | return $result; |
433 | 472 | } |
434 | 473 | |
435 | | - protected function getColumnEditorsShowingData($editor, $value, $attributePath = array()) { |
| 474 | + protected function getColumnEditorsShowingData(Editor $editor, $value, $attributePath = array()) { |
436 | 475 | $result = array(); |
437 | 476 | |
438 | 477 | foreach ($editor->getEditors() as $childEditor) { |
— | — | @@ -454,7 +493,7 @@ |
455 | 494 | return $result; |
456 | 495 | } |
457 | 496 | |
458 | | - protected function getAllColumnEditors($editor, $value) { |
| 497 | + protected function getAllColumnEditors(Editor $editor, $value) { |
459 | 498 | $result = array(); |
460 | 499 | |
461 | 500 | foreach ($editor->getEditors() as $childEditor) { |
— | — | @@ -469,7 +508,7 @@ |
470 | 509 | return $result; |
471 | 510 | } |
472 | 511 | |
473 | | - public function view($idPath, $value) { |
| 512 | + public function view(IdStack $idPath, $value) { |
474 | 513 | $result = '<table id="'. $idPath->getId() .'" class="wiki-data-table">'; |
475 | 514 | $structure = $value->getStructure(); |
476 | 515 | $key = $value->getKey(); |
— | — | @@ -501,7 +540,7 @@ |
502 | 541 | return $result; |
503 | 542 | } |
504 | 543 | |
505 | | - public function edit($idPath, $value) { |
| 544 | + public function edit(IdStack $idPath, $value) { |
506 | 545 | global |
507 | 546 | $wgStylePath; |
508 | 547 | |
— | — | @@ -558,7 +597,7 @@ |
559 | 598 | return $result; |
560 | 599 | } |
561 | 600 | |
562 | | - public function add($idPath) { |
| 601 | + public function add(IdStack $idPath) { |
563 | 602 | if ($this->isAddField) { |
564 | 603 | $result = '<table id="'. $idPath->getId() .'" class="wiki-data-table">'; |
565 | 604 | $headerRows = getStructureAsTableHeaderRows($this->getAddStructure(), 0, $idPath); |
— | — | @@ -578,7 +617,7 @@ |
579 | 618 | return ""; |
580 | 619 | } |
581 | 620 | |
582 | | - function getAddRowAsHTML($idPath, $repeatInput, $allowRemove) { |
| 621 | + function getAddRowAsHTML(IdStack $idPath, $repeatInput, $allowRemove) { |
583 | 622 | global |
584 | 623 | $wgScriptPath; |
585 | 624 | |
— | — | @@ -601,7 +640,7 @@ |
602 | 641 | return $result . '</tr>' . EOL; |
603 | 642 | } |
604 | 643 | |
605 | | - public function getTableStructure($editor, $visibleColumnEditors) { |
| 644 | + public function getTableStructure(Editor $editor, $visibleColumnEditors) { |
606 | 645 | $attributes = array(); |
607 | 646 | |
608 | 647 | foreach($editor->getEditors() as $childEditor) { |
— | — | @@ -646,7 +685,7 @@ |
647 | 686 | return new Structure($attributes); |
648 | 687 | } |
649 | 688 | |
650 | | - public function getUpdateValue($idPath) { |
| 689 | + public function getUpdateValue(IdStack $idPath) { |
651 | 690 | $result = new ArrayRecord($this->getUpdateStructure()); |
652 | 691 | |
653 | 692 | foreach($this->editors as $editor) |
— | — | @@ -659,7 +698,7 @@ |
660 | 699 | return $result; |
661 | 700 | } |
662 | 701 | |
663 | | - public function getAddValue($idPath) { |
| 702 | + public function getAddValue(IdStack $idPath) { |
664 | 703 | $result = new ArrayRecord($this->getAddStructure()); |
665 | 704 | |
666 | 705 | foreach($this->editors as $editor) |
— | — | @@ -690,7 +729,7 @@ |
691 | 730 | return null; |
692 | 731 | } |
693 | 732 | |
694 | | - public function save($idPath, $value) { |
| 733 | + public function save(IdStack $idPath, $value) { |
695 | 734 | foreach($this->editors as $editor) { |
696 | 735 | $attribute = $editor->getAttribute(); |
697 | 736 | $idPath->pushAttribute($attribute); |
— | — | @@ -712,22 +751,22 @@ |
713 | 752 | return $result; |
714 | 753 | } |
715 | 754 | |
716 | | - public function showEditField($idPath) { |
| 755 | + public function showEditField(IdStack $idPath) { |
717 | 756 | return true; |
718 | 757 | } |
719 | 758 | } |
720 | 759 | |
721 | 760 | class RecordTableCellEditor extends RecordEditor { |
722 | | - public function view($idPath, $value) { |
| 761 | + public function view(IdStack $idPath, $value) { |
723 | 762 | } |
724 | 763 | |
725 | | - public function edit($idPath, $value) { |
| 764 | + public function edit(IdStack $idPath, $value) { |
726 | 765 | } |
727 | 766 | |
728 | | - public function add($idPath) { |
| 767 | + public function add(IdStack $idPath) { |
729 | 768 | } |
730 | 769 | |
731 | | - public function save($idPath, $value) { |
| 770 | + public function save(IdStack $idPath, $value) { |
732 | 771 | } |
733 | 772 | } |
734 | 773 | |
— | — | @@ -736,7 +775,7 @@ |
737 | 776 | protected $permissionController; |
738 | 777 | protected $isAddField; |
739 | 778 | |
740 | | - public function __construct($attribute, $permissionController, $isAddField) { |
| 779 | + public function __construct(Attribute $attribute = null, PermissionController $permissionController, $isAddField) { |
741 | 780 | parent::__construct($attribute); |
742 | 781 | |
743 | 782 | $this->permissionController = $permissionController; |
— | — | @@ -751,7 +790,7 @@ |
752 | 791 | return "update-" . $id; |
753 | 792 | } |
754 | 793 | |
755 | | - public function save($idPath, $value) { |
| 794 | + public function save(IdStack $idPath, $value) { |
756 | 795 | } |
757 | 796 | |
758 | 797 | public function getUpdateAttribute() { |
— | — | @@ -768,23 +807,23 @@ |
769 | 808 | return null; |
770 | 809 | } |
771 | 810 | |
772 | | - public abstract function getViewHTML($idPath, $value); |
773 | | - public abstract function getEditHTML($idPath, $value); |
| 811 | + public abstract function getViewHTML(IdStack $idPath, $value); |
| 812 | + public abstract function getEditHTML(IdStack $idPath, $value); |
774 | 813 | public abstract function getInputValue($id); |
775 | 814 | |
776 | | - public function getUpdateValue($idPath) { |
| 815 | + public function getUpdateValue(IdStack $idPath) { |
777 | 816 | return $this->getInputValue("update-" . $idPath->getId()); |
778 | 817 | } |
779 | 818 | |
780 | | - public function getAddValue($idPath) { |
| 819 | + public function getAddValue(IdStack $idPath) { |
781 | 820 | return $this->getInputValue("add-" . $idPath->getId()); |
782 | 821 | } |
783 | 822 | |
784 | | - public function view($idPath, $value) { |
| 823 | + public function view(IdStack $idPath, $value) { |
785 | 824 | return $this->getViewHTML($idPath, $value); |
786 | 825 | } |
787 | 826 | |
788 | | - public function edit($idPath, $value) { |
| 827 | + public function edit(IdStack $idPath, $value) { |
789 | 828 | if ($this->permissionController->allowUpdateOfValue($idPath, $value)) |
790 | 829 | return $this->getEditHTML($idPath, $value); |
791 | 830 | else |
— | — | @@ -795,21 +834,21 @@ |
796 | 835 | return ($value != null) && (trim($value) != ""); |
797 | 836 | } |
798 | 837 | |
799 | | - public function showEditField($idPath) { |
| 838 | + public function showEditField(IdStack $idPath) { |
800 | 839 | return true; |
801 | 840 | } |
802 | 841 | } |
803 | 842 | |
804 | 843 | class LanguageEditor extends ScalarEditor { |
805 | | - public function getViewHTML($idPath, $value) { |
| 844 | + public function getViewHTML(IdStack $idPath, $value) { |
806 | 845 | return languageIdAsText($value); |
807 | 846 | } |
808 | 847 | |
809 | | - public function getEditHTML($idPath, $value) { |
| 848 | + public function getEditHTML(IdStack $idPath, $value) { |
810 | 849 | return getSuggest($this->updateId($idPath->getId()), "language"); |
811 | 850 | } |
812 | 851 | |
813 | | - public function add($idPath) { |
| 852 | + public function add(IdStack $idPath) { |
814 | 853 | return getSuggest($this->addId($idPath->getId()), "language"); |
815 | 854 | } |
816 | 855 | |
— | — | @@ -826,15 +865,15 @@ |
827 | 866 | } |
828 | 867 | |
829 | 868 | class SpellingEditor extends ScalarEditor { |
830 | | - public function getViewHTML($idPath, $value) { |
| 869 | + public function getViewHTML(IdStack $idPath, $value) { |
831 | 870 | return spellingAsLink($value); |
832 | 871 | } |
833 | 872 | |
834 | | - public function getEditHTML($idPath, $value) { |
| 873 | + public function getEditHTML(IdStack $idPath, $value) { |
835 | 874 | return getTextBox($this->updateId($idPath->getId())); |
836 | 875 | } |
837 | 876 | |
838 | | - public function add($idPath) { |
| 877 | + public function add(IdStack $idPath) { |
839 | 878 | if ($this->isAddField) |
840 | 879 | return getTextBox($this->addId($idPath->getId())); |
841 | 880 | else |
— | — | @@ -861,7 +900,7 @@ |
862 | 901 | $this->truncateAt = $truncateAt; |
863 | 902 | } |
864 | 903 | |
865 | | - public function getViewHTML($idPath, $value) { |
| 904 | + public function getViewHTML(IdStack $idPath, $value) { |
866 | 905 | $definition = getDefinedMeaningDefinition($value); |
867 | 906 | $definedMeaningAsLink = definedMeaningAsLink($value); |
868 | 907 | $escapedDefinition = htmlspecialchars($definition); |
— | — | @@ -872,11 +911,11 @@ |
873 | 912 | return $definedMeaningAsLink . ": " . $escapedDefinition; |
874 | 913 | } |
875 | 914 | |
876 | | - public function getEditHTML($idPath, $value) { |
| 915 | + public function getEditHTML(IdStack $idPath, $value) { |
877 | 916 | return ""; |
878 | 917 | } |
879 | 918 | |
880 | | - public function add($idPath) { |
| 919 | + public function add(IdStack $idPath) { |
881 | 920 | if ($this->isAddField) |
882 | 921 | return getTextArea($this->addId($idPath->getId()), "", 3); |
883 | 922 | else |
— | — | @@ -901,7 +940,7 @@ |
902 | 941 | protected $addText = ""; |
903 | 942 | protected $controller; |
904 | 943 | |
905 | | - public function __construct($attribute, $permissionController, $isAddField, $truncate=false, $truncateAt=0, $controller=null) { |
| 944 | + public function __construct(Attribute $attribute = null, PermissionController $permissionController, $isAddField, $truncate=false, $truncateAt=0, UpdateController $controller = null) { |
906 | 945 | parent::__construct($attribute, $permissionController, $isAddField); |
907 | 946 | |
908 | 947 | $this->truncate = $truncate; |
— | — | @@ -909,7 +948,7 @@ |
910 | 949 | $this->controller = $controller; |
911 | 950 | } |
912 | 951 | |
913 | | - public function getViewHTML($idPath, $value) { |
| 952 | + public function getViewHTML(IdStack $idPath, $value) { |
914 | 953 | $escapedValue = htmlspecialchars($value); |
915 | 954 | |
916 | 955 | // global $wgParser, $wgTitle, $wgOut; |
— | — | @@ -921,11 +960,11 @@ |
922 | 961 | return '<span title="'. $escapedValue .'">'. htmlspecialchars(substr($value, 0, $this->truncateAt)) . '...</span>' . EOL; |
923 | 962 | } |
924 | 963 | |
925 | | - public function getEditHTML($idPath, $value) { |
| 964 | + public function getEditHTML(IdStack $idPath, $value) { |
926 | 965 | return getTextArea($this->updateId($idPath->getId()), $value, 3); |
927 | 966 | } |
928 | 967 | |
929 | | - public function add($idPath) { |
| 968 | + public function add(IdStack $idPath) { |
930 | 969 | if ($this->isAddField) |
931 | 970 | return getTextArea($this->addId($idPath->getId()), "", 3); |
932 | 971 | else |
— | — | @@ -943,7 +982,7 @@ |
944 | 983 | $this->addText = $addText; |
945 | 984 | } |
946 | 985 | |
947 | | - public function save($idPath, $value) { |
| 986 | + public function save(IdStack $idPath, $value) { |
948 | 987 | if ($this->controller != null) { |
949 | 988 | $inputValue = $this->getInputValue($this->updateId($idPath->getId())); |
950 | 989 | |
— | — | @@ -954,15 +993,15 @@ |
955 | 994 | } |
956 | 995 | |
957 | 996 | class ShortTextEditor extends ScalarEditor { |
958 | | - public function getViewHTML($idPath, $value) { |
| 997 | + public function getViewHTML(IdStack $idPath, $value) { |
959 | 998 | return htmlspecialchars($value); |
960 | 999 | } |
961 | 1000 | |
962 | | - public function getEditHTML($idPath, $value) { |
| 1001 | + public function getEditHTML(IdStack $idPath, $value) { |
963 | 1002 | return getTextBox($this->updateId($idPath->getId()), $value); |
964 | 1003 | } |
965 | 1004 | |
966 | | - public function add($idPath) { |
| 1005 | + public function add(IdStack $idPath) { |
967 | 1006 | if ($this->isAddField) |
968 | 1007 | return getTextBox($this->addId($idPath->getId()), ""); |
969 | 1008 | else |
— | — | @@ -978,7 +1017,7 @@ |
979 | 1018 | } |
980 | 1019 | |
981 | 1020 | class URLEditor extends ShortTextEditor { |
982 | | - public function getViewHTML($idPath, $value) { |
| 1021 | + public function getViewHTML(IdStack $idPath, $value) { |
983 | 1022 | global |
984 | 1023 | $escapedValue; |
985 | 1024 | |
— | — | @@ -991,21 +1030,21 @@ |
992 | 1031 | class BooleanEditor extends ScalarEditor { |
993 | 1032 | protected $defaultValue; |
994 | 1033 | |
995 | | - public function __construct($attribute, $permissionController, $isAddField, $defaultValue) { |
| 1034 | + public function __construct(Attribute $attribute = null, PermissionController $permissionController, $isAddField, $defaultValue) { |
996 | 1035 | parent::__construct($attribute, $permissionController, $isAddField); |
997 | 1036 | |
998 | 1037 | $this->defaultValue = $defaultValue; |
999 | 1038 | } |
1000 | 1039 | |
1001 | | - public function getViewHTML($idPath, $value) { |
| 1040 | + public function getViewHTML(IdStack $idPath, $value) { |
1002 | 1041 | return booleanAsHTML($value); |
1003 | 1042 | } |
1004 | 1043 | |
1005 | | - public function getEditHTML($idPath, $value) { |
| 1044 | + public function getEditHTML(IdStack $idPath, $value) { |
1006 | 1045 | return getCheckBox($this->updateId($idPath->getId()), $value); |
1007 | 1046 | } |
1008 | 1047 | |
1009 | | - public function add($idPath) { |
| 1048 | + public function add(IdStack $idPath) { |
1010 | 1049 | if ($this->isAddField) |
1011 | 1050 | return getCheckBox($this->addId($idPath->getId()), $this->defaultValue); |
1012 | 1051 | else |
— | — | @@ -1021,7 +1060,7 @@ |
1022 | 1061 | } |
1023 | 1062 | |
1024 | 1063 | abstract class SuggestEditor extends ScalarEditor { |
1025 | | - public function add($idPath) { |
| 1064 | + public function add(IdStack $idPath) { |
1026 | 1065 | if ($this->isAddField) |
1027 | 1066 | return getSuggest($this->addId($idPath->getId()), $this->suggestType()); |
1028 | 1067 | else |
— | — | @@ -1030,7 +1069,7 @@ |
1031 | 1070 | |
1032 | 1071 | protected abstract function suggestType(); |
1033 | 1072 | |
1034 | | - public function getEditHTML($idPath, $value) { |
| 1073 | + public function getEditHTML(IdStack $idPath, $value) { |
1035 | 1074 | return getSuggest($this->updateId($idPath->getId()), $this->suggestType()); |
1036 | 1075 | } |
1037 | 1076 | |
— | — | @@ -1047,7 +1086,7 @@ |
1048 | 1087 | return "defined-meaning"; |
1049 | 1088 | } |
1050 | 1089 | |
1051 | | - public function getViewHTML($idPath, $value) { |
| 1090 | + public function getViewHTML(IdStack $idPath, $value) { |
1052 | 1091 | global |
1053 | 1092 | $definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute; |
1054 | 1093 | $definedMeaningId = $value->getAttributeValue($definedMeaningIdAttribute); |
— | — | @@ -1063,7 +1102,7 @@ |
1064 | 1103 | return "class-attributes-level"; |
1065 | 1104 | } |
1066 | 1105 | |
1067 | | - public function getViewHTML($idPath, $value) { |
| 1106 | + public function getViewHTML(IdStack $idPath, $value) { |
1068 | 1107 | global |
1069 | 1108 | $definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute; |
1070 | 1109 | |
— | — | @@ -1078,19 +1117,19 @@ |
1079 | 1118 | abstract class SelectEditor extends ScalarEditor { |
1080 | 1119 | protected abstract function getOptions(); |
1081 | 1120 | |
1082 | | - public function add($idPath) { |
| 1121 | + public function add(IdStack $idPath) { |
1083 | 1122 | if ($this->isAddField) |
1084 | 1123 | return getSelect($this->addId($idPath->getId()), $this->getOptions()); |
1085 | 1124 | else |
1086 | 1125 | return ""; |
1087 | 1126 | } |
1088 | 1127 | |
1089 | | - public function getViewHTML($idPath, $value) { |
| 1128 | + public function getViewHTML(IdStack $idPath, $value) { |
1090 | 1129 | $options = $this->getOptions(); |
1091 | 1130 | return $options[$value]; |
1092 | 1131 | } |
1093 | 1132 | |
1094 | | - public function getEditHTML($idPath, $value) { |
| 1133 | + public function getEditHTML(IdStack $idPath, $value) { |
1095 | 1134 | return getSelect($this->addId($idPath->getId()), $this->getOptions()); |
1096 | 1135 | } |
1097 | 1136 | |
— | — | @@ -1119,7 +1158,7 @@ |
1120 | 1159 | return array(); |
1121 | 1160 | } |
1122 | 1161 | |
1123 | | - public function getViewHTML($idPath, $value) { |
| 1162 | + public function getViewHTML(IdStack $idPath, $value) { |
1124 | 1163 | global |
1125 | 1164 | $definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute; |
1126 | 1165 | |
— | — | @@ -1153,14 +1192,14 @@ |
1154 | 1193 | protected $attributesLevelName; |
1155 | 1194 | protected $objectIdFetcher; |
1156 | 1195 | |
1157 | | - public function __construct($attribute, $permissionController, $isAddField, $attributesLevelName, Fetcher $objectIdFetcher) { |
| 1196 | + public function __construct(Attribute $attribute = null, PermissionController $permissionController, $isAddField, $attributesLevelName, Fetcher $objectIdFetcher) { |
1158 | 1197 | parent::__construct($attribute, $permissionController, $isAddField); |
1159 | 1198 | |
1160 | 1199 | $this->attributesLevelName = $attributesLevelName; |
1161 | 1200 | $this->objectIdFetcher = $objectIdFetcher; |
1162 | 1201 | } |
1163 | 1202 | |
1164 | | - public function add($idPath) { |
| 1203 | + public function add(IdStack $idPath) { |
1165 | 1204 | if ($this->isAddField) { |
1166 | 1205 | $parameters = array( |
1167 | 1206 | "attributesLevel" => $this->attributesLevelName, |
— | — | @@ -1173,7 +1212,7 @@ |
1174 | 1213 | return ""; |
1175 | 1214 | } |
1176 | 1215 | |
1177 | | - public function getEditHTML($idPath, $value) { |
| 1216 | + public function getEditHTML(IdStack $idPath, $value) { |
1178 | 1217 | $parameters = array("attributesLevel" => $this->attributesLevelName); |
1179 | 1218 | return getSuggest($this->updateId($idPath->getId()), $this->suggestType(), $parameters); |
1180 | 1219 | } |
— | — | @@ -1202,7 +1241,7 @@ |
1203 | 1242 | return 'option-attribute'; |
1204 | 1243 | } |
1205 | 1244 | |
1206 | | - public function add($idPath) { |
| 1245 | + public function add(IdStack $idPath) { |
1207 | 1246 | if ($this->isAddField) { |
1208 | 1247 | global |
1209 | 1248 | $syntransIdAttribute; |
— | — | @@ -1219,7 +1258,7 @@ |
1220 | 1259 | return ''; |
1221 | 1260 | } |
1222 | 1261 | |
1223 | | - public function getEditHTML($idPath, $value) { |
| 1262 | + public function getEditHTML(IdStack $idPath, $value) { |
1224 | 1263 | $parameters = array( |
1225 | 1264 | 'attributesLevel' => $this->attributesLevelName, |
1226 | 1265 | 'onUpdate' => 'updateSelectOptions(\'' . $this->updateId($idPath->getId()) . '-option\'' |
— | — | @@ -1234,7 +1273,7 @@ |
1235 | 1274 | protected $headerLevel = 1; |
1236 | 1275 | protected $htmlTag; |
1237 | 1276 | |
1238 | | - public function __construct($attribute, $headerLevel, $htmlTag) { |
| 1277 | + public function __construct(Attribute $attribute = null, $headerLevel, $htmlTag) { |
1239 | 1278 | parent::__construct($attribute); |
1240 | 1279 | |
1241 | 1280 | $this->htmlTag = $htmlTag; |
— | — | @@ -1256,7 +1295,7 @@ |
1257 | 1296 | return $result; |
1258 | 1297 | } |
1259 | 1298 | |
1260 | | - public function view($idPath, $value) { |
| 1299 | + public function view(IdStack $idPath, $value) { |
1261 | 1300 | $result = ''; |
1262 | 1301 | foreach ($this->editors as $editor) { |
1263 | 1302 | $attribute = $editor->getAttribute(); |
— | — | @@ -1276,11 +1315,11 @@ |
1277 | 1316 | return $result; |
1278 | 1317 | } |
1279 | 1318 | |
1280 | | - public function showEditField($idPath) { |
| 1319 | + public function showEditField(IdStack $idPath) { |
1281 | 1320 | return true; |
1282 | 1321 | } |
1283 | 1322 | |
1284 | | - public function edit($idPath, $value) { |
| 1323 | + public function edit(IdStack $idPath, $value) { |
1285 | 1324 | $result = ''; |
1286 | 1325 | foreach ($this->editors as $editor) { |
1287 | 1326 | $attribute = $editor->getAttribute(); |
— | — | @@ -1300,7 +1339,7 @@ |
1301 | 1340 | return $result; |
1302 | 1341 | } |
1303 | 1342 | |
1304 | | - public function add($idPath) { |
| 1343 | + public function add(IdStack $idPath) { |
1305 | 1344 | $result = ''; |
1306 | 1345 | foreach($this->editors as $editor) { |
1307 | 1346 | if ($attribute = $editor->getAddAttribute()) { |
— | — | @@ -1320,35 +1359,35 @@ |
1321 | 1360 | return $result; |
1322 | 1361 | } |
1323 | 1362 | |
1324 | | - protected function childHeader($editor, $attribute, $class, $attributeId){ |
| 1363 | + protected function childHeader(Editor $editor, Attribute $attribute, $class, $attributeId){ |
1325 | 1364 | $expansionPrefix = $this->getExpansionPrefix($class, $attributeId); |
1326 | 1365 | $this->setExpansionByEditor($editor, $class); |
1327 | 1366 | return '<h'. $this->headerLevel .'><span id="collapse-'. $attributeId .'" class="toggle '. addCollapsablePrefixToClass($class) .'" onclick="toggle(this, event);">' . $expansionPrefix . ' ' . $attribute->name . '</span></h'. $this->headerLevel .'>' . EOL; |
1328 | 1367 | } |
1329 | 1368 | |
1330 | | - protected function viewChild($editor, $idPath, $value, $attribute, $class, $attributeId){ |
| 1369 | + protected function viewChild(Editor $editor, IdStack $idPath, $value, Attribute $attribute, $class, $attributeId){ |
1331 | 1370 | return '<div id="collapsable-'. $attributeId . '" class="expand-' . $class . '">' . $editor->view($idPath, $value->getAttributeValue($attribute)) . '</div>' . EOL; |
1332 | 1371 | } |
1333 | 1372 | |
1334 | | - protected function editChild($editor, $idPath, $value, $attribute, $class, $attributeId) { |
| 1373 | + protected function editChild(Editor $editor, IdStack $idPath, $value, Attribute $attribute, $class, $attributeId) { |
1335 | 1374 | return '<div id="collapsable-'. $attributeId . '" class="expand-' . $class . '">' . $editor->edit($idPath, $value->getAttributeValue($attribute)) . '</div>' . EOL; |
1336 | 1375 | } |
1337 | 1376 | |
1338 | | - protected function addChild($editor, $idPath, $attribute, $class, $attributeId) { |
| 1377 | + protected function addChild(Editor $editor, IdStack $idPath, Attribute $attribute, $class, $attributeId) { |
1339 | 1378 | return '<div id="collapsable-'. $attributeId . '" class="expand-' . $class . '">' . $editor->add($idPath) . '</div>' . EOL; |
1340 | 1379 | } |
1341 | 1380 | |
1342 | | - public function expandEditor($editor) { |
| 1381 | + public function expandEditor(Editor $editor) { |
1343 | 1382 | $this->expandedEditors[] = $editor; |
1344 | 1383 | } |
1345 | 1384 | |
1346 | | - public function setExpansionByEditor($editor, $elementType) { |
| 1385 | + public function setExpansionByEditor(Editor $editor, $elementType) { |
1347 | 1386 | $this->setExpansion(in_array($editor, $this->expandedEditors, true), $elementType); |
1348 | 1387 | } |
1349 | 1388 | } |
1350 | 1389 | |
1351 | 1390 | class RecordUnorderedListEditor extends RecordListEditor { |
1352 | | - public function __construct($attribute, $headerLevel) { |
| 1391 | + public function __construct(Attribute $attribute = null, $headerLevel) { |
1353 | 1392 | parent::__construct($attribute, $headerLevel, "li"); |
1354 | 1393 | } |
1355 | 1394 | |
— | — | @@ -1360,21 +1399,21 @@ |
1361 | 1400 | return ""; |
1362 | 1401 | } |
1363 | 1402 | |
1364 | | - public function view($idPath, $value) { |
| 1403 | + public function view(IdStack $idPath, $value) { |
1365 | 1404 | return $this->wrapInList(parent::view($idPath, $value)); |
1366 | 1405 | } |
1367 | 1406 | |
1368 | | - public function edit($idPath, $value) { |
| 1407 | + public function edit(IdStack $idPath, $value) { |
1369 | 1408 | return $this->wrapInList(parent::edit($idPath, $value)); |
1370 | 1409 | } |
1371 | 1410 | |
1372 | | - public function add($idPath) { |
| 1411 | + public function add(IdStack $idPath) { |
1373 | 1412 | return $this->wrapInList(parent::add($idPath)); |
1374 | 1413 | } |
1375 | 1414 | } |
1376 | 1415 | |
1377 | 1416 | class RecordDivListEditor extends RecordListEditor { |
1378 | | - public function __construct($attribute) { |
| 1417 | + public function __construct(Attribute $attribute = null) { |
1379 | 1418 | parent::__construct($attribute, 0, "div"); |
1380 | 1419 | } |
1381 | 1420 | |
— | — | @@ -1382,19 +1421,19 @@ |
1383 | 1422 | return '<div>' . $listItems . '</div>'; |
1384 | 1423 | } |
1385 | 1424 | |
1386 | | - public function view($idPath, $value) { |
| 1425 | + public function view(IdStack $idPath, $value) { |
1387 | 1426 | return $this->wrapInDiv(parent::view($idPath, $value)); |
1388 | 1427 | } |
1389 | 1428 | |
1390 | | - public function edit($idPath, $value) { |
| 1429 | + public function edit(IdStack $idPath, $value) { |
1391 | 1430 | return $this->wrapInDiv(parent::edit($idPath, $value)); |
1392 | 1431 | } |
1393 | 1432 | |
1394 | | - public function add($idPath) { |
| 1433 | + public function add(IdStack $idPath) { |
1395 | 1434 | return $this->wrapInDiv(parent::add($idPath)); |
1396 | 1435 | } |
1397 | 1436 | |
1398 | | - protected function childHeader($editor, $attribute, $class, $attributeId){ |
| 1437 | + protected function childHeader(Editor $editor, Attribute $attribute, $class, $attributeId){ |
1399 | 1438 | return ""; |
1400 | 1439 | } |
1401 | 1440 | } |
— | — | @@ -1402,7 +1441,7 @@ |
1403 | 1442 | class WrappingEditor implements Editor { |
1404 | 1443 | protected $wrappedEditor; |
1405 | 1444 | |
1406 | | - public function __construct($wrappedEditor) { |
| 1445 | + public function __construct(Editor $wrappedEditor) { |
1407 | 1446 | $this->wrappedEditor = $wrappedEditor; |
1408 | 1447 | } |
1409 | 1448 | |
— | — | @@ -1422,31 +1461,31 @@ |
1423 | 1462 | return $this->wrappedEditor->showsData($value); |
1424 | 1463 | } |
1425 | 1464 | |
1426 | | - public function showEditField($idPath) { |
| 1465 | + public function showEditField(IdStack $idPath) { |
1427 | 1466 | return $this->wrappedEditor->showEditField($idPath); |
1428 | 1467 | } |
1429 | 1468 | |
1430 | | - public function view($idPath, $value) { |
| 1469 | + public function view(IdStack $idPath, $value) { |
1431 | 1470 | return $this->wrappedEditor->view($idPath, $value); |
1432 | 1471 | } |
1433 | 1472 | |
1434 | | - public function edit($idPath, $value) { |
| 1473 | + public function edit(IdStack $idPath, $value) { |
1435 | 1474 | return $this->wrappedEditor->edit($idPath, $value); |
1436 | 1475 | } |
1437 | 1476 | |
1438 | | - public function add($idPath) { |
| 1477 | + public function add(IdStack $idPath) { |
1439 | 1478 | return $this->wrappedEditor->add($idPath); |
1440 | 1479 | } |
1441 | 1480 | |
1442 | | - public function save($idPath, $value) { |
| 1481 | + public function save(IdStack $idPath, $value) { |
1443 | 1482 | $this->wrappedEditor->save($idPath, $value); |
1444 | 1483 | } |
1445 | 1484 | |
1446 | | - public function getUpdateValue($idPath) { |
| 1485 | + public function getUpdateValue(IdStack $idPath) { |
1447 | 1486 | return $this->wrappedEditor->getUpdateValue($idPath); |
1448 | 1487 | } |
1449 | 1488 | |
1450 | | - public function getAddValue($idPath) { |
| 1489 | + public function getAddValue(IdStack $idPath) { |
1451 | 1490 | return $this->wrappedEditor->getAddValue($idPath); |
1452 | 1491 | } |
1453 | 1492 | |
— | — | @@ -1458,20 +1497,20 @@ |
1459 | 1498 | class PopUpEditor extends WrappingEditor { |
1460 | 1499 | protected $linkCaption; |
1461 | 1500 | |
1462 | | - public function __construct($wrappedEditor, $linkCaption) { |
| 1501 | + public function __construct(Editor $wrappedEditor, $linkCaption) { |
1463 | 1502 | parent::__construct($wrappedEditor); |
1464 | 1503 | |
1465 | 1504 | $this->linkCaption = $linkCaption; |
1466 | 1505 | } |
1467 | 1506 | |
1468 | | - public function view($idPath, $value) { |
| 1507 | + public function view(IdStack $idPath, $value) { |
1469 | 1508 | return |
1470 | 1509 | $this->startToggleCode($idPath->getId()) . |
1471 | 1510 | $this->wrappedEditor->view($idPath, $value) . |
1472 | 1511 | $this->endToggleCode($idPath->getId()); |
1473 | 1512 | } |
1474 | 1513 | |
1475 | | - public function edit($idPath, $value) { |
| 1514 | + public function edit(IdStack $idPath, $value) { |
1476 | 1515 | return |
1477 | 1516 | $this->startToggleCode($idPath->getId()) . |
1478 | 1517 | $this->wrappedEditor->edit($idPath, $value) . |
— | — | @@ -1495,24 +1534,24 @@ |
1496 | 1535 | protected $captionEditor; |
1497 | 1536 | protected $valueEditor; |
1498 | 1537 | |
1499 | | - public function __construct($attribute, $permissionController, $showEditFieldChecker, $allowAddController, $allowRemove, $isAddField, $controller, $headerLevel, $childrenExpanded) { |
| 1538 | + public function __construct(Attribute $attribute = null, PermissionController $permissionController, ShowEditFieldChecker $showEditFieldChecker, AllowAddController $allowAddController, $allowRemove, $isAddField, UpdateController $controller = null, $headerLevel, $childrenExpanded) { |
1500 | 1539 | parent::__construct($attribute, $permissionController, $showEditFieldChecker, $allowAddController, $allowRemove, $isAddField, $controller); |
1501 | 1540 | |
1502 | 1541 | $this->headerLevel = $headerLevel; |
1503 | 1542 | $this->childrenExpanded = $childrenExpanded; |
1504 | 1543 | } |
1505 | 1544 | |
1506 | | - public function setCaptionEditor($editor) { |
| 1545 | + public function setCaptionEditor(Editor $editor) { |
1507 | 1546 | $this->captionEditor = $editor; |
1508 | 1547 | $this->editors[0] = $editor; |
1509 | 1548 | } |
1510 | 1549 | |
1511 | | - public function setValueEditor($editor) { |
| 1550 | + public function setValueEditor(Editor $editor) { |
1512 | 1551 | $this->valueEditor = $editor; |
1513 | 1552 | $this->editors[1] = $editor; |
1514 | 1553 | } |
1515 | 1554 | |
1516 | | - public function view($idPath, $value) { |
| 1555 | + public function view(IdStack $idPath, $value) { |
1517 | 1556 | $recordCount = $value->getRecordCount(); |
1518 | 1557 | |
1519 | 1558 | if ($recordCount > 0) { |
— | — | @@ -1552,7 +1591,7 @@ |
1553 | 1592 | return ""; |
1554 | 1593 | } |
1555 | 1594 | |
1556 | | - public function edit($idPath, $value) { |
| 1595 | + public function edit(IdStack $idPath, $value) { |
1557 | 1596 | global |
1558 | 1597 | $wgScriptPath; |
1559 | 1598 | |
— | — | @@ -1614,7 +1653,7 @@ |
1615 | 1654 | return ""; |
1616 | 1655 | } |
1617 | 1656 | |
1618 | | - public function add($idPath) { |
| 1657 | + public function add(IdStack $idPath) { |
1619 | 1658 | $result = '<ul class="collapsable-items">' . EOL; |
1620 | 1659 | $captionAttribute = $this->captionEditor->getAttribute(); |
1621 | 1660 | $valueAttribute = $this->valueEditor->getAttribute(); |
— | — | @@ -1642,11 +1681,11 @@ |
1643 | 1682 | } |
1644 | 1683 | |
1645 | 1684 | class AttributeLabelViewer extends Viewer { |
1646 | | - public function view($idPath, $value) { |
| 1685 | + public function view(IdStack $idPath, $value) { |
1647 | 1686 | return $this->attribute->name; |
1648 | 1687 | } |
1649 | 1688 | |
1650 | | - public function add($idPath) { |
| 1689 | + public function add(IdStack $idPath) { |
1651 | 1690 | return "New " . strtolower($this->attribute->name); |
1652 | 1691 | } |
1653 | 1692 | |
— | — | @@ -1654,7 +1693,7 @@ |
1655 | 1694 | return true; |
1656 | 1695 | } |
1657 | 1696 | |
1658 | | - public function showEditField($idPath){ |
| 1697 | + public function showEditField(IdStack $idPath){ |
1659 | 1698 | return true; |
1660 | 1699 | } |
1661 | 1700 | } |
— | — | @@ -1664,7 +1703,7 @@ |
1665 | 1704 | protected $valueSeparator; |
1666 | 1705 | protected $showAttributeNames; |
1667 | 1706 | |
1668 | | - public function __construct($attribute, $valueSeparator, $attributeSeparator, $showAttributeNames = true) { |
| 1707 | + public function __construct(Attribute $attribute = null, $valueSeparator, $attributeSeparator, $showAttributeNames = true) { |
1669 | 1708 | parent::__construct($attribute); |
1670 | 1709 | |
1671 | 1710 | $this->attributeSeparator = $attributeSeparator; |
— | — | @@ -1672,7 +1711,7 @@ |
1673 | 1712 | $this->showAttributeNames = $showAttributeNames; |
1674 | 1713 | } |
1675 | 1714 | |
1676 | | - public function view($idPath, $value) { |
| 1715 | + public function view(IdStack $idPath, $value) { |
1677 | 1716 | $fields = array(); |
1678 | 1717 | |
1679 | 1718 | foreach($this->editors as $editor) { |
— | — | @@ -1694,7 +1733,7 @@ |
1695 | 1734 | return implode($this->attributeSeparator, $fields); |
1696 | 1735 | } |
1697 | 1736 | |
1698 | | - public function add($idPath) { |
| 1737 | + public function add(IdStack $idPath) { |
1699 | 1738 | $fields = array(); |
1700 | 1739 | |
1701 | 1740 | foreach($this->editors as $editor) { |
— | — | @@ -1711,7 +1750,7 @@ |
1712 | 1751 | return implode($this->attributeSeparator, $fields); |
1713 | 1752 | } |
1714 | 1753 | |
1715 | | - public function edit($idPath, $value) { |
| 1754 | + public function edit(IdStack $idPath, $value) { |
1716 | 1755 | $fields = array(); |
1717 | 1756 | |
1718 | 1757 | foreach($this->editors as $editor) { |
— | — | @@ -1726,7 +1765,7 @@ |
1727 | 1766 | } |
1728 | 1767 | |
1729 | 1768 | class UserEditor extends ScalarEditor { |
1730 | | - public function getViewHTML($idPath, $value) { |
| 1769 | + public function getViewHTML(IdStack $idPath, $value) { |
1731 | 1770 | global |
1732 | 1771 | $wgUser; |
1733 | 1772 | |
— | — | @@ -1736,74 +1775,36 @@ |
1737 | 1776 | return ""; |
1738 | 1777 | } |
1739 | 1778 | |
1740 | | - public function getEditHTML($idPath, $value) { |
| 1779 | + public function getEditHTML(IdStack $idPath, $value) { |
1741 | 1780 | return $this->getViewHTML($idPath, $value); |
1742 | 1781 | } |
1743 | 1782 | |
1744 | 1783 | public function getInputValue($id) { |
1745 | 1784 | } |
1746 | 1785 | |
1747 | | - public function add($idPath) { |
| 1786 | + public function add(IdStack $idPath) { |
1748 | 1787 | } |
1749 | 1788 | } |
1750 | 1789 | |
1751 | 1790 | class TimestampEditor extends ScalarEditor { |
1752 | | - public function getViewHTML($idPath, $value) { |
| 1791 | + public function getViewHTML(IdStack $idPath, $value) { |
1753 | 1792 | if ($value != "") |
1754 | 1793 | return timestampAsText($value); |
1755 | 1794 | else |
1756 | 1795 | return ""; |
1757 | 1796 | } |
1758 | 1797 | |
1759 | | - public function getEditHTML($idPath, $value) { |
| 1798 | + public function getEditHTML(IdStack $idPath, $value) { |
1760 | 1799 | return $this->getViewHTML($idPath, $value); |
1761 | 1800 | } |
1762 | 1801 | |
1763 | 1802 | public function getInputValue($id) { |
1764 | 1803 | } |
1765 | 1804 | |
1766 | | - public function add($idPath) { |
| 1805 | + public function add(IdStack $idPath) { |
1767 | 1806 | } |
1768 | 1807 | } |
1769 | 1808 | |
1770 | | -//added the "allow add controller" to be able to control the usage of the add field in different circumstances |
1771 | | -//instances of this class are used instead of the boolean "allowAdd" in the editors |
1772 | | -class AllowAddController { |
1773 | | - protected $value; |
1774 | | - |
1775 | | - public function __construct($value){ |
1776 | | - $this->value = $value; |
1777 | | - } |
1778 | | - public function check($idPath){ |
1779 | | - return $this->value; |
1780 | | - } |
1781 | | -} |
1782 | | - |
1783 | | -class ShowEditFieldChecker { |
1784 | | - protected $value; |
1785 | | - |
1786 | | - public function __construct($value){ |
1787 | | - $this->value = $value; |
1788 | | - } |
1789 | | - public function check($idPath){ |
1790 | | - return $this->value; |
1791 | | - } |
1792 | | -} |
1793 | | - |
1794 | | -class ShowEditFieldForClassesChecker extends ShowEditFieldChecker{ |
1795 | | - protected $objectIdAttributeLevel; |
1796 | | - protected $objectIdAttribute; |
1797 | | - |
1798 | | - public function __construct($objectIdAttributeLevel, $objectIdAttribute) { |
1799 | | - $this->objectIdAttributeLevel = $objectIdAttributeLevel; |
1800 | | - $this->objectIdAttribute = $objectIdAttribute; |
1801 | | - } |
1802 | | - public function check($idPath) { |
1803 | | - $objectId = $idPath->getKeyStack()->peek($this->objectIdAttributeLevel)->getAttributeValue($this->objectIdAttribute); |
1804 | | - return isClass($objectId); |
1805 | | - } |
1806 | | -} |
1807 | | - |
1808 | 1809 | // The roll back editor is tricked. It shows a checkbox when its value is 'true', meaning that the record is the latest |
1809 | 1810 | // so it can be rolled back. However, when requesting the input value it returns the value of the roll back check box. |
1810 | 1811 | // This can possibly be solved better later on when we choose to let editors fetch the value(s) of the attribute(s) they're |
— | — | @@ -1831,13 +1832,13 @@ |
1832 | 1833 | protected $hasValueFields; |
1833 | 1834 | protected $suggestionsEditor; |
1834 | 1835 | |
1835 | | - public function __construct($attribute, $hasValueFields) { |
| 1836 | + public function __construct(Attribute $attribute = null, $hasValueFields) { |
1836 | 1837 | parent::__construct($attribute, new SimplePermissionController(false), false, false); |
1837 | 1838 | |
1838 | 1839 | $this->hasValueFields = $hasValueFields; |
1839 | 1840 | } |
1840 | 1841 | |
1841 | | - public function getViewHTML($idPath, $value) { |
| 1842 | + public function getViewHTML(IdStack $idPath, $value) { |
1842 | 1843 | global |
1843 | 1844 | $isLatestAttribute, $operationAttribute; |
1844 | 1845 | |
— | — | @@ -1876,11 +1877,11 @@ |
1877 | 1878 | return ""; |
1878 | 1879 | } |
1879 | 1880 | |
1880 | | - public function getEditHTML($idPath, $value) { |
| 1881 | + public function getEditHTML(IdStack $idPath, $value) { |
1881 | 1882 | return $this->getViewHTML($idPath, $value); |
1882 | 1883 | } |
1883 | 1884 | |
1884 | | - protected function getSuggestionsHTML($idPath, $value) { |
| 1885 | + protected function getSuggestionsHTML(IdStack $idPath, $value) { |
1885 | 1886 | $attribute = $this->suggestionsEditor->getAttribute(); |
1886 | 1887 | $idPath->pushAttribute($attribute); |
1887 | 1888 | $result = $this->suggestionsEditor->view($idPath, $value->getAttributeValue($attribute)); |
— | — | @@ -1893,16 +1894,16 @@ |
1894 | 1895 | return ""; |
1895 | 1896 | } |
1896 | 1897 | |
1897 | | - public function add($idPath) { |
| 1898 | + public function add(IdStack $idPath) { |
1898 | 1899 | } |
1899 | 1900 | |
1900 | | - public function setSuggestionsEditor($suggestionsEditor) { |
| 1901 | + public function setSuggestionsEditor(Editor $suggestionsEditor) { |
1901 | 1902 | $this->suggestionsEditor = $suggestionsEditor; |
1902 | 1903 | } |
1903 | 1904 | } |
1904 | 1905 | |
1905 | 1906 | class RecordSetRecordSelector extends WrappingEditor { |
1906 | | - public function view($idPath, $value) { |
| 1907 | + public function view(IdStack $idPath, $value) { |
1907 | 1908 | return getStaticSuggest($idPath->getId(), $this->wrappedEditor->view($idPath, $value), count($value->getKey()->attributes)); |
1908 | 1909 | } |
1909 | 1910 | } |
— | — | @@ -1910,7 +1911,7 @@ |
1911 | 1912 | class RecordSubRecordEditor extends RecordEditor { |
1912 | 1913 | protected $subRecordEditor; |
1913 | 1914 | |
1914 | | - public function view($idPath, $value) { |
| 1915 | + public function view(IdStack $idPath, $value) { |
1915 | 1916 | $attribute = $this->subRecordEditor->getAttribute(); |
1916 | 1917 | $idPath->pushAttribute($attribute); |
1917 | 1918 | $result = $this->subRecordEditor->view($idPath, $value->getAttributeValue($attribute)); |
— | — | @@ -1919,7 +1920,7 @@ |
1920 | 1921 | return $result; |
1921 | 1922 | } |
1922 | 1923 | |
1923 | | - public function edit($idPath, $value) { |
| 1924 | + public function edit(IdStack $idPath, $value) { |
1924 | 1925 | $attribute = $this->subRecordEditor->getAttribute(); |
1925 | 1926 | $idPath->pushAttribute($attribute); |
1926 | 1927 | $result = $this->subRecordEditor->edit($idPath, $value->getAttributeValue($attribute)); |
— | — | @@ -1928,7 +1929,7 @@ |
1929 | 1930 | return $result; |
1930 | 1931 | } |
1931 | 1932 | |
1932 | | - public function add($idPath) { |
| 1933 | + public function add(IdStack $idPath) { |
1933 | 1934 | $attribute = $this->subRecordEditor->getAttribute(); |
1934 | 1935 | $idPath->pushAttribute($attribute); |
1935 | 1936 | $result = $this->subRecordEditor->add($idPath); |
— | — | @@ -1937,7 +1938,7 @@ |
1938 | 1939 | return $result; |
1939 | 1940 | } |
1940 | 1941 | |
1941 | | - public function setSubRecordEditor($subRecordEditor) { |
| 1942 | + public function setSubRecordEditor(Editor $subRecordEditor) { |
1942 | 1943 | $this->subRecordEditor = $subRecordEditor; |
1943 | 1944 | $this->editors[0] = $subRecordEditor; |
1944 | 1945 | } |
— | — | @@ -1946,7 +1947,7 @@ |
1947 | 1948 | class RecordSetFirstRecordEditor extends RecordSetEditor { |
1948 | 1949 | protected $recordEditor; |
1949 | 1950 | |
1950 | | - public function view($idPath, $value) { |
| 1951 | + public function view(IdStack $idPath, $value) { |
1951 | 1952 | if ($value->getRecordCount() > 0) { |
1952 | 1953 | $record = $value->getRecord(0); |
1953 | 1954 | $idPath->pushKey(project($record, $value->getKey())); |
— | — | @@ -1959,7 +1960,7 @@ |
1960 | 1961 | return ""; |
1961 | 1962 | } |
1962 | 1963 | |
1963 | | - public function edit($idPath, $value) { |
| 1964 | + public function edit(IdStack $idPath, $value) { |
1964 | 1965 | if ($value->getRecordCount() > 0) { |
1965 | 1966 | $record = $value->getRecord(0); |
1966 | 1967 | $idPath->pushKey(project($record, $value->getKey())); |
— | — | @@ -1972,11 +1973,11 @@ |
1973 | 1974 | return $result; |
1974 | 1975 | } |
1975 | 1976 | |
1976 | | - public function add($idPath) { |
| 1977 | + public function add(IdStack $idPath) { |
1977 | 1978 | return ""; |
1978 | 1979 | } |
1979 | 1980 | |
1980 | | - public function save($idPath, $value) { |
| 1981 | + public function save(IdStack $idPath, $value) { |
1981 | 1982 | if ($value->getRecordCount() > 0) { |
1982 | 1983 | $record = $value->getRecord(0); |
1983 | 1984 | $idPath->pushKey(project($record, $value->getKey())); |
— | — | @@ -1987,20 +1988,20 @@ |
1988 | 1989 | $this->controller->add($idPath->getKeyStack(), $this->recordEditor->getAddValue($idPath)); |
1989 | 1990 | } |
1990 | 1991 | |
1991 | | - public function setRecordEditor($recordEditor) { |
| 1992 | + public function setRecordEditor(Editor $recordEditor) { |
1992 | 1993 | $this->recordEditor = $recordEditor; |
1993 | 1994 | $this->editors[0] = $recordEditor; |
1994 | 1995 | } |
1995 | 1996 | } |
1996 | 1997 | |
1997 | 1998 | class ObjectPathEditor extends Viewer { |
1998 | | - public function view($idPath, $value) { |
| 1999 | + public function view(IdStack $idPath, $value) { |
1999 | 2000 | return $this->resolveObject($value); |
2000 | 2001 | } |
2001 | 2002 | |
2002 | 2003 | protected function resolveObject($objectId) { |
2003 | | - $dc=wdGetDataSetContext(); |
2004 | | - wfDebug("dc is <$dc>\n"); |
| 2004 | + $dc=wdGetDataSetContext(); |
| 2005 | + wfDebug("dc is <$dc>\n"); |
2005 | 2006 | |
2006 | 2007 | $tableName = getTableNameWithObjectId($objectId); |
2007 | 2008 | |
— | — | @@ -2111,7 +2112,7 @@ |
2112 | 2113 | } |
2113 | 2114 | |
2114 | 2115 | class GotoSourceEditor extends Viewer { |
2115 | | - public function view($idPath, $value) { |
| 2116 | + public function view(IdStack $idPath, $value) { |
2116 | 2117 | global |
2117 | 2118 | $sourceIdentifierAttribute, $collectionIdAttribute, $wgGotoSourceTemplates; |
2118 | 2119 | |