Completed
Push — master ( e0aff5...5f2e51 )
by Jean-Christophe
09:49
created
Ajax/semantic/widgets/base/FieldAsTrait.php 3 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -16,7 +16,14 @@
 block discarded – undo
16 16
 
17 17
 trait FieldAsTrait{
18 18
 
19
+	/**
20
+	 * @param string $prefix
21
+	 */
19 22
 	protected abstract function _getFieldIdentifier($prefix);
23
+
24
+	/**
25
+	 * @param \Closure $callback
26
+	 */
20 27
 	public abstract function setValueFunction($index,$callback);
21 28
 
22 29
 	public function fieldAsImage($index,$size=Size::SMALL,$circular=false){
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@
 block discarded – undo
21 21
 
22 22
 	public function fieldAsImage($index,$size=Size::SMALL,$circular=false){
23 23
 		$this->setValueFunction($index,function($img) use($size,$circular){
24
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
24
+			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) {
25
+				$image->setCircular();
26
+			}
25 27
 			return $image;
26 28
 		}
27 29
 		);
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,55 +15,55 @@  discard block
 block discarded – undo
15 15
  * @property InstanceViewer $_instanceViewer
16 16
  */
17 17
 
18
-trait FieldAsTrait{
18
+trait FieldAsTrait {
19 19
 
20 20
 	protected abstract function _getFieldIdentifier($prefix);
21
-	public abstract function setValueFunction($index,$callback);
21
+	public abstract function setValueFunction($index, $callback);
22 22
 
23
-	private function _getLabelField($caption,$icon=NULL){
24
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
23
+	private function _getLabelField($caption, $icon=NULL) {
24
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
25 25
 		return $label;
26 26
 	}
27 27
 
28
-	public function fieldAsLabel($index,$icon=NULL){
29
-		$this->setValueFunction($index,function($caption) use($icon){
30
-			$lbl=$this->_getLabelField($caption,$icon);
28
+	public function fieldAsLabel($index, $icon=NULL) {
29
+		$this->setValueFunction($index, function($caption) use($icon){
30
+			$lbl=$this->_getLabelField($caption, $icon);
31 31
 			return $lbl;
32 32
 		}
33 33
 		);
34 34
 			return $this;
35 35
 	}
36 36
 
37
-	public function fieldAsImage($index,$size=Size::SMALL,$circular=false){
38
-		$this->setValueFunction($index,function($img) use($size,$circular){
39
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
37
+	public function fieldAsImage($index, $size=Size::SMALL, $circular=false) {
38
+		$this->setValueFunction($index, function($img) use($size, $circular){
39
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
40 40
 			return $image;
41 41
 		}
42 42
 		);
43 43
 			return $this;
44 44
 	}
45 45
 
46
-	public function fieldAsAvatar($index){
47
-		$this->setValueFunction($index,function($img){return (new HtmlImage("",$img))->asAvatar();});
46
+	public function fieldAsAvatar($index) {
47
+		$this->setValueFunction($index, function($img) {return (new HtmlImage("", $img))->asAvatar(); });
48 48
 		return $this;
49 49
 	}
50 50
 
51
-	public function fieldAsRadio($index,$name=NULL){
52
-		$this->setValueFunction($index,function($value)use ($index,$name){
53
-			if(isset($name)===false){
51
+	public function fieldAsRadio($index, $name=NULL) {
52
+		$this->setValueFunction($index, function($value)use ($index, $name){
53
+			if (isset($name)===false) {
54 54
 				$name=$this->_instanceViewer->getCaption($index)."[]";
55 55
 			}
56
-			$radio=new HtmlRadio($this->_getFieldIdentifier("radio"),$name,$value,$value);
56
+			$radio=new HtmlRadio($this->_getFieldIdentifier("radio"), $name, $value, $value);
57 57
 			return $radio;
58 58
 		}
59 59
 		);
60 60
 			return $this;
61 61
 	}
62 62
 
63
-	public function fieldAsInput($index,$name=NULL,$type="text",$placeholder=""){
64
-		$this->setValueFunction($index,function($value) use($index,$name,$type,$placeholder){
65
-			$input=new HtmlInput($this->_getFieldIdentifier("input"),$type,$value,$placeholder);
66
-			if(isset($name)===false){
63
+	public function fieldAsInput($index, $name=NULL, $type="text", $placeholder="") {
64
+		$this->setValueFunction($index, function($value) use($index, $name, $type, $placeholder){
65
+			$input=new HtmlInput($this->_getFieldIdentifier("input"), $type, $value, $placeholder);
66
+			if (isset($name)===false) {
67 67
 				$name=$this->_instanceViewer->getCaption($index)."[]";
68 68
 			}
69 69
 			$input->getField()->setProperty("name", $name);
@@ -73,27 +73,27 @@  discard block
 block discarded – undo
73 73
 			return $this;
74 74
 	}
75 75
 
76
-	public function fieldAsCheckbox($index,$name=NULL){
77
-		$this->setValueFunction($index,function($value) use($index,$name){
78
-			$checkbox=new HtmlCheckbox($this->_getFieldIdentifier("ck"),"",$value);
76
+	public function fieldAsCheckbox($index, $name=NULL) {
77
+		$this->setValueFunction($index, function($value) use($index, $name){
78
+			$checkbox=new HtmlCheckbox($this->_getFieldIdentifier("ck"), "", $value);
79 79
 			$checkbox->setChecked(JString::isBooleanTrue($value));
80
-			if(isset($name)===false){
80
+			if (isset($name)===false) {
81 81
 				$name=$this->_instanceViewer->getCaption($index)."[]";
82 82
 			}
83 83
 			$checkbox->getField()->setProperty("name", $name);
84
-			return $checkbox;}
84
+			return $checkbox; }
85 85
 			);
86 86
 			return $this;
87 87
 	}
88 88
 
89
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$name=NULL){
90
-		$this->setValueFunction($index,function($value) use($index,$elements,$multiple,$name){
91
-			$dd=new HtmlDropdown($this->_getFieldIdentifier("dd"),$value,$elements);
92
-			if(isset($name)===false){
89
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $name=NULL) {
90
+		$this->setValueFunction($index, function($value) use($index, $elements, $multiple, $name){
91
+			$dd=new HtmlDropdown($this->_getFieldIdentifier("dd"), $value, $elements);
92
+			if (isset($name)===false) {
93 93
 				$name=$this->_instanceViewer->getCaption($index)."[]";
94 94
 			}
95
-			$dd->asSelect($name,$multiple);
96
-			return $dd;}
95
+			$dd->asSelect($name, $multiple);
96
+			return $dd; }
97 97
 			);
98 98
 			return $this;
99 99
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 3 patches
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -62,18 +62,21 @@  discard block
 block discarded – undo
62 62
 
63 63
 		$table->setRowCount(0, \sizeof($captions));
64 64
 		$table->setHeaderValues($captions);
65
-		if(isset($this->_compileParts))
66
-			$table->setCompileParts($this->_compileParts);
65
+		if(isset($this->_compileParts)) {
66
+					$table->setCompileParts($this->_compileParts);
67
+		}
67 68
 		if(isset($this->_searchField)){
68
-			if(isset($js))
69
-				$this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]);
69
+			if(isset($js)) {
70
+							$this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]);
71
+			}
70 72
 		}
71 73
 
72 74
 		$this->_generateContent($table);
73 75
 
74 76
 		if($this->_hasCheckboxes){
75
-			if($table->hasPart("thead"))
76
-				$table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort");
77
+			if($table->hasPart("thead")) {
78
+							$table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort");
79
+			}
77 80
 		}
78 81
 
79 82
 		if(isset($this->_pagination) && $this->_pagination->getVisible()){
@@ -307,8 +310,9 @@  discard block
 block discarded – undo
307 310
 	private function getDefaultButton($icon,$class=null){
308 311
 		$bt=$this->getFieldButton("");
309 312
 		$bt->asIcon($icon);
310
-		if(isset($class))
311
-			$bt->addToProperty("class", $class);
313
+		if(isset($class)) {
314
+					$bt->addToProperty("class", $class);
315
+		}
312 316
 		return $bt;
313 317
 	}
314 318
 
Please login to merge, or discard this patch.
Doc Comments   +26 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,6 +41,10 @@  discard block
 block discarded – undo
41 41
 		parent::run($js);
42 42
 	}
43 43
 
44
+	/**
45
+	 * @param string $identifier
46
+	 * @param string $model
47
+	 */
44 48
 	public function __construct($identifier,$model,$modelInstance=NULL) {
45 49
 		parent::__construct($identifier, $model,$modelInstance);
46 50
 		$this->_instanceViewer=new InstanceViewer();
@@ -168,16 +172,26 @@  discard block
 block discarded – undo
168 172
 		return $this;
169 173
 	}
170 174
 
175
+	/**
176
+	 * @param \Closure $field
177
+	 */
171 178
 	public function addField($field){
172 179
 		$this->_instanceViewer->addField($field);
173 180
 		return $this;
174 181
 	}
175 182
 
183
+	/**
184
+	 * @param integer $index
185
+	 * @param \Closure $field
186
+	 */
176 187
 	public function insertField($index,$field){
177 188
 		$this->_instanceViewer->insertField($index, $field);
178 189
 		return $this;
179 190
 	}
180 191
 
192
+	/**
193
+	 * @param \Closure $field
194
+	 */
181 195
 	public function insertInField($index,$field){
182 196
 		$this->_instanceViewer->insertInField($index, $field);
183 197
 		return $this;
@@ -226,16 +240,17 @@  discard block
 block discarded – undo
226 240
 	/**
227 241
 	 * @param string $caption
228 242
 	 * @param callable $callback
229
-	 * @return callable
243
+	 * @return \Closure
230 244
 	 */
231 245
 	private function getFieldButtonCallable($caption,$callback=null){
232 246
 		return $this->getCallable("getFieldButton",[$caption],$callback);
233 247
 	}
234 248
 
235 249
 	/**
236
-	 * @param mixed $object
237 250
 	 * @param callable $callback
238
-	 * @return callable
251
+	 * @param string $thisCallback
252
+	 * @param string[] $parameters
253
+	 * @return \Closure
239 254
 	 */
240 255
 	private function getCallable($thisCallback,$parameters,$callback=null){
241 256
 		$result=function($instance) use($thisCallback,$parameters,$callback){
@@ -296,11 +311,19 @@  discard block
 block discarded – undo
296 311
 		return $this;
297 312
 	}
298 313
 
314
+	/**
315
+	 * @param string $icon
316
+	 * @param string $class
317
+	 */
299 318
 	private function addDefaultButton($icon,$class=null,$callback=null){
300 319
 		$this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback));
301 320
 		return $this;
302 321
 	}
303 322
 
323
+	/**
324
+	 * @param string $icon
325
+	 * @param string $class
326
+	 */
304 327
 	private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){
305 328
 		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback));
306 329
 		return $this;
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	protected $_compileParts;
32 32
 	protected $_toolbarPosition;
33 33
 
34
-	public function run(JsUtils $js){
35
-		if($this->_hasCheckboxes && isset($js)){
34
+	public function run(JsUtils $js) {
35
+		if ($this->_hasCheckboxes && isset($js)) {
36 36
 			$js->execOn("change", "#".$this->identifier." [name='selection[]']", "
37 37
 		var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true;
38 38
 		\$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}});
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
 		parent::run($js);
42 42
 	}
43 43
 
44
-	public function __construct($identifier,$model,$modelInstance=NULL) {
45
-		parent::__construct($identifier, $model,$modelInstance);
44
+	public function __construct($identifier, $model, $modelInstance=NULL) {
45
+		parent::__construct($identifier, $model, $modelInstance);
46 46
 		$this->_instanceViewer=new InstanceViewer();
47
-		$this->content=["table"=>new HtmlTable($identifier, 0,0)];
47
+		$this->content=["table"=>new HtmlTable($identifier, 0, 0)];
48 48
 		$this->_toolbarPosition=PositionInTable::BEFORETABLE;
49 49
 	}
50 50
 
51
-	public function compile(JsUtils $js=NULL,&$view=NULL){
51
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
52 52
 		$this->_instanceViewer->setInstance($this->_model);
53 53
 		$captions=$this->_instanceViewer->getCaptions();
54 54
 
55 55
 		$table=$this->content["table"];
56 56
 
57
-		if($this->_hasCheckboxes){
58
-			$ck=new HtmlCheckbox("main-ck-".$this->identifier,"");
57
+		if ($this->_hasCheckboxes) {
58
+			$ck=new HtmlCheckbox("main-ck-".$this->identifier, "");
59 59
 			$ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);");
60 60
 			$ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);");
61 61
 			\array_unshift($captions, $ck);
@@ -63,44 +63,44 @@  discard block
 block discarded – undo
63 63
 
64 64
 		$table->setRowCount(0, \sizeof($captions));
65 65
 		$table->setHeaderValues($captions);
66
-		if(isset($this->_compileParts))
66
+		if (isset($this->_compileParts))
67 67
 			$table->setCompileParts($this->_compileParts);
68
-		if(isset($this->_searchField)){
69
-			if(isset($js))
70
-				$this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]);
68
+		if (isset($this->_searchField)) {
69
+			if (isset($js))
70
+				$this->_searchField->postOn("change", $this->_urls, "{'s':$(this).val()}", "-#".$this->identifier." tbody", ["preventDefault"=>false]);
71 71
 		}
72 72
 
73 73
 		$this->_generateContent($table);
74 74
 
75
-		if($this->_hasCheckboxes){
76
-			if($table->hasPart("thead"))
77
-				$table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort");
75
+		if ($this->_hasCheckboxes) {
76
+			if ($table->hasPart("thead"))
77
+				$table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort");
78 78
 		}
79 79
 
80
-		if(isset($this->_pagination) && $this->_pagination->getVisible()){
80
+		if (isset($this->_pagination) && $this->_pagination->getVisible()) {
81 81
 			$this->_generatePagination($table);
82 82
 		}
83
-		if(isset($this->_toolbar)){
83
+		if (isset($this->_toolbar)) {
84 84
 			$this->_setToolbarPosition($table, $captions);
85 85
 		}
86
-		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
87
-		return parent::compile($js,$view);
86
+		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
87
+		return parent::compile($js, $view);
88 88
 	}
89 89
 
90
-	private function _generateContent($table){
90
+	private function _generateContent($table) {
91 91
 		$objects=$this->_modelInstance;
92
-		if(isset($this->_pagination)){
92
+		if (isset($this->_pagination)) {
93 93
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
94 94
 		}
95 95
 		InstanceViewer::setIndex(0);
96
-		$table->fromDatabaseObjects($objects, function($instance){
96
+		$table->fromDatabaseObjects($objects, function($instance) {
97 97
 			$this->_instanceViewer->setInstance($instance);
98 98
 			InstanceViewer::$index++;
99
-			$result= $this->_instanceViewer->getValues();
100
-			if($this->_hasCheckboxes){
101
-				$ck=new HtmlCheckbox("ck-".$this->identifier,"");
99
+			$result=$this->_instanceViewer->getValues();
100
+			if ($this->_hasCheckboxes) {
101
+				$ck=new HtmlCheckbox("ck-".$this->identifier, "");
102 102
 				$field=$ck->getField();
103
-				$field->setProperty("value",$this->_instanceViewer->getIdentifier());
103
+				$field->setProperty("value", $this->_instanceViewer->getIdentifier());
104 104
 				$field->setProperty("name", "selection[]");
105 105
 				\array_unshift($result, $ck);
106 106
 			}
@@ -108,25 +108,25 @@  discard block
 block discarded – undo
108 108
 		});
109 109
 	}
110 110
 
111
-	private function _generatePagination($table){
111
+	private function _generatePagination($table) {
112 112
 		$footer=$table->getFooter();
113 113
 		$footer->mergeCol();
114
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
114
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
115 115
 		$menu->floatRight();
116 116
 		$menu->setActiveItem($this->_pagination->getPage()-1);
117 117
 		$footer->setValues($menu);
118
-		$menu->postOnClick($this->_urls,"{'p':$(this).attr('data-page')}","-#".$this->identifier." tbody",["preventDefault"=>false]);
118
+		$menu->postOnClick($this->_urls, "{'p':$(this).attr('data-page')}", "-#".$this->identifier." tbody", ["preventDefault"=>false]);
119 119
 	}
120 120
 
121
-	private function _setToolbarPosition($table,$captions){
122
-		switch ($this->_toolbarPosition){
121
+	private function _setToolbarPosition($table, $captions) {
122
+		switch ($this->_toolbarPosition) {
123 123
 			case PositionInTable::BEFORETABLE:case PositionInTable::AFTERTABLE:
124
-				if(isset($this->_compileParts)===false){
124
+				if (isset($this->_compileParts)===false) {
125 125
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
126 126
 				}
127 127
 				break;
128 128
 			case PositionInTable::HEADER:case PositionInTable::FOOTER: case PositionInTable::BODY:
129
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
129
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
130 130
 				break;
131 131
 		}
132 132
 	}
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
 	 * @param callable $callback function called after the field compilation
139 139
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
140 140
 	 */
141
-	public function afterCompile($index,$callback){
142
-		$this->_instanceViewer->afterCompile($index,$callback);
141
+	public function afterCompile($index, $callback) {
142
+		$this->_instanceViewer->afterCompile($index, $callback);
143 143
 		return $this;
144 144
 	}
145 145
 
146
-	private function addToolbarRow($part,$table,$captions){
146
+	private function addToolbarRow($part, $table, $captions) {
147 147
 		$row=$table->getPart($part)->addRow(\sizeof($captions));
148 148
 		$row->mergeCol();
149 149
 		$row->setValues([$this->_toolbar]);
@@ -158,42 +158,42 @@  discard block
 block discarded – undo
158 158
 		return $this;
159 159
 	}
160 160
 
161
-	public function setCaptions($captions){
161
+	public function setCaptions($captions) {
162 162
 		$this->_instanceViewer->setCaptions($captions);
163 163
 		return $this;
164 164
 	}
165 165
 
166
-	public function setFields($fields){
166
+	public function setFields($fields) {
167 167
 		$this->_instanceViewer->setVisibleProperties($fields);
168 168
 		return $this;
169 169
 	}
170 170
 
171
-	public function addField($field){
171
+	public function addField($field) {
172 172
 		$this->_instanceViewer->addField($field);
173 173
 		return $this;
174 174
 	}
175 175
 
176
-	public function insertField($index,$field){
176
+	public function insertField($index, $field) {
177 177
 		$this->_instanceViewer->insertField($index, $field);
178 178
 		return $this;
179 179
 	}
180 180
 
181
-	public function insertInField($index,$field){
181
+	public function insertInField($index, $field) {
182 182
 		$this->_instanceViewer->insertInField($index, $field);
183 183
 		return $this;
184 184
 	}
185 185
 
186
-	public function setValueFunction($index,$callback){
186
+	public function setValueFunction($index, $callback) {
187 187
 		$this->_instanceViewer->setValueFunction($index, $callback);
188 188
 		return $this;
189 189
 	}
190 190
 
191
-	public function setIdentifierFunction($callback){
191
+	public function setIdentifierFunction($callback) {
192 192
 		$this->_instanceViewer->setIdentifierFunction($callback);
193 193
 		return $this;
194 194
 	}
195 195
 
196
-	public function getHtmlComponent(){
196
+	public function getHtmlComponent() {
197 197
 		return $this->content["table"];
198 198
 	}
199 199
 
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 		return $this;
207 207
 	}
208 208
 
209
-	public function paginate($items_per_page=10,$page=1){
210
-		$this->_pagination=new Pagination($items_per_page,4,$page);
209
+	public function paginate($items_per_page=10, $page=1) {
210
+		$this->_pagination=new Pagination($items_per_page, 4, $page);
211 211
 	}
212 212
 
213 213
 	public function getHasCheckboxes() {
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		return $this;
220 220
 	}
221 221
 
222
-	public function refresh($compileParts=["tbody"]){
222
+	public function refresh($compileParts=["tbody"]) {
223 223
 		$this->_compileParts=$compileParts;
224 224
 		return $this;
225 225
 	}
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
 	 * @param callable $callback
229 229
 	 * @return callable
230 230
 	 */
231
-	private function getFieldButtonCallable($caption,$callback=null){
232
-		return $this->getCallable("getFieldButton",[$caption],$callback);
231
+	private function getFieldButtonCallable($caption, $callback=null) {
232
+		return $this->getCallable("getFieldButton", [$caption], $callback);
233 233
 	}
234 234
 
235 235
 	/**
@@ -237,16 +237,16 @@  discard block
 block discarded – undo
237 237
 	 * @param callable $callback
238 238
 	 * @return callable
239 239
 	 */
240
-	private function getCallable($thisCallback,$parameters,$callback=null){
241
-		$result=function($instance) use($thisCallback,$parameters,$callback){
242
-			$object=call_user_func_array(array($this,$thisCallback), $parameters);
243
-			if(isset($callback)){
244
-				if(\is_callable($callback)){
245
-					$callback($object,$instance);
240
+	private function getCallable($thisCallback, $parameters, $callback=null) {
241
+		$result=function($instance) use($thisCallback, $parameters, $callback){
242
+			$object=call_user_func_array(array($this, $thisCallback), $parameters);
243
+			if (isset($callback)) {
244
+				if (\is_callable($callback)) {
245
+					$callback($object, $instance);
246 246
 				}
247 247
 			}
248
-			if($object instanceof HtmlSemDoubleElement){
249
-				$object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier());
248
+			if ($object instanceof HtmlSemDoubleElement) {
249
+				$object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier());
250 250
 			}
251 251
 			return $object;
252 252
 		};
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 	 * @param string $caption
258 258
 	 * @return HtmlButton
259 259
 	 */
260
-	private function getFieldButton($caption){
261
-		return new HtmlButton("",$caption);
260
+	private function getFieldButton($caption) {
261
+		return new HtmlButton("", $caption);
262 262
 	}
263 263
 
264 264
 	/**
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 	 * @param callable $callback
268 268
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
269 269
 	 */
270
-	public function addFieldButton($caption,$callback=null){
271
-		$this->addField($this->getCallable("getFieldButton",[$caption],$callback));
270
+	public function addFieldButton($caption, $callback=null) {
271
+		$this->addField($this->getCallable("getFieldButton", [$caption], $callback));
272 272
 		return $this;
273 273
 	}
274 274
 
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @param callable $callback
280 280
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
281 281
 	 */
282
-	public function insertFieldButton($index,$caption,$callback=null){
283
-		$this->insertField($index, $this->getFieldButtonCallable($caption,$callback));
282
+	public function insertFieldButton($index, $caption, $callback=null) {
283
+		$this->insertField($index, $this->getFieldButtonCallable($caption, $callback));
284 284
 		return $this;
285 285
 	}
286 286
 
@@ -291,53 +291,53 @@  discard block
 block discarded – undo
291 291
 	 * @param callable $callback
292 292
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
293 293
 	 */
294
-	public function insertInFieldButton($index,$caption,$callback=null){
295
-		$this->insertInField($index, $this->getFieldButtonCallable($caption,$callback));
294
+	public function insertInFieldButton($index, $caption, $callback=null) {
295
+		$this->insertInField($index, $this->getFieldButtonCallable($caption, $callback));
296 296
 		return $this;
297 297
 	}
298 298
 
299
-	private function addDefaultButton($icon,$class=null,$callback=null){
300
-		$this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback));
299
+	private function addDefaultButton($icon, $class=null, $callback=null) {
300
+		$this->addField($this->getCallable("getDefaultButton", [$icon, $class], $callback));
301 301
 		return $this;
302 302
 	}
303 303
 
304
-	private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){
305
-		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback));
304
+	private function insertDefaultButtonIn($index, $icon, $class=null, $callback=null) {
305
+		$this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class], $callback));
306 306
 		return $this;
307 307
 	}
308 308
 
309
-	private function getDefaultButton($icon,$class=null){
309
+	private function getDefaultButton($icon, $class=null) {
310 310
 		$bt=$this->getFieldButton("");
311 311
 		$bt->asIcon($icon);
312
-		if(isset($class))
312
+		if (isset($class))
313 313
 			$bt->addToProperty("class", $class);
314 314
 		return $bt;
315 315
 	}
316 316
 
317
-	public function addDeleteButton($callback=null){
318
-		return $this->addDefaultButton("remove","delete red basic",$callback);
317
+	public function addDeleteButton($callback=null) {
318
+		return $this->addDefaultButton("remove", "delete red basic", $callback);
319 319
 	}
320 320
 
321
-	public function addEditButton($callback=null){
322
-		return $this->addDefaultButton("edit","edit basic",$callback);
321
+	public function addEditButton($callback=null) {
322
+		return $this->addDefaultButton("edit", "edit basic", $callback);
323 323
 	}
324 324
 
325
-	public function addEditDeleteButtons($callbackEdit=null,$callbackDelete=null){
325
+	public function addEditDeleteButtons($callbackEdit=null, $callbackDelete=null) {
326 326
 		$this->addEditButton($callbackEdit);
327 327
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
328
-		$this->insertDeleteButtonIn($index,$callbackDelete);
328
+		$this->insertDeleteButtonIn($index, $callbackDelete);
329 329
 		return $this;
330 330
 	}
331 331
 
332
-	public function insertDeleteButtonIn($index,$callback=null){
333
-		return $this->insertDefaultButtonIn($index,"remove","delete red basic",$callback);
332
+	public function insertDeleteButtonIn($index, $callback=null) {
333
+		return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $callback);
334 334
 	}
335 335
 
336
-	public function insertEditButtonIn($index,$callback=null){
337
-		return $this->insertDefaultButtonIn($index,"edit","edit basic",$callback);
336
+	public function insertEditButtonIn($index, $callback=null) {
337
+		return $this->insertDefaultButtonIn($index, "edit", "edit basic", $callback);
338 338
 	}
339 339
 
340
-	public function setSelectable(){
340
+	public function setSelectable() {
341 341
 		$this->content["table"]->setSelectable();
342 342
 		return $this;
343 343
 	}
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
 	/**
346 346
 	 * @return \Ajax\semantic\html\collections\menus\HtmlMenu
347 347
 	 */
348
-	public function getToolbar(){
349
-		if(isset($this->_toolbar)===false){
348
+	public function getToolbar() {
349
+		if (isset($this->_toolbar)===false) {
350 350
 			$this->_toolbar=new HtmlMenu("toolbar-".$this->identifier);
351 351
 			$this->_toolbar->setSecondary();
352 352
 		}
@@ -358,37 +358,37 @@  discard block
 block discarded – undo
358 358
 	 * @param mixed $element
359 359
 	 * @return \Ajax\common\html\HtmlDoubleElement
360 360
 	 */
361
-	public function addInToolbar($element){
361
+	public function addInToolbar($element) {
362 362
 		$tb=$this->getToolbar();
363 363
 		return $tb->addItem($element);
364 364
 	}
365 365
 
366
-	public function addItemInToolbar($caption,$icon=NULL){
366
+	public function addItemInToolbar($caption, $icon=NULL) {
367 367
 		$result=$this->addInToolbar($caption);
368 368
 		$result->addIcon($icon);
369 369
 		return $result;
370 370
 	}
371 371
 
372
-	public function addButtonInToolbar($caption){
373
-		$bt=new HtmlButton("",$caption);
372
+	public function addButtonInToolbar($caption) {
373
+		$bt=new HtmlButton("", $caption);
374 374
 		return $this->addInToolbar($bt);
375 375
 	}
376 376
 
377
-	public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){
378
-		$bt=new HtmlButton("",$caption);
379
-		$bt->addIcon($icon,$before,$labeled);
377
+	public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) {
378
+		$bt=new HtmlButton("", $caption);
379
+		$bt->addIcon($icon, $before, $labeled);
380 380
 		return $this->addInToolbar($bt);
381 381
 	}
382 382
 
383 383
 
384
-	public function addSearchInToolbar(){
384
+	public function addSearchInToolbar() {
385 385
 		return $this->addInToolbar($this->getSearchField())->setPosition("right");
386 386
 	}
387 387
 
388
-	public function getSearchField(){
389
-		if(isset($this->_searchField)===false){
390
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
391
-			$this->_searchField->addIcon("search",Direction::RIGHT);
388
+	public function getSearchField() {
389
+		if (isset($this->_searchField)===false) {
390
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
391
+			$this->_searchField->addIcon("search", Direction::RIGHT);
392 392
 		}
393 393
 		return $this->_searchField;
394 394
 	}
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 		return $this;
399 399
 	}
400 400
 
401
-	protected function _getFieldIdentifier($prefix){
401
+	protected function _getFieldIdentifier($prefix) {
402 402
 		return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier();
403 403
 	}
404 404
 
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/InstanceViewer.php 2 patches
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -12,27 +12,27 @@  discard block
 block discarded – undo
12 12
 	private $afterCompile;
13 13
 	private static $index=0;
14 14
 
15
-	public function __construct($instance=NULL,$captions=NULL){
15
+	public function __construct($instance=NULL, $captions=NULL) {
16 16
 		$this->values=[];
17 17
 		$this->afterCompile=[];
18
-		if(isset($instance))
18
+		if (isset($instance))
19 19
 			$this->setInstance($instance);
20 20
 		$this->setCaptions($captions);
21 21
 	}
22 22
 
23
-	public function getCaption($index){
24
-		if($this->properties[$index] instanceof \ReflectionProperty)
23
+	public function getCaption($index) {
24
+		if ($this->properties[$index] instanceof \ReflectionProperty)
25 25
 			return $this->properties[$index]->getName();
26
-		elseif(\is_callable($this->properties[$index]))
26
+		elseif (\is_callable($this->properties[$index]))
27 27
 			return "";
28 28
 		else
29 29
 			return $this->properties[$index];
30 30
 	}
31 31
 
32
-	public function getCaptions(){
33
-		if(isset($this->captions)){
34
-			$result= $this->captions;
35
-			for($i=\sizeof($result);$i<$this->count();$i++){
32
+	public function getCaptions() {
33
+		if (isset($this->captions)) {
34
+			$result=$this->captions;
35
+			for ($i=\sizeof($result); $i<$this->count(); $i++) {
36 36
 				$result[]="";
37 37
 			}
38 38
 			return $result;
@@ -40,122 +40,122 @@  discard block
 block discarded – undo
40 40
 		$captions=[];
41 41
 		$index=0;
42 42
 		$count=$this->count();
43
-		while($index<$count){
43
+		while ($index<$count) {
44 44
 			$captions[]=$this->getCaption($index++);
45 45
 		}
46 46
 		return $captions;
47 47
 	}
48 48
 
49
-	public function getValues(){
49
+	public function getValues() {
50 50
 		$values=[];
51 51
 		$index=0;
52 52
 		$count=$this->count();
53
-		while($index<$count){
53
+		while ($index<$count) {
54 54
 			$values[]=$this->getValue($index++);
55 55
 		}
56 56
 		return $values;
57 57
 	}
58 58
 
59
-	public function getIdentifier(){
59
+	public function getIdentifier() {
60 60
 		$value=self::$index;
61
-		if(isset($this->values["identifier"]))
62
-			$value=$this->values["identifier"](self::$index,$this->instance);
61
+		if (isset($this->values["identifier"]))
62
+			$value=$this->values["identifier"](self::$index, $this->instance);
63 63
 		self::$index++;
64 64
 		return $value;
65 65
 	}
66 66
 
67
-	public function getValue($index){
67
+	public function getValue($index) {
68 68
 		$property=$this->properties[$index];
69 69
 		return $this->_getValue($property, $index);
70 70
 	}
71 71
 
72
-	private function _getValue($property,$index){
73
-		if($property instanceof \ReflectionProperty){
72
+	private function _getValue($property, $index) {
73
+		if ($property instanceof \ReflectionProperty) {
74 74
 			$property->setAccessible(true);
75 75
 			$value=$property->getValue($this->instance);
76
-			if(isset($this->values[$index])){
77
-				$value= $this->values[$index]($value);
76
+			if (isset($this->values[$index])) {
77
+				$value=$this->values[$index]($value);
78 78
 			}
79
-		}else{
80
-			if(\is_callable($property))
79
+		} else {
80
+			if (\is_callable($property))
81 81
 				$value=$property($this->instance);
82
-			elseif(\is_array($property)){
83
-				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
82
+			elseif (\is_array($property)) {
83
+				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property);
84 84
 				$value=\implode("", $values);
85
-			}else
85
+			} else
86 86
 				$value=$property;
87 87
 		}
88
-		if(isset($this->afterCompile[$index])){
89
-			if(\is_callable($this->afterCompile[$index])){
90
-				$this->afterCompile[$index]($value,$this->instance,$index);
88
+		if (isset($this->afterCompile[$index])) {
89
+			if (\is_callable($this->afterCompile[$index])) {
90
+				$this->afterCompile[$index]($value, $this->instance, $index);
91 91
 			}
92 92
 		}
93 93
 		return $value;
94 94
 	}
95 95
 
96
-	public function insertField($index,$field){
97
-		array_splice( $this->visibleProperties, $index, 0, $field );
96
+	public function insertField($index, $field) {
97
+		array_splice($this->visibleProperties, $index, 0, $field);
98 98
 		return $this;
99 99
 	}
100 100
 
101
-	public function insertInField($index,$field){
101
+	public function insertInField($index, $field) {
102 102
 		$vb=$this->visibleProperties;
103
-		if(isset($vb[$index])){
104
-			if(\is_array($vb[$index])){
103
+		if (isset($vb[$index])) {
104
+			if (\is_array($vb[$index])) {
105 105
 				$this->visibleProperties[$index][]=$field;
106
-			}else{
107
-				$this->visibleProperties[$index]=[$vb[$index],$field];
106
+			} else {
107
+				$this->visibleProperties[$index]=[$vb[$index], $field];
108 108
 			}
109
-		}else{
109
+		} else {
110 110
 			return $this->insertField($index, $field);
111 111
 		}
112 112
 		return $this;
113 113
 	}
114 114
 
115
-	public function addField($field){
115
+	public function addField($field) {
116 116
 		$this->visibleProperties[]=$field;
117 117
 		return $this;
118 118
 	}
119 119
 
120
-	public function count(){
120
+	public function count() {
121 121
 		return \sizeof($this->properties);
122 122
 	}
123 123
 
124
-	public function visiblePropertiesCount(){
124
+	public function visiblePropertiesCount() {
125 125
 		return \sizeof($this->visibleProperties);
126 126
 	}
127 127
 
128
-	private function showableProperty(\ReflectionProperty $rProperty){
129
-		return JString::startswith($rProperty->getName(),"_")===false;
128
+	private function showableProperty(\ReflectionProperty $rProperty) {
129
+		return JString::startswith($rProperty->getName(), "_")===false;
130 130
 	}
131 131
 
132 132
 	public function setInstance($instance) {
133
-		if(\is_string($instance)){
133
+		if (\is_string($instance)) {
134 134
 			$instance=new $instance();
135 135
 		}
136 136
 		$this->instance=$instance;
137 137
 		$this->properties=[];
138 138
 		$this->reflect=new \ReflectionClass($instance);
139
-		if(\sizeof($this->visibleProperties)===0){
139
+		if (\sizeof($this->visibleProperties)===0) {
140 140
 			$this->properties=$this->getDefaultProperties();
141
-		}else{
142
-			foreach ($this->visibleProperties as $property){
143
-				if(\is_callable($property)){
141
+		} else {
142
+			foreach ($this->visibleProperties as $property) {
143
+				if (\is_callable($property)) {
144 144
 					$this->properties[]=$property;
145
-				}elseif(\is_string($property)){
146
-					try{
145
+				}elseif (\is_string($property)) {
146
+					try {
147 147
 						$rProperty=$this->reflect->getProperty($property);
148 148
 						$this->properties[]=$rProperty;
149
-					}catch(\Exception $e){
149
+					}catch (\Exception $e) {
150 150
 						$this->properties[]=$property;
151 151
 					}
152
-				}elseif(\is_int($property)){
152
+				}elseif (\is_int($property)) {
153 153
 					$props=$this->getDefaultProperties();
154
-					if(isset($props[$property]))
154
+					if (isset($props[$property]))
155 155
 						$this->properties[]=$props[$property];
156 156
 					else
157 157
 						$this->properties[]=$property;
158
-				}else{
158
+				} else {
159 159
 					$this->properties[]=$property;
160 160
 				}
161 161
 			}
@@ -163,12 +163,12 @@  discard block
 block discarded – undo
163 163
 		return $this;
164 164
 	}
165 165
 
166
-	private function getDefaultProperties(){
166
+	private function getDefaultProperties() {
167 167
 		$result=[];
168 168
 		$properties=$this->reflect->getProperties();
169
-		foreach ($properties as $property){
169
+		foreach ($properties as $property) {
170 170
 			$showable=$this->showableProperty($property);
171
-			if($showable!==false){
171
+			if ($showable!==false) {
172 172
 				$result[]=$property;
173 173
 			}
174 174
 		}
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 		return $this;
186 186
 	}
187 187
 
188
-	public function setValueFunction($index,$callback){
188
+	public function setValueFunction($index, $callback) {
189 189
 		$this->values[$index]=$callback;
190 190
 		return $this;
191 191
 	}
192 192
 
193
-	public function setIdentifierFunction($callback){
193
+	public function setIdentifierFunction($callback) {
194 194
 		$this->values["identifier"]=$callback;
195 195
 		return $this;
196 196
 	}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @param callable $callback function called after the field compilation
211 211
 	 * @return \Ajax\semantic\widgets\datatable\InstanceViewer
212 212
 	 */
213
-	public function afterCompile($index,$callback){
213
+	public function afterCompile($index, $callback) {
214 214
 		$this->afterCompile[$index]=$callback;
215 215
 		return $this;
216 216
 	}
Please login to merge, or discard this patch.
Braces   +32 added lines, -27 removed lines patch added patch discarded remove patch
@@ -15,18 +15,20 @@  discard block
 block discarded – undo
15 15
 	public function __construct($instance=NULL,$captions=NULL){
16 16
 		$this->values=[];
17 17
 		$this->afterCompile=[];
18
-		if(isset($instance))
19
-			$this->setInstance($instance);
18
+		if(isset($instance)) {
19
+					$this->setInstance($instance);
20
+		}
20 21
 		$this->setCaptions($captions);
21 22
 	}
22 23
 
23 24
 	public function getCaption($index){
24
-		if($this->properties[$index] instanceof \ReflectionProperty)
25
-			return $this->properties[$index]->getName();
26
-		elseif(\is_callable($this->properties[$index]))
27
-			return "";
28
-		else
29
-			return $this->properties[$index];
25
+		if($this->properties[$index] instanceof \ReflectionProperty) {
26
+					return $this->properties[$index]->getName();
27
+		} elseif(\is_callable($this->properties[$index])) {
28
+					return "";
29
+		} else {
30
+					return $this->properties[$index];
31
+		}
30 32
 	}
31 33
 
32 34
 	public function getCaptions(){
@@ -58,8 +60,9 @@  discard block
 block discarded – undo
58 60
 
59 61
 	public function getIdentifier(){
60 62
 		$value=self::$index;
61
-		if(isset($this->values["identifier"]))
62
-			$value=$this->values["identifier"](self::$index,$this->instance);
63
+		if(isset($this->values["identifier"])) {
64
+					$value=$this->values["identifier"](self::$index,$this->instance);
65
+		}
63 66
 		self::$index++;
64 67
 		return $value;
65 68
 	}
@@ -76,14 +79,15 @@  discard block
 block discarded – undo
76 79
 			if(isset($this->values[$index])){
77 80
 				$value= $this->values[$index]($value);
78 81
 			}
79
-		}else{
80
-			if(\is_callable($property))
81
-				$value=$property($this->instance);
82
-			elseif(\is_array($property)){
82
+		} else{
83
+			if(\is_callable($property)) {
84
+							$value=$property($this->instance);
85
+			} elseif(\is_array($property)){
83 86
 				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
84 87
 				$value=\implode("", $values);
85
-			}else
86
-				$value=$property;
88
+			} else {
89
+							$value=$property;
90
+			}
87 91
 		}
88 92
 		if(isset($this->afterCompile[$index])){
89 93
 			if(\is_callable($this->afterCompile[$index])){
@@ -103,10 +107,10 @@  discard block
 block discarded – undo
103 107
 		if(isset($vb[$index])){
104 108
 			if(\is_array($vb[$index])){
105 109
 				$this->visibleProperties[$index][]=$field;
106
-			}else{
110
+			} else{
107 111
 				$this->visibleProperties[$index]=[$vb[$index],$field];
108 112
 			}
109
-		}else{
113
+		} else{
110 114
 			return $this->insertField($index, $field);
111 115
 		}
112 116
 		return $this;
@@ -138,24 +142,25 @@  discard block
 block discarded – undo
138 142
 		$this->reflect=new \ReflectionClass($instance);
139 143
 		if(\sizeof($this->visibleProperties)===0){
140 144
 			$this->properties=$this->getDefaultProperties();
141
-		}else{
145
+		} else{
142 146
 			foreach ($this->visibleProperties as $property){
143 147
 				if(\is_callable($property)){
144 148
 					$this->properties[]=$property;
145
-				}elseif(\is_string($property)){
149
+				} elseif(\is_string($property)){
146 150
 					try{
147 151
 						$rProperty=$this->reflect->getProperty($property);
148 152
 						$this->properties[]=$rProperty;
149
-					}catch(\Exception $e){
153
+					} catch(\Exception $e){
150 154
 						$this->properties[]=$property;
151 155
 					}
152
-				}elseif(\is_int($property)){
156
+				} elseif(\is_int($property)){
153 157
 					$props=$this->getDefaultProperties();
154
-					if(isset($props[$property]))
155
-						$this->properties[]=$props[$property];
156
-					else
157
-						$this->properties[]=$property;
158
-				}else{
158
+					if(isset($props[$property])) {
159
+											$this->properties[]=$props[$property];
160
+					} else {
161
+											$this->properties[]=$property;
162
+					}
163
+				} else{
159 164
 					$this->properties[]=$property;
160 165
 				}
161 166
 			}
Please login to merge, or discard this patch.