Completed
Push — master ( da7bd7...a4feba )
by Jean-Christophe
03:22
created
Ajax/semantic/html/content/table/HtmlTableContent.php 1 patch
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -62,6 +62,9 @@  discard block
 block discarded – undo
62 62
 		return $tr;
63 63
 	}
64 64
 
65
+	/**
66
+	 * @param integer $value
67
+	 */
65 68
 	public function newRow($value) {
66 69
 		return $this->createItem($value);
67 70
 	}
@@ -160,6 +163,9 @@  discard block
 block discarded – undo
160 163
 		return $this;
161 164
 	}
162 165
 
166
+	/**
167
+	 * @param integer $colIndex
168
+	 */
163 169
 	public function setColValues($colIndex, $values=array()) {
164 170
 		$count=$this->count();
165 171
 		if (!\is_array($values)) {
@@ -180,6 +186,9 @@  discard block
 block discarded – undo
180 186
 		return $this;
181 187
 	}
182 188
 
189
+	/**
190
+	 * @param integer $rowIndex
191
+	 */
183 192
 	public function setRowValues($rowIndex, $values=array()) {
184 193
 		$count=$this->count();
185 194
 		if (!\is_array($values)) {
@@ -189,6 +198,9 @@  discard block
 block discarded – undo
189 198
 		return $this;
190 199
 	}
191 200
 
201
+	/**
202
+	 * @param string $function
203
+	 */
192 204
 	private function colAlign($colIndex, $function) {
193 205
 		$count=$this->count();
194 206
 		for($i=0; $i < $count; $i++) {
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/FieldAsTrait.php 2 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -29,9 +29,17 @@  discard block
 block discarded – undo
29 29
 trait FieldAsTrait{
30 30
 
31 31
 	abstract protected function _getFieldIdentifier($prefix,$name="");
32
+
33
+	/**
34
+	 * @param \Closure $callback
35
+	 */
32 36
 	abstract public function setValueFunction($index,$callback);
33 37
 	abstract protected function _getFieldName($index);
34 38
 	abstract protected function _getFieldCaption($index);
39
+
40
+	/**
41
+	 * @param string $event
42
+	 */
35 43
 	abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL);
36 44
 
37 45
 	/**
@@ -242,6 +250,9 @@  discard block
 block discarded – undo
242 250
 		}
243 251
 	}
244 252
 
253
+	/**
254
+	 * @param integer $index
255
+	 */
245 256
 	public function fieldAs($index,$type,$attributes=NULL){
246 257
 		$method="fieldAs".\ucfirst($type);
247 258
 		if(\method_exists($this, $method)){
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -26,23 +26,23 @@  discard block
 block discarded – undo
26 26
  * @property boolean $_edition
27 27
  * @property mixed _modelInstance
28 28
  */
29
-trait FieldAsTrait{
29
+trait FieldAsTrait {
30 30
 
31
-	abstract protected function _getFieldIdentifier($prefix,$name="");
32
-	abstract public function setValueFunction($index,$callback);
31
+	abstract protected function _getFieldIdentifier($prefix, $name="");
32
+	abstract public function setValueFunction($index, $callback);
33 33
 	abstract protected function _getFieldName($index);
34 34
 	abstract protected function _getFieldCaption($index);
35
-	abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL);
35
+	abstract protected function _buttonAsSubmit(HtmlButton&$button, $event, $url, $responseElement=NULL, $parameters=NULL);
36 36
 
37 37
 	/**
38 38
 	 * @param HtmlFormField $element
39 39
 	 * @param array $attributes
40 40
 	 */
41
-	protected function _applyAttributes($element,&$attributes,$index){
42
-		if(isset($attributes["jsCallback"])){
41
+	protected function _applyAttributes($element, &$attributes, $index) {
42
+		if (isset($attributes["jsCallback"])) {
43 43
 			$callback=$attributes["jsCallback"];
44
-			if(\is_callable($callback)){
45
-				$callback($element,$this->_modelInstance,$index);
44
+			if (\is_callable($callback)) {
45
+				$callback($element, $this->_modelInstance, $index);
46 46
 				unset($attributes["jsCallback"]);
47 47
 			}
48 48
 		}
@@ -52,43 +52,43 @@  discard block
 block discarded – undo
52 52
 		$element->fromArray($attributes);
53 53
 	}
54 54
 
55
-	private function _getLabelField($caption,$icon=NULL){
56
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
55
+	private function _getLabelField($caption, $icon=NULL) {
56
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
57 57
 		return $label;
58 58
 	}
59 59
 
60 60
 
61
-	protected function _addRules($element,&$attributes){
62
-		if(isset($attributes["rules"])){
61
+	protected function _addRules($element, &$attributes) {
62
+		if (isset($attributes["rules"])) {
63 63
 			$rules=$attributes["rules"];
64
-			if(\is_array($rules)){
64
+			if (\is_array($rules)) {
65 65
 				$element->addRules($rules);
66 66
 			}
67
-			else{
67
+			else {
68 68
 				$element->addRule($rules);
69 69
 			}
70 70
 			unset($attributes["rules"]);
71 71
 		}
72 72
 	}
73 73
 
74
-	protected function _prepareFormFields(&$field,$name,&$attributes){
74
+	protected function _prepareFormFields(&$field, $name, &$attributes) {
75 75
 		$field->setName($name);
76 76
 		$this->_addRules($field, $attributes);
77 77
 		return $field;
78 78
 	}
79 79
 
80
-	protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){
81
-		$this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){
80
+	protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) {
81
+		$this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){
82 82
 			$caption=$this->_getFieldCaption($index);
83 83
 			$name=$this->_getFieldName($index);
84
-			$id=$this->_getFieldIdentifier($prefix,$name);
85
-			if(isset($attributes["name"])){
84
+			$id=$this->_getFieldIdentifier($prefix, $name);
85
+			if (isset($attributes["name"])) {
86 86
 				$name=$attributes["name"];
87 87
 				unset($attributes["name"]);
88 88
 			}
89
-			$element=$elementCallback($id,$name,$value,$caption);
90
-			if(\is_array($attributes)){
91
-				$this->_applyAttributes($element, $attributes,$index);
89
+			$element=$elementCallback($id, $name, $value, $caption);
90
+			if (\is_array($attributes)) {
91
+				$this->_applyAttributes($element, $attributes, $index);
92 92
 			}
93 93
 			$element->setDisabled(!$this->_edition);
94 94
 			return $element;
@@ -97,175 +97,175 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 
99 99
 
100
-	public function fieldAsProgress($index,$label=NULL, $attributes=array()){
101
-		$this->setValueFunction($index,function($value) use($label,$attributes){
102
-			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes);
100
+	public function fieldAsProgress($index, $label=NULL, $attributes=array()) {
101
+		$this->setValueFunction($index, function($value) use($label, $attributes){
102
+			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
103 103
 			return $pb;
104 104
 		});
105 105
 			return $this;
106 106
 	}
107 107
 
108
-	public function fieldAsRating($index,$max=5, $icon=""){
109
-		$this->setValueFunction($index,function($value) use($max,$icon){
110
-			$rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon);
108
+	public function fieldAsRating($index, $max=5, $icon="") {
109
+		$this->setValueFunction($index, function($value) use($max, $icon){
110
+			$rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
111 111
 			return $rating;
112 112
 		});
113 113
 			return $this;
114 114
 	}
115 115
 
116
-	public function fieldAsLabel($index,$icon=NULL){
117
-		$this->setValueFunction($index,function($caption) use($icon){
118
-			$lbl=$this->_getLabelField($caption,$icon);
116
+	public function fieldAsLabel($index, $icon=NULL) {
117
+		$this->setValueFunction($index, function($caption) use($icon){
118
+			$lbl=$this->_getLabelField($caption, $icon);
119 119
 			return $lbl;
120 120
 		});
121 121
 			return $this;
122 122
 	}
123 123
 
124
-	public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){
125
-		return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){
126
-			$header=new HtmlHeader($id,$niveau,$value);
127
-			if(isset($icon))
124
+	public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) {
125
+		return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){
126
+			$header=new HtmlHeader($id, $niveau, $value);
127
+			if (isset($icon))
128 128
 				$header->asIcon($icon, $value);
129 129
 			return $header;
130
-		}, $index,$attributes,"header");
130
+		}, $index, $attributes, "header");
131 131
 	}
132 132
 
133 133
 
134
-	public function fieldAsImage($index,$size=Size::MINI,$circular=false){
135
-		$this->setValueFunction($index,function($img) use($size,$circular){
136
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
134
+	public function fieldAsImage($index, $size=Size::MINI, $circular=false) {
135
+		$this->setValueFunction($index, function($img) use($size, $circular){
136
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
137 137
 			return $image;
138 138
 		});
139 139
 			return $this;
140 140
 	}
141 141
 
142
-	public function fieldAsFlag($index){
143
-		$this->setValueFunction($index,function($flag){
144
-			$flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag);
142
+	public function fieldAsFlag($index) {
143
+		$this->setValueFunction($index, function($flag) {
144
+			$flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag);
145 145
 			return $flag;
146 146
 		});
147 147
 			return $this;
148 148
 	}
149 149
 
150
-	public function fieldAsAvatar($index,$attributes=NULL){
151
-		return $this->_fieldAs(function($id,$name,$value){
152
-			$img=new HtmlImage($id,$value);
150
+	public function fieldAsAvatar($index, $attributes=NULL) {
151
+		return $this->_fieldAs(function($id, $name, $value) {
152
+			$img=new HtmlImage($id, $value);
153 153
 			$img->asAvatar();
154 154
 			return $img;
155
-		}, $index,$attributes,"avatar");
155
+		}, $index, $attributes, "avatar");
156 156
 	}
157 157
 
158
-	public function fieldAsRadio($index,$attributes=NULL){
159
-		return $this->_fieldAs(function($id,$name,$value) use($attributes){
160
-			$input= new HtmlRadio($id,$name,$value,$value);
158
+	public function fieldAsRadio($index, $attributes=NULL) {
159
+		return $this->_fieldAs(function($id, $name, $value) use($attributes){
160
+			$input=new HtmlRadio($id, $name, $value, $value);
161 161
 			return $this->_prepareFormFields($input, $name, $attributes);
162
-		}, $index,$attributes,"radio");
162
+		}, $index, $attributes, "radio");
163 163
 	}
164 164
 
165
-	public function fieldAsRadios($index,$elements=[],$attributes=NULL){
166
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){
167
-			return HtmlFormFields::radios($name,$elements,$caption,$value);
168
-		}, $index,$attributes,"radios");
165
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
166
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){
167
+			return HtmlFormFields::radios($name, $elements, $caption, $value);
168
+		}, $index, $attributes, "radios");
169 169
 	}
170 170
 
171
-	public function fieldAsInput($index,$attributes=NULL){
172
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
173
-			$input= new HtmlFormInput($id,$caption,"text",$value);
171
+	public function fieldAsInput($index, $attributes=NULL) {
172
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
173
+			$input=new HtmlFormInput($id, $caption, "text", $value);
174 174
 			return $this->_prepareFormFields($input, $name, $attributes);
175
-		}, $index,$attributes,"input");
175
+		}, $index, $attributes, "input");
176 176
 	}
177 177
 
178
-	public function fieldAsTextarea($index,$attributes=NULL){
179
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
180
-			$textarea=new HtmlFormTextarea($id,$caption,$value);
178
+	public function fieldAsTextarea($index, $attributes=NULL) {
179
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
180
+			$textarea=new HtmlFormTextarea($id, $caption, $value);
181 181
 			return $this->_prepareFormFields($textarea, $name, $attributes);
182
-		}, $index,$attributes,"textarea");
182
+		}, $index, $attributes, "textarea");
183 183
 	}
184 184
 
185
-	public function fieldAsHidden($index,$attributes=NULL){
186
-		if(!\is_array($attributes)){
185
+	public function fieldAsHidden($index, $attributes=NULL) {
186
+		if (!\is_array($attributes)) {
187 187
 			$attributes=[];
188 188
 		}
189 189
 		$attributes["imputType"]="hidden";
190
-		return $this->fieldAsInput($index,$attributes);
190
+		return $this->fieldAsInput($index, $attributes);
191 191
 	}
192 192
 
193
-	public function fieldAsCheckbox($index,$attributes=NULL){
194
-		return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){
195
-			$input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier());
193
+	public function fieldAsCheckbox($index, $attributes=NULL) {
194
+		return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){
195
+			$input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier());
196 196
 			$input->setChecked(JString::isBooleanTrue($value));
197 197
 			return $this->_prepareFormFields($input, $name, $attributes);
198
-		}, $index,$attributes,"ck");
198
+		}, $index, $attributes, "ck");
199 199
 	}
200 200
 
201
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
202
-		return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){
203
-			$dd=new HtmlFormDropdown($id,$elements,$caption,$value);
204
-			$dd->asSelect($name,$multiple);
201
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
202
+		return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){
203
+			$dd=new HtmlFormDropdown($id, $elements, $caption, $value);
204
+			$dd->asSelect($name, $multiple);
205 205
 			return $this->_prepareFormFields($dd, $name, $attributes);
206
-		}, $index,$attributes,"dd");
206
+		}, $index, $attributes, "dd");
207 207
 	}
208 208
 
209
-	public function fieldAsMessage($index,$attributes=NULL){
210
-		return $this->_fieldAs(function($id,$name,$value,$caption){
211
-			$mess= new HtmlMessage("message-".$id,$caption);
209
+	public function fieldAsMessage($index, $attributes=NULL) {
210
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
211
+			$mess=new HtmlMessage("message-".$id, $caption);
212 212
 			$mess->addHeader($value);
213 213
 			return $mess;
214
-		}, $index,$attributes,"message");
214
+		}, $index, $attributes, "message");
215 215
 	}
216 216
 
217
-	public function fieldAsLink($index,$attributes=NULL){
218
-		return $this->_fieldAs(function($id,$name,$value,$caption){
219
-			$lnk= new HtmlLink("message-".$id,"#",$caption);
217
+	public function fieldAsLink($index, $attributes=NULL) {
218
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
219
+			$lnk=new HtmlLink("message-".$id, "#", $caption);
220 220
 			return $lnk;
221
-		}, $index,$attributes,"link");
221
+		}, $index, $attributes, "link");
222 222
 	}
223 223
 
224 224
 	/**Change fields type
225 225
 	 * @param array $types an array or associative array $type=>$attributes
226 226
 	 */
227
-	public function fieldsAs(array $types){
227
+	public function fieldsAs(array $types) {
228 228
 		$i=0;
229
-		if(JArray::isAssociative($types)){
230
-			foreach ($types as $type=>$attributes){
231
-				if(\is_int($type))
232
-					$this->fieldAs($i++,$attributes,[]);
233
-				else{
234
-					$type=preg_replace('/\d/', '', $type );
235
-					$this->fieldAs($i++,$type,$attributes);
229
+		if (JArray::isAssociative($types)) {
230
+			foreach ($types as $type=>$attributes) {
231
+				if (\is_int($type))
232
+					$this->fieldAs($i++, $attributes, []);
233
+				else {
234
+					$type=preg_replace('/\d/', '', $type);
235
+					$this->fieldAs($i++, $type, $attributes);
236 236
 				}
237 237
 			}
238
-		}else{
239
-			foreach ($types as $type){
240
-				$this->fieldAs($i++,$type);
238
+		} else {
239
+			foreach ($types as $type) {
240
+				$this->fieldAs($i++, $type);
241 241
 			}
242 242
 		}
243 243
 	}
244 244
 
245
-	public function fieldAs($index,$type,$attributes=NULL){
245
+	public function fieldAs($index, $type, $attributes=NULL) {
246 246
 		$method="fieldAs".\ucfirst($type);
247
-		if(\method_exists($this, $method)){
248
-			if(!\is_array($attributes)){
247
+		if (\method_exists($this, $method)) {
248
+			if (!\is_array($attributes)) {
249 249
 				$attributes=[$index];
250
-			}else{
250
+			} else {
251 251
 				\array_unshift($attributes, $index);
252 252
 			}
253
-			\call_user_func_array([$this,$method], $attributes);
253
+			\call_user_func_array([$this, $method], $attributes);
254 254
 		}
255 255
 	}
256 256
 
257
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
258
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){
259
-			$button=new HtmlButton($id,$caption,$cssStyle);
260
-			$this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]);
257
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
258
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){
259
+			$button=new HtmlButton($id, $caption, $cssStyle);
260
+			$this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]);
261 261
 			return $button;
262
-		}, $index,$attributes,"submit");
262
+		}, $index, $attributes, "submit");
263 263
 	}
264 264
 
265
-	public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){
266
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){
267
-			$button=new HtmlButton($id,$value,$cssStyle);
265
+	public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) {
266
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){
267
+			$button=new HtmlButton($id, $value, $cssStyle);
268 268
 			return $button;
269
-		}, $index,$attributes,"button");
269
+		}, $index, $attributes, "button");
270 270
 	}
