@@ -17,10 +17,10 @@ discard block |
||
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 |
||
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() { |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | public function addToProperty($name, $value, $separator=" ") { |
59 | - if ($value !== "" && $this->propertyContains($name, $value) === false) { |
|
59 | + if ($value!=="" && $this->propertyContains($name, $value)===false) { |
|
60 | 60 | $v=@$this->properties[$name]; |
61 | - if (isset($v) && $v !== "") |
|
62 | - $v=$v . $separator . $value; |
|
61 | + if (isset($v) && $v!=="") |
|
62 | + $v=$v.$separator.$value; |
|
63 | 63 | else |
64 | 64 | $v=$value; |
65 | 65 | |
@@ -75,23 +75,23 @@ discard block |
||
75 | 75 | |
76 | 76 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
77 | 77 | $result=$this->getTemplate($js); |
78 | - foreach ( $this as $key => $value ) { |
|
79 | - if (PhalconUtils::startsWith($key, "_") === false && $key !== "events") { |
|
78 | + foreach ($this as $key => $value) { |
|
79 | + if (PhalconUtils::startsWith($key, "_")===false && $key!=="events") { |
|
80 | 80 | if (is_array($value)) { |
81 | 81 | $v=PropertyWrapper::wrap($value, $js); |
82 | - } else { |
|
82 | + }else { |
|
83 | 83 | $v=$value; |
84 | 84 | } |
85 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
85 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | if (isset($js)) { |
89 | 89 | $this->run($js); |
90 | 90 | } |
91 | - if (isset($view) === true) { |
|
91 | + if (isset($view)===true) { |
|
92 | 92 | $controls=$view->getVar("q"); |
93 | - if (isset($controls) === false) { |
|
94 | - $controls=array (); |
|
93 | + if (isset($controls)===false) { |
|
94 | + $controls=array(); |
|
95 | 95 | } |
96 | 96 | $controls[$this->identifier]=$result; |
97 | 97 | $view->setVar("q", $controls); |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | |
102 | 102 | protected function ctrl($name, $value, $typeCtrl) { |
103 | 103 | if (is_array($typeCtrl)) { |
104 | - if (array_search($value, $typeCtrl) === false) { |
|
105 | - throw new \Exception("La valeur passée a propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
104 | + if (array_search($value, $typeCtrl)===false) { |
|
105 | + throw new \Exception("La valeur passée a propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
106 | 106 | } |
107 | - } else { |
|
107 | + }else { |
|
108 | 108 | if (!$typeCtrl($value)) { |
109 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
109 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | return true; |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
124 | - if ($this->ctrl($name, $value, $typeCtrl) === true) |
|
124 | + if ($this->ctrl($name, $value, $typeCtrl)===true) |
|
125 | 125 | return $this->setProperty($name, $value); |
126 | 126 | return $this; |
127 | 127 | } |
128 | 128 | |
129 | 129 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
130 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
130 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
131 | 131 | return $name=$value; |
132 | 132 | } |
133 | 133 | return $this; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
137 | 137 | if (is_array($typeCtrl)) { |
138 | 138 | $this->removeOldValues($name, $typeCtrl); |
139 | - $name.=$separator . $value; |
|
139 | + $name.=$separator.$value; |
|
140 | 140 | } |
141 | 141 | return $this; |
142 | 142 | } |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
161 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
161 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
162 | 162 | if (is_array($typeCtrl)) { |
163 | 163 | $this->removeOldValues($name, $typeCtrl); |
164 | 164 | } |
165 | - $name.=$separator . $value; |
|
165 | + $name.=$separator.$value; |
|
166 | 166 | } |
167 | 167 | return $this; |
168 | 168 | } |
169 | 169 | |
170 | 170 | protected function addToMember(&$name, $value, $separator=" ") { |
171 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
171 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | public function addToPropertyCtrlCheck($name, $value, $typeCtrl) { |
189 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
189 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
190 | 190 | return $this->addToProperty($name, $value); |
191 | 191 | } |
192 | 192 | return $this; |
@@ -214,28 +214,28 @@ discard block |
||
214 | 214 | } |
215 | 215 | |
216 | 216 | public function fromArray($array) { |
217 | - foreach ( $this as $key => $value ) { |
|
217 | + foreach ($this as $key => $value) { |
|
218 | 218 | if (array_key_exists($key, $array) && !PhalconUtils::startsWith($key, "_")) { |
219 | - $setter="set" . ucfirst($key); |
|
219 | + $setter="set".ucfirst($key); |
|
220 | 220 | $this->$setter($array[$key]); |
221 | 221 | unset($array[$key]); |
222 | 222 | } |
223 | 223 | } |
224 | - foreach ( $array as $key => $value ) { |
|
224 | + foreach ($array as $key => $value) { |
|
225 | 225 | if (method_exists($this, $key)) { |
226 | 226 | try { |
227 | 227 | $this->$key($value); |
228 | 228 | unset($array[$key]); |
229 | - } catch ( \Exception $e ) { |
|
229 | + } catch (\Exception $e) { |
|
230 | 230 | // Nothing to do |
231 | 231 | } |
232 | - } else { |
|
233 | - $setter="set" . ucfirst($key); |
|
232 | + }else { |
|
233 | + $setter="set".ucfirst($key); |
|
234 | 234 | if (method_exists($this, $setter)) { |
235 | 235 | try { |
236 | 236 | $this->$setter($value); |
237 | 237 | unset($array[$key]); |
238 | - } catch ( \Exception $e ) { |
|
238 | + } catch (\Exception $e) { |
|
239 | 239 | // Nothing to do |
240 | 240 | } |
241 | 241 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | public function fromDatabaseObjects($objects, $function) { |
248 | 248 | if (isset($objects)) { |
249 | - foreach ( $objects as $object ) { |
|
249 | + foreach ($objects as $object) { |
|
250 | 250 | $this->fromDatabaseObject($object, $function); |
251 | 251 | } |
252 | 252 | } |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
268 | - if ($stopPropagation === true) { |
|
269 | - $jsCode="event.stopPropagation();" . $jsCode; |
|
268 | + if ($stopPropagation===true) { |
|
269 | + $jsCode="event.stopPropagation();".$jsCode; |
|
270 | 270 | } |
271 | - if ($preventDefault === true) { |
|
272 | - $jsCode="event.preventDefault();" . $jsCode; |
|
271 | + if ($preventDefault===true) { |
|
272 | + $jsCode="event.preventDefault();".$jsCode; |
|
273 | 273 | } |
274 | 274 | return $this->_addEvent($event, $jsCode); |
275 | 275 | } |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | if (array_key_exists($event, $this->_events)) { |
279 | 279 | if (is_array($this->_events[$event])) { |
280 | 280 | $this->_events[$event][]=$jsCode; |
281 | - } else { |
|
282 | - $this->_events[$event]=array ($this->_events[$event],$jsCode ); |
|
281 | + }else { |
|
282 | + $this->_events[$event]=array($this->_events[$event], $jsCode); |
|
283 | 283 | } |
284 | - } else { |
|
284 | + }else { |
|
285 | 285 | $this->_events[$event]=$jsCode; |
286 | 286 | } |
287 | 287 | return $this; |
@@ -301,15 +301,15 @@ discard block |
||
301 | 301 | |
302 | 302 | public function addEventsOnRun(JsUtils $js) { |
303 | 303 | if (isset($this->_bsComponent)) { |
304 | - foreach ( $this->_events as $event => $jsCode ) { |
|
304 | + foreach ($this->_events as $event => $jsCode) { |
|
305 | 305 | $code=$jsCode; |
306 | 306 | if (is_array($jsCode)) { |
307 | 307 | $code=""; |
308 | - foreach ( $jsCode as $jsC ) { |
|
308 | + foreach ($jsCode as $jsC) { |
|
309 | 309 | if ($jsC instanceof AjaxCall) { |
310 | - $code.="\n" . $jsC->compile($js); |
|
311 | - } else { |
|
312 | - $code.="\n" . $jsC; |
|
310 | + $code.="\n".$jsC->compile($js); |
|
311 | + }else { |
|
312 | + $code.="\n".$jsC; |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | } elseif ($jsCode instanceof AjaxCall) { |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | } |
318 | 318 | $this->_bsComponent->addEvent($event, $code); |
319 | 319 | } |
320 | - $this->_events=array (); |
|
320 | + $this->_events=array(); |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | 324 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
325 | - $params=array ("url" => $url,"responseElement" => $responseElement ); |
|
325 | + $params=array("url" => $url, "responseElement" => $responseElement); |
|
326 | 326 | $params=array_merge($params, $parameters); |
327 | 327 | $this->_addEvent($event, new AjaxCall($operation, $params)); |
328 | 328 | return $this; |
@@ -358,15 +358,15 @@ discard block |
||
358 | 358 | if (is_array($elements)) { |
359 | 359 | $flag=false; |
360 | 360 | $index=0; |
361 | - while ( !$flag && $index < sizeof($elements) ) { |
|
361 | + while (!$flag && $index<sizeof($elements)) { |
|
362 | 362 | if ($elements[$index] instanceof BaseHtml) |
363 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
363 | + $flag=($elements[$index]->getIdentifier()===$identifier); |
|
364 | 364 | $index++; |
365 | 365 | } |
366 | - if ($flag === true) |
|
367 | - return $elements[$index - 1]; |
|
366 | + if ($flag===true) |
|
367 | + return $elements[$index-1]; |
|
368 | 368 | } elseif ($elements instanceof BaseHtml) { |
369 | - if ($elements->getIdentifier() === $identifier) |
|
369 | + if ($elements->getIdentifier()===$identifier) |
|
370 | 370 | return $elements; |
371 | 371 | } |
372 | 372 | return null; |
@@ -388,14 +388,14 @@ discard block |
||
388 | 388 | if (is_array($value)) { |
389 | 389 | $value=implode(",", $value); |
390 | 390 | } |
391 | - if (strrpos($value, 'this') === false && strrpos($value, 'event') === false) { |
|
392 | - $value='"' . $value . '"'; |
|
391 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false) { |
|
392 | + $value='"'.$value.'"'; |
|
393 | 393 | } |
394 | 394 | return $value; |
395 | 395 | } |
396 | 396 | |
397 | 397 | public function jsDoJquery($jqueryCall, $param="") { |
398 | - return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . $this->_prep_value($param) . ");"; |
|
398 | + return "$('#".$this->identifier."').".$jqueryCall."(".$this->_prep_value($param).");"; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | public function executeOnRun($jsCode) { |