Completed
Push — master ( b0560a...f1cdc4 )
by Jean-Christophe
03:54
created
Ajax/semantic/html/elements/HtmlInput.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 	use IconTrait;
13 13
 
14 14
 	public function __construct($identifier, $type="text", $value="", $placeholder="") {
15
-		parent::__construct("div-" . $identifier, "div", "ui input");
15
+		parent::__construct("div-".$identifier, "div", "ui input");
16 16
 		$this->content=new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder);
17
-		self::$_states=[ State::DISABLED,State::FOCUS,State::ERROR ];
18
-		self::$_variations=[ Variation::TRANSPARENT ];
17
+		self::$_states=[State::DISABLED, State::FOCUS, State::ERROR];
18
+		self::$_variations=[Variation::TRANSPARENT];
19 19
 	}
20 20
 
21 21
 	public function setFocus() {
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 
25 25
 	public function addLoading() {
26
-		if ($this->_hasIcon === false) {
26
+		if ($this->_hasIcon===false) {
27 27
 			throw new \Exception("Input must have an icon for showing a loader, use addIcon before");
28 28
 		}
29 29
 		return $this->addToProperty("class", State::LOADING);
@@ -31,31 +31,31 @@  discard block
 block discarded – undo
31 31
 
32 32
 	public function labeled($label, $direction=Direction::LEFT, $icon=NULL) {
33 33
 		$labelO=$label;
34
-		if (\is_object($label) === false) {
35
-			$labelO=new HtmlLabel("label-" . $this->identifier, $label);
34
+		if (\is_object($label)===false) {
35
+			$labelO=new HtmlLabel("label-".$this->identifier, $label);
36 36
 			if (isset($icon))
37 37
 				$labelO->addIcon($icon);
38
-		} else {
39
-			$labelO->addToPropertyCtrl("class", "label", array ("label" ));
38
+		}else {
39
+			$labelO->addToPropertyCtrl("class", "label", array("label"));
40 40
 		}
41
-		$this->addToProperty("class", $direction . " labeled");
42
-		$this->addContent($labelO, \strstr($direction, Direction::LEFT) !== false);
41
+		$this->addToProperty("class", $direction." labeled");
42
+		$this->addContent($labelO, \strstr($direction, Direction::LEFT)!==false);
43 43
 		return $labelO;
44 44
 	}
45 45
 
46 46
 	public function labeledToCorner($label, $direction=Direction::LEFT, $icon=NULL) {
47
-		return $this->labeled($label, $direction . " corner", $icon)->toCorner($direction);
47
+		return $this->labeled($label, $direction." corner", $icon)->toCorner($direction);
48 48
 	}
49 49
 
50 50
 	public function addAction($action, $direction=Direction::LEFT, $icon=NULL, $labeled=false) {
51 51
 		$actionO=$action;
52
-		if (\is_object($action) === false) {
53
-			$actionO=new HtmlButton("action-" . $this->identifier, $action);
52
+		if (\is_object($action)===false) {
53
+			$actionO=new HtmlButton("action-".$this->identifier, $action);
54 54
 			if (isset($icon))
55 55
 				$actionO->addIcon($icon, true, $labeled);
56 56
 		}
57
-		$this->addToProperty("class", $direction . " action");
58
-		$this->addContent($actionO, \strstr($direction, Direction::LEFT) !== false);
57
+		$this->addToProperty("class", $direction." action");
58
+		$this->addContent($actionO, \strstr($direction, Direction::LEFT)!==false);
59 59
 		return $actionO;
60 60
 	}
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/common/html/BaseHtml.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 abstract class BaseHtml extends BaseWidget {
18 18
 	protected $_template;
19 19
 	protected $tagName;
20
-	protected $properties=array ();
21
-	protected $_events=array ();
22
-	protected $_wrapBefore=array ();
23
-	protected $_wrapAfter=array ();
20
+	protected $properties=array();
21
+	protected $_events=array();
22
+	protected $_wrapBefore=array();
23
+	protected $_wrapAfter=array();
24 24
 	protected $_bsComponent;
25 25
 
26 26
 	public function getBsComponent() {
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	}
34 34
 
35 35
 	protected function getTemplate(JsUtils $js=NULL) {
36
-		return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js);
36
+		return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js);
37 37
 	}
38 38
 
39 39
 	public function getProperties() {
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 
58 58
 	public function addToProperty($name, $value, $separator=" ") {
59 59
 		if (\is_array($value)) {
60
-			foreach ( $value as $v ) {
60
+			foreach ($value as $v) {
61 61
 				$this->addToProperty($name, $v, $separator);
62 62
 			}
63
-		} else if ($value !== "" && $this->propertyContains($name, $value) === false) {
63
+		}else if ($value!=="" && $this->propertyContains($name, $value)===false) {
64 64
 			$v=@$this->properties[$name];
65
-			if (isset($v) && $v !== "")
66
-				$v=$v . $separator . $value;
65
+			if (isset($v) && $v!=="")
66
+				$v=$v.$separator.$value;
67 67
 			else
68 68
 				$v=$value;
69 69
 			
@@ -79,23 +79,23 @@  discard block
 block discarded – undo
79 79
 
80 80
 	public function compile(JsUtils $js=NULL, View $view=NULL) {
81 81
 		$result=$this->getTemplate($js);
82
-		foreach ( $this as $key => $value ) {
83
-			if (PhalconUtils::startsWith($key, "_") === false && $key !== "events") {
82
+		foreach ($this as $key => $value) {
83
+			if (PhalconUtils::startsWith($key, "_")===false && $key!=="events") {
84 84
 				if (is_array($value)) {
85 85
 					$v=PropertyWrapper::wrap($value, $js);
86
-				} else {
86
+				}else {
87 87
 					$v=$value;
88 88
 				}
89
-				$result=str_ireplace("%" . $key . "%", $v, $result);
89
+				$result=str_ireplace("%".$key."%", $v, $result);
90 90
 			}
91 91
 		}
92 92
 		if (isset($js)) {
93 93
 			$this->run($js);
94 94
 		}
95
-		if (isset($view) === true) {
95
+		if (isset($view)===true) {
96 96
 			$controls=$view->getVar("q");
97
-			if (isset($controls) === false) {
98
-				$controls=array ();
97
+			if (isset($controls)===false) {
98
+				$controls=array();
99 99
 			}
100 100
 			$controls[$this->identifier]=$result;
101 101
 			$view->setVar("q", $controls);
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 
106 106
 	protected function ctrl($name, $value, $typeCtrl) {
107 107
 		if (is_array($typeCtrl)) {
108
-			if (array_search($value, $typeCtrl) === false) {
109
-				throw new \Exception("La valeur passée a propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
108
+			if (array_search($value, $typeCtrl)===false) {
109
+				throw new \Exception("La valeur passée a propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
110 110
 			}
111
-		} else {
111
+		}else {
112 112
 			if (!$typeCtrl($value)) {
113
-				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
113
+				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
114 114
 			}
115 115
 		}
116 116
 		return true;
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 	}
126 126
 
127 127
 	protected function setPropertyCtrl($name, $value, $typeCtrl) {
128
-		if ($this->ctrl($name, $value, $typeCtrl) === true)
128
+		if ($this->ctrl($name, $value, $typeCtrl)===true)
129 129
 			return $this->setProperty($name, $value);
130 130
 		return $this;
131 131
 	}
132 132
 
133 133
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
134
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
134
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
135 135
 			return $name=$value;
136 136
 		}
137 137
 		return $this;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") {
141 141
 		if (is_array($typeCtrl)) {
142 142
 			$this->removeOldValues($name, $typeCtrl);
143
-			$name.=$separator . $value;
143
+			$name.=$separator.$value;
144 144
 		}
145 145
 		return $this;
146 146
 	}
@@ -162,17 +162,17 @@  discard block
 block discarded – undo
162 162
 	}
163 163
 
164 164
 	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
165
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
165
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
166 166
 			if (is_array($typeCtrl)) {
167 167
 				$this->removeOldValues($name, $typeCtrl);
168 168
 			}
169
-			$name.=$separator . $value;
169
+			$name.=$separator.$value;
170 170
 		}
171 171
 		return $this;
172 172
 	}
173 173
 
174 174
 	protected function addToMember(&$name, $value, $separator=" ") {
175
-		$name=str_ireplace($value, "", $name) . $separator . $value;
175
+		$name=str_ireplace($value, "", $name).$separator.$value;
176 176
 		return $this;
177 177
 	}
178 178
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	}
191 191
 
192 192
 	public function addToPropertyCtrlCheck($name, $value, $typeCtrl) {
193
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
193
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
194 194
 			return $this->addToProperty($name, $value);
195 195
 		}
196 196
 		return $this;
@@ -218,28 +218,28 @@  discard block
 block discarded – undo
218 218
 	}
219 219
 
220 220
 	public function fromArray($array) {
221
-		foreach ( $this as $key => $value ) {
221
+		foreach ($this as $key => $value) {
222 222
 			if (array_key_exists($key, $array) && !PhalconUtils::startsWith($key, "_")) {
223
-				$setter="set" . ucfirst($key);
223
+				$setter="set".ucfirst($key);
224 224
 				$this->$setter($array[$key]);
225 225
 				unset($array[$key]);
226 226
 			}
227 227
 		}
228
-		foreach ( $array as $key => $value ) {
228
+		foreach ($array as $key => $value) {
229 229
 			if (method_exists($this, $key)) {
230 230
 				try {
231 231
 					$this->$key($value);
232 232
 					unset($array[$key]);
233
-				} catch ( \Exception $e ) {
233
+				} catch (\Exception $e) {
234 234
 					// Nothing to do
235 235
 				}
236
-			} else {
237
-				$setter="set" . ucfirst($key);
236
+			}else {
237
+				$setter="set".ucfirst($key);
238 238
 				if (method_exists($this, $setter)) {
239 239
 					try {
240 240
 						$this->$setter($value);
241 241
 						unset($array[$key]);
242
-					} catch ( \Exception $e ) {
242
+					} catch (\Exception $e) {
243 243
 						// Nothing to do
244 244
 					}
245 245
 				}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 
251 251
 	public function fromDatabaseObjects($objects, $function) {
252 252
 		if (isset($objects)) {
253
-			foreach ( $objects as $object ) {
253
+			foreach ($objects as $object) {
254 254
 				$this->fromDatabaseObject($object, $function);
255 255
 			}
256 256
 		}
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 	}
270 270
 
271 271
 	public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
272
-		if ($stopPropagation === true) {
273
-			$jsCode="event.stopPropagation();" . $jsCode;
272
+		if ($stopPropagation===true) {
273
+			$jsCode="event.stopPropagation();".$jsCode;
274 274
 		}
275
-		if ($preventDefault === true) {
276
-			$jsCode="event.preventDefault();" . $jsCode;
275
+		if ($preventDefault===true) {
276
+			$jsCode="event.preventDefault();".$jsCode;
277 277
 		}
278 278
 		return $this->_addEvent($event, $jsCode);
279 279
 	}
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
 		if (array_key_exists($event, $this->_events)) {
283 283
 			if (is_array($this->_events[$event])) {
284 284
 				$this->_events[$event][]=$jsCode;
285
-			} else {
286
-				$this->_events[$event]=array ($this->_events[$event],$jsCode );
285
+			}else {
286
+				$this->_events[$event]=array($this->_events[$event], $jsCode);
287 287
 			}
288
-		} else {
288
+		}else {
289 289
 			$this->_events[$event]=$jsCode;
290 290
 		}
291 291
 		return $this;
@@ -305,15 +305,15 @@  discard block
 block discarded – undo
305 305
 
306 306
 	public function addEventsOnRun(JsUtils $js) {
307 307
 		if (isset($this->_bsComponent)) {
308
-			foreach ( $this->_events as $event => $jsCode ) {
308
+			foreach ($this->_events as $event => $jsCode) {
309 309
 				$code=$jsCode;
310 310
 				if (is_array($jsCode)) {
311 311
 					$code="";
312
-					foreach ( $jsCode as $jsC ) {
312
+					foreach ($jsCode as $jsC) {
313 313
 						if ($jsC instanceof AjaxCall) {
314
-							$code.="\n" . $jsC->compile($js);
315
-						} else {
316
-							$code.="\n" . $jsC;
314
+							$code.="\n".$jsC->compile($js);
315
+						}else {
316
+							$code.="\n".$jsC;
317 317
 						}
318 318
 					}
319 319
 				} elseif ($jsCode instanceof AjaxCall) {
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
 				}
322 322
 				$this->_bsComponent->addEvent($event, $code);
323 323
 			}
324
-			$this->_events=array ();
324
+			$this->_events=array();
325 325
 		}
326 326
 	}
327 327
 
328 328
 	public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) {
329
-		$params=array ("url" => $url,"responseElement" => $responseElement );
329
+		$params=array("url" => $url, "responseElement" => $responseElement);
330 330
 		$params=array_merge($params, $parameters);
331 331
 		$this->_addEvent($event, new AjaxCall($operation, $params));
332 332
 		return $this;
@@ -362,15 +362,15 @@  discard block
 block discarded – undo
362 362
 		if (is_array($elements)) {
363 363
 			$flag=false;
364 364
 			$index=0;
365
-			while ( !$flag && $index < sizeof($elements) ) {
365
+			while (!$flag && $index<sizeof($elements)) {
366 366
 				if ($elements[$index] instanceof BaseHtml)
367
-					$flag=($elements[$index]->getIdentifier() === $identifier);
367
+					$flag=($elements[$index]->getIdentifier()===$identifier);
368 368
 				$index++;
369 369
 			}
370
-			if ($flag === true)
371
-				return $elements[$index - 1];
370
+			if ($flag===true)
371
+				return $elements[$index-1];
372 372
 		} elseif ($elements instanceof BaseHtml) {
373
-			if ($elements->getIdentifier() === $identifier)
373
+			if ($elements->getIdentifier()===$identifier)
374 374
 				return $elements;
375 375
 		}
376 376
 		return null;
@@ -392,14 +392,14 @@  discard block
 block discarded – undo
392 392
 		if (is_array($value)) {
393 393
 			$value=implode(",", $value);
394 394
 		}
395
-		if (strrpos($value, 'this') === false && strrpos($value, 'event') === false) {
396
-			$value='"' . $value . '"';
395
+		if (strrpos($value, 'this')===false && strrpos($value, 'event')===false) {
396
+			$value='"'.$value.'"';
397 397
 		}
398 398
 		return $value;
399 399
 	}
400 400
 
401 401
 	public function jsDoJquery($jqueryCall, $param="") {
402
-		return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . $this->_prep_value($param) . ");";
402
+		return "$('#".$this->identifier."').".$jqueryCall."(".$this->_prep_value($param).");";
403 403
 	}
404 404
 
405 405
 	public function executeOnRun($jsCode) {
Please login to merge, or discard this patch.