271 271
 }
272 272
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/service/JString.php 2 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -5,10 +5,17 @@  discard block
 block discarded – undo
5 5
 	public static function contains($hay,$needle){
6 6
 		return strpos($hay, $needle) !== false;
7 7
 	}
8
+
9
+	/**
10
+	 * @param string $needle
11
+	 */
8 12
 	public static function startswith($hay, $needle) {
9 13
 		return substr($hay, 0, strlen($needle)) === $needle;
10 14
 	}
11 15
 
16
+	/**
17
+	 * @param string $needle
18
+	 */
12 19
 	public static function endswith($hay, $needle) {
13 20
 		return substr($hay, -strlen($needle)) === $needle;
14 21
 	}
@@ -46,6 +53,12 @@  discard block
 block discarded – undo
46 53
 		return \preg_replace($from, $to, $subject, 1);
47 54
 	}
48 55
 
56
+	/**
57
+	 * @param string $fromFirst
58
+	 * @param string $toFirst
59
+	 * @param string $fromLast
60
+	 * @param string $toLast
61
+	 */
49 62
 	public static function replaceAtFirstAndLast($subject,$fromFirst,$toFirst,$fromLast,$toLast){
50 63
 		$s=self::replaceAtFirst($subject, $fromFirst, $toFirst);
51 64
 		return self::replaceAtLast($s, $fromLast, $toLast);
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -2,62 +2,62 @@
 block discarded – undo
2 2
 namespace Ajax\service;
3 3
 class JString {
4 4
 
5
-	public static function contains($hay,$needle){
6
-		return strpos($hay, $needle) !== false;
5
+	public static function contains($hay, $needle) {
6
+		return strpos($hay, $needle)!==false;
7 7
 	}
8 8
 	public static function startswith($hay, $needle) {
9
-		return substr($hay, 0, strlen($needle)) === $needle;
9
+		return substr($hay, 0, strlen($needle))===$needle;
10 10
 	}
11 11
 
12 12
 	public static function endswith($hay, $needle) {
13
-		return substr($hay, -strlen($needle)) === $needle;
13
+		return substr($hay, -strlen($needle))===$needle;
14 14
 	}
15 15
 
16
-	public static function isNull($s){
16
+	public static function isNull($s) {
17 17
 		return (!isset($s) || NULL===$s || ""===$s);
18 18
 	}
19
-	public static function isNotNull($s){
19
+	public static function isNotNull($s) {
20 20
 		return (isset($s) && NULL!==$s && ""!==$s);
21 21
 	}
22 22
 
23
-	public static function isBoolean($value){
23
+	public static function isBoolean($value) {
24 24
 		return \is_bool($value) || $value==1 || $value==0;
25 25
 	}
26 26
 
27
-	public static function isBooleanTrue($value){
27
+	public static function isBooleanTrue($value) {
28 28
 		return $value==1 || $value;
29 29
 	}
30 30
 
31
-	public static function isBooleanFalse($value){
31
+	public static function isBooleanFalse($value) {
32 32
 		return $value==0 || !$value;
33 33
 	}
34 34
 
35
-	public static function camelCaseToSeparated($input,$separator=" "){
35
+	public static function camelCaseToSeparated($input, $separator=" ") {
36 36
 		return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator.'$0', $input));
37 37
 	}
38 38
 
39
-	public static function replaceAtFirst($subject,$from, $to){
40
-		$from = '/\A'.preg_quote($from, '/').'/';
39
+	public static function replaceAtFirst($subject, $from, $to) {
40
+		$from='/\A'.preg_quote($from, '/').'/';
41 41
 		return \preg_replace($from, $to, $subject, 1);
42 42
 	}
43 43
 
44
-	public static function replaceAtLast($subject,$from, $to){
45
-		$from = '/'.preg_quote($from, '/').'\z/';
44
+	public static function replaceAtLast($subject, $from, $to) {
45
+		$from='/'.preg_quote($from, '/').'\z/';
46 46
 		return \preg_replace($from, $to, $subject, 1);
47 47
 	}
48 48
 
49
-	public static function replaceAtFirstAndLast($subject,$fromFirst,$toFirst,$fromLast,$toLast){
49
+	public static function replaceAtFirstAndLast($subject, $fromFirst, $toFirst, $fromLast, $toLast) {
50 50
 		$s=self::replaceAtFirst($subject, $fromFirst, $toFirst);
51 51
 		return self::replaceAtLast($s, $fromLast, $toLast);
52 52
 	}
53 53
 
54
-	public static function getValueBetween(&$str,$before="{{",$after="}}"){
54
+	public static function getValueBetween(&$str, $before="{{", $after="}}") {
55 55
 		$matches=[];
56 56
 		$_before=\preg_quote($before);
57 57
 		$_after=\preg_quote($after);
58
-		if(\preg_match('/'.$_before.'(.*?)'.$_after.'/s', $str, $matches)===1){
58
+		if (\preg_match('/'.$_before.'(.*?)'.$_after.'/s', $str, $matches)===1) {
59 59
 			$result=$matches[1];
60
-			$str=\str_replace($before.$result.$after,"", $str);
60
+			$str=\str_replace($before.$result.$after, "", $str);
61 61
 		}
62 62
 		return $result;
63 63
 	}
Please login to merge, or discard this patch.
Ajax/common/Widget.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 use Ajax\semantic\html\modules\HtmlModal;
21 21
 
22 22
 abstract class Widget extends HtmlDoubleElement {
23
-	use FieldAsTrait,FormTrait;
23
+	use FieldAsTrait, FormTrait;
24 24
 
25 25
 	/**
26 26
 	 * @var string classname
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
 	protected $_generated;
54 54
 
55 55
 
56
-	public function __construct($identifier,$model,$modelInstance=NULL) {
56
+	public function __construct($identifier, $model, $modelInstance=NULL) {
57 57
 		parent::__construct($identifier);
58 58
 		$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
59 59
 		$this->setModel($model);
60
-		if(isset($modelInstance)){
60
+		if (isset($modelInstance)) {
61 61
 			$this->show($modelInstance);
62 62
 		}
63 63
 		$this->_generated=false;
64 64
 	}
65 65
 
66
-	protected function _init($instanceViewer,$contentKey,$content,$edition){
66
+	protected function _init($instanceViewer, $contentKey, $content, $edition) {
67 67
 		$this->_instanceViewer=$instanceViewer;
68 68
 		$this->content=[$contentKey=>$content];
69 69
 		$this->_toolbarPosition=PositionInTable::BEFORETABLE;
@@ -74,31 +74,31 @@  discard block
 block discarded – undo
74 74
 	 * @param int|string $fieldName
75 75
 	 * @return int|string
76 76
 	 */
77
-	protected function _getIndex($fieldName){
77
+	protected function _getIndex($fieldName) {
78 78
 		$index=$fieldName;
79
-		if(\is_string($fieldName)){
79
+		if (\is_string($fieldName)) {
80 80
 			$fields=$this->_instanceViewer->getVisibleProperties();
81 81
 			$index=\array_search($fieldName, $fields);
82 82
 		}
83 83
 		return $index;
84 84
 	}
85 85
 
86
-	protected function _getFieldIdentifier($prefix,$name=""){
86
+	protected function _getFieldIdentifier($prefix, $name="") {
87 87
 		return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier();
88 88
 	}
89 89
 
90
-	protected function _getFieldName($index){
90
+	protected function _getFieldName($index) {
91 91
 		return $this->_instanceViewer->getFieldName($index);
92 92
 	}
93 93
 
94
-	protected function _getFieldCaption($index){
94
+	protected function _getFieldCaption($index) {
95 95
 		return $this->_instanceViewer->getCaption($index);
96 96
 	}
97 97
 
98
-	abstract protected  function _setToolbarPosition($table,$captions=NULL);
98
+	abstract protected  function _setToolbarPosition($table, $captions=NULL);
99 99
 
100
-	public function show($modelInstance){
101
-		if(\is_array($modelInstance)){
100
+	public function show($modelInstance) {
101
+		if (\is_array($modelInstance)) {
102 102
 			$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
103 103
 		}
104 104
 		$this->_modelInstance=$modelInstance;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
 	abstract public function getHtmlComponent();
126 126
 
127
-	public function setAttached($value=true){
127
+	public function setAttached($value=true) {
128 128
 		return $this->getHtmlComponent()->setAttached($value);
129 129
 	}
130 130
 
@@ -135,66 +135,66 @@  discard block
 block discarded – undo
135 135
 	 * @param callable $callback function called after the field compilation
136 136
 	 * @return Widget
137 137
 	 */
138
-	public function afterCompile($index,$callback){
138
+	public function afterCompile($index, $callback) {
139 139
 		$index=$this->_getIndex($index);
140 140
 		$this->_instanceViewer->afterCompile($index, $callback);
141 141
 		return $this;
142 142
 	}
143 143
 
144
-	public function setColor($color){
144
+	public function setColor($color) {
145 145
 		return $this->getHtmlComponent()->setColor($color);
146 146
 	}
147 147
 
148 148
 
149
-	public function setCaptions($captions){
149
+	public function setCaptions($captions) {
150 150
 		$this->_instanceViewer->setCaptions($captions);
151 151
 		return $this;
152 152
 	}
153 153
 
154
-	public function setCaption($index,$caption){
154
+	public function setCaption($index, $caption) {
155 155
 		$this->_instanceViewer->setCaption($this->_getIndex($index), $caption);
156 156
 		return $this;
157 157
 	}
158 158
 
159
-	public function setFields($fields){
159
+	public function setFields($fields) {
160 160
 		$this->_instanceViewer->setVisibleProperties($fields);
161 161
 		return $this;
162 162
 	}
163 163
 
164
-	public function addField($field){
164
+	public function addField($field) {
165 165
 		$this->_instanceViewer->addField($field);
166 166
 		return $this;
167 167
 	}
168 168
 
169
-	public function addMessage($attributes=NULL,$fieldName="message"){
169
+	public function addMessage($attributes=NULL, $fieldName="message") {
170 170
 		$this->_instanceViewer->addField($fieldName);
171 171
 		$count=$this->_instanceViewer->visiblePropertiesCount();
172
-		return $this->fieldAsMessage($count-1,$attributes);
172
+		return $this->fieldAsMessage($count-1, $attributes);
173 173
 	}
174 174
 
175
-	public function addErrorMessage(){
176
-		return $this->addMessage(["error"=>true],"message");
175
+	public function addErrorMessage() {
176
+		return $this->addMessage(["error"=>true], "message");
177 177
 	}
178 178
 
179
-	public function insertField($index,$field){
179
+	public function insertField($index, $field) {
180 180
 		$index=$this->_getIndex($index);
181 181
 		$this->_instanceViewer->insertField($index, $field);
182 182
 		return $this;
183 183
 	}
184 184
 
185
-	public function insertInField($index,$field){
185
+	public function insertInField($index, $field) {
186 186
 		$index=$this->_getIndex($index);
187 187
 		$this->_instanceViewer->insertInField($index, $field);
188 188
 		return $this;
189 189
 	}
190 190
 
191
-	public function setValueFunction($index,$callback){
191
+	public function setValueFunction($index, $callback) {
192 192
 		$index=$this->_getIndex($index);
193 193
 		$this->_instanceViewer->setValueFunction($index, $callback);
194 194
 		return $this;
195 195
 	}
196 196
 
197
-	public function setIdentifierFunction($callback){
197
+	public function setIdentifierFunction($callback) {
198 198
 		$this->_instanceViewer->setIdentifierFunction($callback);
199 199
 		return $this;
200 200
 	}
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 	/**
203 203
 	 * @return \Ajax\semantic\html\collections\menus\HtmlMenu
204 204
 	 */
205
-	public function getToolbar(){
206
-		if(isset($this->_toolbar)===false){
205
+	public function getToolbar() {
206
+		if (isset($this->_toolbar)===false) {
207 207
 			$this->_toolbar=new HtmlMenu("toolbar-".$this->identifier);
208 208
 		}
209 209
 		return $this->_toolbar;
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
 	 * @param callable $callback function to call on $element
216 216
 	 * @return \Ajax\common\html\HtmlDoubleElement
217 217
 	 */
218
-	public function addInToolbar($element,$callback=NULL){
218
+	public function addInToolbar($element, $callback=NULL) {
219 219
 		$tb=$this->getToolbar();
220
-		if($element instanceof BaseWidget){
221
-			if($element->getIdentifier()===""){
220
+		if ($element instanceof BaseWidget) {
221
+			if ($element->getIdentifier()==="") {
222 222
 				$element->setIdentifier("tb-item-".$this->identifier."-".$tb->count());
223 223
 			}
224 224
 		}
225
-		if(isset($callback)){
226
-			if(\is_callable($callback)){
225
+		if (isset($callback)) {
226
+			if (\is_callable($callback)) {
227 227
 				$callback($element);
228 228
 			}
229 229
 		}
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 	 * @param callable $callback function($element)
237 237
 	 * @return \Ajax\common\html\HtmlDoubleElement
238 238
 	 */
239
-	public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){
240
-		$result=$this->addInToolbar($caption,$callback);
241
-		if(isset($icon))
239
+	public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) {
240
+		$result=$this->addInToolbar($caption, $callback);
241
+		if (isset($icon))
242 242
 			$result->addIcon($icon);
243 243
 		return $result;
244 244
 	}
@@ -248,14 +248,14 @@  discard block
 block discarded – undo
248 248
 	 * @param callable $callback function($element)
249 249
 	 * @return \Ajax\common\Widget
250 250
 	 */
251
-	public function addItemsInToolbar(array $items,$callback=NULL){
252
-		if(JArray::isAssociative($items)){
253
-			foreach ($items as $icon=>$item){
254
-				$this->addItemInToolbar($item,$icon,$callback);
251
+	public function addItemsInToolbar(array $items, $callback=NULL) {
252
+		if (JArray::isAssociative($items)) {
253
+			foreach ($items as $icon=>$item) {
254
+				$this->addItemInToolbar($item, $icon, $callback);
255 255
 			}
256
-		}else{
257
-			foreach ($items as $item){
258
-				$this->addItemInToolbar($item,null,$callback);
256
+		} else {
257
+			foreach ($items as $item) {
258
+				$this->addItemInToolbar($item, null, $callback);
259 259
 			}
260 260
 		}
261 261
 		return $this;
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
 	 * @param callable $callback function($element)
268 268
 	 * @return \Ajax\common\html\HtmlDoubleElement
269 269
 	 */
270
-	public function addDropdownInToolbar($value,$items,$callback=NULL){
270
+	public function addDropdownInToolbar($value, $items, $callback=NULL) {
271 271
 		$dd=$value;
272 272
 		if (\is_string($value)) {
273
-			$dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items);
273
+			$dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items);
274 274
 		}
275
-		return $this->addInToolbar($dd,$callback);
275
+		return $this->addInToolbar($dd, $callback);
276 276
 	}
277 277
 
278 278
 	/**
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
 	 * @param callable $callback function($element)
282 282
 	 * @return \Ajax\common\html\HtmlDoubleElement
283 283
 	 */
284
-	public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){
285
-		$bt=new HtmlButton("bt-".$caption,$caption,$cssStyle);
286
-		return $this->addInToolbar($bt,$callback);
284
+	public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) {
285
+		$bt=new HtmlButton("bt-".$caption, $caption, $cssStyle);
286
+		return $this->addInToolbar($bt, $callback);
287 287
 	}
288 288
 
289 289
 	/**
@@ -292,9 +292,9 @@  discard block
 block discarded – undo
292 292
 	 * @param callable $callback function($element)
293 293
 	 * @return \Ajax\common\html\HtmlDoubleElement
294 294
 	 */
295
-	public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){
296
-		$bts=new HtmlButtonGroups("",$captions,$asIcon);
297
-		return $this->addInToolbar($bts,$callback);
295
+	public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) {
296
+		$bts=new HtmlButtonGroups("", $captions, $asIcon);
297
+		return $this->addInToolbar($bts, $callback);
298 298
 	}
299 299
 
300 300
 	/**
@@ -304,15 +304,15 @@  discard block
 block discarded – undo
304 304
 	 * @param boolean $labeled
305 305
 	 * @return \Ajax\common\html\HtmlDoubleElement
306 306
 	 */
307
-	public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){
308
-		$bt=new HtmlButton("",$caption);
309
-		$bt->addIcon($icon,$before,$labeled);
307
+	public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) {
308
+		$bt=new HtmlButton("", $caption);
309
+		$bt->addIcon($icon, $before, $labeled);
310 310
 		return $this->addInToolbar($bt);
311 311
 	}
312 312
 
313
-	public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){
314
-		$button=new HtmlButton($identifier,$value,$cssStyle);
315
-		$this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters);
313
+	public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) {
314
+		$button=new HtmlButton($identifier, $value, $cssStyle);
315
+		$this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters);
316 316
 		return $this->addInToolbar($button);
317 317
 	}
318 318
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	 * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model
343 343
 	 * @return \Ajax\common\Widget
344 344
 	 */
345
-	public function setDefaultValueFunction($defaultValueFunction){
345
+	public function setDefaultValueFunction($defaultValueFunction) {
346 346
 		$this->_instanceViewer->setDefaultValueFunction($defaultValueFunction);
347 347
 		return $this;
348 348
 	}
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 * @param string|boolean $disable
352 352
 	 * @return string
353 353
 	 */
354
-	public function jsDisabled($disable=true){
354
+	public function jsDisabled($disable=true) {
355 355
 		return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");";
356 356
 	}
357 357
 
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
 	 * @param callable $callback function($element)
361 361
 	 * @return \Ajax\common\html\HtmlDoubleElement
362 362
 	 */
363
-	public function addEditButtonInToolbar($caption,$callback=NULL){
364
-		$bt=new HtmlButton($this->identifier."-editBtn",$caption);
363
+	public function addEditButtonInToolbar($caption, $callback=NULL) {
364
+		$bt=new HtmlButton($this->identifier."-editBtn", $caption);
365 365
 		$bt->setToggle();
366 366
 		$bt->setActive($this->_edition);
367 367
 		$bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')")));
368
-		return $this->addInToolbar($bt,$callback);
368
+		return $this->addInToolbar($bt, $callback);
369 369
 	}
370 370
 
371 371
 	public function setToolbar(HtmlMenu $_toolbar) {
@@ -379,35 +379,35 @@  discard block
 block discarded – undo
379 379
 	}
380 380
 
381 381
 	public function getForm() {
382
-		if(!isset($this->_form)){
382
+		if (!isset($this->_form)) {
383 383
 			$this->_form=new HtmlForm("frm-".$this->identifier);
384 384
 			$this->setEdition(true);
385 385
 		}
386 386
 		return $this->_form;
387 387
 	}
388 388
 
389
-	public function run(JsUtils $js){
389
+	public function run(JsUtils $js) {
390 390
 		$result=parent::run($js);
391
-		if(isset($this->_form)){
391
+		if (isset($this->_form)) {
392 392
 			$result=$this->runForm($js);
393 393
 		}
394 394
 		return $result;
395 395
 	}
396 396
 
397
-	protected function runForm(JsUtils $js){
397
+	protected function runForm(JsUtils $js) {
398 398
 		$fields=$this->getContentInstances(HtmlFormField::class);
399
-		foreach ($fields as $field){
399
+		foreach ($fields as $field) {
400 400
 			$this->_form->addField($field);
401 401
 		}
402 402
 		return $this->_form->run($js);
403 403
 	}
404 404
 
405
-	protected function _compileForm(){
406
-		if(isset($this->_form)){
405
+	protected function _compileForm() {
406
+		if (isset($this->_form)) {
407 407
 			$noValidate="";
408
-			if(\sizeof($this->_form->getValidationParams())>0)
408
+			if (\sizeof($this->_form->getValidationParams())>0)
409 409
 				$noValidate="novalidate";
410
-			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>");
410
+			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>");
411 411
 		}
412 412
 	}
413 413
 
@@ -416,26 +416,26 @@  discard block
 block discarded – undo
416 416
 		return $this;
417 417
 	}
418 418
 
419
-	public function moveFieldTo($from,$to){
419
+	public function moveFieldTo($from, $to) {
420 420
 		return $this->_instanceViewer->moveFieldTo($from, $to);
421 421
 	}
422 422
 
423
-	public function swapFields($index1,$index2){
423
+	public function swapFields($index1, $index2) {
424 424
 		$index1=$this->_getIndex($index1);
425 425
 		$index2=$this->_getIndex($index2);
426 426
 		return $this->_instanceViewer->swapFields($index1, $index2);
427 427
 	}
428 428
 
429
-	public function removeField($index){
429
+	public function removeField($index) {
430 430
 		$index=$this->_getIndex($index);
431 431
 		$this->_instanceViewer->removeField($index);
432 432
 		return $this;
433 433
 	}
434 434
 
435
-	public function asModal($header){
436
-		$modal=new HtmlModal("modal-".$this->identifier,$header);
435
+	public function asModal($header) {
436
+		$modal=new HtmlModal("modal-".$this->identifier, $header);
437 437
 		$modal->setContent($this);
438
-		if(isset($this->_form)){
438
+		if (isset($this->_form)) {
439 439
 			$this->_form->onSuccess($modal->jsHide());
440 440
 		}
441 441
 		return $modal;
Please login to merge, or discard this patch.
Ajax/common/components/SimpleComponent.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,27 +19,27 @@  discard block
 block discarded – undo
19 19
 
20 20
 	public function __construct(JsUtils $js=NULL) {
21 21
 		parent::__construct($js);
22
-		$this->events=array ();
22
+		$this->events=array();
23 23
 	}
24 24
 
25 25
 	protected function compileEvents() {
26
-		foreach ( $this->events as $event => $jsCode ) {
26
+		foreach ($this->events as $event => $jsCode) {
27 27
 			$itemSelector=JString::getValueBetween($jsCode);
28
-			if($event=="execute"){
28
+			if ($event=="execute") {
29 29
 				$this->jquery_code_for_compile []=$jsCode;
30
-			}else if($event=="beforeExecute"){
30
+			} else if ($event=="beforeExecute") {
31 31
 				\array_unshift($this->jquery_code_for_compile, $jsCode);
32
-			}else{
32
+			} else {
33 33
 				$selector=$this->_createSelector($itemSelector, $this->attachTo);
34 34
 				$this->jquery_code_for_compile []="$( \"".$selector."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});";
35 35
 			}
36 36
 		}
37 37
 	}
38 38
 
39
-	protected function _createSelector($itemSelector,$selector){
40
-		if(!isset($itemSelector))
39
+	protected function _createSelector($itemSelector, $selector) {
40
+		if (!isset($itemSelector))
41 41
 			$itemSelector=$this->itemSelector;
42
-		if(isset($itemSelector) && $itemSelector!=="")
42
+		if (isset($itemSelector) && $itemSelector!=="")
43 43
 			$selector.=" ".$itemSelector;
44 44
 		return $selector;
45 45
 	}
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		$result=implode("\n", $this->jquery_code_for_compile);
49 49
 		$result=str_ireplace("\"%", "", $result);
50 50
 		$result=str_ireplace("%\"", "", $result);
51
-		$result=str_replace(array (
51
+		$result=str_replace(array(
52 52
 				"\\n",
53 53
 				"\\r",
54 54
 				"\\t"
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
 	public function getScript() {
60 60
 		$allParams=$this->params;
61
-		$this->jquery_code_for_compile=array ();
61
+		$this->jquery_code_for_compile=array();
62 62
 		$this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");";
63 63
 		$this->compileEvents();
64 64
 		return $this->compileJQueryCode();
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 			$itemSelector=JString::getValueBetween($jsCode);
28 28
 			if($event=="execute"){
29 29
 				$this->jquery_code_for_compile []=$jsCode;
30
-			}else if($event=="beforeExecute"){
30
+			} else if($event=="beforeExecute"){
31 31
 				\array_unshift($this->jquery_code_for_compile, $jsCode);
32
-			}else{
32
+			} else{
33 33
 				$selector=$this->_createSelector($itemSelector, $this->attachTo);
34 34
 				$this->jquery_code_for_compile []="$( \"".$selector."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});";
35 35
 			}
@@ -37,10 +37,12 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	protected function _createSelector($itemSelector,$selector){
40
-		if(!isset($itemSelector))
41
-			$itemSelector=$this->itemSelector;
42
-		if(isset($itemSelector) && $itemSelector!=="")
43
-			$selector.=" ".$itemSelector;
40
+		if(!isset($itemSelector)) {
41
+					$itemSelector=$this->itemSelector;
42
+		}
43
+		if(isset($itemSelector) && $itemSelector!=="") {
44
+					$selector.=" ".$itemSelector;
45
+		}
44 46
 		return $selector;
45 47
 	}
46 48
 
@@ -83,8 +85,9 @@  discard block
 block discarded – undo
83 85
 
84 86
 	protected function setParamCtrl($key, $value, $typeCtrl) {
85 87
 		if (\is_array($typeCtrl)) {
86
-			if (array_search($value, $typeCtrl)===false)
87
-				throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
88
+			if (array_search($value, $typeCtrl)===false) {
89
+							throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
90
+			}
88 91
 		} else {
89 92
 			if (!$typeCtrl($value)) {
90 93
 				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." au composant ".$this->uiName);
Please login to merge, or discard this patch.
Ajax/common/html/BaseHtml.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  * @version 1.3
16 16
  */
17 17
 abstract class BaseHtml extends BaseWidget {
18
-	use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait;
18
+	use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait;
19 19
 	protected $_template;
20 20
 	protected $tagName;
21
-	protected $_wrapBefore=array ();
22
-	protected $_wrapAfter=array ();
21
+	protected $_wrapBefore=array();
22
+	protected $_wrapAfter=array();
23 23
 	protected $_bsComponent;
24 24
 	protected $_compiled=false;
25 25
 
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	abstract public function run(JsUtils $js);
32 32
 
33
-	private function _callSetter($setter,$key,$value,&$array){
33
+	private function _callSetter($setter, $key, $value, &$array) {
34 34
 		$result=false;
35 35
 		if (method_exists($this, $setter) && !JString::startswith($key, "_")) {
36 36
 			try {
37 37
 				$this->$setter($value);
38 38
 				unset($array[$key]);
39 39
 				$result=true;
40
-			} catch ( \Exception $e ) {
40
+			}catch (\Exception $e) {
41 41
 				$result=false;
42 42
 			}
43 43
 		}
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	protected function getTemplate(JsUtils $js=NULL) {
48
-		return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js);
48
+		return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js);
49 49
 	}
50 50
 
51 51
 	protected function ctrl($name, $value, $typeCtrl) {
52 52
 		if (\is_array($typeCtrl)) {
53
-			if (array_search($value, $typeCtrl) === false) {
54
-				throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
53
+			if (array_search($value, $typeCtrl)===false) {
54
+				throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
55 55
 			}
56 56
 		} else {
57 57
 			if (!$typeCtrl($value)) {
58
-				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
58
+				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
59 59
 			}
60 60
 		}
61 61
 		return true;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
 
66 66
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
67
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
67
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
68 68
 			return $name=$value;
69 69
 		}
70 70
 		return $this;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") {
74 74
 		if (\is_array($typeCtrl)) {
75 75
 			$this->removeOldValues($name, $typeCtrl);
76
-			$name.=$separator . $value;
76
+			$name.=$separator.$value;
77 77
 		}
78 78
 		return $this;
79 79
 	}
@@ -81,17 +81,17 @@  discard block
 block discarded – undo
81 81
 
82 82
 
83 83
 	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
84
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
84
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
85 85
 			if (\is_array($typeCtrl)) {
86 86
 				$this->removeOldValues($name, $typeCtrl);
87 87
 			}
88
-			$name.=$separator . $value;
88
+			$name.=$separator.$value;
89 89
 		}
90 90
 		return $this;
91 91
 	}
92 92
 
93 93
 	protected function addToMember(&$name, $value, $separator=" ") {
94
-		$name=str_ireplace($value, "", $name) . $separator . $value;
94
+		$name=str_ireplace($value, "", $name).$separator.$value;
95 95
 		return $this;
96 96
 	}
97 97
 
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
 		$oldValue=trim($oldValue);
103 103
 	}
104 104
 
105
-	protected function _getElementBy($callback,$elements){
105
+	protected function _getElementBy($callback, $elements) {
106 106
 		if (\is_array($elements)) {
107 107
 			$flag=false;
108 108
 			$index=0;
109
-			while ( !$flag && $index < sizeof($elements) ) {
109
+			while (!$flag && $index<sizeof($elements)) {
110 110
 				if ($elements[$index] instanceof BaseHtml)
111 111
 					$flag=($callback($elements[$index]));
112 112
 					$index++;
113 113
 			}
114
-			if ($flag === true)
115
-				return $elements[$index - 1];
114
+			if ($flag===true)
115
+				return $elements[$index-1];
116 116
 		} elseif ($elements instanceof BaseHtml) {
117 117
 			if ($callback($elements))
118 118
 				return $elements;
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
 	}
141 141
 
142 142
 	public function fromArray($array) {
143
-		foreach ( $this as $key => $value ) {
144
-			if(array_key_exists($key, $array)===true)
145
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
143
+		foreach ($this as $key => $value) {
144
+			if (array_key_exists($key, $array)===true)
145
+				$this->_callSetter("set".ucfirst($key), $key, $array[$key], $array);
146 146
 		}
147
-		foreach ( $array as $key => $value ) {
148
-			if($this->_callSetter($key, $key, $value, $array)===false){
149
-				$this->_callSetter("set" . ucfirst($key), $key, $value, $array);
147
+		foreach ($array as $key => $value) {
148
+			if ($this->_callSetter($key, $key, $value, $array)===false) {
149
+				$this->_callSetter("set".ucfirst($key), $key, $value, $array);
150 150
 			}
151 151
 		}
152 152
 		return $array;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
 	public function fromDatabaseObjects($objects, $function) {
156 156
 		if (isset($objects)) {
157
-			foreach ( $objects as $object ) {
157
+			foreach ($objects as $object) {
158 158
 				$this->fromDatabaseObject($object, $function);
159 159
 			}
160 160
 		}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 
176 176
 
177 177
 	public function getElementById($identifier, $elements) {
178
-		return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements);
178
+		return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements);
179 179
 	}
180 180
 
181 181
 	public function getBsComponent() {
@@ -190,24 +190,24 @@  discard block
 block discarded – undo
190 190
 	protected function compile_once(JsUtils $js=NULL, &$view=NULL) {
191 191
 	}
192 192
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
193
-		if(!$this->_compiled){
194
-			$this->compile_once($js,$view);
193
+		if (!$this->_compiled) {
194
+			$this->compile_once($js, $view);
195 195
 			$this->_compiled=true;
196 196
 		}
197 197
 		$result=$this->getTemplate($js);
198
-		foreach ( $this as $key => $value ) {
199
-			if (JString::startswith($key, "_") === false && $key !== "events") {
198
+		foreach ($this as $key => $value) {
199
+			if (JString::startswith($key, "_")===false && $key!=="events") {
200 200
 				if (\is_array($value)) {
201 201
 					$v=PropertyWrapper::wrap($value, $js);
202 202
 				} else {
203 203
 					$v=$value;
204 204
 				}
205
-				$result=str_ireplace("%" . $key . "%", $v, $result);
205
+				$result=str_ireplace("%".$key."%", $v, $result);
206 206
 			}
207 207
 		}
208 208
 		if (isset($js)===true) {
209 209
 			$this->run($js);
210
-			if (isset($view) === true) {
210
+			if (isset($view)===true) {
211 211
 				$js->addViewElement($this->_identifier, $result, $view);
212 212
 			}
213 213
 		}
Please login to merge, or discard this patch.
Ajax/service/AjaxCall.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,29 +28,29 @@
 block discarded – undo
28 28
 		$method="get";
29 29
 		extract($this->parameters);
30 30
 		$result=$this->_eventPreparing($preventDefault, $stopPropagation);
31
-		switch($this->method) {
31
+		switch ($this->method) {
32 32
 			case "get":
33
-				$result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr,$jqueryDone,$ajaxTransition);
33
+				$result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr, $jqueryDone, $ajaxTransition);
34 34
 				break;
35 35
 			case "post":
36
-				$result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition);
36
+				$result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition);
37 37
 				break;
38 38
 			case "postForm":
39
-				$result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition);
39
+				$result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition);
40 40
 				break;
41 41
 			case "json":
42
-				$result.=$js->jsonDeferred($url,$method,$params,$jsCallback);
42
+				$result.=$js->jsonDeferred($url, $method, $params, $jsCallback);
43 43
 				break;
44 44
 			case "jsonArray":
45
-				$result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback);
45
+				$result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $params, $jsCallback);
46 46
 				break;
47 47
 		}
48
-		if(isset($eventItemSelector))
48
+		if (isset($eventItemSelector))
49 49
 			$result="{{".$eventItemSelector."}}".$result;
50 50
 		return $result;
51 51
 	}
52 52
 
53
-	protected function _eventPreparing($preventDefault,$stopPropagation){
53
+	protected function _eventPreparing($preventDefault, $stopPropagation) {
54 54
 		$result="";
55 55
 		if ($preventDefault===true) {
56 56
 			$result.=Javascript::$preventDefault;
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function compile(JsUtils $js=null) {
17
-		if ($js==null)
18
-			return;
17
+		if ($js==null) {
18
+					return;
19
+		}
19 20
 		$params="{}";
20 21
 		$jsCallback=NULL;
21 22
 		$attr="id";
@@ -45,8 +46,9 @@  discard block
 block discarded – undo
45 46
 				$result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback);
46 47
 				break;
47 48
 		}
48
-		if(isset($eventItemSelector))
49
-			$result="{{".$eventItemSelector."}}".$result;
49
+		if(isset($eventItemSelector)) {
50
+					$result="{{".$eventItemSelector."}}".$result;
51
+		}
50 52
 		return $result;
51 53
 	}
52 54
 
Please login to merge, or discard this patch.
Ajax/semantic/components/Checkbox.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 		$this->params["onUnchecked"]="%function(){".$value."}%";
21 21
 	}
22 22
 
23
-	public function setOnChange($value){
23
+	public function setOnChange($value) {
24 24
 		$this->params["onChange"]="%function(){".$value."}%";
25 25
 	}
26 26
 	//TODO other events implementation
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 2 patches
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *
24 24
  */
25 25
 class DataTable extends Widget {
26
-	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait;
26
+	use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait;
27 27
 	protected $_searchField;
28 28
 	protected $_urls;
29 29
 	protected $_pagination;
@@ -39,35 +39,35 @@  discard block
 block discarded – undo
39 39
 	protected $_sortable;
40 40
 
41 41
 
42
-	public function __construct($identifier,$model,$modelInstance=NULL) {
43
-		parent::__construct($identifier, $model,$modelInstance);
44
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
42
+	public function __construct($identifier, $model, $modelInstance=NULL) {
43
+		parent::__construct($identifier, $model, $modelInstance);
44
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
45 45
 		$this->_urls=[];
46
-		$this->_emptyMessage=new HtmlMessage("","nothing to display");
46
+		$this->_emptyMessage=new HtmlMessage("", "nothing to display");
47 47
 		$this->_emptyMessage->setIcon("info circle");
48 48
 	}
49 49
 
50
-	public function run(JsUtils $js){
51
-		if($this->_hasCheckboxes && isset($js)){
50
+	public function run(JsUtils $js) {
51
+		if ($this->_hasCheckboxes && isset($js)) {
52 52
 			$this->_runCheckboxes($js);
53 53
 		}
54
-		if($this->_visibleHover){
55
-			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
56
-			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
54
+		if ($this->_visibleHover) {
55
+			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]);
56
+			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]);
57 57
 		}
58
-		if(\is_array($this->_deleteBehavior))
59
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
60
-		if(\is_array($this->_editBehavior))
61
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
58
+		if (\is_array($this->_deleteBehavior))
59
+			$this->_generateBehavior("delete", $this->_deleteBehavior, $js);
60
+		if (\is_array($this->_editBehavior))
61
+			$this->_generateBehavior("edit", $this->_editBehavior, $js);
62 62
 		return parent::run($js);
63 63
 	}
64 64
 
65 65
 
66 66
 
67
-	protected function _generateBehavior($op,$params,JsUtils $js){
68
-		if(isset($this->_urls[$op])){
69
-			$params=\array_merge($params,["attr"=>"data-ajax"]);
70
-			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params);
67
+	protected function _generateBehavior($op, $params, JsUtils $js) {
68
+		if (isset($this->_urls[$op])) {
69
+			$params=\array_merge($params, ["attr"=>"data-ajax"]);
70
+			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params);
71 71
 		}
72 72
 	}
73 73
 
@@ -80,137 +80,137 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 
82 82
 
83
-	public function compile(JsUtils $js=NULL,&$view=NULL){
84
-		if(!$this->_generated){
83
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
84
+		if (!$this->_generated) {
85 85
 			$this->_instanceViewer->setInstance($this->_model);
86 86
 			$captions=$this->_instanceViewer->getCaptions();
87 87
 
88 88
 			$table=$this->content["table"];
89 89
 
90
-			if($this->_hasCheckboxes){
90
+			if ($this->_hasCheckboxes) {
91 91
 				$this->_generateMainCheckbox($captions);
92 92
 			}
93 93
 
94 94
 			$table->setRowCount(0, \sizeof($captions));
95
-			$this->_generateHeader($table,$captions);
95
+			$this->_generateHeader($table, $captions);
96 96
 
97
-			if(isset($this->_compileParts))
97
+			if (isset($this->_compileParts))
98 98
 				$table->setCompileParts($this->_compileParts);
99 99
 
100
-			if(isset($this->_searchField) && isset($js)){
101
-				if(isset($this->_urls["refresh"]))
102
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
100
+			if (isset($this->_searchField) && isset($js)) {
101
+				if (isset($this->_urls["refresh"]))
102
+					$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
103 103
 			}
104 104
 
105 105
 			$this->_generateContent($table);
106 106
 
107
-			if($this->_hasCheckboxes && $table->hasPart("thead")){
107
+			if ($this->_hasCheckboxes && $table->hasPart("thead")) {
108 108
 					$table->getHeader()->getCell(0, 0)->addClass("no-sort");
109 109
 			}
110 110
 
111
-			if(isset($this->_toolbar)){
111
+			if (isset($this->_toolbar)) {
112 112
 				$this->_setToolbarPosition($table, $captions);
113 113
 			}
114
-			if(isset($this->_pagination) && $this->_pagination->getVisible()){
115
-				$this->_generatePagination($table,$js);
114
+			if (isset($this->_pagination) && $this->_pagination->getVisible()) {
115
+				$this->_generatePagination($table, $js);
116 116
 			}
117 117
 
118
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
118
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
119 119
 			$this->_compileForm();
120 120
 
121 121
 			$this->_generated=true;
122 122
 		}
123
-		return parent::compile($js,$view);
123
+		return parent::compile($js, $view);
124 124
 	}
125 125
 
126
-	protected function _generateHeader(HtmlTable $table,$captions){
126
+	protected function _generateHeader(HtmlTable $table, $captions) {
127 127
 		$table->setHeaderValues($captions);
128
-		if(isset($this->_sortable)){
128
+		if (isset($this->_sortable)) {
129 129
 			$table->setSortable($this->_sortable);
130 130
 		}
131 131
 	}
132 132
 
133 133
 
134 134
 
135
-	protected function _generateContent($table){
135
+	protected function _generateContent($table) {
136 136
 		$objects=$this->_modelInstance;
137
-		if(isset($this->_pagination)){
137
+		if (isset($this->_pagination)) {
138 138
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
139 139
 		}
140 140
 			InstanceViewer::setIndex(0);
141 141
 			$table->fromDatabaseObjects($objects, function($instance) use($table){
142 142
 				return $this->_generateRow($instance, $table);
143 143
 			});
144
-		if($table->getRowCount()==0){
144
+		if ($table->getRowCount()==0) {
145 145
 			$result=$table->addRow();
146 146
 			$result->mergeRow();
147 147
 			$result->setValues([$this->_emptyMessage]);
148 148
 		}
149 149
 	}
150 150
 
151
-	protected function _generateRow($instance,&$table,$checkedClass=null){
151
+	protected function _generateRow($instance, &$table, $checkedClass=null) {
152 152
 		$this->_instanceViewer->setInstance($instance);
153 153
 		InstanceViewer::$index++;
154
-		$values= $this->_instanceViewer->getValues();
154
+		$values=$this->_instanceViewer->getValues();
155 155
 		$id=$this->_instanceViewer->getIdentifier();
156
-		if($this->_hasCheckboxes){
157
-			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,"");
156
+		if ($this->_hasCheckboxes) {
157
+			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, "");
158 158
 			$ck->setOnChange("event.stopPropagation();");
159 159
 			$field=$ck->getField();
160
-			$field->setProperty("value",$id);
160
+			$field->setProperty("value", $id);
161 161
 			$field->setProperty("name", "selection[]");
162
-			if(isset($checkedClass))
162
+			if (isset($checkedClass))
163 163
 				$field->setClass($checkedClass);
164 164
 			\array_unshift($values, $ck);
165 165
 		}
166 166
 		$result=$table->newRow();
167 167
 		$result->setIdentifier($this->identifier."-tr-".$id);
168
-		$result->setProperty("data-ajax",$id);
168
+		$result->setProperty("data-ajax", $id);
169 169
 		$result->setValues($values);
170
-		$result->addToProperty("class",$this->_rowClass);
170
+		$result->addToProperty("class", $this->_rowClass);
171 171
 		return $result;
172 172
 	}
173 173
 
174
-	protected function _generatePagination($table,$js=NULL){
175
-		if(isset($this->_toolbar)){
176
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
174
+	protected function _generatePagination($table, $js=NULL) {
175
+		if (isset($this->_toolbar)) {
176
+			if ($this->_toolbarPosition==PositionInTable::FOOTER)
177 177
 				$this->_toolbar->setFloated("left");
178 178
 		}
179 179
 		$footer=$table->getFooter();
180 180
 		$footer->mergeCol();
181
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
181
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
182 182
 		$menu->floatRight();
183 183
 		$menu->setActiveItem($this->_pagination->getPage()-1);
184 184
 		$footer->addValues($menu);
185
-		$this->_associatePaginationBehavior($menu,$js);
185
+		$this->_associatePaginationBehavior($menu, $js);
186 186
 	}
187 187
 
188
-	protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){
189
-		if(isset($this->_urls["refresh"])){
190
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
188
+	protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) {
189
+		if (isset($this->_urls["refresh"])) {
190
+			$menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
191 191
 		}
192 192
 	}
193 193
 
194
-	protected function _getFieldName($index){
194
+	protected function _getFieldName($index) {
195 195
 		return parent::_getFieldName($index)."[]";
196 196
 	}
197 197
 
198
-	protected function _getFieldCaption($index){
198
+	protected function _getFieldCaption($index) {
199 199
 		return null;
200 200
 	}
201 201
 
202
-	protected function _setToolbarPosition($table,$captions=NULL){
203
-		switch ($this->_toolbarPosition){
202
+	protected function _setToolbarPosition($table, $captions=NULL) {
203
+		switch ($this->_toolbarPosition) {
204 204
 			case PositionInTable::BEFORETABLE:
205 205
 			case PositionInTable::AFTERTABLE:
206
-				if(isset($this->_compileParts)===false){
206
+				if (isset($this->_compileParts)===false) {
207 207
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
208 208
 				}
209 209
 				break;
210 210
 			case PositionInTable::HEADER:
211 211
 			case PositionInTable::FOOTER:
212 212
 			case PositionInTable::BODY:
213
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
213
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
214 214
 				break;
215 215
 		}
216 216
 	}
@@ -222,23 +222,23 @@  discard block
 block discarded – undo
222 222
 	 * @param callable $callback function called after the field compilation
223 223
 	 * @return DataTable
224 224
 	 */
225
-	public function afterCompile($index,$callback){
226
-		$this->_instanceViewer->afterCompile($index,$callback);
225
+	public function afterCompile($index, $callback) {
226
+		$this->_instanceViewer->afterCompile($index, $callback);
227 227
 		return $this;
228 228
 	}
229 229
 
230
-	private function addToolbarRow($part,$table,$captions){
230
+	private function addToolbarRow($part, $table, $captions) {
231 231
 		$hasPart=$table->hasPart($part);
232
-		if($hasPart){
232
+		if ($hasPart) {
233 233
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
234
-		}else{
234
+		} else {
235 235
 			$row=$table->getPart($part)->getRow(0);
236 236
 		}
237 237
 		$row->mergeCol();
238 238
 		$row->setValues([$this->_toolbar]);
239 239
 	}
240 240
 
241
-	public function getHtmlComponent(){
241
+	public function getHtmlComponent() {
242 242
 		return $this->content["table"];
243 243
 	}
244 244
 
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
 	 * @return DataTable
253 253
 	 */
254 254
 	public function setUrls($urls) {
255
-		if(\is_array($urls)){
256
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
257
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
258
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
259
-		}else{
260
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
255
+		if (\is_array($urls)) {
256
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
257
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
258
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
259
+		} else {
260
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls];
261 261
 		}
262 262
 		return $this;
263 263
 	}
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
271 271
 	 * @return DataTable
272 272
 	 */
273
-	public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){
274
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount);
273
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
274
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
275 275
 		return $this;
276 276
 	}
277 277
 
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
283 283
 	 * @return DataTable
284 284
 	 */
285
-	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
286
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
285
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
286
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
287 287
 		return $this;
288 288
 	}
289 289
 
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
 	 * @param array $compileParts
294 294
 	 * @return DataTable
295 295
 	 */
296
-	public function refresh($compileParts=["tbody"]){
296
+	public function refresh($compileParts=["tbody"]) {
297 297
 		$this->_compileParts=$compileParts;
298 298
 		return $this;
299 299
 	}
300 300
 
301 301
 
302
-	public function addSearchInToolbar($position=Direction::RIGHT){
302
+	public function addSearchInToolbar($position=Direction::RIGHT) {
303 303
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
304 304
 	}
305 305
 
306
-	public function getSearchField(){
307
-		if(isset($this->_searchField)===false){
308
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
309
-			$this->_searchField->addIcon("search",Direction::RIGHT);
306
+	public function getSearchField() {
307
+		if (isset($this->_searchField)===false) {
308
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
309
+			$this->_searchField->addIcon("search", Direction::RIGHT);
310 310
 		}
311 311
 		return $this->_searchField;
312 312
 	}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 		return $this;
323 323
 	}
324 324
 
325
-	public function asForm(){
325
+	public function asForm() {
326 326
 		return $this->getForm();
327 327
 	}
328 328
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 
331 331
 	protected function getTargetSelector() {
332 332
 		$result=$this->_targetSelector;
333
-		if(!isset($result))
333
+		if (!isset($result))
334 334
 			$result="#".$this->identifier;
335 335
 		return $result;
336 336
 	}
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	}
347 347
 
348 348
 	public function getRefreshSelector() {
349
-		if(isset($this->_refreshSelector))
349
+		if (isset($this->_refreshSelector))
350 350
 			return $this->_refreshSelector;
351 351
 		return "#".$this->identifier." tbody";
352 352
 	}
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 	 * {@inheritDoc}
361 361
 	 * @see \Ajax\common\Widget::show()
362 362
 	 */
363
-	public function show($modelInstance){
364
-		if(\is_array($modelInstance)){
365
-			if(\is_array(array_values($modelInstance)[0]))
363
+	public function show($modelInstance) {
364
+		if (\is_array($modelInstance)) {
365
+			if (\is_array(array_values($modelInstance)[0]))
366 366
 				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
367 367
 		}
368 368
 		$this->_modelInstance=$modelInstance;
Please login to merge, or discard this patch.
Braces   +29 added lines, -20 removed lines patch added patch discarded remove patch
@@ -55,10 +55,12 @@  discard block
 block discarded – undo
55 55
 			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
56 56
 			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
57 57
 		}
58
-		if(\is_array($this->_deleteBehavior))
59
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
60
-		if(\is_array($this->_editBehavior))
61
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
58
+		if(\is_array($this->_deleteBehavior)) {
59
+					$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
60
+		}
61
+		if(\is_array($this->_editBehavior)) {
62
+					$this->_generateBehavior("edit",$this->_editBehavior,$js);
63
+		}
62 64
 		return parent::run($js);
63 65
 	}
64 66
 
@@ -94,12 +96,14 @@  discard block
 block discarded – undo
94 96
 			$table->setRowCount(0, \sizeof($captions));
95 97
 			$this->_generateHeader($table,$captions);
96 98
 
97
-			if(isset($this->_compileParts))
98
-				$table->setCompileParts($this->_compileParts);
99
+			if(isset($this->_compileParts)) {
100
+							$table->setCompileParts($this->_compileParts);
101
+			}
99 102
 
100 103
 			if(isset($this->_searchField) && isset($js)){
101
-				if(isset($this->_urls["refresh"]))
102
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
104
+				if(isset($this->_urls["refresh"])) {
105
+									$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
106
+				}
103 107
 			}
104 108
 
105 109
 			$this->_generateContent($table);
@@ -159,8 +163,9 @@  discard block
 block discarded – undo
159 163
 			$field=$ck->getField();
160 164
 			$field->setProperty("value",$id);
161 165
 			$field->setProperty("name", "selection[]");
162
-			if(isset($checkedClass))
163
-				$field->setClass($checkedClass);
166
+			if(isset($checkedClass)) {
167
+							$field->setClass($checkedClass);
168
+			}
164 169
 			\array_unshift($values, $ck);
165 170
 		}
166 171
 		$result=$table->newRow();
@@ -173,8 +178,9 @@  discard block
 block discarded – undo
173 178
 
174 179
 	protected function _generatePagination($table,$js=NULL){
175 180
 		if(isset($this->_toolbar)){
176
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
177
-				$this->_toolbar->setFloated("left");
181
+			if($this->_toolbarPosition==PositionInTable::FOOTER) {
182
+							$this->_toolbar->setFloated("left");
183
+			}
178 184
 		}
179 185
 		$footer=$table->getFooter();
180 186
 		$footer->mergeCol();
@@ -231,7 +237,7 @@  discard block
 block discarded – undo
231 237
 		$hasPart=$table->hasPart($part);
232 238
 		if($hasPart){
233 239
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
234
-		}else{
240
+		} else{
235 241
 			$row=$table->getPart($part)->getRow(0);
236 242
 		}
237 243
 		$row->mergeCol();
@@ -256,7 +262,7 @@  discard block
 block discarded – undo
256 262
 			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
257 263
 			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
258 264
 			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
259
-		}else{
265
+		} else{
260 266
 			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
261 267
 		}
262 268
 		return $this;
@@ -330,8 +336,9 @@  discard block
 block discarded – undo
330 336
 
331 337
 	protected function getTargetSelector() {
332 338
 		$result=$this->_targetSelector;
333
-		if(!isset($result))
334
-			$result="#".$this->identifier;
339
+		if(!isset($result)) {
340
+					$result="#".$this->identifier;
341
+		}
335 342
 		return $result;
336 343
 	}
337 344
 
@@ -346,8 +353,9 @@  discard block
 block discarded – undo
346 353
 	}
347 354
 
348 355
 	public function getRefreshSelector() {
349
-		if(isset($this->_refreshSelector))
350
-			return $this->_refreshSelector;
356
+		if(isset($this->_refreshSelector)) {
357
+					return $this->_refreshSelector;
358
+		}
351 359
 		return "#".$this->identifier." tbody";
352 360
 	}
353 361
 
@@ -362,8 +370,9 @@  discard block
 block discarded – undo
362 370
 	 */
363 371
 	public function show($modelInstance){
364 372
 		if(\is_array($modelInstance)){
365
-			if(\is_array(array_values($modelInstance)[0]))
366
-				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
373
+			if(\is_array(array_values($modelInstance)[0])) {
374
+							$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
375
+			}
367 376
 		}
368 377
 		$this->_modelInstance=$modelInstance;
369 378
 	}
Please login to merge, or discard this patch.