Completed
Push — master ( 772d83...24138a )
by Jean-Christophe
10:15
created
Ajax/semantic/html/collections/form/traits/FormTrait.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -6,28 +6,28 @@  discard block
 block discarded – undo
6 6
 use Ajax\service\AjaxCall;
7 7
 use Ajax\JsUtils;
8 8
 
9
-trait FormTrait{
9
+trait FormTrait {
10 10
 
11 11
 	/**
12 12
 	 * @return HtmlForm
13 13
 	 */
14 14
 	abstract protected function getForm();
15 15
 
16
-	protected function addCompoValidation($compo,$field){
16
+	protected function addCompoValidation($compo, $field) {
17 17
 		$validation=$field->getValidation();
18
-		if(isset($validation)){
18
+		if (isset($validation)) {
19 19
 			$validation->setIdentifier($field->getDataField()->getIdentifier());
20 20
 			$compo->addFieldValidation($validation);
21 21
 		}
22 22
 		return $compo;
23 23
 	}
24 24
 
25
-	protected function _runValidationParams(&$compo,JsUtils $js=NULL){
25
+	protected function _runValidationParams(&$compo, JsUtils $js=NULL) {
26 26
 		$form=$this->getForm();
27 27
 		$params=$form->getValidationParams();
28
-		if(isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall){
28
+		if (isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall) {
29 29
 			$compilation=$params["_ajaxSubmit"]->compile($js);
30
-			$compilation=str_ireplace("\"","%quote%", $compilation);
30
+			$compilation=str_ireplace("\"", "%quote%", $compilation);
31 31
 			$this->onSuccess($compilation);
32 32
 			$form->removeValidationParam("_ajaxSubmit");
33 33
 		}
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 		return $this->getForm()->addToProperty("class", "loading");
41 41
 	}
42 42
 
43
-	public function setAttached($value=true){
43
+	public function setAttached($value=true) {
44 44
 		$form=$this->getForm();
45
-		if($value)
46
-			$form->addToPropertyCtrl("class", "attached", array ("attached" ));
45
+		if ($value)
46
+			$form->addToPropertyCtrl("class", "attached", array("attached"));
47 47
 		return $form;
48 48
 	}
49 49
 
50
-	public function addErrorMessage(){
50
+	public function addErrorMessage() {
51 51
 		return $this->getForm()->addContent((new HtmlMessage(""))->setError());
52 52
 	}
53 53
 
@@ -62,38 +62,38 @@  discard block
 block discarded – undo
62 62
 	 * @param string $responseElement
63 63
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
64 64
 	 */
65
-	public function submitOn($event,$identifier,$url,$responseElement){
65
+	public function submitOn($event, $identifier, $url, $responseElement) {
66 66
 		$form=$this->getForm();
67 67
 		$elem=$form->getElementById($identifier, $form->getContent());
68
-		if(isset($elem)){
69
-			$this->_buttonAsSubmit($elem, $event,$url,$responseElement);
68
+		if (isset($elem)) {
69
+			$this->_buttonAsSubmit($elem, $event, $url, $responseElement);
70 70
 		}
71 71
 		return $form;
72 72
 	}
73 73
 
74
-	public function submitOnClick($identifier,$url,$responseElement){
74
+	public function submitOnClick($identifier, $url, $responseElement) {
75 75
 		return $this->submitOn("click", $identifier, $url, $responseElement);
76 76
 	}
77 77
 
78
-	public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){
79
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
80
-		return $this->_buttonAsSubmit($bt, "click",$url,$responseElement);
78
+	public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) {
79
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
80
+		return $this->_buttonAsSubmit($bt, "click", $url, $responseElement);
81 81
 	}
82 82
 
83
-	protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL,$parameters=NULL){
83
+	protected function _buttonAsSubmit(&$button, $event, $url, $responseElement=NULL, $parameters=NULL) {
84 84
 		$form=$this->getForm();
85
-		if(isset($url) && isset($responseElement)){
85
+		if (isset($url) && isset($responseElement)) {
86 86
 			$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');");
87
-			$params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url];
88
-			if(\is_array($parameters))
89
-				$params=\array_merge($params,$parameters);
87
+			$params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url];
88
+			if (\is_array($parameters))
89
+				$params=\array_merge($params, $parameters);
90 90
 			$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params));
91 91
 		}
92 92
 		return $button;
93 93
 	}
94 94
 
95
-	public function addReset($identifier,$value,$cssStyle=NULL){
96
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
95
+	public function addReset($identifier, $value, $cssStyle=NULL) {
96
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
97 97
 		$bt->setProperty("type", "reset");
98 98
 		return $bt;
99 99
 	}
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @param string $jsCode
104 104
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
105 105
 	 */
106
-	public function onValid($jsCode){
106
+	public function onValid($jsCode) {
107 107
 		$form=$this->getForm();
108 108
 		$form->addValidationParam("onValid", "%function(){".$jsCode."}%");
109 109
 		return $form;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @param string $jsCode can use event and fields parameters
115 115
 	 * @return HtmlForm
116 116
 	 */
117
-	public function onSuccess($jsCode){
117
+	public function onSuccess($jsCode) {
118 118
 		$form=$this->getForm();
119 119
 		$form->addValidationParam("onSuccess", "%function(evt,fields){".$jsCode."}%");
120 120
 		return $form;
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/table/traits/TableTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace Ajax\semantic\html\collections\table\traits;
3 3
 
4
-trait TableTrait{
4
+trait TableTrait {
5 5
 	/**
6 6
 	 * @return HtmlTable
7 7
 	 */
8 8
 	abstract protected function getTable();
9 9
 
10
-	protected function addToPropertyTable($property,$value){
10
+	protected function addToPropertyTable($property, $value) {
11 11
 		return $this->getTable()->addToProperty($property, $value);
12 12
 	}
13 13
 
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
 	public function setBasic($very=false) {
19 19
 		$table=$this->getTable();
20 20
 		if ($very)
21
-			$table->addToPropertyCtrl("class", "very", array ("very" ));
22
-		return $table->addToPropertyCtrl("class", "basic", array ("basic" ));
21
+			$table->addToPropertyCtrl("class", "very", array("very"));
22
+		return $table->addToPropertyCtrl("class", "basic", array("basic"));
23 23
 	}
24 24
 
25 25
 	public function setCompact($very=false) {
26 26
 		$table=$this->getTable();
27 27
 		if ($very)
28
-			$table->addToPropertyCtrl("class", "very", array ("very" ));
29
-		return $table->addToPropertyCtrl("class", "compact", array ("compact" ));
28
+			$table->addToPropertyCtrl("class", "very", array("very"));
29
+		return $table->addToPropertyCtrl("class", "compact", array("compact"));
30 30
 	}
31 31
 
32 32
 	public function setCollapsing() {
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/FieldAsTrait.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -23,23 +23,23 @@  discard block
 block discarded – undo
23 23
  * @property boolean $_edition
24 24
  * @property mixed _modelInstance
25 25
  */
26
-trait FieldAsTrait{
26
+trait FieldAsTrait {
27 27
 
28
-	abstract protected function _getFieldIdentifier($prefix,$name="");
29
-	abstract public function setValueFunction($index,$callback);
28
+	abstract protected function _getFieldIdentifier($prefix, $name="");
29
+	abstract public function setValueFunction($index, $callback);
30 30
 	abstract protected function _getFieldName($index);
31 31
 	abstract protected function _getFieldCaption($index);
32
-	abstract protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL,$parameters=NULL);
32
+	abstract protected function _buttonAsSubmit(&$button, $event, $url, $responseElement=NULL, $parameters=NULL);
33 33
 
34 34
 	/**
35 35
 	 * @param HtmlFormField $element
36 36
 	 * @param array $attributes
37 37
 	 */
38
-	protected function _applyAttributes($element,&$attributes,$index){
39
-		if(isset($attributes["callback"])){
38
+	protected function _applyAttributes($element, &$attributes, $index) {
39
+		if (isset($attributes["callback"])) {
40 40
 			$callback=$attributes["callback"];
41
-			if(\is_callable($callback)){
42
-				$callback($element,$this->_modelInstance,$index);
41
+			if (\is_callable($callback)) {
42
+				$callback($element, $this->_modelInstance, $index);
43 43
 				unset($attributes["callback"]);
44 44
 			}
45 45
 		}
@@ -49,42 +49,42 @@  discard block
 block discarded – undo
49 49
 		$element->fromArray($attributes);
50 50
 	}
51 51
 
52
-	private function _getLabelField($caption,$icon=NULL){
53
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
52
+	private function _getLabelField($caption, $icon=NULL) {
53
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
54 54
 		return $label;
55 55
 	}
56 56
 
57
-	protected function _addRules($element,&$attributes){
58
-		if(isset($attributes["rules"])){
57
+	protected function _addRules($element, &$attributes) {
58
+		if (isset($attributes["rules"])) {
59 59
 			$rules=$attributes["rules"];
60
-			if(\is_array($rules)){
60
+			if (\is_array($rules)) {
61 61
 				$element->addRules($rules);
62 62
 			}
63
-			else{
63
+			else {
64 64
 				$element->addRule($rules);
65 65
 			}
66 66
 			unset($attributes["rules"]);
67 67
 		}
68 68
 	}
69 69
 
70
-	protected function _prepareFormFields(&$field,$name,&$attributes){
70
+	protected function _prepareFormFields(&$field, $name, &$attributes) {
71 71
 		$field->setName($name);
72 72
 		$this->_addRules($field, $attributes);
73 73
 		return $field;
74 74
 	}
75 75
 
76
-	protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){
77
-		$this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){
76
+	protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) {
77
+		$this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){
78 78
 			$caption=$this->_getFieldCaption($index);
79 79
 			$name=$this->_getFieldName($index);
80
-			$id=$this->_getFieldIdentifier($prefix,$name);
81
-			if(isset($attributes["name"])){
80
+			$id=$this->_getFieldIdentifier($prefix, $name);
81
+			if (isset($attributes["name"])) {
82 82
 				$name=$attributes["name"];
83 83
 				unset($attributes["name"]);
84 84
 			}
85
-			$element=$elementCallback($id,$name,$value,$caption);
86
-			if(\is_array($attributes)){
87
-				$this->_applyAttributes($element, $attributes,$index);
85
+			$element=$elementCallback($id, $name, $value, $caption);
86
+			if (\is_array($attributes)) {
87
+				$this->_applyAttributes($element, $attributes, $index);
88 88
 			}
89 89
 			$element->setDisabled(!$this->_edition);
90 90
 			return $element;
@@ -93,153 +93,153 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 
95 95
 
96
-	public function fieldAsProgress($index,$label=NULL, $attributes=array()){
97
-		$this->setValueFunction($index,function($value) use($label,$attributes){
98
-			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes);
96
+	public function fieldAsProgress($index, $label=NULL, $attributes=array()) {
97
+		$this->setValueFunction($index, function($value) use($label, $attributes){
98
+			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
99 99
 			return $pb;
100 100
 		});
101 101
 			return $this;
102 102
 	}
103 103
 
104
-	public function fieldAsRating($index,$max=5, $icon=""){
105
-		$this->setValueFunction($index,function($value) use($max,$icon){
106
-			$rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon);
104
+	public function fieldAsRating($index, $max=5, $icon="") {
105
+		$this->setValueFunction($index, function($value) use($max, $icon){
106
+			$rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
107 107
 			return $rating;
108 108
 		});
109 109
 			return $this;
110 110
 	}
111 111
 
112
-	public function fieldAsLabel($index,$icon=NULL){
113
-		$this->setValueFunction($index,function($caption) use($icon){
114
-			$lbl=$this->_getLabelField($caption,$icon);
112
+	public function fieldAsLabel($index, $icon=NULL) {
113
+		$this->setValueFunction($index, function($caption) use($icon){
114
+			$lbl=$this->_getLabelField($caption, $icon);
115 115
 			return $lbl;
116 116
 		});
117 117
 			return $this;
118 118
 	}
119 119
 
120
-	public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){
121
-		return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){
122
-			$header=new HtmlHeader($id,$niveau,$value);
123
-			if(isset($icon))
120
+	public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) {
121
+		return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){
122
+			$header=new HtmlHeader($id, $niveau, $value);
123
+			if (isset($icon))
124 124
 				$header->asIcon($icon, $value);
125 125
 			return $header;
126
-		}, $index,$attributes,"header");
126
+		}, $index, $attributes, "header");
127 127
 	}
128 128
 
129 129
 
130
-	public function fieldAsImage($index,$size=Size::MINI,$circular=false){
131
-		$this->setValueFunction($index,function($img) use($size,$circular){
132
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
130
+	public function fieldAsImage($index, $size=Size::MINI, $circular=false) {
131
+		$this->setValueFunction($index, function($img) use($size, $circular){
132
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
133 133
 			return $image;
134 134
 		});
135 135
 			return $this;
136 136
 	}
137 137
 
138
-	public function fieldAsAvatar($index,$attributes=NULL){
139
-		return $this->_fieldAs(function($id,$name,$value){
140
-			$img=new HtmlImage($id,$value);
138
+	public function fieldAsAvatar($index, $attributes=NULL) {
139
+		return $this->_fieldAs(function($id, $name, $value) {
140
+			$img=new HtmlImage($id, $value);
141 141
 			$img->asAvatar();
142 142
 			return $img;
143
-		}, $index,$attributes,"avatar");
143
+		}, $index, $attributes, "avatar");
144 144
 	}
145 145
 
146
-	public function fieldAsRadio($index,$attributes=NULL){
147
-		return $this->_fieldAs(function($id,$name,$value){
148
-			$input= new HtmlRadio($id,$name,$value,$value);
146
+	public function fieldAsRadio($index, $attributes=NULL) {
147
+		return $this->_fieldAs(function($id, $name, $value) {
148
+			$input=new HtmlRadio($id, $name, $value, $value);
149 149
 			return $input;
150
-		}, $index,$attributes,"radio");
150
+		}, $index, $attributes, "radio");
151 151
 	}
152 152
 
153
-	public function fieldAsRadios($index,$elements=[],$attributes=NULL){
154
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){
155
-			return HtmlFormFields::radios($name,$elements,$caption,$value);
156
-		}, $index,$attributes,"radios");
153
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
154
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){
155
+			return HtmlFormFields::radios($name, $elements, $caption, $value);
156
+		}, $index, $attributes, "radios");
157 157
 	}
158 158
 
159
-	public function fieldAsInput($index,$attributes=NULL){
160
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
161
-			$input= new HtmlFormInput($id,$caption,"text",$value);
159
+	public function fieldAsInput($index, $attributes=NULL) {
160
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
161
+			$input=new HtmlFormInput($id, $caption, "text", $value);
162 162
 			return $this->_prepareFormFields($input, $name, $attributes);
163
-		}, $index,$attributes,"input");
163
+		}, $index, $attributes, "input");
164 164
 	}
165 165
 
166
-	public function fieldAsTextarea($index,$attributes=NULL){
167
-		return $this->_fieldAs(function($id,$name,$value){
168
-			$textarea=new HtmlFormTextarea($id,null,$value);
166
+	public function fieldAsTextarea($index, $attributes=NULL) {
167
+		return $this->_fieldAs(function($id, $name, $value) {
168
+			$textarea=new HtmlFormTextarea($id, null, $value);
169 169
 			$textarea->setName($name);
170 170
 			return $textarea;
171
-		}, $index,$attributes,"textarea");
171
+		}, $index, $attributes, "textarea");
172 172
 	}
173 173
 
174
-	public function fieldAsHidden($index,$attributes=NULL){
175
-		if(!\is_array($attributes)){
174
+	public function fieldAsHidden($index, $attributes=NULL) {
175
+		if (!\is_array($attributes)) {
176 176
 			$attributes=[];
177 177
 		}
178 178
 		$attributes["imputType"]="hidden";
179
-		return $this->fieldAsInput($index,$attributes);
179
+		return $this->fieldAsInput($index, $attributes);
180 180
 	}
181 181
 
182
-	public function fieldAsCheckbox($index,$attributes=NULL){
183
-		return $this->_fieldAs(function($id,$name,$value){
184
-			$input=new HtmlFormCheckbox($id,NULL,$this->_instanceViewer->getIdentifier());
182
+	public function fieldAsCheckbox($index, $attributes=NULL) {
183
+		return $this->_fieldAs(function($id, $name, $value) {
184
+			$input=new HtmlFormCheckbox($id, NULL, $this->_instanceViewer->getIdentifier());
185 185
 			$input->setChecked(JString::isBooleanTrue($value));
186 186
 			$input->setName($name);
187 187
 			return $input;
188
-		}, $index,$attributes,"ck");
188
+		}, $index, $attributes, "ck");
189 189
 	}
190 190
 
191
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
192
-		return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){
193
-			$dd=new HtmlFormDropdown($id,$elements,NULL,$value);
194
-			$dd->asSelect($name,$multiple);
191
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
192
+		return $this->_fieldAs(function($id, $name, $value) use($elements, $multiple){
193
+			$dd=new HtmlFormDropdown($id, $elements, NULL, $value);
194
+			$dd->asSelect($name, $multiple);
195 195
 			return $dd;
196
-		}, $index,$attributes,"dd");
196
+		}, $index, $attributes, "dd");
197 197
 	}
198 198
 
199
-	public function fieldAsMessage($index,$attributes=NULL){
200
-		return $this->_fieldAs(function($id,$name,$value,$caption){
201
-			$mess= new HtmlMessage("message-".$id,$value);
199
+	public function fieldAsMessage($index, $attributes=NULL) {
200
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
201
+			$mess=new HtmlMessage("message-".$id, $value);
202 202
 			$mess->addHeader($caption);
203 203
 			return $mess;
204
-		}, $index,$attributes,"message");
204
+		}, $index, $attributes, "message");
205 205
 	}
206 206
 
207 207
 	/**Change fields type
208 208
 	 * @param array $types an array or associative array $type=>$attribute
209 209
 	 */
210
-	public function fieldsAs(array $types){
210
+	public function fieldsAs(array $types) {
211 211
 		$i=0;
212
-		if(JArray::isAssociative($types)){
213
-			foreach ($types as $type=>$attributes){
214
-				if(\is_int($type))
215
-					$this->fieldAs($i++,$attributes,[]);
212
+		if (JArray::isAssociative($types)) {
213
+			foreach ($types as $type=>$attributes) {
214
+				if (\is_int($type))
215
+					$this->fieldAs($i++, $attributes, []);
216 216
 				else
217
-					$this->fieldAs($i++,$type,$attributes);
217
+					$this->fieldAs($i++, $type, $attributes);
218 218
 			}
219
-		}else{
220
-			foreach ($types as $type){
221
-				$this->fieldAs($i++,$type);
219
+		} else {
220
+			foreach ($types as $type) {
221
+				$this->fieldAs($i++, $type);
222 222
 			}
223 223
 		}
224 224
 	}
225 225
 
226
-	public function fieldAs($index,$type,$attributes=NULL){
226
+	public function fieldAs($index, $type, $attributes=NULL) {
227 227
 		$method="fieldAs".\ucfirst($type);
228
-		if(\method_exists($this, $method)){
229
-			if(!\is_array($attributes)){
228
+		if (\method_exists($this, $method)) {
229
+			if (!\is_array($attributes)) {
230 230
 				$attributes=[$index];
231
-			}else{
231
+			} else {
232 232
 				\array_unshift($attributes, $index);
233 233
 			}
234
-			\call_user_func_array([$this,$method], $attributes);
234
+			\call_user_func_array([$this, $method], $attributes);
235 235
 		}
236 236
 	}
237 237
 
238
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
239
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){
240
-			$button=new HtmlButton($id,$value,$cssStyle);
241
-			$this->_buttonAsSubmit($button,"click",$url,$responseElement,$attributes["ajax"]);
238
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
239
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){
240
+			$button=new HtmlButton($id, $value, $cssStyle);
241
+			$this->_buttonAsSubmit($button, "click", $url, $responseElement, $attributes["ajax"]);
242 242
 			return $button;
243
-		}, $index,$attributes,"submit");
243
+		}, $index, $attributes, "submit");
244 244
 	}
245 245
 }
246 246
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/InstanceViewer.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -17,183 +17,183 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public static $index=0;
19 19
 
20
-	public function __construct($identifier,$instance=NULL,$captions=NULL){
20
+	public function __construct($identifier, $instance=NULL, $captions=NULL) {
21 21
 		$this->widgetIdentifier=$identifier;
22 22
 		$this->values=[];
23 23
 		$this->afterCompile=[];
24
-		if(isset($instance))
24
+		if (isset($instance))
25 25
 			$this->setInstance($instance);
26 26
 		$this->setCaptions($captions);
27 27
 		$this->captionCallback=NULL;
28
-		$this->defaultValueFunction=function($name,$value){return $value;};
28
+		$this->defaultValueFunction=function($name, $value) {return $value; };
29 29
 	}
30 30
 
31
-	public function getValues(){
31
+	public function getValues() {
32 32
 		$values=[];
33 33
 		$index=0;
34 34
 		$count=$this->count();
35
-		while($index<$count){
35
+		while ($index<$count) {
36 36
 			$values[]=$this->getValue($index++);
37 37
 		}
38 38
 		return $values;
39 39
 	}
40 40
 
41
-	public function getIdentifier($index=NULL){
42
-		if(!isset($index))
41
+	public function getIdentifier($index=NULL) {
42
+		if (!isset($index))
43 43
 			$index=self::$index;
44 44
 		$value=$index;
45
-		if(isset($this->values["identifier"]))
46
-			$value=$this->values["identifier"]($index,$this->instance);
45
+		if (isset($this->values["identifier"]))
46
+			$value=$this->values["identifier"]($index, $this->instance);
47 47
 		return $value;
48 48
 	}
49 49
 
50
-	public function getValue($index){
50
+	public function getValue($index) {
51 51
 		$property=$this->properties[$index];
52 52
 		return $this->_getValue($property, $index);
53 53
 	}
54 54
 
55
-	protected function _beforeAddProperty($index,&$field){
55
+	protected function _beforeAddProperty($index, &$field) {
56 56
 
57 57
 	}
58 58
 
59
-	protected function _getDefaultValue($name,$value,$index){
59
+	protected function _getDefaultValue($name, $value, $index) {
60 60
 		$func=$this->defaultValueFunction;
61
-		return $func($name,$value,$index,$this->instance);
61
+		return $func($name, $value, $index, $this->instance);
62 62
 	}
63 63
 
64
-	protected function _getValue($property,$index){
65
-		if($property instanceof \ReflectionProperty){
64
+	protected function _getValue($property, $index) {
65
+		if ($property instanceof \ReflectionProperty) {
66 66
 			$property->setAccessible(true);
67 67
 			$value=$property->getValue($this->instance);
68
-			if(isset($this->values[$index])){
69
-				$value= $this->values[$index]($value,$this->instance,$index);
70
-			}else{
71
-				$value=$this->_getDefaultValue($property->getName(),$value, $index);
68
+			if (isset($this->values[$index])) {
69
+				$value=$this->values[$index]($value, $this->instance, $index);
70
+			} else {
71
+				$value=$this->_getDefaultValue($property->getName(), $value, $index);
72 72
 			}
73
-		}else{
74
-			if(\is_callable($property))
73
+		} else {
74
+			if (\is_callable($property))
75 75
 				$value=$property($this->instance);
76
-			elseif(\is_array($property)){
77
-				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
76
+			elseif (\is_array($property)) {
77
+				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property);
78 78
 				$value=\implode("", $values);
79
-			}else{
80
-				if(isset($this->values[$index])){
81
-					$value= $this->values[$index]($property,$this->instance,$index);
82
-				}elseif(isset($this->instance->{$property})){
79
+			} else {
80
+				if (isset($this->values[$index])) {
81
+					$value=$this->values[$index]($property, $this->instance, $index);
82
+				}elseif (isset($this->instance->{$property})) {
83 83
 					$value=$this->instance->{$property};
84 84
 				}
85
-				else{
85
+				else {
86 86
 					$value=null;
87 87
 				}
88 88
 			}
89 89
 		}
90
-		if(isset($this->afterCompile[$index])){
91
-			if(\is_callable($this->afterCompile[$index])){
92
-				$this->afterCompile[$index]($value,$this->instance,$index);
90
+		if (isset($this->afterCompile[$index])) {
91
+			if (\is_callable($this->afterCompile[$index])) {
92
+				$this->afterCompile[$index]($value, $this->instance, $index);
93 93
 			}
94 94
 		}
95 95
 		return $value;
96 96
 	}
97 97
 
98
-	public function insertField($index,$field){
99
-		array_splice( $this->visibleProperties, $index, 0, $field );
98
+	public function insertField($index, $field) {
99
+		array_splice($this->visibleProperties, $index, 0, $field);
100 100
 		return $this;
101 101
 	}
102 102
 
103
-	public function insertInField($index,$field){
103
+	public function insertInField($index, $field) {
104 104
 		$vb=$this->visibleProperties;
105
-		if(isset($vb[$index])){
106
-			if(\is_array($vb[$index])){
105
+		if (isset($vb[$index])) {
106
+			if (\is_array($vb[$index])) {
107 107
 				$this->visibleProperties[$index][]=$field;
108
-			}else{
109
-				$this->visibleProperties[$index]=[$vb[$index],$field];
108
+			} else {
109
+				$this->visibleProperties[$index]=[$vb[$index], $field];
110 110
 			}
111
-		}else{
111
+		} else {
112 112
 			return $this->insertField($index, $field);
113 113
 		}
114 114
 		return $this;
115 115
 	}
116 116
 
117
-	public function addField($field){
117
+	public function addField($field) {
118 118
 		$this->visibleProperties[]=$field;
119 119
 		return $this;
120 120
 	}
121 121
 
122
-	public function count(){
122
+	public function count() {
123 123
 		return \sizeof($this->properties);
124 124
 	}
125 125
 
126
-	public function visiblePropertiesCount(){
126
+	public function visiblePropertiesCount() {
127 127
 		return \sizeof($this->visibleProperties);
128 128
 	}
129 129
 
130
-	public function getProperty($index){
130
+	public function getProperty($index) {
131 131
 		return $this->properties[$index];
132 132
 	}
133 133
 
134
-	public function getFieldName($index){
134
+	public function getFieldName($index) {
135 135
 		$property=$this->getProperty($index);
136
-		if($property instanceof \ReflectionProperty){
136
+		if ($property instanceof \ReflectionProperty) {
137 137
 			$result=$property->getName();
138
-		}elseif(\is_callable($property)){
138
+		}elseif (\is_callable($property)) {
139 139
 			$result=$this->visibleProperties[$index];
140
-		}else{
140
+		} else {
141 141
 			$result=$property;
142 142
 		}
143 143
 		return $result;
144 144
 	}
145 145
 
146 146
 
147
-	protected function showableProperty(\ReflectionProperty $rProperty){
148
-		return JString::startswith($rProperty->getName(),"_")===false;
147
+	protected function showableProperty(\ReflectionProperty $rProperty) {
148
+		return JString::startswith($rProperty->getName(), "_")===false;
149 149
 	}
150 150
 
151 151
 	public function setInstance($instance) {
152
-		if(\is_string($instance)){
152
+		if (\is_string($instance)) {
153 153
 			$instance=new $instance();
154 154
 		}
155 155
 		$this->instance=$instance;
156 156
 		$this->properties=[];
157 157
 		$this->reflect=new \ReflectionClass($instance);
158
-		if(\sizeof($this->visibleProperties)===0){
158
+		if (\sizeof($this->visibleProperties)===0) {
159 159
 			$this->properties=$this->getDefaultProperties();
160
-		}else{
161
-			foreach ($this->visibleProperties as $property){
160
+		} else {
161
+			foreach ($this->visibleProperties as $property) {
162 162
 				$this->setInstanceProperty($property);
163 163
 			}
164 164
 		}
165 165
 		return $this;
166 166
 	}
167 167
 
168
-	private function setInstanceProperty($property){
169
-		if(\is_callable($property)){
168
+	private function setInstanceProperty($property) {
169
+		if (\is_callable($property)) {
170 170
 			$this->properties[]=$property;
171
-		}elseif(\is_string($property)){
172
-			try{
171
+		}elseif (\is_string($property)) {
172
+			try {
173 173
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
174 174
 				$rProperty=$this->reflect->getProperty($property);
175 175
 				$this->properties[]=$rProperty;
176
-			}catch(\Exception $e){
176
+			}catch (\Exception $e) {
177 177
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
178 178
 				$this->properties[]=$property;
179 179
 			}
180
-		}elseif(\is_int($property)){
180
+		}elseif (\is_int($property)) {
181 181
 			$props=$this->getDefaultProperties();
182
-			if(isset($props[$property]))
182
+			if (isset($props[$property]))
183 183
 				$this->properties[]=$props[$property];
184 184
 				else
185 185
 					$this->properties[]=$property;
186
-		}else{
186
+		} else {
187 187
 			$this->properties[]=$property;
188 188
 		}
189 189
 	}
190 190
 
191
-	protected function getDefaultProperties(){
191
+	protected function getDefaultProperties() {
192 192
 		$result=[];
193 193
 		$properties=$this->reflect->getProperties();
194
-		foreach ($properties as $property){
194
+		foreach ($properties as $property) {
195 195
 			$showable=$this->showableProperty($property);
196
-			if($showable!==false){
196
+			if ($showable!==false) {
197 197
 				$result[]=$property;
198 198
 			}
199 199
 		}
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
 		return $this;
206 206
 	}
207 207
 
208
-	public function setValueFunction($index,$callback){
208
+	public function setValueFunction($index, $callback) {
209 209
 		$this->values[$index]=$callback;
210 210
 		return $this;
211 211
 	}
212 212
 
213
-	public function setIdentifierFunction($callback){
213
+	public function setIdentifierFunction($callback) {
214 214
 		$this->values["identifier"]=$callback;
215 215
 		return $this;
216 216
 	}
@@ -223,41 +223,41 @@  discard block
 block discarded – undo
223 223
 		return $this->properties;
224 224
 	}
225 225
 
226
-	public function getCaption($index){
227
-		if(isset($this->captions[$index])){
226
+	public function getCaption($index) {
227
+		if (isset($this->captions[$index])) {
228 228
 			return $this->captions[$index];
229 229
 		}
230
-		if($this->properties[$index] instanceof \ReflectionProperty)
230
+		if ($this->properties[$index] instanceof \ReflectionProperty)
231 231
 			return $this->properties[$index]->getName();
232
-		elseif(\is_callable($this->properties[$index]))
232
+		elseif (\is_callable($this->properties[$index]))
233 233
 			return "";
234 234
 		else
235 235
 			return $this->properties[$index];
236 236
 	}
237 237
 
238
-	public function getCaptions(){
239
-		if(isset($this->captions)){
240
-			$captions= $this->captions;
241
-			for($i=\sizeof($captions);$i<$this->count();$i++){
238
+	public function getCaptions() {
239
+		if (isset($this->captions)) {
240
+			$captions=$this->captions;
241
+			for ($i=\sizeof($captions); $i<$this->count(); $i++) {
242 242
 				$captions[]="";
243 243
 			}
244
-		}else{
244
+		} else {
245 245
 			$captions=[];
246 246
 			$index=0;
247 247
 			$count=$this->count();
248
-			while($index<$count){
248
+			while ($index<$count) {
249 249
 				$captions[]=$this->getCaption($index++);
250 250
 			}
251 251
 		}
252
-		if(isset($this->captionCallback) && \is_callable($this->captionCallback)){
252
+		if (isset($this->captionCallback) && \is_callable($this->captionCallback)) {
253 253
 			$callback=$this->captionCallback;
254
-			$callback($captions,$this->instance);
254
+			$callback($captions, $this->instance);
255 255
 		}
256 256
 		return $captions;
257 257
 	}
258 258
 
259
-	public function setCaption($index,$caption){
260
-		if(isset($this->captions)===false)
259
+	public function setCaption($index, $caption) {
260
+		if (isset($this->captions)===false)
261 261
 			$this->captions=[];
262 262
 		$this->captions[$index]=$caption;
263 263
 		return $this;
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	 * @param callable $callback function called after the field compilation
276 276
 	 * @return \Ajax\semantic\widgets\datatable\InstanceViewer
277 277
 	 */
278
-	public function afterCompile($index,$callback){
278
+	public function afterCompile($index, $callback) {
279 279
 		$this->afterCompile[$index]=$callback;
280 280
 		return $this;
281 281
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 1 patch
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -34,33 +34,33 @@  discard block
 block discarded – undo
34 34
 	protected $_visibleHover=false;
35 35
 	protected $_targetSelector;
36 36
 
37
-	public function __construct($identifier,$model,$modelInstance=NULL) {
38
-		parent::__construct($identifier, $model,$modelInstance);
39
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
37
+	public function __construct($identifier, $model, $modelInstance=NULL) {
38
+		parent::__construct($identifier, $model, $modelInstance);
39
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
40 40
 		$this->_urls=[];
41 41
 	}
42 42
 
43
-	public function run(JsUtils $js){
44
-		if($this->_hasCheckboxes && isset($js)){
43
+	public function run(JsUtils $js) {
44
+		if ($this->_hasCheckboxes && isset($js)) {
45 45
 			$js->execOn("change", "#".$this->identifier." [name='selection[]']", "
46 46
 					var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true;
47 47
 					\$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}});
48 48
 					if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');}");
49 49
 		}
50
-		if($this->_visibleHover){
51
-			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
52
-			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
50
+		if ($this->_visibleHover) {
51
+			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]);
52
+			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]);
53 53
 		}
54
-		if($this->_hasDelete)
54
+		if ($this->_hasDelete)
55 55
 			$this->_generateBehavior("delete", $js);
56
-		if($this->_hasEdit)
56
+		if ($this->_hasEdit)
57 57
 			$this->_generateBehavior("edit", $js);
58 58
 		return parent::run($js);
59 59
 	}
60 60
 
61
-	protected function _generateBehavior($op,JsUtils $js){
62
-		if(isset($this->_urls[$op]))
63
-			$js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]);
61
+	protected function _generateBehavior($op, JsUtils $js) {
62
+		if (isset($this->_urls[$op]))
63
+			$js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op], $this->getTargetSelector(), ["preventDefault"=>false, "attr"=>"data-ajax"]);
64 64
 	}
65 65
 
66 66
 	/**
@@ -72,67 +72,67 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 
75
-	public function compile(JsUtils $js=NULL,&$view=NULL){
76
-		if(!$this->_generated){
75
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
76
+		if (!$this->_generated) {
77 77
 			$this->_instanceViewer->setInstance($this->_model);
78 78
 			$captions=$this->_instanceViewer->getCaptions();
79 79
 
80 80
 			$table=$this->content["table"];
81 81
 
82
-			if($this->_hasCheckboxes){
82
+			if ($this->_hasCheckboxes) {
83 83
 				$this->_generateMainCheckbox($captions);
84 84
 			}
85 85
 
86 86
 			$table->setRowCount(0, \sizeof($captions));
87 87
 			$table->setHeaderValues($captions);
88
-			if(isset($this->_compileParts))
88
+			if (isset($this->_compileParts))
89 89
 				$table->setCompileParts($this->_compileParts);
90 90
 
91
-			if(isset($this->_searchField) && isset($js)){
92
-				if(isset($this->_urls["refresh"]))
93
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
91
+			if (isset($this->_searchField) && isset($js)) {
92
+				if (isset($this->_urls["refresh"]))
93
+					$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
94 94
 			}
95 95
 
96 96
 			$this->_generateContent($table);
97 97
 
98
-			if($this->_hasCheckboxes && $table->hasPart("thead")){
99
-					$table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort");
98
+			if ($this->_hasCheckboxes && $table->hasPart("thead")) {
99
+					$table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort");
100 100
 			}
101 101
 
102
-			if(isset($this->_pagination) && $this->_pagination->getVisible()){
102
+			if (isset($this->_pagination) && $this->_pagination->getVisible()) {
103 103
 				$this->_generatePagination($table);
104 104
 			}
105
-			if(isset($this->_toolbar)){
105
+			if (isset($this->_toolbar)) {
106 106
 				$this->_setToolbarPosition($table, $captions);
107 107
 			}
108
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
108
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
109 109
 			$this->_compileForm();
110 110
 			$this->_generated=true;
111 111
 		}
112
-		return parent::compile($js,$view);
112
+		return parent::compile($js, $view);
113 113
 	}
114 114
 
115
-	private function _generateMainCheckbox(&$captions){
116
-		$ck=new HtmlCheckbox("main-ck-".$this->identifier,"");
115
+	private function _generateMainCheckbox(&$captions) {
116
+		$ck=new HtmlCheckbox("main-ck-".$this->identifier, "");
117 117
 		$ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);");
118 118
 		$ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);");
119 119
 		\array_unshift($captions, $ck);
120 120
 	}
121 121
 
122
-	protected function _generateContent($table){
122
+	protected function _generateContent($table) {
123 123
 		$objects=$this->_modelInstance;
124
-		if(isset($this->_pagination)){
124
+		if (isset($this->_pagination)) {
125 125
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
126 126
 		}
127 127
 		InstanceViewer::setIndex(0);
128 128
 		$table->fromDatabaseObjects($objects, function($instance) use($table){
129 129
 			$this->_instanceViewer->setInstance($instance);
130 130
 			InstanceViewer::$index++;
131
-			$values= $this->_instanceViewer->getValues();
132
-			if($this->_hasCheckboxes){
133
-				$ck=new HtmlCheckbox("ck-".$this->identifier,"");
131
+			$values=$this->_instanceViewer->getValues();
132
+			if ($this->_hasCheckboxes) {
133
+				$ck=new HtmlCheckbox("ck-".$this->identifier, "");
134 134
 				$field=$ck->getField();
135
-				$field->setProperty("value",$this->_instanceViewer->getIdentifier());
135
+				$field->setProperty("value", $this->_instanceViewer->getIdentifier());
136 136
 				$field->setProperty("name", "selection[]");
137 137
 				\array_unshift($values, $ck);
138 138
 			}
@@ -143,37 +143,37 @@  discard block
 block discarded – undo
143 143
 		});
144 144
 	}
145 145
 
146
-	private function _generatePagination($table){
146
+	private function _generatePagination($table) {
147 147
 		$footer=$table->getFooter();
148 148
 		$footer->mergeCol();
149
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
149
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
150 150
 		$menu->floatRight();
151 151
 		$menu->setActiveItem($this->_pagination->getPage()-1);
152 152
 		$footer->setValues($menu);
153
-		if(isset($this->_urls["refresh"]))
154
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
153
+		if (isset($this->_urls["refresh"]))
154
+			$menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
155 155
 	}
156 156
 
157
-	protected function _getFieldName($index){
157
+	protected function _getFieldName($index) {
158 158
 		return parent::_getFieldName($index)."[]";
159 159
 	}
160 160
 
161
-	protected function _getFieldCaption($index){
161
+	protected function _getFieldCaption($index) {
162 162
 		return null;
163 163
 	}
164 164
 
165
-	protected function _setToolbarPosition($table,$captions=NULL){
166
-		switch ($this->_toolbarPosition){
165
+	protected function _setToolbarPosition($table, $captions=NULL) {
166
+		switch ($this->_toolbarPosition) {
167 167
 			case PositionInTable::BEFORETABLE:
168 168
 			case PositionInTable::AFTERTABLE:
169
-				if(isset($this->_compileParts)===false){
169
+				if (isset($this->_compileParts)===false) {
170 170
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
171 171
 				}
172 172
 				break;
173 173
 			case PositionInTable::HEADER:
174 174
 			case PositionInTable::FOOTER:
175 175
 			case PositionInTable::BODY:
176
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
176
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
177 177
 				break;
178 178
 		}
179 179
 	}
@@ -185,23 +185,23 @@  discard block
 block discarded – undo
185 185
 	 * @param callable $callback function called after the field compilation
186 186
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
187 187
 	 */
188
-	public function afterCompile($index,$callback){
189
-		$this->_instanceViewer->afterCompile($index,$callback);
188
+	public function afterCompile($index, $callback) {
189
+		$this->_instanceViewer->afterCompile($index, $callback);
190 190
 		return $this;
191 191
 	}
192 192
 
193
-	private function addToolbarRow($part,$table,$captions){
193
+	private function addToolbarRow($part, $table, $captions) {
194 194
 		$hasPart=$table->hasPart($part);
195
-		if($hasPart){
195
+		if ($hasPart) {
196 196
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
197
-		}else{
197
+		} else {
198 198
 			$row=$table->getPart($part)->getRow(0);
199 199
 		}
200 200
 		$row->mergeCol();
201 201
 		$row->setValues([$this->_toolbar]);
202 202
 	}
203 203
 
204
-	public function getHtmlComponent(){
204
+	public function getHtmlComponent() {
205 205
 		return $this->content["table"];
206 206
 	}
207 207
 
@@ -215,18 +215,18 @@  discard block
 block discarded – undo
215 215
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
216 216
 	 */
217 217
 	public function setUrls($urls) {
218
-		if(\is_array($urls)){
219
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
220
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
221
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
222
-		}else{
223
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
218
+		if (\is_array($urls)) {
219
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
220
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
221
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
222
+		} else {
223
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls];
224 224
 		}
225 225
 		return $this;
226 226
 	}
227 227
 
228
-	public function paginate($items_per_page=10,$page=1){
229
-		$this->_pagination=new Pagination($items_per_page,4,$page);
228
+	public function paginate($items_per_page=10, $page=1) {
229
+		$this->_pagination=new Pagination($items_per_page, 4, $page);
230 230
 	}
231 231
 
232 232
 	public function getHasCheckboxes() {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		return $this;
239 239
 	}
240 240
 
241
-	public function refresh($compileParts=["tbody"]){
241
+	public function refresh($compileParts=["tbody"]) {
242 242
 		$this->_compileParts=$compileParts;
243 243
 		return $this;
244 244
 	}
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param boolean $visibleHover
249 249
 	 * @return callable
250 250
 	 */
251
-	private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){
252
-		return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback);
251
+	private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) {
252
+		return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback);
253 253
 	}
254 254
 
255 255
 	/**
@@ -258,19 +258,19 @@  discard block
 block discarded – undo
258 258
 	 * @param callable $callback
259 259
 	 * @return callable
260 260
 	 */
261
-	private function getCallable($thisCallback,$parameters,$callback=null){
262
-		$result=function($instance) use($thisCallback,$parameters,$callback){
263
-			$object=call_user_func_array(array($this,$thisCallback), $parameters);
264
-			if(isset($callback)){
265
-				if(\is_callable($callback)){
266
-					$callback($object,$instance);
261
+	private function getCallable($thisCallback, $parameters, $callback=null) {
262
+		$result=function($instance) use($thisCallback, $parameters, $callback){
263
+			$object=call_user_func_array(array($this, $thisCallback), $parameters);
264
+			if (isset($callback)) {
265
+				if (\is_callable($callback)) {
266
+					$callback($object, $instance);
267 267
 				}
268 268
 			}
269
-			if($object instanceof HtmlSemDoubleElement){
270
-				$object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier());
271
-				if($object->propertyContains("class","visibleover")){
269
+			if ($object instanceof HtmlSemDoubleElement) {
270
+				$object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier());
271
+				if ($object->propertyContains("class", "visibleover")) {
272 272
 					$this->_visibleHover=true;
273
-					$object->setProperty("style","visibility:hidden;");
273
+					$object->setProperty("style", "visibility:hidden;");
274 274
 				}
275 275
 			}
276 276
 			return $object;
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
 	 * @param string $caption
283 283
 	 * @return HtmlButton
284 284
 	 */
285
-	private function getFieldButton($caption,$visibleHover=true){
286
-		$bt= new HtmlButton("",$caption);
287
-		if($visibleHover)
285
+	private function getFieldButton($caption, $visibleHover=true) {
286
+		$bt=new HtmlButton("", $caption);
287
+		if ($visibleHover)
288 288
 			$this->_visibleOver($bt);
289 289
 		return $bt;
290 290
 	}
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 	 * @param boolean $visibleHover
297 297
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
298 298
 	 */
299
-	public function addFieldButton($caption,$visibleHover=true,$callback=null){
300
-		$this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback));
299
+	public function addFieldButton($caption, $visibleHover=true, $callback=null) {
300
+		$this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback));
301 301
 		return $this;
302 302
 	}
303 303
 
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 	 * @param callable $callback
309 309
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
310 310
 	 */
311
-	public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){
312
-		$this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
311
+	public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) {
312
+		$this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
313 313
 		return $this;
314 314
 	}
315 315
 
@@ -320,64 +320,64 @@  discard block
 block discarded – undo
320 320
 	 * @param callable $callback
321 321
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
322 322
 	 */
323
-	public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){
324
-		$this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
323
+	public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) {
324
+		$this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
325 325
 		return $this;
326 326
 	}
327 327
 
328
-	private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){
329
-		$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
328
+	private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) {
329
+		$this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
330 330
 		return $this;
331 331
 	}
332 332
 
333
-	private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){
334
-		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
333
+	private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) {
334
+		$this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
335 335
 		return $this;
336 336
 	}
337 337
 
338
-	private function getDefaultButton($icon,$class=null,$visibleHover=true){
339
-		$bt=$this->getFieldButton("",$visibleHover);
338
+	private function getDefaultButton($icon, $class=null, $visibleHover=true) {
339
+		$bt=$this->getFieldButton("", $visibleHover);
340 340
 		$bt->asIcon($icon);
341
-		if(isset($class))
341
+		if (isset($class))
342 342
 			$bt->addToProperty("class", $class);
343 343
 		return $bt;
344 344
 	}
345 345
 
346
-	public function addDeleteButton($visibleHover=true,$generateBehavior=true,$callback=null){
346
+	public function addDeleteButton($visibleHover=true, $generateBehavior=true, $callback=null) {
347 347
 		$this->_hasDelete=$generateBehavior;
348
-		return $this->addDefaultButton("remove","delete red basic",$visibleHover,$callback);
348
+		return $this->addDefaultButton("remove", "delete red basic", $visibleHover, $callback);
349 349
 	}
350 350
 
351
-	public function addEditButton($visibleHover=true,$generateBehavior=true,$callback=null){
351
+	public function addEditButton($visibleHover=true, $generateBehavior=true, $callback=null) {
352 352
 		$this->_hasEdit=$generateBehavior;
353
-		return $this->addDefaultButton("edit","edit basic",$visibleHover,$callback);
353
+		return $this->addDefaultButton("edit", "edit basic", $visibleHover, $callback);
354 354
 	}
355 355
 
356
-	public function addEditDeleteButtons($visibleHover=true,$generateBehavior=true,$callbackEdit=null,$callbackDelete=null){
357
-		$this->addEditButton($visibleHover,$generateBehavior,$callbackEdit);
356
+	public function addEditDeleteButtons($visibleHover=true, $generateBehavior=true, $callbackEdit=null, $callbackDelete=null) {
357
+		$this->addEditButton($visibleHover, $generateBehavior, $callbackEdit);
358 358
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
359
-		$this->insertDeleteButtonIn($index,$visibleHover,$generateBehavior,$callbackDelete);
359
+		$this->insertDeleteButtonIn($index, $visibleHover, $generateBehavior, $callbackDelete);
360 360
 		return $this;
361 361
 	}
362 362
 
363
-	public function insertDeleteButtonIn($index,$visibleHover=true,$generateBehavior=true,$callback=null){
363
+	public function insertDeleteButtonIn($index, $visibleHover=true, $generateBehavior=true, $callback=null) {
364 364
 		$this->_hasDelete=$generateBehavior;
365
-		return $this->insertDefaultButtonIn($index,"remove","delete red basic",$visibleHover,$callback);
365
+		return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $visibleHover, $callback);
366 366
 	}
367 367
 
368
-	public function insertEditButtonIn($index,$visibleHover=true,$generateBehavior=true,$callback=null){
368
+	public function insertEditButtonIn($index, $visibleHover=true, $generateBehavior=true, $callback=null) {
369 369
 		$this->_hasEdit=$generateBehavior;
370
-		return $this->insertDefaultButtonIn($index,"edit","edit basic",$visibleHover,$callback);
370
+		return $this->insertDefaultButtonIn($index, "edit", "edit basic", $visibleHover, $callback);
371 371
 	}
372 372
 
373
-	public function addSearchInToolbar($position=Direction::RIGHT){
373
+	public function addSearchInToolbar($position=Direction::RIGHT) {
374 374
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
375 375
 	}
376 376
 
377
-	public function getSearchField(){
378
-		if(isset($this->_searchField)===false){
379
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
380
-			$this->_searchField->addIcon("search",Direction::RIGHT);
377
+	public function getSearchField() {
378
+		if (isset($this->_searchField)===false) {
379
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
380
+			$this->_searchField->addIcon("search", Direction::RIGHT);
381 381
 		}
382 382
 		return $this->_searchField;
383 383
 	}
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 		return $this;
394 394
 	}
395 395
 
396
-	public function asForm(){
396
+	public function asForm() {
397 397
 		return $this->getForm();
398 398
 	}
399 399
 
@@ -406,24 +406,24 @@  discard block
 block discarded – undo
406 406
 	 * @param array $attributes
407 407
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
408 408
 	 */
409
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
410
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){
411
-			$button=new HtmlButton($id,$value,$cssStyle);
412
-			$button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]);
413
-			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
409
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
410
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){
411
+			$button=new HtmlButton($id, $value, $cssStyle);
412
+			$button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]);
413
+			if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
414 414
 				$this->_visibleOver($button);
415 415
 			return $button;
416
-		}, $index,$attributes);
416
+		}, $index, $attributes);
417 417
 	}
418 418
 
419
-	protected function _visibleOver($element){
419
+	protected function _visibleOver($element) {
420 420
 		$this->_visibleHover=true;
421
-		return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;");
421
+		return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;");
422 422
 	}
423 423
 
424 424
 	protected function getTargetSelector() {
425 425
 		$result=$this->_targetSelector;
426
-		if(!isset($result))
426
+		if (!isset($result))
427 427
 			$result="#".$this->identifier;
428 428
 		return $result;
429 429
 	}
Please login to merge, or discard this patch.