Passed
Push — master ( 514b5f...6cf655 )
by Jean-Christophe
02:23
created
Ajax/common/html/BaseHtml.php 2 patches
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -112,15 +112,18 @@  discard block
 block discarded – undo
112 112
 			$flag = false;
113 113
 			$index = 0;
114 114
 			while (! $flag && $index < sizeof($elements)) {
115
-				if ($elements[$index] instanceof BaseHtml)
116
-					$flag = ($callback($elements[$index]));
115
+				if ($elements[$index] instanceof BaseHtml) {
116
+									$flag = ($callback($elements[$index]));
117
+				}
117 118
 				$index ++;
118 119
 			}
119
-			if ($flag === true)
120
-				return $elements[$index - 1];
120
+			if ($flag === true) {
121
+							return $elements[$index - 1];
122
+			}
121 123
 		} elseif ($elements instanceof BaseHtml) {
122
-			if ($callback($elements))
123
-				return $elements;
124
+			if ($callback($elements)) {
125
+							return $elements;
126
+			}
124 127
 		}
125 128
 		return null;
126 129
 	}
@@ -146,8 +149,9 @@  discard block
 block discarded – undo
146 149
 
147 150
 	public function fromArray($array) {
148 151
 		foreach ($this as $key => $value) {
149
-			if (array_key_exists($key, $array) === true)
150
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
152
+			if (array_key_exists($key, $array) === true) {
153
+							$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
154
+			}
151 155
 		}
152 156
 		foreach ($array as $key => $value) {
153 157
 			if ($this->_callSetter($key, $key, $value, $array) === false) {
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -15,21 +15,21 @@  discard block
 block discarded – undo
15 15
  * @version 1.3.3
16 16
  */
17 17
 abstract class BaseHtml extends BaseWidget {
18
-	use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait;
18
+	use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait;
19 19
 
20 20
 	protected $_template;
21 21
 
22 22
 	protected $tagName;
23 23
 
24
-	protected $_wrapBefore = array();
24
+	protected $_wrapBefore=array();
25 25
 
26
-	protected $_wrapAfter = array();
26
+	protected $_wrapAfter=array();
27 27
 
28 28
 	protected $_bsComponent;
29 29
 
30
-	protected $_compiled = false;
30
+	protected $_compiled=false;
31 31
 
32
-	protected $_runned = false;
32
+	protected $_runned=false;
33 33
 
34 34
 	protected $_postCompile;
35 35
 
@@ -43,31 +43,31 @@  discard block
 block discarded – undo
43 43
 	abstract public function run(JsUtils $js);
44 44
 
45 45
 	private function _callSetter($setter, $key, $value, &$array) {
46
-		$result = false;
47
-		if (method_exists($this, $setter) && substr($setter, 0, 1) !== "_") {
46
+		$result=false;
47
+		if (method_exists($this, $setter) && substr($setter, 0, 1)!=="_") {
48 48
 			try {
49 49
 				$this->$setter($value);
50 50
 				unset($array[$key]);
51
-				$result = true;
52
-			} catch (\Exception $e) {
53
-				$result = false;
51
+				$result=true;
52
+			}catch (\Exception $e) {
53
+				$result=false;
54 54
 			}
55 55
 		}
56 56
 		return $result;
57 57
 	}
58 58
 
59
-	protected function getTemplate(JsUtils $js = NULL, $view = null) {
60
-		return PropertyWrapper::wrap($this->_wrapBefore, $js, $view) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js, $view);
59
+	protected function getTemplate(JsUtils $js=NULL, $view=null) {
60
+		return PropertyWrapper::wrap($this->_wrapBefore, $js, $view).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js, $view);
61 61
 	}
62 62
 
63 63
 	protected function ctrl($name, $value, $typeCtrl) {
64 64
 		if (\is_array($typeCtrl)) {
65
-			if (array_search($value, $typeCtrl) === false) {
66
-				throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
65
+			if (array_search($value, $typeCtrl)===false) {
66
+				throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
67 67
 			}
68 68
 		} else {
69
-			if (! $typeCtrl($value)) {
70
-				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
69
+			if (!$typeCtrl($value)) {
70
+				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
71 71
 			}
72 72
 		}
73 73
 		return true;
@@ -75,49 +75,49 @@  discard block
 block discarded – undo
75 75
 
76 76
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
77 77
 		$this->ctrl($name, $value, $typeCtrl);
78
-		$name = $value;
78
+		$name=$value;
79 79
 		return $this;
80 80
 	}
81 81
 
82
-	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator = " ") {
82
+	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") {
83 83
 		if (\is_array($typeCtrl)) {
84 84
 			$this->removeOldValues($name, $typeCtrl);
85
-			$name .= $separator . $value;
85
+			$name.=$separator.$value;
86 86
 		}
87 87
 		return $this;
88 88
 	}
89 89
 
90
-	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator = " ") {
90
+	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
91 91
 		$this->ctrl($name, $value, $typeCtrl);
92 92
 		if (\is_array($typeCtrl)) {
93 93
 			$this->removeOldValues($name, $typeCtrl);
94 94
 		}
95
-		$name .= $separator . $value;
95
+		$name.=$separator.$value;
96 96
 		return $this;
97 97
 	}
98 98
 
99
-	protected function addToMember(&$name, $value, $separator = " ") {
100
-		$name = str_ireplace($value, "", $name) . $separator . $value;
99
+	protected function addToMember(&$name, $value, $separator=" ") {
100
+		$name=str_ireplace($value, "", $name).$separator.$value;
101 101
 		return $this;
102 102
 	}
103 103
 
104 104
 	protected function removeOldValues(&$oldValue, $allValues) {
105
-		$oldValue = str_ireplace($allValues, "", $oldValue);
106
-		$oldValue = trim($oldValue);
105
+		$oldValue=str_ireplace($allValues, "", $oldValue);
106
+		$oldValue=trim($oldValue);
107 107
 	}
108 108
 
109 109
 	protected function _getElementBy($callback, $elements) {
110 110
 		if (\is_array($elements)) {
111
-			$elements = \array_values($elements);
112
-			$flag = false;
113
-			$index = 0;
114
-			while (! $flag && $index < sizeof($elements)) {
111
+			$elements=\array_values($elements);
112
+			$flag=false;
113
+			$index=0;
114
+			while (!$flag && $index<sizeof($elements)) {
115 115
 				if ($elements[$index] instanceof BaseHtml)
116
-					$flag = ($callback($elements[$index]));
117
-				$index ++;
116
+					$flag=($callback($elements[$index]));
117
+				$index++;
118 118
 			}
119
-			if ($flag === true)
120
-				return $elements[$index - 1];
119
+			if ($flag===true)
120
+				return $elements[$index-1];
121 121
 		} elseif ($elements instanceof BaseHtml) {
122 122
 			if ($callback($elements))
123 123
 				return $elements;
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 	}
127 127
 
128 128
 	protected function setWrapBefore($wrapBefore) {
129
-		$this->_wrapBefore = $wrapBefore;
129
+		$this->_wrapBefore=$wrapBefore;
130 130
 		return $this;
131 131
 	}
132 132
 
133 133
 	protected function setWrapAfter($wrapAfter) {
134
-		$this->_wrapAfter = $wrapAfter;
134
+		$this->_wrapAfter=$wrapAfter;
135 135
 		return $this;
136 136
 	}
137 137
 
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
 	}
141 141
 
142 142
 	public function setTagName($tagName) {
143
-		$this->tagName = $tagName;
143
+		$this->tagName=$tagName;
144 144
 		return $this;
145 145
 	}
146 146
 
147 147
 	public function fromArray($array) {
148 148
 		foreach ($this as $key => $value) {
149
-			if (array_key_exists($key, $array) === true)
150
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
149
+			if (array_key_exists($key, $array)===true)
150
+				$this->_callSetter("set".ucfirst($key), $key, $array[$key], $array);
151 151
 		}
152 152
 		foreach ($array as $key => $value) {
153
-			if ($this->_callSetter($key, $key, $value, $array) === false) {
154
-				$this->_callSetter("set" . ucfirst($key), $key, $value, $array);
153
+			if ($this->_callSetter($key, $key, $value, $array)===false) {
154
+				$this->_callSetter("set".ucfirst($key), $key, $value, $array);
155 155
 			}
156 156
 		}
157 157
 		return $array;
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
 
169 169
 	public function fromDatabaseObject($object, $function) {}
170 170
 
171
-	public function wrap($before, $after = "") {
171
+	public function wrap($before, $after="") {
172 172
 		if (isset($before)) {
173 173
 			array_unshift($this->_wrapBefore, $before);
174 174
 		}
175
-		$this->_wrapAfter[] = $after;
175
+		$this->_wrapAfter[]=$after;
176 176
 		return $this;
177 177
 	}
178 178
 
179 179
 	public function getElementById($identifier, $elements) {
180
-		return $this->_getElementBy(function (BaseWidget $element) use ($identifier) {
181
-			return $element->getIdentifier() === $identifier;
180
+		return $this->_getElementBy(function(BaseWidget $element) use ($identifier) {
181
+			return $element->getIdentifier()===$identifier;
182 182
 		}, $elements);
183 183
 	}
184 184
 
@@ -187,50 +187,50 @@  discard block
 block discarded – undo
187 187
 	}
188 188
 
189 189
 	public function setBsComponent($bsComponent) {
190
-		$this->_bsComponent = $bsComponent;
190
+		$this->_bsComponent=$bsComponent;
191 191
 		return $this;
192 192
 	}
193 193
 
194
-	protected function compile_once(JsUtils $js = NULL, &$view = NULL) {
195
-		if (! $this->_compiled) {
194
+	protected function compile_once(JsUtils $js=NULL, &$view=NULL) {
195
+		if (!$this->_compiled) {
196 196
 			if (isset($js)) {
197
-				$beforeCompile = $js->getParam("beforeCompileHtml");
197
+				$beforeCompile=$js->getParam("beforeCompileHtml");
198 198
 				if (\is_callable($beforeCompile)) {
199 199
 					$beforeCompile($this, $js, $view);
200 200
 				}
201 201
 			}
202 202
 			$this->callCallback($this->_preCompile);
203 203
 			unset($this->properties["jsCallback"]);
204
-			$this->_compiled = true;
204
+			$this->_compiled=true;
205 205
 		}
206 206
 	}
207 207
 
208
-	public function compile(JsUtils $js = NULL, &$view = NULL) {
208
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
209 209
 		$this->compile_once($js, $view);
210
-		$result = $this->getTemplate($js, $view);
210
+		$result=$this->getTemplate($js, $view);
211 211
 		foreach ($this as $key => $value) {
212
-			if (\strstr($result, "%{$key}%") !== false) {
212
+			if (\strstr($result, "%{$key}%")!==false) {
213 213
 				if (\is_array($value)) {
214
-					$v = PropertyWrapper::wrap($value, $js, $view);
214
+					$v=PropertyWrapper::wrap($value, $js, $view);
215 215
 				} elseif ($value instanceof \stdClass) {
216
-					$v = \print_r($value, true);
216
+					$v=\print_r($value, true);
217 217
 				} elseif ($value instanceof BaseHtml) {
218
-					$v = $value->compile($js, $view);
218
+					$v=$value->compile($js, $view);
219 219
 				} else {
220
-					$v = $value;
220
+					$v=$value;
221 221
 				}
222
-				$result = \str_replace("%{$key}%", $v ?? '', $result);
222
+				$result=\str_replace("%{$key}%", $v ?? '', $result);
223 223
 			}
224 224
 		}
225
-		if (isset($js) === true) {
225
+		if (isset($js)===true) {
226 226
 			$this->run($js);
227
-			if (isset($view) === true) {
227
+			if (isset($view)===true) {
228 228
 				$js->addViewElement($this->getLibraryId(), $result, $view);
229 229
 			}
230 230
 		}
231 231
 
232 232
 		if (\is_callable($this->_postCompile)) {
233
-			$pc = $this->_postCompile;
233
+			$pc=$this->_postCompile;
234 234
 			$pc($this);
235 235
 		}
236 236
 		return $result;
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
 	 *        	default: ["jsCallback"=>"","jqueryDone"=>"append"]
248 248
 	 * @return \Ajax\common\html\BaseHtml
249 249
 	 */
250
-	public function setDraggable($attr = "id", $dropZone = null, $parameters = []) {
250
+	public function setDraggable($attr="id", $dropZone=null, $parameters=[]) {
251 251
 		$this->setProperty("draggable", "true");
252 252
 		$this->addEvent("dragstart", Javascript::draggable($attr));
253 253
 		if (isset($dropZone) && $dropZone instanceof BaseHtml) {
254
-			$jqueryDone = "append";
255
-			$jsCallback = "";
254
+			$jqueryDone="append";
255
+			$jsCallback="";
256 256
 			extract($parameters);
257 257
 			$dropZone->asDropZone($jsCallback, $jqueryDone, $parameters);
258 258
 		}
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 	 * @param array $parameters
268 268
 	 * @return \Ajax\common\html\BaseHtml
269 269
 	 */
270
-	public function asDropZone($jsCallback = "", $jqueryDone = "append", $parameters = []) {
271
-		$stopPropagation = false;
270
+	public function asDropZone($jsCallback="", $jqueryDone="append", $parameters=[]) {
271
+		$stopPropagation=false;
272 272
 		$this->addEvent("dragover", '', $stopPropagation, true);
273 273
 		extract($parameters);
274 274
 		$this->addEvent("drop", Javascript::dropZone($jqueryDone, $jsCallback), $stopPropagation, true);
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 	 * @param array $parameters
286 286
 	 * @return \Ajax\common\html\BaseHtml
287 287
 	 */
288
-	public function asFileDropZone($responseElement = null, $url = null, $progress = null, $jsCallback = "", $parameters = []) {
289
-		$stopPropagation = false;
290
-		$defaultAjaxAttributes = [
288
+	public function asFileDropZone($responseElement=null, $url=null, $progress=null, $jsCallback="", $parameters=[]) {
289
+		$stopPropagation=false;
290
+		$defaultAjaxAttributes=[
291 291
 			'contentType' => 'false',
292 292
 			'processData' => 'false'
293 293
 		];
@@ -295,15 +295,15 @@  discard block
 block discarded – undo
295 295
 		extract($parameters);
296 296
 		$this->addEvent("drop", Javascript::fileDropZone($jsCallback), $stopPropagation, true);
297 297
 		if (isset($ajaxAttributes)) {
298
-			$ajaxAttributes += $defaultAjaxAttributes;
298
+			$ajaxAttributes+=$defaultAjaxAttributes;
299 299
 		} else {
300
-			$ajaxAttributes = $defaultAjaxAttributes;
300
+			$ajaxAttributes=$defaultAjaxAttributes;
301 301
 		}
302 302
 		if (isset($progress)) {
303
-			$progress = new HtmlProgress($this->_identifier . '-pg', 0, $progress);
303
+			$progress=new HtmlProgress($this->_identifier.'-pg', 0, $progress);
304 304
 			$progress->setTotal(100);
305 305
 			$this->wrap('', $progress);
306
-			$ajaxAttributes['upload'] = "$('#" . $this->_identifier . "-pg').progress('set percent', Math.ceil(event.loaded/event.total)*100);";
306
+			$ajaxAttributes['upload']="$('#".$this->_identifier."-pg').progress('set percent', Math.ceil(event.loaded/event.total)*100);";
307 307
 		}
308 308
 		if (isset($url)) {
309 309
 			$this->postOn('upload', $url, 'event.target.upload', $responseElement, $ajaxAttributes);
@@ -316,21 +316,21 @@  discard block
 block discarded – undo
316 316
 	}
317 317
 
318 318
 	public function onPostCompile($callback) {
319
-		$this->_postCompile = $callback;
319
+		$this->_postCompile=$callback;
320 320
 	}
321 321
 
322 322
 	public function onPreCompile($callback) {
323
-		$this->_preCompile = $this->addCallback($this->_preCompile, $callback);
323
+		$this->_preCompile=$this->addCallback($this->_preCompile, $callback);
324 324
 	}
325 325
 
326 326
 	private function addCallback($originalValue, $callback) {
327 327
 		if (isset($originalValue)) {
328
-			if (! is_array($originalValue)) {
329
-				$result = [
328
+			if (!is_array($originalValue)) {
329
+				$result=[
330 330
 					$originalValue
331 331
 				];
332 332
 			}
333
-			$result[] = $callback;
333
+			$result[]=$callback;
334 334
 			return $result;
335 335
 		}
336 336
 		return $callback;
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsInternalTrait.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@  discard block
 block discarded – undo
5 5
 
6 6
 trait JsUtilsInternalTrait {
7 7
 
8
-	protected $jquery_code_for_compile = array();
8
+	protected $jquery_code_for_compile=array();
9 9
 
10
-	protected $jquery_code_for_compile_at_last = array();
10
+	protected $jquery_code_for_compile_at_last=array();
11 11
 
12 12
 	protected function _addToCompile($jsScript) {
13
-		$this->jquery_code_for_compile[] = $jsScript;
13
+		$this->jquery_code_for_compile[]=$jsScript;
14 14
 	}
15 15
 
16 16
 	/**
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @param BaseGui $library
19 19
 	 * @param mixed $view
20 20
 	 */
21
-	protected function _compileLibrary(BaseGui $library, &$view = NULL) {
21
+	protected function _compileLibrary(BaseGui $library, &$view=NULL) {
22 22
 		if (isset($view))
23 23
 			$library->compileHtml($this, $view);
24 24
 		if ($library->isAutoCompile()) {
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
 	}
28 28
 
29 29
 	protected function defer($script) {
30
-		$result = "window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};";
31
-		$result .= "window.defer(function(){" . $script . "})";
30
+		$result="window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};";
31
+		$result.="window.defer(function(){".$script."})";
32 32
 		return $result;
33 33
 	}
34 34
 
35 35
 	protected function ready($script) {
36
-		$result = '$(document).ready(function() {' . "\n";
37
-		$result .= $script . '})';
36
+		$result='$(document).ready(function() {'."\n";
37
+		$result.=$script.'})';
38 38
 		return $result;
39 39
 	}
40 40
 
41 41
 	protected function minify($input) {
42
-		if (trim($input) === "")
42
+		if (trim($input)==="")
43 43
 			return $input;
44
-		$input = preg_replace(array(
44
+		$input=preg_replace(array(
45 45
 			// Remove comment(s)
46 46
 			'#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
47 47
 			// Remove white-space(s) outside the string and regex
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 			'$1$3',
60 60
 			'$1.$3'
61 61
 		), $input);
62
-		$input = str_replace("}$", "};$", $input);
62
+		$input=str_replace("}$", "};$", $input);
63 63
 		return $input;
64 64
 	}
65 65
 
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	 * @param string $src
70 70
 	 * @return string
71 71
 	 */
72
-	protected function _open_script($src = '') {
73
-		$str = '<script ';
74
-		$str .= ($src == '') ? '>' : ' src="' . $src . '">';
72
+	protected function _open_script($src='') {
73
+		$str='<script ';
74
+		$str.=($src=='') ? '>' : ' src="'.$src.'">';
75 75
 		return $str;
76 76
 	}
77 77
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @param string $extra
82 82
 	 * @return string
83 83
 	 */
84
-	protected function _close_script($extra = "\n") {
84
+	protected function _close_script($extra="\n") {
85 85
 		return "</script>$extra";
86 86
 	}
87 87
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@  discard block
 block discarded – undo
19 19
 	 * @param mixed $view
20 20
 	 */
21 21
 	protected function _compileLibrary(BaseGui $library, &$view = NULL) {
22
-		if (isset($view))
23
-			$library->compileHtml($this, $view);
22
+		if (isset($view)) {
23
+					$library->compileHtml($this, $view);
24
+		}
24 25
 		if ($library->isAutoCompile()) {
25 26
 			$library->compile(true);
26 27
 		}
@@ -39,8 +40,9 @@  discard block
 block discarded – undo
39 40
 	}
40 41
 
41 42
 	protected function minify($input) {
42
-		if (trim($input) === "")
43
-			return $input;
43
+		if (trim($input) === "") {
44
+					return $input;
45
+		}
44 46
 		$input = preg_replace(array(
45 47
 			// Remove comment(s)
46 48
 			'#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
Please login to merge, or discard this patch.
Ajax/semantic/components/validation/FieldValidation.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	protected $customRules;
32 32
 
33
-	protected $hasCustomRules = false;
33
+	protected $hasCustomRules=false;
34 34
 
35 35
 	/**
36 36
 	 *
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	protected $optional;
42 42
 
43 43
 	public function __construct($identifier) {
44
-		$this->identifier = $identifier;
45
-		$this->rules = [];
44
+		$this->identifier=$identifier;
45
+		$this->rules=[];
46 46
 	}
47 47
 
48 48
 	public function getIdentifier() {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	}
51 51
 
52 52
 	public function setIdentifier($identifier) {
53
-		$this->identifier = $identifier;
53
+		$this->identifier=$identifier;
54 54
 		return $this;
55 55
 	}
56 56
 
@@ -65,47 +65,47 @@  discard block
 block discarded – undo
65 65
 	 * @param string $value
66 66
 	 * @return Rule
67 67
 	 */
68
-	public function addRule($type, $prompt = NULL, $value = NULL) {
68
+	public function addRule($type, $prompt=NULL, $value=NULL) {
69 69
 		if ($type instanceof Rule) {
70
-			$rule = $type;
70
+			$rule=$type;
71 71
 			if ($type instanceof CustomRule) {
72
-				$this->customRules[] = $type;
73
-				$this->hasCustomRules = true;
72
+				$this->customRules[]=$type;
73
+				$this->hasCustomRules=true;
74 74
 			}
75 75
 		} elseif (\is_array($type)) {
76
-			$value = JArray::getValue($type, "value", 2);
77
-			$prompt = JArray::getValue($type, "prompt", 1);
78
-			$type = JArray::getValue($type, "type", 0);
79
-			$rule = new Rule($type, $prompt, $value);
76
+			$value=JArray::getValue($type, "value", 2);
77
+			$prompt=JArray::getValue($type, "prompt", 1);
78
+			$type=JArray::getValue($type, "type", 0);
79
+			$rule=new Rule($type, $prompt, $value);
80 80
 		} else {
81
-			$rule = new Rule($type, $prompt, $value);
81
+			$rule=new Rule($type, $prompt, $value);
82 82
 		}
83
-		$this->rules[] = $rule;
83
+		$this->rules[]=$rule;
84 84
 		return $rule;
85 85
 	}
86 86
 
87 87
 	#[\ReturnTypeWillChange]
88 88
 	public function jsonSerialize() {
89
-		$result = [
89
+		$result=[
90 90
 			"identifier" => $this->identifier,
91 91
 			"rules" => $this->rules
92 92
 		];
93 93
 		if ($this->optional) {
94
-			$result["optional"] = true;
94
+			$result["optional"]=true;
95 95
 		}
96 96
 		if (isset($this->depends)) {
97
-			$result["depends"] = $this->depends;
97
+			$result["depends"]=$this->depends;
98 98
 		}
99 99
 		return $result;
100 100
 	}
101 101
 
102 102
 	public function setDepends($depends) {
103
-		$this->depends = $depends;
103
+		$this->depends=$depends;
104 104
 		return $this;
105 105
 	}
106 106
 
107 107
 	public function setOptional($optional) {
108
-		$this->optional = $optional;
108
+		$this->optional=$optional;
109 109
 		return $this;
110 110
 	}
111 111
 
Please login to merge, or discard this patch.
Ajax/semantic/components/validation/Rule.php 2 patches
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @version 1.001
9 9
  * Generates a JSON Rule for the validation of a field
10 10
  */
11
-class Rule implements \JsonSerializable{
11
+class Rule implements \JsonSerializable {
12 12
 	/**
13 13
 	 * @var string
14 14
 	 */
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	private $value;
25 25
 
26
-	public function __construct($type,$prompt=NULL,$value=NULL){
26
+	public function __construct($type, $prompt=NULL, $value=NULL) {
27 27
 		$this->type=$type;
28 28
 		$this->prompt=$prompt;
29 29
 		$this->value=$value;
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 
59 59
 	#[\ReturnTypeWillChange]
60 60
 	public function jsonSerialize() {
61
-		$result= ["type"=>$this->type];
62
-		if(isset($this->prompt))
61
+		$result=["type"=>$this->type];
62
+		if (isset($this->prompt))
63 63
 			$result["prompt"]=$this->prompt;
64
-		if(isset($this->value))
64
+		if (isset($this->value))
65 65
 			$result["value"]=$this->value;
66 66
 		return $result;
67 67
 	}
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 * @param string $prompt
73 73
 	 * @return \Ajax\semantic\components\validation\Rule
74 74
 	 */
75
-	public static function match($name,$prompt=NULL){
76
-		return new Rule("match[".$name."]",$prompt);
75
+	public static function match($name, $prompt=NULL) {
76
+		return new Rule("match[".$name."]", $prompt);
77 77
 	}
78 78
 
79 79
 	/**
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 	 * @param string $prompt
83 83
 	 * @return \Ajax\semantic\components\validation\Rule
84 84
 	 */
85
-	public static function different($name,$prompt=NULL){
86
-		return new Rule("different[".$name."]",$prompt);
85
+	public static function different($name, $prompt=NULL) {
86
+		return new Rule("different[".$name."]", $prompt);
87 87
 	}
88 88
 
89 89
 	/**
@@ -93,82 +93,82 @@  discard block
 block discarded – undo
93 93
 	 * @param string $prompt
94 94
 	 * @return \Ajax\semantic\components\validation\Rule
95 95
 	 */
96
-	public static function integer($min=NULL,$max=NULL,$prompt=NULL){
97
-		if(\is_int($min) && \is_int($max))
98
-			return new Rule("integer[{$min}..{$max}]",$prompt);
99
-		return new Rule("integer",$prompt);
96
+	public static function integer($min=NULL, $max=NULL, $prompt=NULL) {
97
+		if (\is_int($min) && \is_int($max))
98
+			return new Rule("integer[{$min}..{$max}]", $prompt);
99
+		return new Rule("integer", $prompt);
100 100
 	}
101 101
 
102
-	public static function decimal($prompt=NULL){
103
-		return new Rule("decimal",$prompt);
102
+	public static function decimal($prompt=NULL) {
103
+		return new Rule("decimal", $prompt);
104 104
 	}
105 105
 
106
-	public static function number($prompt=NULL){
107
-		return new Rule("number",$prompt);
106
+	public static function number($prompt=NULL) {
107
+		return new Rule("number", $prompt);
108 108
 	}
109 109
 
110
-	public static function is($value,$prompt=NULL){
111
-		return new Rule("is[".$value."]",$prompt);
110
+	public static function is($value, $prompt=NULL) {
111
+		return new Rule("is[".$value."]", $prompt);
112 112
 	}
113 113
 
114
-	public static function isExactly($value,$prompt=NULL){
115
-		return new Rule("isExactly[".$value."]",$prompt);
114
+	public static function isExactly($value, $prompt=NULL) {
115
+		return new Rule("isExactly[".$value."]", $prompt);
116 116
 	}
117 117
 
118
-	public static function not($value,$prompt=NULL){
119
-		return new Rule("not[".$value."]",$prompt);
118
+	public static function not($value, $prompt=NULL) {
119
+		return new Rule("not[".$value."]", $prompt);
120 120
 	}
121 121
 
122
-	public static function notExactly($value,$prompt=NULL){
123
-		return new Rule("notExactly[".$value."]",$prompt);
122
+	public static function notExactly($value, $prompt=NULL) {
123
+		return new Rule("notExactly[".$value."]", $prompt);
124 124
 	}
125 125
 
126
-	public static function contains($value,$prompt=NULL){
127
-		return new Rule("contains[".$value."]",$prompt);
126
+	public static function contains($value, $prompt=NULL) {
127
+		return new Rule("contains[".$value."]", $prompt);
128 128
 	}
129 129
 
130
-	public static function containsExactly($value,$prompt=NULL){
131
-		return new Rule("containsExactly[".$value."]",$prompt);
130
+	public static function containsExactly($value, $prompt=NULL) {
131
+		return new Rule("containsExactly[".$value."]", $prompt);
132 132
 	}
133 133
 
134
-	public static function doesntContain($value,$prompt=NULL){
135
-		return new Rule("doesntContain[".$value."]",$prompt);
134
+	public static function doesntContain($value, $prompt=NULL) {
135
+		return new Rule("doesntContain[".$value."]", $prompt);
136 136
 	}
137 137
 
138
-	public static function doesntContainExactly($value,$prompt=NULL){
139
-		return new Rule("doesntContainExactly[".$value."]",$prompt);
138
+	public static function doesntContainExactly($value, $prompt=NULL) {
139
+		return new Rule("doesntContainExactly[".$value."]", $prompt);
140 140
 	}
141 141
 
142
-	public static function minCount($value,$prompt=NULL){
143
-		return new Rule("minCount[".$value."]",$prompt);
142
+	public static function minCount($value, $prompt=NULL) {
143
+		return new Rule("minCount[".$value."]", $prompt);
144 144
 	}
145 145
 
146
-	public static function maxCount($value,$prompt=NULL){
147
-		return new Rule("maxCount[".$value."]",$prompt);
146
+	public static function maxCount($value, $prompt=NULL) {
147
+		return new Rule("maxCount[".$value."]", $prompt);
148 148
 	}
149 149
 
150
-	public static function exactCount($value,$prompt=NULL){
151
-		return new Rule("exactCount[".$value."]",$prompt);
150
+	public static function exactCount($value, $prompt=NULL) {
151
+		return new Rule("exactCount[".$value."]", $prompt);
152 152
 	}
153 153
 
154
-	public static function email($prompt=NULL){
155
-		return new Rule("email",$prompt);
154
+	public static function email($prompt=NULL) {
155
+		return new Rule("email", $prompt);
156 156
 	}
157 157
 
158
-	public static function url($prompt=NULL){
159
-		return new Rule("url",$prompt);
158
+	public static function url($prompt=NULL) {
159
+		return new Rule("url", $prompt);
160 160
 	}
161 161
 
162
-	public static function regExp($value,$prompt=NULL){
163
-		return new Rule("regExp",$prompt,$value);
162
+	public static function regExp($value, $prompt=NULL) {
163
+		return new Rule("regExp", $prompt, $value);
164 164
 	}
165 165
 
166
-	public static function custom($name,$jsFunction){
167
-		return "$.fn.form.settings.rules.".$name." =".$jsFunction ;
166
+	public static function custom($name, $jsFunction) {
167
+		return "$.fn.form.settings.rules.".$name." =".$jsFunction;
168 168
 	}
169 169
 
170
-	public static function ajax(JsUtils $js,$name,$url,$params,$jsCallback,$method="post",$parameters=[]){
171
-		$parameters=\array_merge(["async"=>false,"url"=>$url,"params"=>$params,"hasLoader"=>false,"jsCallback"=>$jsCallback,"dataType"=>"json","stopPropagation"=>false,"preventDefault"=>false,"responseElement"=>null],$parameters);
170
+	public static function ajax(JsUtils $js, $name, $url, $params, $jsCallback, $method="post", $parameters=[]) {
171
+		$parameters=\array_merge(["async"=>false, "url"=>$url, "params"=>$params, "hasLoader"=>false, "jsCallback"=>$jsCallback, "dataType"=>"json", "stopPropagation"=>false, "preventDefault"=>false, "responseElement"=>null], $parameters);
172 172
 		$ajax=new AjaxCall($method, $parameters);
173 173
 		return self::custom($name, "function(value,ruleValue){var result=true;".$ajax->compile($js)."return result;}");
174 174
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -59,10 +59,12 @@  discard block
 block discarded – undo
59 59
 	#[\ReturnTypeWillChange]
60 60
 	public function jsonSerialize() {
61 61
 		$result= ["type"=>$this->type];
62
-		if(isset($this->prompt))
63
-			$result["prompt"]=$this->prompt;
64
-		if(isset($this->value))
65
-			$result["value"]=$this->value;
62
+		if(isset($this->prompt)) {
63
+					$result["prompt"]=$this->prompt;
64
+		}
65
+		if(isset($this->value)) {
66
+					$result["value"]=$this->value;
67
+		}
66 68
 		return $result;
67 69
 	}
68 70
 
@@ -94,8 +96,9 @@  discard block
 block discarded – undo
94 96
 	 * @return \Ajax\semantic\components\validation\Rule
95 97
 	 */
96 98
 	public static function integer($min=NULL,$max=NULL,$prompt=NULL){
97
-		if(\is_int($min) && \is_int($max))
98
-			return new Rule("integer[{$min}..{$max}]",$prompt);
99
+		if(\is_int($min) && \is_int($max)) {
100
+					return new Rule("integer[{$min}..{$max}]",$prompt);
101
+		}
99 102
 		return new Rule("integer",$prompt);
100 103
 	}
101 104
 
Please login to merge, or discard this patch.
Ajax/service/Javascript.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -3,36 +3,36 @@  discard block
 block discarded – undo
3 3
 
4 4
 class Javascript {
5 5
 
6
-	public static $preventDefault = "\nif(event && event.preventDefault) event.preventDefault();\n";
6
+	public static $preventDefault="\nif(event && event.preventDefault) event.preventDefault();\n";
7 7
 
8
-	public static $stopPropagation = "\nif(event && event.stopPropagation) event.stopPropagation();\n";
8
+	public static $stopPropagation="\nif(event && event.stopPropagation) event.stopPropagation();\n";
9 9
 
10
-	public static function draggable($attr = "id") {
11
-		return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;dt.setData("text/plain",JSON.stringify({id:$(event.target).attr("id"),data:$(event.target).attr("' . $attr . '")}));';
10
+	public static function draggable($attr="id") {
11
+		return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;dt.setData("text/plain",JSON.stringify({id:$(event.target).attr("id"),data:$(event.target).attr("'.$attr.'")}));';
12 12
 	}
13 13
 
14
-	public static function dropZone($jqueryDone, $jsCallback = "") {
15
-		$done = ($jqueryDone != null) ? '$(event.target).' . $jqueryDone . '($("#"+_data.id));' : '';
16
-		return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var _data=JSON.parse(dt.getData("text/plain"));' . $done . 'var data=_data.data;' . $jsCallback;
14
+	public static function dropZone($jqueryDone, $jsCallback="") {
15
+		$done=($jqueryDone!=null) ? '$(event.target).'.$jqueryDone.'($("#"+_data.id));' : '';
16
+		return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var _data=JSON.parse(dt.getData("text/plain"));'.$done.'var data=_data.data;'.$jsCallback;
17 17
 	}
18 18
 
19
-	public static function fileDropZone($jsCallback = "") {
20
-		$done = 'event.target.upload=formData;$(event.target).trigger("upload");';
21
-		return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var files=dt.files;var formData = new FormData();for (var i = 0; i < files.length; i++) {formData.append("file-"+i,files[i]);}' . $done . $jsCallback;
19
+	public static function fileDropZone($jsCallback="") {
20
+		$done='event.target.upload=formData;$(event.target).trigger("upload");';
21
+		return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var files=dt.files;var formData = new FormData();for (var i = 0; i < files.length; i++) {formData.append("file-"+i,files[i]);}'.$done.$jsCallback;
22 22
 	}
23 23
 
24 24
 	public static function containsCode($expression) {
25
-		if ($expression == null) {
25
+		if ($expression==null) {
26 26
 			return false;
27 27
 		}
28
-		return \strrpos($expression, 'this') !== false || \strrpos($expression, 'event') !== false || \strrpos($expression, 'self') !== false;
28
+		return \strrpos($expression, 'this')!==false || \strrpos($expression, 'event')!==false || \strrpos($expression, 'self')!==false;
29 29
 	}
30 30
 
31 31
 	public static function isFunction($jsCode) {
32 32
 		return JString::startswith($jsCode, "function");
33 33
 	}
34 34
 
35
-	public static function fileUploadBehavior($id = '') {
35
+	public static function fileUploadBehavior($id='') {
36 36
 		return "$('input:text, .ui.button', '#{$id}').on('click', function (e) {e.preventDefault();\$('input:file', '#{$id}').click();});
37 37
 				$('input:file', '#{$id}').on('change', function (e) {if(e.target.files.length){var name = e.target.files[0].name;$('input:text', $(e.target).parent()).val(name);}});";
38 38
 	}
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	 * @return string
47 47
 	 */
48 48
 	public static function prep_element($element) {
49
-		if (self::containsCode($element) === false) {
50
-			$element = '"' . addslashes($element ?? '') . '"';
49
+		if (self::containsCode($element)===false) {
50
+			$element='"'.addslashes($element ?? '').'"';
51 51
 		}
52 52
 		return $element;
53 53
 	}
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public static function prep_value($value) {
64 64
 		if (\is_array($value)) {
65
-			$value = implode(",", $value);
65
+			$value=implode(",", $value);
66 66
 		}
67
-		if (self::containsCode($value) === false) {
68
-			$value = \str_replace([
67
+		if (self::containsCode($value)===false) {
68
+			$value=\str_replace([
69 69
 				"\\",
70 70
 				"\""
71 71
 			], [
72 72
 				"\\\\",
73 73
 				"\\\""
74 74
 			], $value);
75
-			$value = '"' . $value . '"';
75
+			$value='"'.$value.'"';
76 76
 		}
77 77
 		return trim($value, "%");
78 78
 	}
79 79
 
80 80
 	public static function prep_jquery_selector($value) {
81
-		if (JString::startswith($value, '$(') === false) {
82
-			return '$(' . self::prep_value($value) . ')';
81
+		if (JString::startswith($value, '$(')===false) {
82
+			return '$('.self::prep_value($value).')';
83 83
 		}
84 84
 		return $value;
85 85
 	}
Please login to merge, or discard this patch.