r23670 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23669‎ | r23670 | r23671 >
Date:15:22, 3 July 2007
Author:proes
Status:old
Tags:
Comment:
Added type hints to Editor.php
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Editor.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php
@@ -28,7 +28,7 @@
2929 $this->currentClass = $prefix;
3030 }
3131
32 - protected function getKeyIds($record) {
 32+ protected function getKeyIds(Record $record) {
3333 $ids = array();
3434
3535 foreach($record->getStructure()->getAttributes() as $attribute)
@@ -55,12 +55,12 @@
5656 $this->currentClass = array_pop($this->classStack);
5757 }
5858
59 - public function pushKey($record) {
 59+ public function pushKey(Record $record) {
6060 $this->keyStack->push($record);
6161 $this->pushId(implode("-", $this->getKeyIds($record)));
6262 }
6363
64 - public function pushAttribute($attribute) {
 64+ public function pushAttribute(Attribute $attribute) {
6565 # FIXME: check attribute id existence
6666 @$id=$attribute->id;
6767 $this->pushId($id);
@@ -90,20 +90,59 @@
9191 }
9292 }
9393
 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+
94133 interface Editor {
95134 public function getAttribute();
96135 public function getUpdateAttribute();
97136 public function getAddAttribute();
98137
99138 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);
105144
106 - public function getUpdateValue($idPath);
107 - public function getAddValue($idPath);
 145+ public function getUpdateValue(IdStack $idPath);
 146+ public function getAddValue(IdStack $idPath);
108147
109148 public function getEditors();
110149 }
@@ -113,11 +152,11 @@
114153 protected $editors = array();
115154 protected $attribute;
116155
117 - public function __construct($attribute) {
 156+ public function __construct(Attribute $attribute = null) {
118157 $this->attribute = $attribute;
119158 }
120159
121 - public function addEditor($editor) {
 160+ public function addEditor(Editor $editor) {
122161 $this->editors[] = $editor;
123162 }
124163
@@ -166,25 +205,25 @@
167206 return null;
168207 }
169208
170 - public function edit($idPath, $value) {
 209+ public function edit(IdStack $idPath, $value) {
171210 return $this->view($idPath, $value);
172211 }
173212
174 - public function add($idPath) {
 213+ public function add(IdStack $idPath) {
175214 }
176215
177 - public function save($idPath, $value) {
 216+ public function save(IdStack $idPath, $value) {
178217 }
179218
180 - public function getUpdateValue($idPath) {
 219+ public function getUpdateValue(IdStack $idPath) {
181220 return null;
182221 }
183222
184 - public function getAddValue($idPath) {
 223+ public function getAddValue(IdStack $idPath) {
185224 return null;
186225 }
187226
188 - public function showEditField($idPath) {
 227+ public function showEditField(IdStack $idPath) {
189228 return true;
190229 }
191230 }
@@ -197,7 +236,7 @@
198237 protected $isAddField;
199238 protected $controller;
200239
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) {
202241 parent::__construct($attribute);
203242
204243 $this->permissionController = $permissionController;
@@ -208,7 +247,7 @@
209248 $this->controller = $controller;
210249 }
211250
212 - public function getAddValue($idPath) {
 251+ public function getAddValue(IdStack $idPath) {
213252 $addStructure = $this->getAddStructure();
214253
215254 if (count($addStructure->getAttributes()) > 0) {
@@ -230,7 +269,7 @@
231270 return null;
232271 }
233272
234 - protected function saveRecord($idPath, $record) {
 273+ protected function saveRecord(IdStack $idPath, Record $record) {
235274 foreach($this->editors as $editor) {
236275 $attribute = $editor->getAttribute();
237276 $value = $record->getAttributeValue($attribute);
@@ -240,7 +279,7 @@
241280 }
242281 }
243282
244 - protected function updateRecord($idPath, $record, $structure, $editors) {
 283+ protected function updateRecord(IdStack $idPath, Record $record, Structure $structure, $editors) {
245284 if (count($editors) > 0) {
246285 $updateRecord = $this->getUpdateRecord($idPath, $structure, $editors);
247286
@@ -249,7 +288,7 @@
250289 }
251290 }
252291
253 - protected function removeRecord($idPath) {
 292+ protected function removeRecord(IdStack $idPath) {
254293 global
255294 $wgRequest;
256295
@@ -270,7 +309,7 @@
271310 return new Structure($attributes);
272311 }
273312
274 - public function getUpdateValue($idPath) {
 313+ public function getUpdateValue(IdStack $idPath) {
275314 return null;
276315 }
277316
@@ -314,7 +353,7 @@
315354 return $addEditors;
316355 }
317356
318 - public function getAddRecord($idPath, $structure, $editors) {
 357+ public function getAddRecord(IdStack $idPath, Structure $structure, $editors) {
319358 $result = new ArrayRecord($structure);
320359
321360 foreach($editors as $editor)
@@ -327,7 +366,7 @@
328367 return $result;
329368 }
330369
331 - public function getUpdateRecord($idPath, $structure, $editors) {
 370+ public function getUpdateRecord(IdStack $idPath, Structure $structure, $editors) {
332371 $result = new ArrayRecord($structure);
333372
334373 foreach($editors as $editor)
@@ -340,7 +379,7 @@
341380 return $result;
342381 }
343382
344 - public function save($idPath, $value) {
 383+ public function save(IdStack $idPath, $value) {
345384 if ($this->allowAddController->check($idPath) && $this->controller != null) {
346385 $addStructure = $this->getAddStructure();
347386
@@ -390,7 +429,7 @@
391430 return $value->getRecordCount() > 0;
392431 }
393432
394 - public function showEditField($idPath) {
 433+ public function showEditField(IdStack $idPath) {
395434 return $this->showEditFieldChecker->check($idPath);
396435 }
397436 }
@@ -413,7 +452,7 @@
414453 $this->rowHTMLAttributes = $rowHTMLAttributes;
415454 }
416455
417 - protected function columnShowsData($columnEditor, $value, $attributePath) {
 456+ protected function columnShowsData(Editor $columnEditor, $value, $attributePath) {
418457 $result = false;
419458 $recordCount = $value->getRecordCount();
420459 $i = 0;
@@ -431,7 +470,7 @@
432471 return $result;
433472 }
434473
435 - protected function getColumnEditorsShowingData($editor, $value, $attributePath = array()) {
 474+ protected function getColumnEditorsShowingData(Editor $editor, $value, $attributePath = array()) {
436475 $result = array();
437476
438477 foreach ($editor->getEditors() as $childEditor) {
@@ -454,7 +493,7 @@
455494 return $result;
456495 }
457496
458 - protected function getAllColumnEditors($editor, $value) {
 497+ protected function getAllColumnEditors(Editor $editor, $value) {
459498 $result = array();
460499
461500 foreach ($editor->getEditors() as $childEditor) {
@@ -469,7 +508,7 @@
470509 return $result;
471510 }
472511
473 - public function view($idPath, $value) {
 512+ public function view(IdStack $idPath, $value) {
474513 $result = '<table id="'. $idPath->getId() .'" class="wiki-data-table">';
475514 $structure = $value->getStructure();
476515 $key = $value->getKey();
@@ -501,7 +540,7 @@
502541 return $result;
503542 }
504543
505 - public function edit($idPath, $value) {
 544+ public function edit(IdStack $idPath, $value) {
506545 global
507546 $wgStylePath;
508547
@@ -558,7 +597,7 @@
559598 return $result;
560599 }
561600
562 - public function add($idPath) {
 601+ public function add(IdStack $idPath) {
563602 if ($this->isAddField) {
564603 $result = '<table id="'. $idPath->getId() .'" class="wiki-data-table">';
565604 $headerRows = getStructureAsTableHeaderRows($this->getAddStructure(), 0, $idPath);
@@ -578,7 +617,7 @@
579618 return "";
580619 }
581620
582 - function getAddRowAsHTML($idPath, $repeatInput, $allowRemove) {
 621+ function getAddRowAsHTML(IdStack $idPath, $repeatInput, $allowRemove) {
583622 global
584623 $wgScriptPath;
585624
@@ -601,7 +640,7 @@
602641 return $result . '</tr>' . EOL;
603642 }
604643
605 - public function getTableStructure($editor, $visibleColumnEditors) {
 644+ public function getTableStructure(Editor $editor, $visibleColumnEditors) {
606645 $attributes = array();
607646
608647 foreach($editor->getEditors() as $childEditor) {
@@ -646,7 +685,7 @@
647686 return new Structure($attributes);
648687 }
649688
650 - public function getUpdateValue($idPath) {
 689+ public function getUpdateValue(IdStack $idPath) {
651690 $result = new ArrayRecord($this->getUpdateStructure());
652691
653692 foreach($this->editors as $editor)
@@ -659,7 +698,7 @@
660699 return $result;
661700 }
662701
663 - public function getAddValue($idPath) {
 702+ public function getAddValue(IdStack $idPath) {
664703 $result = new ArrayRecord($this->getAddStructure());
665704
666705 foreach($this->editors as $editor)
@@ -690,7 +729,7 @@
691730 return null;
692731 }
693732
694 - public function save($idPath, $value) {
 733+ public function save(IdStack $idPath, $value) {
695734 foreach($this->editors as $editor) {
696735 $attribute = $editor->getAttribute();
697736 $idPath->pushAttribute($attribute);
@@ -712,22 +751,22 @@
713752 return $result;
714753 }
715754
716 - public function showEditField($idPath) {
 755+ public function showEditField(IdStack $idPath) {
717756 return true;
718757 }
719758 }
720759
721760 class RecordTableCellEditor extends RecordEditor {
722 - public function view($idPath, $value) {
 761+ public function view(IdStack $idPath, $value) {
723762 }
724763
725 - public function edit($idPath, $value) {
 764+ public function edit(IdStack $idPath, $value) {
726765 }
727766
728 - public function add($idPath) {
 767+ public function add(IdStack $idPath) {
729768 }
730769
731 - public function save($idPath, $value) {
 770+ public function save(IdStack $idPath, $value) {
732771 }
733772 }
734773
@@ -736,7 +775,7 @@
737776 protected $permissionController;
738777 protected $isAddField;
739778
740 - public function __construct($attribute, $permissionController, $isAddField) {
 779+ public function __construct(Attribute $attribute = null, PermissionController $permissionController, $isAddField) {
741780 parent::__construct($attribute);
742781
743782 $this->permissionController = $permissionController;
@@ -751,7 +790,7 @@
752791 return "update-" . $id;
753792 }
754793
755 - public function save($idPath, $value) {
 794+ public function save(IdStack $idPath, $value) {
756795 }
757796
758797 public function getUpdateAttribute() {
@@ -768,23 +807,23 @@
769808 return null;
770809 }
771810
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);
774813 public abstract function getInputValue($id);
775814
776 - public function getUpdateValue($idPath) {
 815+ public function getUpdateValue(IdStack $idPath) {
777816 return $this->getInputValue("update-" . $idPath->getId());
778817 }
779818
780 - public function getAddValue($idPath) {
 819+ public function getAddValue(IdStack $idPath) {
781820 return $this->getInputValue("add-" . $idPath->getId());
782821 }
783822
784 - public function view($idPath, $value) {
 823+ public function view(IdStack $idPath, $value) {
785824 return $this->getViewHTML($idPath, $value);
786825 }
787826
788 - public function edit($idPath, $value) {
 827+ public function edit(IdStack $idPath, $value) {
789828 if ($this->permissionController->allowUpdateOfValue($idPath, $value))
790829 return $this->getEditHTML($idPath, $value);
791830 else
@@ -795,21 +834,21 @@
796835 return ($value != null) && (trim($value) != "");
797836 }
798837
799 - public function showEditField($idPath) {
 838+ public function showEditField(IdStack $idPath) {
800839 return true;
801840 }
802841 }
803842
804843 class LanguageEditor extends ScalarEditor {
805 - public function getViewHTML($idPath, $value) {
 844+ public function getViewHTML(IdStack $idPath, $value) {
806845 return languageIdAsText($value);
807846 }
808847
809 - public function getEditHTML($idPath, $value) {
 848+ public function getEditHTML(IdStack $idPath, $value) {
810849 return getSuggest($this->updateId($idPath->getId()), "language");
811850 }
812851
813 - public function add($idPath) {
 852+ public function add(IdStack $idPath) {
814853 return getSuggest($this->addId($idPath->getId()), "language");
815854 }
816855
@@ -826,15 +865,15 @@
827866 }
828867
829868 class SpellingEditor extends ScalarEditor {
830 - public function getViewHTML($idPath, $value) {
 869+ public function getViewHTML(IdStack $idPath, $value) {
831870 return spellingAsLink($value);
832871 }
833872
834 - public function getEditHTML($idPath, $value) {
 873+ public function getEditHTML(IdStack $idPath, $value) {
835874 return getTextBox($this->updateId($idPath->getId()));
836875 }
837876
838 - public function add($idPath) {
 877+ public function add(IdStack $idPath) {
839878 if ($this->isAddField)
840879 return getTextBox($this->addId($idPath->getId()));
841880 else
@@ -861,7 +900,7 @@
862901 $this->truncateAt = $truncateAt;
863902 }
864903
865 - public function getViewHTML($idPath, $value) {
 904+ public function getViewHTML(IdStack $idPath, $value) {
866905 $definition = getDefinedMeaningDefinition($value);
867906 $definedMeaningAsLink = definedMeaningAsLink($value);
868907 $escapedDefinition = htmlspecialchars($definition);
@@ -872,11 +911,11 @@
873912 return $definedMeaningAsLink . ": " . $escapedDefinition;
874913 }
875914
876 - public function getEditHTML($idPath, $value) {
 915+ public function getEditHTML(IdStack $idPath, $value) {
877916 return "";
878917 }
879918
880 - public function add($idPath) {
 919+ public function add(IdStack $idPath) {
881920 if ($this->isAddField)
882921 return getTextArea($this->addId($idPath->getId()), "", 3);
883922 else
@@ -901,7 +940,7 @@
902941 protected $addText = "";
903942 protected $controller;
904943
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) {
906945 parent::__construct($attribute, $permissionController, $isAddField);
907946
908947 $this->truncate = $truncate;
@@ -909,7 +948,7 @@
910949 $this->controller = $controller;
911950 }
912951
913 - public function getViewHTML($idPath, $value) {
 952+ public function getViewHTML(IdStack $idPath, $value) {
914953 $escapedValue = htmlspecialchars($value);
915954
916955 // global $wgParser, $wgTitle, $wgOut;
@@ -921,11 +960,11 @@
922961 return '<span title="'. $escapedValue .'">'. htmlspecialchars(substr($value, 0, $this->truncateAt)) . '...</span>' . EOL;
923962 }
924963
925 - public function getEditHTML($idPath, $value) {
 964+ public function getEditHTML(IdStack $idPath, $value) {
926965 return getTextArea($this->updateId($idPath->getId()), $value, 3);
927966 }
928967
929 - public function add($idPath) {
 968+ public function add(IdStack $idPath) {
930969 if ($this->isAddField)
931970 return getTextArea($this->addId($idPath->getId()), "", 3);
932971 else
@@ -943,7 +982,7 @@
944983 $this->addText = $addText;
945984 }
946985
947 - public function save($idPath, $value) {
 986+ public function save(IdStack $idPath, $value) {
948987 if ($this->controller != null) {
949988 $inputValue = $this->getInputValue($this->updateId($idPath->getId()));
950989
@@ -954,15 +993,15 @@
955994 }
956995
957996 class ShortTextEditor extends ScalarEditor {
958 - public function getViewHTML($idPath, $value) {
 997+ public function getViewHTML(IdStack $idPath, $value) {
959998 return htmlspecialchars($value);
960999 }
9611000
962 - public function getEditHTML($idPath, $value) {
 1001+ public function getEditHTML(IdStack $idPath, $value) {
9631002 return getTextBox($this->updateId($idPath->getId()), $value);
9641003 }
9651004
966 - public function add($idPath) {
 1005+ public function add(IdStack $idPath) {
9671006 if ($this->isAddField)
9681007 return getTextBox($this->addId($idPath->getId()), "");
9691008 else
@@ -978,7 +1017,7 @@
9791018 }
9801019
9811020 class URLEditor extends ShortTextEditor {
982 - public function getViewHTML($idPath, $value) {
 1021+ public function getViewHTML(IdStack $idPath, $value) {
9831022 global
9841023 $escapedValue;
9851024
@@ -991,21 +1030,21 @@
9921031 class BooleanEditor extends ScalarEditor {
9931032 protected $defaultValue;
9941033
995 - public function __construct($attribute, $permissionController, $isAddField, $defaultValue) {
 1034+ public function __construct(Attribute $attribute = null, PermissionController $permissionController, $isAddField, $defaultValue) {
9961035 parent::__construct($attribute, $permissionController, $isAddField);
9971036
9981037 $this->defaultValue = $defaultValue;
9991038 }
10001039
1001 - public function getViewHTML($idPath, $value) {
 1040+ public function getViewHTML(IdStack $idPath, $value) {
10021041 return booleanAsHTML($value);
10031042 }
10041043
1005 - public function getEditHTML($idPath, $value) {
 1044+ public function getEditHTML(IdStack $idPath, $value) {
10061045 return getCheckBox($this->updateId($idPath->getId()), $value);
10071046 }
10081047
1009 - public function add($idPath) {
 1048+ public function add(IdStack $idPath) {
10101049 if ($this->isAddField)
10111050 return getCheckBox($this->addId($idPath->getId()), $this->defaultValue);
10121051 else
@@ -1021,7 +1060,7 @@
10221061 }
10231062
10241063 abstract class SuggestEditor extends ScalarEditor {
1025 - public function add($idPath) {
 1064+ public function add(IdStack $idPath) {
10261065 if ($this->isAddField)
10271066 return getSuggest($this->addId($idPath->getId()), $this->suggestType());
10281067 else
@@ -1030,7 +1069,7 @@
10311070
10321071 protected abstract function suggestType();
10331072
1034 - public function getEditHTML($idPath, $value) {
 1073+ public function getEditHTML(IdStack $idPath, $value) {
10351074 return getSuggest($this->updateId($idPath->getId()), $this->suggestType());
10361075 }
10371076
@@ -1047,7 +1086,7 @@
10481087 return "defined-meaning";
10491088 }
10501089
1051 - public function getViewHTML($idPath, $value) {
 1090+ public function getViewHTML(IdStack $idPath, $value) {
10521091 global
10531092 $definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute;
10541093 $definedMeaningId = $value->getAttributeValue($definedMeaningIdAttribute);
@@ -1063,7 +1102,7 @@
10641103 return "class-attributes-level";
10651104 }
10661105
1067 - public function getViewHTML($idPath, $value) {
 1106+ public function getViewHTML(IdStack $idPath, $value) {
10681107 global
10691108 $definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute;
10701109
@@ -1078,19 +1117,19 @@
10791118 abstract class SelectEditor extends ScalarEditor {
10801119 protected abstract function getOptions();
10811120
1082 - public function add($idPath) {
 1121+ public function add(IdStack $idPath) {
10831122 if ($this->isAddField)
10841123 return getSelect($this->addId($idPath->getId()), $this->getOptions());
10851124 else
10861125 return "";
10871126 }
10881127
1089 - public function getViewHTML($idPath, $value) {
 1128+ public function getViewHTML(IdStack $idPath, $value) {
10901129 $options = $this->getOptions();
10911130 return $options[$value];
10921131 }
10931132
1094 - public function getEditHTML($idPath, $value) {
 1133+ public function getEditHTML(IdStack $idPath, $value) {
10951134 return getSelect($this->addId($idPath->getId()), $this->getOptions());
10961135 }
10971136
@@ -1119,7 +1158,7 @@
11201159 return array();
11211160 }
11221161
1123 - public function getViewHTML($idPath, $value) {
 1162+ public function getViewHTML(IdStack $idPath, $value) {
11241163 global
11251164 $definedMeaningIdAttribute, $definedMeaningLabelAttribute, $definedMeaningDefiningExpressionAttribute;
11261165
@@ -1153,14 +1192,14 @@
11541193 protected $attributesLevelName;
11551194 protected $objectIdFetcher;
11561195
1157 - public function __construct($attribute, $permissionController, $isAddField, $attributesLevelName, Fetcher $objectIdFetcher) {
 1196+ public function __construct(Attribute $attribute = null, PermissionController $permissionController, $isAddField, $attributesLevelName, Fetcher $objectIdFetcher) {
11581197 parent::__construct($attribute, $permissionController, $isAddField);
11591198
11601199 $this->attributesLevelName = $attributesLevelName;
11611200 $this->objectIdFetcher = $objectIdFetcher;
11621201 }
11631202
1164 - public function add($idPath) {
 1203+ public function add(IdStack $idPath) {
11651204 if ($this->isAddField) {
11661205 $parameters = array(
11671206 "attributesLevel" => $this->attributesLevelName,
@@ -1173,7 +1212,7 @@
11741213 return "";
11751214 }
11761215
1177 - public function getEditHTML($idPath, $value) {
 1216+ public function getEditHTML(IdStack $idPath, $value) {
11781217 $parameters = array("attributesLevel" => $this->attributesLevelName);
11791218 return getSuggest($this->updateId($idPath->getId()), $this->suggestType(), $parameters);
11801219 }
@@ -1202,7 +1241,7 @@
12031242 return 'option-attribute';
12041243 }
12051244
1206 - public function add($idPath) {
 1245+ public function add(IdStack $idPath) {
12071246 if ($this->isAddField) {
12081247 global
12091248 $syntransIdAttribute;
@@ -1219,7 +1258,7 @@
12201259 return '';
12211260 }
12221261
1223 - public function getEditHTML($idPath, $value) {
 1262+ public function getEditHTML(IdStack $idPath, $value) {
12241263 $parameters = array(
12251264 'attributesLevel' => $this->attributesLevelName,
12261265 'onUpdate' => 'updateSelectOptions(\'' . $this->updateId($idPath->getId()) . '-option\''
@@ -1234,7 +1273,7 @@
12351274 protected $headerLevel = 1;
12361275 protected $htmlTag;
12371276
1238 - public function __construct($attribute, $headerLevel, $htmlTag) {
 1277+ public function __construct(Attribute $attribute = null, $headerLevel, $htmlTag) {
12391278 parent::__construct($attribute);
12401279
12411280 $this->htmlTag = $htmlTag;
@@ -1256,7 +1295,7 @@
12571296 return $result;
12581297 }
12591298
1260 - public function view($idPath, $value) {
 1299+ public function view(IdStack $idPath, $value) {
12611300 $result = '';
12621301 foreach ($this->editors as $editor) {
12631302 $attribute = $editor->getAttribute();
@@ -1276,11 +1315,11 @@
12771316 return $result;
12781317 }
12791318
1280 - public function showEditField($idPath) {
 1319+ public function showEditField(IdStack $idPath) {
12811320 return true;
12821321 }
12831322
1284 - public function edit($idPath, $value) {
 1323+ public function edit(IdStack $idPath, $value) {
12851324 $result = '';
12861325 foreach ($this->editors as $editor) {
12871326 $attribute = $editor->getAttribute();
@@ -1300,7 +1339,7 @@
13011340 return $result;
13021341 }
13031342
1304 - public function add($idPath) {
 1343+ public function add(IdStack $idPath) {
13051344 $result = '';
13061345 foreach($this->editors as $editor) {
13071346 if ($attribute = $editor->getAddAttribute()) {
@@ -1320,35 +1359,35 @@
13211360 return $result;
13221361 }
13231362
1324 - protected function childHeader($editor, $attribute, $class, $attributeId){
 1363+ protected function childHeader(Editor $editor, Attribute $attribute, $class, $attributeId){
13251364 $expansionPrefix = $this->getExpansionPrefix($class, $attributeId);
13261365 $this->setExpansionByEditor($editor, $class);
13271366 return '<h'. $this->headerLevel .'><span id="collapse-'. $attributeId .'" class="toggle '. addCollapsablePrefixToClass($class) .'" onclick="toggle(this, event);">' . $expansionPrefix . '&nbsp;' . $attribute->name . '</span></h'. $this->headerLevel .'>' . EOL;
13281367 }
13291368
1330 - protected function viewChild($editor, $idPath, $value, $attribute, $class, $attributeId){
 1369+ protected function viewChild(Editor $editor, IdStack $idPath, $value, Attribute $attribute, $class, $attributeId){
13311370 return '<div id="collapsable-'. $attributeId . '" class="expand-' . $class . '">' . $editor->view($idPath, $value->getAttributeValue($attribute)) . '</div>' . EOL;
13321371 }
13331372
1334 - protected function editChild($editor, $idPath, $value, $attribute, $class, $attributeId) {
 1373+ protected function editChild(Editor $editor, IdStack $idPath, $value, Attribute $attribute, $class, $attributeId) {
13351374 return '<div id="collapsable-'. $attributeId . '" class="expand-' . $class . '">' . $editor->edit($idPath, $value->getAttributeValue($attribute)) . '</div>' . EOL;
13361375 }
13371376
1338 - protected function addChild($editor, $idPath, $attribute, $class, $attributeId) {
 1377+ protected function addChild(Editor $editor, IdStack $idPath, Attribute $attribute, $class, $attributeId) {
13391378 return '<div id="collapsable-'. $attributeId . '" class="expand-' . $class . '">' . $editor->add($idPath) . '</div>' . EOL;
13401379 }
13411380
1342 - public function expandEditor($editor) {
 1381+ public function expandEditor(Editor $editor) {
13431382 $this->expandedEditors[] = $editor;
13441383 }
13451384
1346 - public function setExpansionByEditor($editor, $elementType) {
 1385+ public function setExpansionByEditor(Editor $editor, $elementType) {
13471386 $this->setExpansion(in_array($editor, $this->expandedEditors, true), $elementType);
13481387 }
13491388 }
13501389
13511390 class RecordUnorderedListEditor extends RecordListEditor {
1352 - public function __construct($attribute, $headerLevel) {
 1391+ public function __construct(Attribute $attribute = null, $headerLevel) {
13531392 parent::__construct($attribute, $headerLevel, "li");
13541393 }
13551394
@@ -1360,21 +1399,21 @@
13611400 return "";
13621401 }
13631402
1364 - public function view($idPath, $value) {
 1403+ public function view(IdStack $idPath, $value) {
13651404 return $this->wrapInList(parent::view($idPath, $value));
13661405 }
13671406
1368 - public function edit($idPath, $value) {
 1407+ public function edit(IdStack $idPath, $value) {
13691408 return $this->wrapInList(parent::edit($idPath, $value));
13701409 }
13711410
1372 - public function add($idPath) {
 1411+ public function add(IdStack $idPath) {
13731412 return $this->wrapInList(parent::add($idPath));
13741413 }
13751414 }
13761415
13771416 class RecordDivListEditor extends RecordListEditor {
1378 - public function __construct($attribute) {
 1417+ public function __construct(Attribute $attribute = null) {
13791418 parent::__construct($attribute, 0, "div");
13801419 }
13811420
@@ -1382,19 +1421,19 @@
13831422 return '<div>' . $listItems . '</div>';
13841423 }
13851424
1386 - public function view($idPath, $value) {
 1425+ public function view(IdStack $idPath, $value) {
13871426 return $this->wrapInDiv(parent::view($idPath, $value));
13881427 }
13891428
1390 - public function edit($idPath, $value) {
 1429+ public function edit(IdStack $idPath, $value) {
13911430 return $this->wrapInDiv(parent::edit($idPath, $value));
13921431 }
13931432
1394 - public function add($idPath) {
 1433+ public function add(IdStack $idPath) {
13951434 return $this->wrapInDiv(parent::add($idPath));
13961435 }
13971436
1398 - protected function childHeader($editor, $attribute, $class, $attributeId){
 1437+ protected function childHeader(Editor $editor, Attribute $attribute, $class, $attributeId){
13991438 return "";
14001439 }
14011440 }
@@ -1402,7 +1441,7 @@
14031442 class WrappingEditor implements Editor {
14041443 protected $wrappedEditor;
14051444
1406 - public function __construct($wrappedEditor) {
 1445+ public function __construct(Editor $wrappedEditor) {
14071446 $this->wrappedEditor = $wrappedEditor;
14081447 }
14091448
@@ -1422,31 +1461,31 @@
14231462 return $this->wrappedEditor->showsData($value);
14241463 }
14251464
1426 - public function showEditField($idPath) {
 1465+ public function showEditField(IdStack $idPath) {
14271466 return $this->wrappedEditor->showEditField($idPath);
14281467 }
14291468
1430 - public function view($idPath, $value) {
 1469+ public function view(IdStack $idPath, $value) {
14311470 return $this->wrappedEditor->view($idPath, $value);
14321471 }
14331472
1434 - public function edit($idPath, $value) {
 1473+ public function edit(IdStack $idPath, $value) {
14351474 return $this->wrappedEditor->edit($idPath, $value);
14361475 }
14371476
1438 - public function add($idPath) {
 1477+ public function add(IdStack $idPath) {
14391478 return $this->wrappedEditor->add($idPath);
14401479 }
14411480
1442 - public function save($idPath, $value) {
 1481+ public function save(IdStack $idPath, $value) {
14431482 $this->wrappedEditor->save($idPath, $value);
14441483 }
14451484
1446 - public function getUpdateValue($idPath) {
 1485+ public function getUpdateValue(IdStack $idPath) {
14471486 return $this->wrappedEditor->getUpdateValue($idPath);
14481487 }
14491488
1450 - public function getAddValue($idPath) {
 1489+ public function getAddValue(IdStack $idPath) {
14511490 return $this->wrappedEditor->getAddValue($idPath);
14521491 }
14531492
@@ -1458,20 +1497,20 @@
14591498 class PopUpEditor extends WrappingEditor {
14601499 protected $linkCaption;
14611500
1462 - public function __construct($wrappedEditor, $linkCaption) {
 1501+ public function __construct(Editor $wrappedEditor, $linkCaption) {
14631502 parent::__construct($wrappedEditor);
14641503
14651504 $this->linkCaption = $linkCaption;
14661505 }
14671506
1468 - public function view($idPath, $value) {
 1507+ public function view(IdStack $idPath, $value) {
14691508 return
14701509 $this->startToggleCode($idPath->getId()) .
14711510 $this->wrappedEditor->view($idPath, $value) .
14721511 $this->endToggleCode($idPath->getId());
14731512 }
14741513
1475 - public function edit($idPath, $value) {
 1514+ public function edit(IdStack $idPath, $value) {
14761515 return
14771516 $this->startToggleCode($idPath->getId()) .
14781517 $this->wrappedEditor->edit($idPath, $value) .
@@ -1495,24 +1534,24 @@
14961535 protected $captionEditor;
14971536 protected $valueEditor;
14981537
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) {
15001539 parent::__construct($attribute, $permissionController, $showEditFieldChecker, $allowAddController, $allowRemove, $isAddField, $controller);
15011540
15021541 $this->headerLevel = $headerLevel;
15031542 $this->childrenExpanded = $childrenExpanded;
15041543 }
15051544
1506 - public function setCaptionEditor($editor) {
 1545+ public function setCaptionEditor(Editor $editor) {
15071546 $this->captionEditor = $editor;
15081547 $this->editors[0] = $editor;
15091548 }
15101549
1511 - public function setValueEditor($editor) {
 1550+ public function setValueEditor(Editor $editor) {
15121551 $this->valueEditor = $editor;
15131552 $this->editors[1] = $editor;
15141553 }
15151554
1516 - public function view($idPath, $value) {
 1555+ public function view(IdStack $idPath, $value) {
15171556 $recordCount = $value->getRecordCount();
15181557
15191558 if ($recordCount > 0) {
@@ -1552,7 +1591,7 @@
15531592 return "";
15541593 }
15551594
1556 - public function edit($idPath, $value) {
 1595+ public function edit(IdStack $idPath, $value) {
15571596 global
15581597 $wgScriptPath;
15591598
@@ -1614,7 +1653,7 @@
16151654 return "";
16161655 }
16171656
1618 - public function add($idPath) {
 1657+ public function add(IdStack $idPath) {
16191658 $result = '<ul class="collapsable-items">' . EOL;
16201659 $captionAttribute = $this->captionEditor->getAttribute();
16211660 $valueAttribute = $this->valueEditor->getAttribute();
@@ -1642,11 +1681,11 @@
16431682 }
16441683
16451684 class AttributeLabelViewer extends Viewer {
1646 - public function view($idPath, $value) {
 1685+ public function view(IdStack $idPath, $value) {
16471686 return $this->attribute->name;
16481687 }
16491688
1650 - public function add($idPath) {
 1689+ public function add(IdStack $idPath) {
16511690 return "New " . strtolower($this->attribute->name);
16521691 }
16531692
@@ -1654,7 +1693,7 @@
16551694 return true;
16561695 }
16571696
1658 - public function showEditField($idPath){
 1697+ public function showEditField(IdStack $idPath){
16591698 return true;
16601699 }
16611700 }
@@ -1664,7 +1703,7 @@
16651704 protected $valueSeparator;
16661705 protected $showAttributeNames;
16671706
1668 - public function __construct($attribute, $valueSeparator, $attributeSeparator, $showAttributeNames = true) {
 1707+ public function __construct(Attribute $attribute = null, $valueSeparator, $attributeSeparator, $showAttributeNames = true) {
16691708 parent::__construct($attribute);
16701709
16711710 $this->attributeSeparator = $attributeSeparator;
@@ -1672,7 +1711,7 @@
16731712 $this->showAttributeNames = $showAttributeNames;
16741713 }
16751714
1676 - public function view($idPath, $value) {
 1715+ public function view(IdStack $idPath, $value) {
16771716 $fields = array();
16781717
16791718 foreach($this->editors as $editor) {
@@ -1694,7 +1733,7 @@
16951734 return implode($this->attributeSeparator, $fields);
16961735 }
16971736
1698 - public function add($idPath) {
 1737+ public function add(IdStack $idPath) {
16991738 $fields = array();
17001739
17011740 foreach($this->editors as $editor) {
@@ -1711,7 +1750,7 @@
17121751 return implode($this->attributeSeparator, $fields);
17131752 }
17141753
1715 - public function edit($idPath, $value) {
 1754+ public function edit(IdStack $idPath, $value) {
17161755 $fields = array();
17171756
17181757 foreach($this->editors as $editor) {
@@ -1726,7 +1765,7 @@
17271766 }
17281767
17291768 class UserEditor extends ScalarEditor {
1730 - public function getViewHTML($idPath, $value) {
 1769+ public function getViewHTML(IdStack $idPath, $value) {
17311770 global
17321771 $wgUser;
17331772
@@ -1736,74 +1775,36 @@
17371776 return "";
17381777 }
17391778
1740 - public function getEditHTML($idPath, $value) {
 1779+ public function getEditHTML(IdStack $idPath, $value) {
17411780 return $this->getViewHTML($idPath, $value);
17421781 }
17431782
17441783 public function getInputValue($id) {
17451784 }
17461785
1747 - public function add($idPath) {
 1786+ public function add(IdStack $idPath) {
17481787 }
17491788 }
17501789
17511790 class TimestampEditor extends ScalarEditor {
1752 - public function getViewHTML($idPath, $value) {
 1791+ public function getViewHTML(IdStack $idPath, $value) {
17531792 if ($value != "")
17541793 return timestampAsText($value);
17551794 else
17561795 return "";
17571796 }
17581797
1759 - public function getEditHTML($idPath, $value) {
 1798+ public function getEditHTML(IdStack $idPath, $value) {
17601799 return $this->getViewHTML($idPath, $value);
17611800 }
17621801
17631802 public function getInputValue($id) {
17641803 }
17651804
1766 - public function add($idPath) {
 1805+ public function add(IdStack $idPath) {
17671806 }
17681807 }
17691808
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 -
18081809 // The roll back editor is tricked. It shows a checkbox when its value is 'true', meaning that the record is the latest
18091810 // so it can be rolled back. However, when requesting the input value it returns the value of the roll back check box.
18101811 // 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 @@
18321833 protected $hasValueFields;
18331834 protected $suggestionsEditor;
18341835
1835 - public function __construct($attribute, $hasValueFields) {
 1836+ public function __construct(Attribute $attribute = null, $hasValueFields) {
18361837 parent::__construct($attribute, new SimplePermissionController(false), false, false);
18371838
18381839 $this->hasValueFields = $hasValueFields;
18391840 }
18401841
1841 - public function getViewHTML($idPath, $value) {
 1842+ public function getViewHTML(IdStack $idPath, $value) {
18421843 global
18431844 $isLatestAttribute, $operationAttribute;
18441845
@@ -1876,11 +1877,11 @@
18771878 return "";
18781879 }
18791880
1880 - public function getEditHTML($idPath, $value) {
 1881+ public function getEditHTML(IdStack $idPath, $value) {
18811882 return $this->getViewHTML($idPath, $value);
18821883 }
18831884
1884 - protected function getSuggestionsHTML($idPath, $value) {
 1885+ protected function getSuggestionsHTML(IdStack $idPath, $value) {
18851886 $attribute = $this->suggestionsEditor->getAttribute();
18861887 $idPath->pushAttribute($attribute);
18871888 $result = $this->suggestionsEditor->view($idPath, $value->getAttributeValue($attribute));
@@ -1893,16 +1894,16 @@
18941895 return "";
18951896 }
18961897
1897 - public function add($idPath) {
 1898+ public function add(IdStack $idPath) {
18981899 }
18991900
1900 - public function setSuggestionsEditor($suggestionsEditor) {
 1901+ public function setSuggestionsEditor(Editor $suggestionsEditor) {
19011902 $this->suggestionsEditor = $suggestionsEditor;
19021903 }
19031904 }
19041905
19051906 class RecordSetRecordSelector extends WrappingEditor {
1906 - public function view($idPath, $value) {
 1907+ public function view(IdStack $idPath, $value) {
19071908 return getStaticSuggest($idPath->getId(), $this->wrappedEditor->view($idPath, $value), count($value->getKey()->attributes));
19081909 }
19091910 }
@@ -1910,7 +1911,7 @@
19111912 class RecordSubRecordEditor extends RecordEditor {
19121913 protected $subRecordEditor;
19131914
1914 - public function view($idPath, $value) {
 1915+ public function view(IdStack $idPath, $value) {
19151916 $attribute = $this->subRecordEditor->getAttribute();
19161917 $idPath->pushAttribute($attribute);
19171918 $result = $this->subRecordEditor->view($idPath, $value->getAttributeValue($attribute));
@@ -1919,7 +1920,7 @@
19201921 return $result;
19211922 }
19221923
1923 - public function edit($idPath, $value) {
 1924+ public function edit(IdStack $idPath, $value) {
19241925 $attribute = $this->subRecordEditor->getAttribute();
19251926 $idPath->pushAttribute($attribute);
19261927 $result = $this->subRecordEditor->edit($idPath, $value->getAttributeValue($attribute));
@@ -1928,7 +1929,7 @@
19291930 return $result;
19301931 }
19311932
1932 - public function add($idPath) {
 1933+ public function add(IdStack $idPath) {
19331934 $attribute = $this->subRecordEditor->getAttribute();
19341935 $idPath->pushAttribute($attribute);
19351936 $result = $this->subRecordEditor->add($idPath);
@@ -1937,7 +1938,7 @@
19381939 return $result;
19391940 }
19401941
1941 - public function setSubRecordEditor($subRecordEditor) {
 1942+ public function setSubRecordEditor(Editor $subRecordEditor) {
19421943 $this->subRecordEditor = $subRecordEditor;
19431944 $this->editors[0] = $subRecordEditor;
19441945 }
@@ -1946,7 +1947,7 @@
19471948 class RecordSetFirstRecordEditor extends RecordSetEditor {
19481949 protected $recordEditor;
19491950
1950 - public function view($idPath, $value) {
 1951+ public function view(IdStack $idPath, $value) {
19511952 if ($value->getRecordCount() > 0) {
19521953 $record = $value->getRecord(0);
19531954 $idPath->pushKey(project($record, $value->getKey()));
@@ -1959,7 +1960,7 @@
19601961 return "";
19611962 }
19621963
1963 - public function edit($idPath, $value) {
 1964+ public function edit(IdStack $idPath, $value) {
19641965 if ($value->getRecordCount() > 0) {
19651966 $record = $value->getRecord(0);
19661967 $idPath->pushKey(project($record, $value->getKey()));
@@ -1972,11 +1973,11 @@
19731974 return $result;
19741975 }
19751976
1976 - public function add($idPath) {
 1977+ public function add(IdStack $idPath) {
19771978 return "";
19781979 }
19791980
1980 - public function save($idPath, $value) {
 1981+ public function save(IdStack $idPath, $value) {
19811982 if ($value->getRecordCount() > 0) {
19821983 $record = $value->getRecord(0);
19831984 $idPath->pushKey(project($record, $value->getKey()));
@@ -1987,20 +1988,20 @@
19881989 $this->controller->add($idPath->getKeyStack(), $this->recordEditor->getAddValue($idPath));
19891990 }
19901991
1991 - public function setRecordEditor($recordEditor) {
 1992+ public function setRecordEditor(Editor $recordEditor) {
19921993 $this->recordEditor = $recordEditor;
19931994 $this->editors[0] = $recordEditor;
19941995 }
19951996 }
19961997
19971998 class ObjectPathEditor extends Viewer {
1998 - public function view($idPath, $value) {
 1999+ public function view(IdStack $idPath, $value) {
19992000 return $this->resolveObject($value);
20002001 }
20012002
20022003 protected function resolveObject($objectId) {
2003 - $dc=wdGetDataSetContext();
2004 - wfDebug("dc is <$dc>\n");
 2004+ $dc=wdGetDataSetContext();
 2005+ wfDebug("dc is <$dc>\n");
20052006
20062007 $tableName = getTableNameWithObjectId($objectId);
20072008
@@ -2111,7 +2112,7 @@
21122113 }
21132114
21142115 class GotoSourceEditor extends Viewer {
2115 - public function view($idPath, $value) {
 2116+ public function view(IdStack $idPath, $value) {
21162117 global
21172118 $sourceIdentifierAttribute, $collectionIdAttribute, $wgGotoSourceTemplates;
21182119

Status & tagging log