@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | use BaseHtmlEventsTrait; |
18 | 18 | protected $_template; |
19 | 19 | protected $tagName; |
20 | - protected $properties=array (); |
|
21 | - protected $_wrapBefore=array (); |
|
22 | - protected $_wrapAfter=array (); |
|
20 | + protected $properties=array(); |
|
21 | + protected $_wrapBefore=array(); |
|
22 | + protected $_wrapAfter=array(); |
|
23 | 23 | protected $_bsComponent; |
24 | 24 | |
25 | 25 | public function getBsComponent() { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | protected function getTemplate(JsUtils $js=NULL) { |
35 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
35 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getProperties() { |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | |
57 | 57 | public function addToProperty($name, $value, $separator=" ") { |
58 | 58 | if (\is_array($value)) { |
59 | - foreach ( $value as $v ) { |
|
59 | + foreach ($value as $v) { |
|
60 | 60 | $this->addToProperty($name, $v, $separator); |
61 | 61 | } |
62 | - } else if ($value !== "" && $this->propertyContains($name, $value) === false) { |
|
62 | + } else if ($value!=="" && $this->propertyContains($name, $value)===false) { |
|
63 | 63 | $v=@$this->properties[$name]; |
64 | - if (isset($v) && $v !== "") |
|
65 | - $v=$v . $separator . $value; |
|
64 | + if (isset($v) && $v!=="") |
|
65 | + $v=$v.$separator.$value; |
|
66 | 66 | else |
67 | 67 | $v=$value; |
68 | 68 | |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | |
79 | 79 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
80 | 80 | $result=$this->getTemplate($js); |
81 | - foreach ( $this as $key => $value ) { |
|
82 | - if (JString::startswith($key, "_") === false && $key !== "events") { |
|
81 | + foreach ($this as $key => $value) { |
|
82 | + if (JString::startswith($key, "_")===false && $key!=="events") { |
|
83 | 83 | if (is_array($value)) { |
84 | 84 | $v=PropertyWrapper::wrap($value, $js); |
85 | 85 | } else { |
86 | 86 | $v=$value; |
87 | 87 | } |
88 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
88 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | if (isset($js)===true) { |
92 | 92 | $this->run($js); |
93 | - if (isset($view) === true) { |
|
93 | + if (isset($view)===true) { |
|
94 | 94 | $js->addViewElement($this->identifier, $result, $view); |
95 | 95 | } |
96 | 96 | } |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | |
100 | 100 | protected function ctrl($name, $value, $typeCtrl) { |
101 | 101 | if (is_array($typeCtrl)) { |
102 | - if (array_search($value, $typeCtrl) === false) { |
|
103 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
102 | + if (array_search($value, $typeCtrl)===false) { |
|
103 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
104 | 104 | } |
105 | 105 | } else { |
106 | 106 | if (!$typeCtrl($value)) { |
107 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
107 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | return true; |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
122 | - if ($this->ctrl($name, $value, $typeCtrl) === true) |
|
122 | + if ($this->ctrl($name, $value, $typeCtrl)===true) |
|
123 | 123 | return $this->setProperty($name, $value); |
124 | 124 | return $this; |
125 | 125 | } |
126 | 126 | |
127 | 127 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
128 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
128 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
129 | 129 | return $name=$value; |
130 | 130 | } |
131 | 131 | return $this; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
135 | 135 | if (is_array($typeCtrl)) { |
136 | 136 | $this->removeOldValues($name, $typeCtrl); |
137 | - $name.=$separator . $value; |
|
137 | + $name.=$separator.$value; |
|
138 | 138 | } |
139 | 139 | return $this; |
140 | 140 | } |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
159 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
159 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
160 | 160 | if (is_array($typeCtrl)) { |
161 | 161 | $this->removeOldValues($name, $typeCtrl); |
162 | 162 | } |
163 | - $name.=$separator . $value; |
|
163 | + $name.=$separator.$value; |
|
164 | 164 | } |
165 | 165 | return $this; |
166 | 166 | } |
167 | 167 | |
168 | 168 | protected function addToMember(&$name, $value, $separator=" ") { |
169 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
169 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
170 | 170 | return $this; |
171 | 171 | } |
172 | 172 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | public function addToPropertyCtrlCheck($name, $value, $typeCtrl) { |
187 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
187 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
188 | 188 | return $this->addToProperty($name, $value); |
189 | 189 | } |
190 | 190 | return $this; |
@@ -212,26 +212,26 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | public function fromArray($array) { |
215 | - foreach ( $this as $key => $value ) { |
|
216 | - if(array_key_exists($key, $array)===true) |
|
217 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
215 | + foreach ($this as $key => $value) { |
|
216 | + if (array_key_exists($key, $array)===true) |
|
217 | + $this->_callSetter("set".ucfirst($key), $key, $array[$key], $array); |
|
218 | 218 | } |
219 | - foreach ( $array as $key => $value ) { |
|
220 | - if($this->_callSetter($key, $key, $value, $array)===false){ |
|
221 | - $this->_callSetter("set" . ucfirst($key), $key, $value, $array); |
|
219 | + foreach ($array as $key => $value) { |
|
220 | + if ($this->_callSetter($key, $key, $value, $array)===false) { |
|
221 | + $this->_callSetter("set".ucfirst($key), $key, $value, $array); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | return $array; |
225 | 225 | } |
226 | 226 | |
227 | - private function _callSetter($setter,$key,$value,&$array){ |
|
227 | + private function _callSetter($setter, $key, $value, &$array) { |
|
228 | 228 | $result=false; |
229 | 229 | if (method_exists($this, $setter) && !JString::startswith($key, "_")) { |
230 | 230 | try { |
231 | 231 | $this->$setter($value); |
232 | 232 | unset($array[$key]); |
233 | 233 | $result=true; |
234 | - } catch ( \Exception $e ) { |
|
234 | + }catch (\Exception $e) { |
|
235 | 235 | $result=false; |
236 | 236 | } |
237 | 237 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | public function fromDatabaseObjects($objects, $function) { |
242 | 242 | if (isset($objects)) { |
243 | - foreach ( $objects as $object ) { |
|
243 | + foreach ($objects as $object) { |
|
244 | 244 | $this->fromDatabaseObject($object, $function); |
245 | 245 | } |
246 | 246 | } |
@@ -264,33 +264,33 @@ discard block |
||
264 | 264 | if (is_array($elements)) { |
265 | 265 | $flag=false; |
266 | 266 | $index=0; |
267 | - while ( !$flag && $index < sizeof($elements) ) { |
|
267 | + while (!$flag && $index<sizeof($elements)) { |
|
268 | 268 | if ($elements[$index] instanceof BaseHtml) |
269 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
269 | + $flag=($elements[$index]->getIdentifier()===$identifier); |
|
270 | 270 | $index++; |
271 | 271 | } |
272 | - if ($flag === true) |
|
273 | - return $elements[$index - 1]; |
|
272 | + if ($flag===true) |
|
273 | + return $elements[$index-1]; |
|
274 | 274 | } elseif ($elements instanceof BaseHtml) { |
275 | - if ($elements->getIdentifier() === $identifier) |
|
275 | + if ($elements->getIdentifier()===$identifier) |
|
276 | 276 | return $elements; |
277 | 277 | } |
278 | 278 | return null; |
279 | 279 | } |
280 | 280 | |
281 | - protected function getElementByPropertyValue($propertyName,$value, $elements) { |
|
281 | + protected function getElementByPropertyValue($propertyName, $value, $elements) { |
|
282 | 282 | if (is_array($elements)) { |
283 | 283 | $flag=false; |
284 | 284 | $index=0; |
285 | - while ( !$flag && $index < sizeof($elements) ) { |
|
285 | + while (!$flag && $index<sizeof($elements)) { |
|
286 | 286 | if ($elements[$index] instanceof BaseHtml) |
287 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
287 | + $flag=($elements[$index]->propertyContains($propertyName, $value)===true); |
|
288 | 288 | $index++; |
289 | 289 | } |
290 | - if ($flag === true) |
|
291 | - return $elements[$index - 1]; |
|
290 | + if ($flag===true) |
|
291 | + return $elements[$index-1]; |
|
292 | 292 | } elseif ($elements instanceof BaseHtml) { |
293 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
293 | + if ($elements->propertyContains($propertyName, $value)===true) |
|
294 | 294 | return $elements; |
295 | 295 | } |
296 | 296 | return null; |
@@ -50,8 +50,9 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | public function getProperty($name) { |
53 | - if (array_key_exists($name, $this->properties)) |
|
54 | - return $this->properties[$name]; |
|
53 | + if (array_key_exists($name, $this->properties)) { |
|
54 | + return $this->properties[$name]; |
|
55 | + } |
|
55 | 56 | } |
56 | 57 | |
57 | 58 | public function addToProperty($name, $value, $separator=" ") { |
@@ -61,10 +62,11 @@ discard block |
||
61 | 62 | } |
62 | 63 | } else if ($value !== "" && $this->propertyContains($name, $value) === false) { |
63 | 64 | $v=@$this->properties[$name]; |
64 | - if (isset($v) && $v !== "") |
|
65 | - $v=$v . $separator . $value; |
|
66 | - else |
|
67 | - $v=$value; |
|
65 | + if (isset($v) && $v !== "") { |
|
66 | + $v=$v . $separator . $value; |
|
67 | + } else { |
|
68 | + $v=$value; |
|
69 | + } |
|
68 | 70 | |
69 | 71 | return $this->setProperty($name, $v); |
70 | 72 | } |
@@ -119,8 +121,9 @@ discard block |
||
119 | 121 | } |
120 | 122 | |
121 | 123 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
122 | - if ($this->ctrl($name, $value, $typeCtrl) === true) |
|
123 | - return $this->setProperty($name, $value); |
|
124 | + if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
125 | + return $this->setProperty($name, $value); |
|
126 | + } |
|
124 | 127 | return $this; |
125 | 128 | } |
126 | 129 | |
@@ -150,8 +153,9 @@ discard block |
||
150 | 153 | } |
151 | 154 | |
152 | 155 | public function removeProperty($name) { |
153 | - if (\array_key_exists($name, $this->properties)) |
|
154 | - unset($this->properties[$name]); |
|
156 | + if (\array_key_exists($name, $this->properties)) { |
|
157 | + unset($this->properties[$name]); |
|
158 | + } |
|
155 | 159 | return $this; |
156 | 160 | } |
157 | 161 | |
@@ -171,8 +175,9 @@ discard block |
||
171 | 175 | } |
172 | 176 | |
173 | 177 | protected function addToPropertyUnique($name, $value, $typeCtrl) { |
174 | - if (@class_exists($typeCtrl, true)) |
|
175 | - $typeCtrl=$typeCtrl::getConstants(); |
|
178 | + if (@class_exists($typeCtrl, true)) { |
|
179 | + $typeCtrl=$typeCtrl::getConstants(); |
|
180 | + } |
|
176 | 181 | if (is_array($typeCtrl)) { |
177 | 182 | $this->removeOldValues($this->properties[$name], $typeCtrl); |
178 | 183 | } |
@@ -213,8 +218,9 @@ discard block |
||
213 | 218 | |
214 | 219 | public function fromArray($array) { |
215 | 220 | foreach ( $this as $key => $value ) { |
216 | - if(array_key_exists($key, $array)===true) |
|
217 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
221 | + if(array_key_exists($key, $array)===true) { |
|
222 | + $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
223 | + } |
|
218 | 224 | } |
219 | 225 | foreach ( $array as $key => $value ) { |
220 | 226 | if($this->_callSetter($key, $key, $value, $array)===false){ |
@@ -265,15 +271,18 @@ discard block |
||
265 | 271 | $flag=false; |
266 | 272 | $index=0; |
267 | 273 | while ( !$flag && $index < sizeof($elements) ) { |
268 | - if ($elements[$index] instanceof BaseHtml) |
|
269 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
274 | + if ($elements[$index] instanceof BaseHtml) { |
|
275 | + $flag=($elements[$index]->getIdentifier() === $identifier); |
|
276 | + } |
|
270 | 277 | $index++; |
271 | 278 | } |
272 | - if ($flag === true) |
|
273 | - return $elements[$index - 1]; |
|
279 | + if ($flag === true) { |
|
280 | + return $elements[$index - 1]; |
|
281 | + } |
|
274 | 282 | } elseif ($elements instanceof BaseHtml) { |
275 | - if ($elements->getIdentifier() === $identifier) |
|
276 | - return $elements; |
|
283 | + if ($elements->getIdentifier() === $identifier) { |
|
284 | + return $elements; |
|
285 | + } |
|
277 | 286 | } |
278 | 287 | return null; |
279 | 288 | } |
@@ -283,15 +292,18 @@ discard block |
||
283 | 292 | $flag=false; |
284 | 293 | $index=0; |
285 | 294 | while ( !$flag && $index < sizeof($elements) ) { |
286 | - if ($elements[$index] instanceof BaseHtml) |
|
287 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
295 | + if ($elements[$index] instanceof BaseHtml) { |
|
296 | + $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
297 | + } |
|
288 | 298 | $index++; |
289 | 299 | } |
290 | - if ($flag === true) |
|
291 | - return $elements[$index - 1]; |
|
300 | + if ($flag === true) { |
|
301 | + return $elements[$index - 1]; |
|
302 | + } |
|
292 | 303 | } elseif ($elements instanceof BaseHtml) { |
293 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
294 | - return $elements; |
|
304 | + if ($elements->propertyContains($propertyName, $value) === true) { |
|
305 | + return $elements; |
|
306 | + } |
|
295 | 307 | } |
296 | 308 | return null; |
297 | 309 | } |