@@ -48,6 +48,9 @@ discard block |
||
48 | 48 | return $this; |
49 | 49 | } |
50 | 50 | |
51 | + /** |
|
52 | + * @param string $name |
|
53 | + */ |
|
51 | 54 | public function getProperty($name) { |
52 | 55 | if (array_key_exists($name, $this->properties)) |
53 | 56 | return $this->properties [$name]; |
@@ -113,6 +116,10 @@ discard block |
||
113 | 116 | return $this; |
114 | 117 | } |
115 | 118 | |
119 | + /** |
|
120 | + * @param string $name |
|
121 | + * @param string[] $typeCtrl |
|
122 | + */ |
|
116 | 123 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
117 | 124 | if ($this->ctrl($name, $value, $typeCtrl)===true) { |
118 | 125 | return $name=$value; |
@@ -128,6 +135,10 @@ discard block |
||
128 | 135 | return $this; |
129 | 136 | } |
130 | 137 | |
138 | + /** |
|
139 | + * @param string $name |
|
140 | + * @param string[] $typeCtrl |
|
141 | + */ |
|
131 | 142 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
132 | 143 | if ($this->ctrl($name, $value, $typeCtrl)===true) { |
133 | 144 | if (is_array($typeCtrl)) { |
@@ -138,6 +149,9 @@ discard block |
||
138 | 149 | return $this; |
139 | 150 | } |
140 | 151 | |
152 | + /** |
|
153 | + * @param string $name |
|
154 | + */ |
|
141 | 155 | protected function addToMember(&$name, $value, $separator=" ") { |
142 | 156 | $name=str_ireplace($value, "", $name).$separator.$value; |
143 | 157 | return $this; |
@@ -152,6 +166,10 @@ discard block |
||
152 | 166 | return $this->addToProperty($name, $value); |
153 | 167 | } |
154 | 168 | |
169 | + /** |
|
170 | + * @param string $name |
|
171 | + * @param string[] $typeCtrl |
|
172 | + */ |
|
155 | 173 | public function addToPropertyCtrl($name, $value, $typeCtrl) { |
156 | 174 | // if($this->ctrl($name, $value, $typeCtrl)===true){ |
157 | 175 | return $this->addToPropertyUnique($name, $value, $typeCtrl); |
@@ -219,6 +237,9 @@ discard block |
||
219 | 237 | |
220 | 238 | } |
221 | 239 | |
240 | + /** |
|
241 | + * @param string $before |
|
242 | + */ |
|
222 | 243 | public function wrap($before, $after="") { |
223 | 244 | $this->wrapBefore.=$before; |
224 | 245 | $this->wrapAfter=$after.$this->wrapAfter; |
@@ -285,6 +306,9 @@ discard block |
||
285 | 306 | } |
286 | 307 | } |
287 | 308 | |
309 | + /** |
|
310 | + * @param string $operation |
|
311 | + */ |
|
288 | 312 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
289 | 313 | $params=array ( |
290 | 314 | "url" => $url, |
@@ -295,14 +319,23 @@ discard block |
||
295 | 319 | return $this; |
296 | 320 | } |
297 | 321 | |
322 | + /** |
|
323 | + * @param string $event |
|
324 | + */ |
|
298 | 325 | public function getOn($event, $url, $responseElement="", $parameters=array()) { |
299 | 326 | return $this->_ajaxOn("get", $event, $url, $responseElement, $parameters); |
300 | 327 | } |
301 | 328 | |
329 | + /** |
|
330 | + * @param string $url |
|
331 | + */ |
|
302 | 332 | public function getOnClick($url, $responseElement="", $parameters=array()) { |
303 | 333 | return $this->getOn("click", $url, $responseElement, $parameters); |
304 | 334 | } |
305 | 335 | |
336 | + /** |
|
337 | + * @param string $event |
|
338 | + */ |
|
306 | 339 | public function postOn($event, $url, $params="{}", $responseElement="", $parameters=array()) { |
307 | 340 | $parameters ["params"]=$params; |
308 | 341 | return $this->_ajaxOn("post", $event, $url, $responseElement, $parameters); |
@@ -312,6 +345,9 @@ discard block |
||
312 | 345 | return $this->postOn("click", $url, $params, $responseElement, $parameters); |
313 | 346 | } |
314 | 347 | |
348 | + /** |
|
349 | + * @param string $event |
|
350 | + */ |
|
315 | 351 | public function postFormOn($event, $url, $form, $responseElement="", $parameters=array()) { |
316 | 352 | $parameters ["form"]=$form; |
317 | 353 | return $this->_ajaxOn("postForm", $event, $url, $responseElement, $parameters); |
@@ -361,6 +397,9 @@ discard block |
||
361 | 397 | return $value; |
362 | 398 | } |
363 | 399 | |
400 | + /** |
|
401 | + * @param string $jqueryCall |
|
402 | + */ |
|
364 | 403 | public function jsDoJquery($jqueryCall, $param=""){ |
365 | 404 | return "$('#".$this->identifier."').".$jqueryCall."(".$this->_prep_value($param).");"; |
366 | 405 | } |
@@ -49,16 +49,18 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | public function getProperty($name) { |
52 | - if (array_key_exists($name, $this->properties)) |
|
53 | - return $this->properties [$name]; |
|
52 | + if (array_key_exists($name, $this->properties)) { |
|
53 | + return $this->properties [$name]; |
|
54 | + } |
|
54 | 55 | } |
55 | 56 | |
56 | 57 | public function addToProperty($name, $value, $separator=" ") { |
57 | 58 | $v=$this->properties [$name]; |
58 | - if (isset($v)&&$v!=="") |
|
59 | - $v=$v.$separator.$value; |
|
60 | - else |
|
61 | - $v=$value; |
|
59 | + if (isset($v)&&$v!=="") { |
|
60 | + $v=$v.$separator.$value; |
|
61 | + } else { |
|
62 | + $v=$value; |
|
63 | + } |
|
62 | 64 | |
63 | 65 | return $this->setProperty($name, $v); |
64 | 66 | } |
@@ -108,8 +110,9 @@ discard block |
||
108 | 110 | } |
109 | 111 | |
110 | 112 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
111 | - if ($this->ctrl($name, $value, $typeCtrl)===true) |
|
112 | - return $this->setProperty($name, $value); |
|
113 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
114 | + return $this->setProperty($name, $value); |
|
115 | + } |
|
113 | 116 | return $this; |
114 | 117 | } |
115 | 118 | |
@@ -144,8 +147,9 @@ discard block |
||
144 | 147 | } |
145 | 148 | |
146 | 149 | protected function addToPropertyUnique($name, $value, $typeCtrl) { |
147 | - if (@class_exists($typeCtrl, true)) |
|
148 | - $typeCtrl=$typeCtrl::getConstants(); |
|
150 | + if (@class_exists($typeCtrl, true)) { |
|
151 | + $typeCtrl=$typeCtrl::getConstants(); |
|
152 | + } |
|
149 | 153 | if (is_array($typeCtrl)) { |
150 | 154 | $this->removeOldValues($this->properties [$name], $typeCtrl); |
151 | 155 | } |
@@ -326,15 +330,18 @@ discard block |
||
326 | 330 | $flag=false; |
327 | 331 | $index=0; |
328 | 332 | while ( !$flag&&$index<sizeof($elements) ) { |
329 | - if ($elements [$index] instanceof BaseHtml) |
|
330 | - $flag=($elements [$index]->getIdentifier()===$identifier); |
|
333 | + if ($elements [$index] instanceof BaseHtml) { |
|
334 | + $flag=($elements [$index]->getIdentifier()===$identifier); |
|
335 | + } |
|
331 | 336 | $index++; |
332 | 337 | } |
333 | - if ($flag===true) |
|
334 | - return $elements [$index-1]; |
|
338 | + if ($flag===true) { |
|
339 | + return $elements [$index-1]; |
|
340 | + } |
|
335 | 341 | } elseif ($elements instanceof BaseHtml) { |
336 | - if ($elements->getIdentifier()===$identifier) |
|
337 | - return $elements; |
|
342 | + if ($elements->getIdentifier()===$identifier) { |
|
343 | + return $elements; |
|
344 | + } |
|
338 | 345 | } |
339 | 346 | return null; |
340 | 347 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | abstract class BaseHtml extends BaseWidget { |
16 | 16 | protected $_template; |
17 | 17 | protected $tagName; |
18 | - protected $properties=array (); |
|
19 | - protected $events=array (); |
|
18 | + protected $properties=array(); |
|
19 | + protected $events=array(); |
|
20 | 20 | protected $wrapBefore=""; |
21 | 21 | protected $wrapAfter=""; |
22 | 22 | protected $_bsComponent; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | public function addToProperty($name, $value, $separator=" ") { |
57 | 57 | $v=$this->properties [$name]; |
58 | - if (isset($v)&&$v!=="") |
|
58 | + if (isset($v) && $v!=="") |
|
59 | 59 | $v=$v.$separator.$value; |
60 | 60 | else |
61 | 61 | $v=$value; |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | |
71 | 71 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
72 | 72 | $result=$this->getTemplate(); |
73 | - foreach ( $this as $key => $value ) { |
|
74 | - if (PhalconUtils::startsWith($key, "_")===false&&$key!=="events") { |
|
73 | + foreach ($this as $key => $value) { |
|
74 | + if (PhalconUtils::startsWith($key, "_")===false && $key!=="events") { |
|
75 | 75 | if (is_array($value)) { |
76 | 76 | $v=PropertyWrapper::wrap($value, $js); |
77 | - } else { |
|
77 | + }else { |
|
78 | 78 | $v=$value; |
79 | 79 | } |
80 | 80 | $result=str_ireplace("%".$key."%", $v, $result); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | if (isset($view)===true) { |
87 | 87 | $controls=$view->getVar("q"); |
88 | 88 | if (isset($controls)===false) { |
89 | - $controls=array (); |
|
89 | + $controls=array(); |
|
90 | 90 | } |
91 | 91 | $controls [$this->identifier]=$result; |
92 | 92 | $view->setVar("q", $controls); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | if (array_search($value, $typeCtrl)===false) { |
100 | 100 | throw new \Exception("La valeur passée a propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
101 | 101 | } |
102 | - } else { |
|
102 | + }else { |
|
103 | 103 | if (!$typeCtrl($value)) { |
104 | 104 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
105 | 105 | } |
@@ -176,28 +176,28 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | public function fromArray($array) { |
179 | - foreach ( $this as $key => $value ) { |
|
179 | + foreach ($this as $key => $value) { |
|
180 | 180 | if (array_key_exists($key, $array) && !PhalconUtils::startsWith($key, "_")) { |
181 | 181 | $setter="set".ucfirst($key); |
182 | 182 | $this->$setter($array [$key]); |
183 | 183 | unset($array [$key]); |
184 | 184 | } |
185 | 185 | } |
186 | - foreach ( $array as $key => $value ) { |
|
186 | + foreach ($array as $key => $value) { |
|
187 | 187 | if (method_exists($this, $key)) { |
188 | 188 | try { |
189 | 189 | $this->$key($value); |
190 | 190 | unset($array [$key]); |
191 | - } catch ( \Exception $e ) { |
|
191 | + } catch (\Exception $e) { |
|
192 | 192 | // Nothing to do |
193 | 193 | } |
194 | - } else { |
|
194 | + }else { |
|
195 | 195 | $setter="set".ucfirst($key); |
196 | 196 | if (method_exists($this, $setter)) { |
197 | 197 | try { |
198 | 198 | $this->$setter($value); |
199 | 199 | unset($array [$key]); |
200 | - } catch ( \Exception $e ) { |
|
200 | + } catch (\Exception $e) { |
|
201 | 201 | // Nothing to do |
202 | 202 | } |
203 | 203 | } |
@@ -206,21 +206,21 @@ discard block |
||
206 | 206 | return $array; |
207 | 207 | } |
208 | 208 | |
209 | - public function fromDatabaseObjects($objects,$function) { |
|
210 | - if(isset($objects)){ |
|
211 | - foreach ($objects as $object){ |
|
212 | - $this->fromDatabaseObject($object,$function); |
|
209 | + public function fromDatabaseObjects($objects, $function) { |
|
210 | + if (isset($objects)) { |
|
211 | + foreach ($objects as $object) { |
|
212 | + $this->fromDatabaseObject($object, $function); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | return $this; |
216 | 216 | } |
217 | 217 | |
218 | - public function fromDatabaseObject($object,$function){ |
|
218 | + public function fromDatabaseObject($object, $function) { |
|
219 | 219 | |
220 | 220 | } |
221 | 221 | |
222 | 222 | public function wrap($before, $after="") { |
223 | - if(isset($before)){ |
|
223 | + if (isset($before)) { |
|
224 | 224 | $this->wrapBefore.=$before; |
225 | 225 | } |
226 | 226 | $this->wrapAfter=$after.$this->wrapAfter; |
@@ -242,13 +242,13 @@ discard block |
||
242 | 242 | if (array_key_exists($event, $this->events)) { |
243 | 243 | if (is_array($this->events [$event])) { |
244 | 244 | $this->events [$event] []=$jsCode; |
245 | - } else { |
|
246 | - $this->events [$event]=array ( |
|
245 | + }else { |
|
246 | + $this->events [$event]=array( |
|
247 | 247 | $this->events [$event], |
248 | 248 | $jsCode |
249 | 249 | ); |
250 | 250 | } |
251 | - } else { |
|
251 | + }else { |
|
252 | 252 | $this->events [$event]=$jsCode; |
253 | 253 | } |
254 | 254 | } |
@@ -267,14 +267,14 @@ discard block |
||
267 | 267 | |
268 | 268 | public function addEventsOnRun(JsUtils $js) { |
269 | 269 | if (isset($this->_bsComponent)) { |
270 | - foreach ( $this->events as $event => $jsCode ) { |
|
270 | + foreach ($this->events as $event => $jsCode) { |
|
271 | 271 | $code=$jsCode; |
272 | 272 | if (is_array($jsCode)) { |
273 | 273 | $code=""; |
274 | - foreach ( $jsCode as $jsC ) { |
|
274 | + foreach ($jsCode as $jsC) { |
|
275 | 275 | if ($jsC instanceof AjaxCall) { |
276 | 276 | $code.="\n".$jsC->compile($js); |
277 | - } else { |
|
277 | + }else { |
|
278 | 278 | $code.="\n".$jsC; |
279 | 279 | } |
280 | 280 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | } |
289 | 289 | |
290 | 290 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
291 | - $params=array ( |
|
291 | + $params=array( |
|
292 | 292 | "url" => $url, |
293 | 293 | "responseElement" => $responseElement |
294 | 294 | ); |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | if (is_array($elements)) { |
328 | 328 | $flag=false; |
329 | 329 | $index=0; |
330 | - while ( !$flag&&$index<sizeof($elements) ) { |
|
330 | + while (!$flag && $index<sizeof($elements)) { |
|
331 | 331 | if ($elements [$index] instanceof BaseHtml) |
332 | 332 | $flag=($elements [$index]->getIdentifier()===$identifier); |
333 | 333 | $index++; |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | return null; |
342 | 342 | } |
343 | 343 | |
344 | - public function __toString(){ |
|
344 | + public function __toString() { |
|
345 | 345 | return $this->compile(); |
346 | 346 | } |
347 | 347 | |
@@ -357,25 +357,25 @@ discard block |
||
357 | 357 | if (is_array($value)) { |
358 | 358 | $value=implode(",", $value); |
359 | 359 | } |
360 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false) { |
|
360 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false) { |
|
361 | 361 | $value='"'.$value.'"'; |
362 | 362 | } |
363 | 363 | return $value; |
364 | 364 | } |
365 | 365 | |
366 | - public function jsDoJquery($jqueryCall, $param=""){ |
|
366 | + public function jsDoJquery($jqueryCall, $param="") { |
|
367 | 367 | return "$('#".$this->identifier."').".$jqueryCall."(".$this->_prep_value($param).");"; |
368 | 368 | } |
369 | 369 | |
370 | - public function jsHtml($content=""){ |
|
371 | - return $this->jsDoJquery("html",$content); |
|
370 | + public function jsHtml($content="") { |
|
371 | + return $this->jsDoJquery("html", $content); |
|
372 | 372 | } |
373 | 373 | |
374 | - public function jsShow(){ |
|
374 | + public function jsShow() { |
|
375 | 375 | return $this->jsDoJquery("show"); |
376 | 376 | } |
377 | 377 | |
378 | - public function jsHide(){ |
|
378 | + public function jsHide() { |
|
379 | 379 | return $this->jsDoJquery("hide"); |
380 | 380 | } |
381 | 381 | } |
382 | 382 | \ No newline at end of file |
@@ -7,6 +7,9 @@ |
||
7 | 7 | |
8 | 8 | class PropertyWrapper { |
9 | 9 | |
10 | + /** |
|
11 | + * @param \Ajax\JsUtils $js |
|
12 | + */ |
|
10 | 13 | public static function wrap($input, $js=NULL, $separator=' ', $valueQuote='"') { |
11 | 14 | $output=""; |
12 | 15 | if (is_string($input)) { |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace Ajax\bootstrap\html\base; |
4 | 4 | |
5 | 5 | use Ajax\service\JArray; |
6 | -use Ajax\service\AjaxCall; |
|
7 | 6 | |
8 | 7 | class PropertyWrapper { |
9 | 8 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | $value1=reset($input); |
18 | 18 | if (is_object($value1)) { |
19 | 19 | $output=PropertyWrapper::wrapObjects($input, $js, $separator=' '); |
20 | - } else |
|
20 | + }else |
|
21 | 21 | $output=PropertyWrapper::wrapStrings($input, $separator=' ', $valueQuote='"'); |
22 | 22 | } |
23 | 23 | } |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | |
27 | 27 | public static function wrapStrings($input, $separator=' ', $valueQuote='"') { |
28 | 28 | if (JArray::isAssociative($input)===true) { |
29 | - $result=implode($separator, array_map(function ($v, $k) use($valueQuote) { |
|
29 | + $result=implode($separator, array_map(function($v, $k) use($valueQuote) { |
|
30 | 30 | return $k.'='.$valueQuote.$v.$valueQuote; |
31 | 31 | }, $input, array_keys($input))); |
32 | - } else { |
|
32 | + }else { |
|
33 | 33 | $result=implode($separator, array_values($input)); |
34 | 34 | } |
35 | 35 | return $result; |
36 | 36 | } |
37 | 37 | |
38 | 38 | public static function wrapObjects($input, $js=NULL, $separator=' ') { |
39 | - return implode($separator, array_map(function ($v) use($js) { |
|
39 | + return implode($separator, array_map(function($v) use($js) { |
|
40 | 40 | return $v->compile($js); |
41 | 41 | }, $input)); |
42 | 42 | } |
@@ -17,8 +17,9 @@ |
||
17 | 17 | $value1=reset($input); |
18 | 18 | if (is_object($value1)) { |
19 | 19 | $output=PropertyWrapper::wrapObjects($input, $js, $separator=' '); |
20 | - } else |
|
21 | - $output=PropertyWrapper::wrapStrings($input, $separator=' ', $valueQuote='"'); |
|
20 | + } else { |
|
21 | + $output=PropertyWrapper::wrapStrings($input, $separator=' ', $valueQuote='"'); |
|
22 | + } |
|
22 | 23 | } |
23 | 24 | } |
24 | 25 | return $output; |
@@ -18,6 +18,9 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class HtmlListgroupItem extends HtmlElementAsContent { |
20 | 20 | |
21 | + /** |
|
22 | + * @param HtmlDoubleElement $element |
|
23 | + */ |
|
21 | 24 | public function __construct($element) { |
22 | 25 | parent::__construct($element); |
23 | 26 | $this->element->setProperty("class", "list-group-item"); |
@@ -37,7 +40,7 @@ discard block |
||
37 | 40 | * define the Panel style |
38 | 41 | * avaible values : "list-group-item-default","list-group-item-primary","list-group-item-success","list-group-item-info","list-group-item-warning","list-group-item-danger" |
39 | 42 | * @param string|int $cssStyle |
40 | - * @return \Ajax\bootstrap\html\HtmlListgroupItem default : "list-group-item-default" |
|
43 | + * @return \Ajax\bootstrap\html\base\HtmlSingleElement default : "list-group-item-default" |
|
41 | 44 | */ |
42 | 45 | public function setStyle($cssStyle) { |
43 | 46 | if (!PhalconUtils::startsWith($cssStyle, "list-group-item")) |
@@ -71,7 +71,7 @@ |
||
71 | 71 | $element=new HtmlDoubleElement("", "p"); |
72 | 72 | $element->setContent($content); |
73 | 73 | $element->setClass("list-group-item-text"); |
74 | - $this->element->setContent(array ( |
|
74 | + $this->element->setContent(array( |
|
75 | 75 | $elementHeader, |
76 | 76 | $element |
77 | 77 | )); |
@@ -40,8 +40,9 @@ |
||
40 | 40 | * @return \Ajax\bootstrap\html\HtmlListgroupItem default : "list-group-item-default" |
41 | 41 | */ |
42 | 42 | public function setStyle($cssStyle) { |
43 | - if (!PhalconUtils::startsWith($cssStyle, "list-group-item")) |
|
44 | - $cssStyle="list-group-item".$cssStyle; |
|
43 | + if (!PhalconUtils::startsWith($cssStyle, "list-group-item")) { |
|
44 | + $cssStyle="list-group-item".$cssStyle; |
|
45 | + } |
|
45 | 46 | $this->element->addToPropertyCtrl("class", $cssStyle, CssRef::Styles("list-group-item")); |
46 | 47 | return $this->element; |
47 | 48 | } |
@@ -175,7 +175,6 @@ discard block |
||
175 | 175 | * Associate an ajax get to the breadcrumbs elements, displayed in $targetSelector |
176 | 176 | * $attr member is used to build each element url |
177 | 177 | * @param string $targetSelector the target of the get |
178 | - * @param string $attr the html attribute used to build the elements url |
|
179 | 178 | * @return HtmlBreadcrumbs |
180 | 179 | */ |
181 | 180 | public function autoGetOnClick($targetSelector){ |
@@ -197,6 +196,9 @@ discard block |
||
197 | 196 | $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
198 | 197 | } |
199 | 198 | |
199 | + /** |
|
200 | + * @param integer $index |
|
201 | + */ |
|
200 | 202 | public function getElement($index){ |
201 | 203 | return $this->content[$index]; |
202 | 204 | } |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | if(is_array($element)){ |
68 | 68 | $elm=new HtmlLink("lnk-".$this->identifier."-".$size); |
69 | 69 | $elm->fromArray($element); |
70 | - }else if($element instanceof HtmlLink){ |
|
70 | + } else if($element instanceof HtmlLink){ |
|
71 | 71 | $elm=$element; |
72 | - }else{ |
|
72 | + } else{ |
|
73 | 73 | $elm=new HtmlLink("lnk-".$this->identifier."-".$size,$href,$element); |
74 | 74 | if(isset($glyph)){ |
75 | 75 | $elm->wrapContentWithGlyph($glyph); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | if($this->absolutePaths===true){ |
118 | 118 | return $this->_hrefFunction($this->content[$index]); |
119 | - }else{ |
|
119 | + } else{ |
|
120 | 120 | return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),0,$index+1)); |
121 | 121 | } |
122 | 122 | } |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | * @param boolean $autoActive sets the last element's class to <b>active</b> if true |
36 | 36 | * @param function $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()} |
37 | 37 | */ |
38 | - public function __construct($identifier,$elements=array(),$autoActive=true,$hrefFunction=NULL){ |
|
39 | - parent::__construct($identifier,"ol"); |
|
38 | + public function __construct($identifier, $elements=array(), $autoActive=true, $hrefFunction=NULL) { |
|
39 | + parent::__construct($identifier, "ol"); |
|
40 | 40 | $this->setProperty("class", "breadcrumb"); |
41 | 41 | $this->content=array(); |
42 | 42 | $this->autoActive=$autoActive; |
43 | 43 | $this->absolutePaths; |
44 | - $this->_hrefFunction=function ($e){return $e->getContent();}; |
|
45 | - if(isset($hrefFunction)){ |
|
44 | + $this->_hrefFunction=function($e) {return $e->getContent(); }; |
|
45 | + if (isset($hrefFunction)) { |
|
46 | 46 | $this->_hrefFunction=$hrefFunction; |
47 | 47 | } |
48 | 48 | $this->addElements($elements); |
@@ -53,43 +53,43 @@ discard block |
||
53 | 53 | * @param string $href |
54 | 54 | * @return \Ajax\bootstrap\html\HtmlLink |
55 | 55 | */ |
56 | - public function addElement($element,$href="",$glyph=NULL){ |
|
56 | + public function addElement($element, $href="", $glyph=NULL) { |
|
57 | 57 | $size=sizeof($this->content); |
58 | - if(is_array($element)){ |
|
58 | + if (is_array($element)) { |
|
59 | 59 | $elm=new HtmlLink("lnk-".$this->identifier."-".$size); |
60 | 60 | $elm->fromArray($element); |
61 | - }else if($element instanceof HtmlLink){ |
|
61 | + }else if ($element instanceof HtmlLink) { |
|
62 | 62 | $elm=$element; |
63 | - }else{ |
|
64 | - $elm=new HtmlLink("lnk-".$this->identifier."-".$size,$href,$element); |
|
65 | - if(isset($glyph)){ |
|
63 | + }else { |
|
64 | + $elm=new HtmlLink("lnk-".$this->identifier."-".$size, $href, $element); |
|
65 | + if (isset($glyph)) { |
|
66 | 66 | $elm->wrapContentWithGlyph($glyph); |
67 | 67 | } |
68 | 68 | } |
69 | - $elm->wrap("<li>","</li>"); |
|
69 | + $elm->wrap("<li>", "</li>"); |
|
70 | 70 | $this->content[]=$elm; |
71 | 71 | $elm->setProperty($this->attr, $this->getHref($size)); |
72 | 72 | return $elm; |
73 | 73 | } |
74 | 74 | |
75 | - public function setActive($index=null){ |
|
76 | - if(!isset($index)){ |
|
75 | + public function setActive($index=null) { |
|
76 | + if (!isset($index)) { |
|
77 | 77 | $index=sizeof($this->content)-1; |
78 | 78 | } |
79 | - $li=new HtmlDoubleElement("","li"); |
|
79 | + $li=new HtmlDoubleElement("", "li"); |
|
80 | 80 | $li->setClass("active"); |
81 | 81 | $li->setContent($this->content[$index]->getContent()); |
82 | 82 | $this->content[$index]=$li; |
83 | 83 | } |
84 | 84 | |
85 | - public function addElements($elements){ |
|
86 | - foreach ( $elements as $element ) { |
|
85 | + public function addElements($elements) { |
|
86 | + foreach ($elements as $element) { |
|
87 | 87 | $this->addElement($element); |
88 | 88 | } |
89 | 89 | return $this; |
90 | 90 | } |
91 | 91 | |
92 | - public function fromArray($array){ |
|
92 | + public function fromArray($array) { |
|
93 | 93 | $array=parent::fromArray($array); |
94 | 94 | $this->addElements($array); |
95 | 95 | return $array; |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | * @param string $separator |
102 | 102 | * @return string |
103 | 103 | */ |
104 | - public function getHref($index=null,$separator="/"){ |
|
105 | - if(!isset($index)){ |
|
104 | + public function getHref($index=null, $separator="/") { |
|
105 | + if (!isset($index)) { |
|
106 | 106 | $index=sizeof($this->content); |
107 | 107 | } |
108 | - if($this->absolutePaths===true){ |
|
108 | + if ($this->absolutePaths===true) { |
|
109 | 109 | return $this->_hrefFunction($this->content[$index]); |
110 | - }else{ |
|
111 | - return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),0,$index+1)); |
|
110 | + }else { |
|
111 | + return $this->root.implode($separator, array_slice(array_map(function($e) {return $this->_hrefFunction($e); }, $this->content), 0, $index+1)); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @see \Ajax\bootstrap\html\BaseHtml::compile() |
118 | 118 | */ |
119 | 119 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
120 | - if($this->autoActive){ |
|
120 | + if ($this->autoActive) { |
|
121 | 121 | $this->setActive(); |
122 | 122 | } |
123 | 123 | return parent::compile($js, $view); |
@@ -135,19 +135,19 @@ discard block |
||
135 | 135 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
136 | 136 | */ |
137 | 137 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
138 | - foreach ($this->content as $element){ |
|
139 | - $element->on($event,$jsCode,$stopPropagation,$preventDefault); |
|
138 | + foreach ($this->content as $element) { |
|
139 | + $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
|
140 | 140 | } |
141 | 141 | return $this; |
142 | 142 | } |
143 | 143 | |
144 | 144 | public function setAutoActive($autoActive) { |
145 | - $this->autoActive = $autoActive; |
|
145 | + $this->autoActive=$autoActive; |
|
146 | 146 | return $this; |
147 | 147 | } |
148 | 148 | |
149 | 149 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
150 | - foreach ($this->content as $element){ |
|
150 | + foreach ($this->content as $element) { |
|
151 | 151 | $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
152 | 152 | } |
153 | 153 | return $this; |
@@ -160,18 +160,18 @@ discard block |
||
160 | 160 | * @param string $attr the html attribute used to build the elements url |
161 | 161 | * @return HtmlBreadcrumbs |
162 | 162 | */ |
163 | - public function autoGetOnClick($targetSelector){ |
|
164 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
163 | + public function autoGetOnClick($targetSelector) { |
|
164 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
165 | 165 | } |
166 | 166 | |
167 | - public function contentAsString(){ |
|
168 | - if($this->autoActive){ |
|
167 | + public function contentAsString() { |
|
168 | + if ($this->autoActive) { |
|
169 | 169 | $this->setActive(); |
170 | 170 | } |
171 | 171 | return parent::contentAsString(); |
172 | 172 | } |
173 | 173 | |
174 | - public function getElement($index){ |
|
174 | + public function getElement($index) { |
|
175 | 175 | return $this->content[$index]; |
176 | 176 | } |
177 | 177 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param mixed $glyph |
181 | 181 | * @param int $index |
182 | 182 | */ |
183 | - public function addGlyph($glyph,$index){ |
|
183 | + public function addGlyph($glyph, $index) { |
|
184 | 184 | $elm=$this->getElement($index); |
185 | 185 | return $elm->wrapContentWithGlyph($glyph); |
186 | 186 | } |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | * @param Dispatcher $dispatcher the request dispatcher |
191 | 191 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
192 | 192 | */ |
193 | - public function fromDispatcher($dispatcher){ |
|
194 | - $items=array($dispatcher->getControllerName(),$dispatcher->getActionName()); |
|
195 | - $items=array_merge($items,$dispatcher->getParams()); |
|
193 | + public function fromDispatcher($dispatcher) { |
|
194 | + $items=array($dispatcher->getControllerName(), $dispatcher->getActionName()); |
|
195 | + $items=array_merge($items, $dispatcher->getParams()); |
|
196 | 196 | return $this->addElements($items); |
197 | 197 | } |
198 | 198 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
204 | 204 | */ |
205 | 205 | public function setHrefFunction($_hrefFunction) { |
206 | - $this->_hrefFunction = $_hrefFunction; |
|
206 | + $this->_hrefFunction=$_hrefFunction; |
|
207 | 207 | return $this; |
208 | 208 | } |
209 | 209 |
@@ -48,6 +48,9 @@ |
||
48 | 48 | $element->setStyle($value); |
49 | 49 | } |
50 | 50 | |
51 | + /** |
|
52 | + * @param HtmlDropdown $bt |
|
53 | + */ |
|
51 | 54 | private function dropdownAsButton($bt) { |
52 | 55 | $this->addExistingDropDown($bt); |
53 | 56 | $bt->setTagName("button"); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return HtmlButtongroups default : "" |
35 | 35 | */ |
36 | 36 | public function setSize($size) { |
37 | - foreach ( $this->elements as $element ) { |
|
37 | + foreach ($this->elements as $element) { |
|
38 | 38 | $element->setSize($size); |
39 | 39 | } |
40 | 40 | if (is_int($size)) { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | public function setStyle($value) { |
47 | - foreach ( $this->elements as $element ) |
|
47 | + foreach ($this->elements as $element) |
|
48 | 48 | $element->setStyle($value); |
49 | 49 | } |
50 | 50 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public function addElement($element) { |
65 | 65 | $result=$element; |
66 | 66 | $iid=sizeof($this->elements)+1; |
67 | - if (($element instanceof HtmlDropdown)||($element instanceof HtmlSplitbutton)) { |
|
67 | + if (($element instanceof HtmlDropdown) || ($element instanceof HtmlSplitbutton)) { |
|
68 | 68 | $this->addExistingDropDown($element); |
69 | 69 | $this->elements[]=$element; |
70 | 70 | } elseif ($element instanceof HtmlButton) { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | else |
79 | 79 | $bt=new HtmlDropdown($this->identifier."-dropdown-".$iid); |
80 | 80 | $this->dropdownAsButton($bt); |
81 | - } else |
|
81 | + }else |
|
82 | 82 | $bt=new HtmlButton($this->identifier."-button-".$iid); |
83 | 83 | $bt->fromArray($element); |
84 | 84 | $this->elements[]=$bt; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | public function addElements($elements) { |
96 | - foreach ( $elements as $element ) { |
|
96 | + foreach ($elements as $element) { |
|
97 | 97 | $this->addElement($element); |
98 | 98 | } |
99 | 99 | return $this; |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | public function setAlignment($value) { |
111 | 111 | if (is_int($value)) { |
112 | 112 | $value=CssRef::alignment("btn-group")[$value]; |
113 | - } else |
|
113 | + }else |
|
114 | 114 | $value="btn-group-".$value; |
115 | 115 | if (strstr($value, "justified")) { |
116 | - foreach ( $this->elements as $element ) { |
|
116 | + foreach ($this->elements as $element) { |
|
117 | 117 | $element->wrap('<div class="btn-group" role="group">', '</div>'); |
118 | 118 | } |
119 | 119 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
145 | 145 | */ |
146 | 146 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
147 | - foreach ( $this->elements as $element ) { |
|
147 | + foreach ($this->elements as $element) { |
|
148 | 148 | $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
149 | 149 | } |
150 | 150 | return $this; |
@@ -44,8 +44,9 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | public function setStyle($value) { |
47 | - foreach ( $this->elements as $element ) |
|
48 | - $element->setStyle($value); |
|
47 | + foreach ( $this->elements as $element ) { |
|
48 | + $element->setStyle($value); |
|
49 | + } |
|
49 | 50 | } |
50 | 51 | |
51 | 52 | private function dropdownAsButton($bt) { |
@@ -70,16 +71,18 @@ discard block |
||
70 | 71 | } elseif ($element instanceof HtmlButton) { |
71 | 72 | $this->elements[]=$element; |
72 | 73 | } elseif (is_array($element)) { |
73 | - if (array_key_exists("glyph", $element)) |
|
74 | - $bt=new HtmlGlyphButton($this->identifier."-button-".$iid); |
|
75 | - elseif (array_key_exists("btnCaption", $element)) { |
|
76 | - if (array_key_exists("split", $element)) |
|
77 | - $bt=new HtmlSplitbutton($this->identifier."-dropdown-".$iid); |
|
78 | - else |
|
79 | - $bt=new HtmlDropdown($this->identifier."-dropdown-".$iid); |
|
74 | + if (array_key_exists("glyph", $element)) { |
|
75 | + $bt=new HtmlGlyphButton($this->identifier."-button-".$iid); |
|
76 | + } elseif (array_key_exists("btnCaption", $element)) { |
|
77 | + if (array_key_exists("split", $element)) { |
|
78 | + $bt=new HtmlSplitbutton($this->identifier."-dropdown-".$iid); |
|
79 | + } else { |
|
80 | + $bt=new HtmlDropdown($this->identifier."-dropdown-".$iid); |
|
81 | + } |
|
80 | 82 | $this->dropdownAsButton($bt); |
81 | - } else |
|
82 | - $bt=new HtmlButton($this->identifier."-button-".$iid); |
|
83 | + } else { |
|
84 | + $bt=new HtmlButton($this->identifier."-button-".$iid); |
|
85 | + } |
|
83 | 86 | $bt->fromArray($element); |
84 | 87 | $this->elements[]=$bt; |
85 | 88 | $result=$bt; |
@@ -110,8 +113,9 @@ discard block |
||
110 | 113 | public function setAlignment($value) { |
111 | 114 | if (is_int($value)) { |
112 | 115 | $value=CssRef::alignment("btn-group")[$value]; |
113 | - } else |
|
114 | - $value="btn-group-".$value; |
|
116 | + } else { |
|
117 | + $value="btn-group-".$value; |
|
118 | + } |
|
115 | 119 | if (strstr($value, "justified")) { |
116 | 120 | foreach ( $this->elements as $element ) { |
117 | 121 | $element->wrap('<div class="btn-group" role="group">', '</div>'); |
@@ -126,9 +130,9 @@ discard block |
||
126 | 130 | * @return HtmlButton |
127 | 131 | */ |
128 | 132 | public function getElement($index) { |
129 | - if (is_int($index)) |
|
130 | - return $this->elements[$index]; |
|
131 | - else { |
|
133 | + if (is_int($index)) { |
|
134 | + return $this->elements[$index]; |
|
135 | + } else { |
|
132 | 136 | $elm=$this->getElementById($index, $this->elements); |
133 | 137 | return $elm; |
134 | 138 | } |
@@ -11,6 +11,11 @@ discard block |
||
11 | 11 | |
12 | 12 | class HtmlButtontoolbar extends HtmlButtongroups { |
13 | 13 | |
14 | + /** |
|
15 | + * @param string $identifier |
|
16 | + * @param string $cssStyle |
|
17 | + * @param string $size |
|
18 | + */ |
|
14 | 19 | public function __construct($identifier, $elements=array(), $cssStyle=NULL, $size=NULL, $tagName="div") { |
15 | 20 | parent::__construct($identifier, $elements, $cssStyle, $size, $tagName); |
16 | 21 | $this->setClass("btn-toolbar"); |
@@ -56,7 +61,7 @@ discard block |
||
56 | 61 | |
57 | 62 | /** |
58 | 63 | * return the Buttongroups at position $index |
59 | - * @return \Ajax\bootstrap\html\HtmlButtongroups |
|
64 | + * @return HtmlButton |
|
60 | 65 | */ |
61 | 66 | public function getGroup($index) { |
62 | 67 | return parent::getElement($index); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | public function addElement($element) { |
24 | 24 | if ($element instanceof HtmlButtongroups) { |
25 | 25 | $this->elements []=$element; |
26 | - } else { |
|
26 | + }else { |
|
27 | 27 | $this->getLastButtonGroup()->addElement($element); |
28 | 28 | } |
29 | 29 | } |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | $element=null; |
79 | 79 | $i=0; |
80 | 80 | if (is_int($index)) { |
81 | - $elements=array (); |
|
82 | - foreach ( $this->elements as $group ) { |
|
81 | + $elements=array(); |
|
82 | + foreach ($this->elements as $group) { |
|
83 | 83 | $elements=array_merge($elements, $group->getElements()); |
84 | 84 | } |
85 | 85 | if ($index<sizeof($elements)) { |
86 | 86 | $element=$elements [$index]; |
87 | 87 | } |
88 | - } else { |
|
89 | - while ( $element==null&&$i<sizeof($this->elements) ) { |
|
88 | + }else { |
|
89 | + while ($element==null && $i<sizeof($this->elements)) { |
|
90 | 90 | $element=$this->elements [$i]->getElement($index); |
91 | 91 | $i++; |
92 | 92 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | */ |
46 | 46 | private function getLastButtonGroup() { |
47 | 47 | $nb=sizeof($this->elements); |
48 | - if ($nb>0) |
|
49 | - $bg=$this->elements [$nb-1]; |
|
50 | - else { |
|
48 | + if ($nb>0) { |
|
49 | + $bg=$this->elements [$nb-1]; |
|
50 | + } else { |
|
51 | 51 | $bg=new HtmlButtongroups($this->identifier."-buttongroups-".$nb); |
52 | 52 | $this->elements []=$bg; |
53 | 53 | } |
@@ -65,8 +65,9 @@ discard block |
||
65 | 65 | public function getLastGroup() { |
66 | 66 | $bg=null; |
67 | 67 | $nb=sizeof($this->elements); |
68 | - if ($nb>0) |
|
69 | - $bg=$this->elements [$nb-1]; |
|
68 | + if ($nb>0) { |
|
69 | + $bg=$this->elements [$nb-1]; |
|
70 | + } |
|
70 | 71 | return $bg; |
71 | 72 | } |
72 | 73 |
@@ -23,6 +23,9 @@ discard block |
||
23 | 23 | protected $_base=""; |
24 | 24 | protected $_glyphs=array (); |
25 | 25 | |
26 | + /** |
|
27 | + * @param string $identifier |
|
28 | + */ |
|
26 | 29 | public function __construct($identifier, $images=NULL) { |
27 | 30 | parent::__construct($identifier); |
28 | 31 | $this->_template=include 'templates/tplCarousel.php'; |
@@ -61,7 +64,7 @@ discard block |
||
61 | 64 | * |
62 | 65 | * @param string $caption |
63 | 66 | * @param string $sens |
64 | - * @return HtmlCarouselControl|string |
|
67 | + * @return HtmlCarouselControl |
|
65 | 68 | */ |
66 | 69 | private function createControl($caption="next", $sens="left") { |
67 | 70 | $control=new HtmlCarouselControl($sens."-ctrl-".$this->identifier); |
@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | * @version 1.001 |
17 | 17 | */ |
18 | 18 | class HtmlCarousel extends BaseHtml { |
19 | - protected $indicators=array (); |
|
20 | - protected $slides=array (); |
|
19 | + protected $indicators=array(); |
|
20 | + protected $slides=array(); |
|
21 | 21 | protected $leftControl=""; |
22 | 22 | protected $rightControl=""; |
23 | 23 | protected $_base=""; |
24 | - protected $_glyphs=array (); |
|
24 | + protected $_glyphs=array(); |
|
25 | 25 | |
26 | 26 | public function __construct($identifier, $images=NULL) { |
27 | 27 | parent::__construct($identifier); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | public function setBase($_base) { |
41 | - foreach ($this->slides as $slide){ |
|
41 | + foreach ($this->slides as $slide) { |
|
42 | 42 | $imgSrc=$slide->getImageSrc(); |
43 | 43 | $slide->setImageSrc(str_replace($this->_base.$imgSrc, $_base.$imgSrc, $imgSrc)); |
44 | 44 | } |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | public function addImage($imageSrc, $imageAlt="", $caption=NULL, $description=NULL) { |
96 | - if(is_array($imageSrc)){ |
|
97 | - $this->addImage($imageSrc[0],@$imageSrc[1],@$imageSrc[2],@$imageSrc[3]); |
|
98 | - }else{ |
|
96 | + if (is_array($imageSrc)) { |
|
97 | + $this->addImage($imageSrc[0], @$imageSrc[1], @$imageSrc[2], @$imageSrc[3]); |
|
98 | + }else { |
|
99 | 99 | $image=new HtmlCarouselItem("item-".$this->identifier); |
100 | 100 | $image->setImageSrc($this->_base.$imageSrc); |
101 | 101 | $image->setImageAlt($imageAlt); |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function fromArray($array) { |
120 | 120 | if (is_array($array) && sizeof($array)>0) { |
121 | - foreach ( $array as $value ) { |
|
121 | + foreach ($array as $value) { |
|
122 | 122 | if (is_array($value)) { |
123 | 123 | $this->addImage($value ["src"], @$value ["alt"], @$value ["caption"], @$value ["description"]); |
124 | - } else { |
|
124 | + }else { |
|
125 | 125 | $this->addImage($value); |
126 | 126 | } |
127 | 127 | } |
@@ -75,27 +75,30 @@ |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | private function getGlyph($sens="left") { |
78 | - if (array_key_exists($sens, $this->_glyphs)) |
|
79 | - return $this->_glyphs [$sens]; |
|
78 | + if (array_key_exists($sens, $this->_glyphs)) { |
|
79 | + return $this->_glyphs [$sens]; |
|
80 | + } |
|
80 | 81 | return "glyphicon-chevron-".$sens; |
81 | 82 | } |
82 | 83 | |
83 | 84 | public function setRightGlyph($glyphicon) { |
84 | 85 | $glyphs=CssRef::glyphIcons(); |
85 | - if (array_search($glyphicon, $glyphs)!==false) |
|
86 | - $this->_glyphs ["right"]=$glyphicon; |
|
86 | + if (array_search($glyphicon, $glyphs)!==false) { |
|
87 | + $this->_glyphs ["right"]=$glyphicon; |
|
88 | + } |
|
87 | 89 | } |
88 | 90 | |
89 | 91 | public function setLeftGlyph($glyphicon) { |
90 | 92 | $glyphs=CssRef::glyphIcons(); |
91 | - if (array_search($glyphicon, $glyphs)!==false) |
|
92 | - $this->_glyphs ["left"]=$glyphicon; |
|
93 | + if (array_search($glyphicon, $glyphs)!==false) { |
|
94 | + $this->_glyphs ["left"]=$glyphicon; |
|
95 | + } |
|
93 | 96 | } |
94 | 97 | |
95 | 98 | public function addImage($imageSrc, $imageAlt="", $caption=NULL, $description=NULL) { |
96 | 99 | if(is_array($imageSrc)){ |
97 | 100 | $this->addImage($imageSrc[0],@$imageSrc[1],@$imageSrc[2],@$imageSrc[3]); |
98 | - }else{ |
|
101 | + } else{ |
|
99 | 102 | $image=new HtmlCarouselItem("item-".$this->identifier); |
100 | 103 | $image->setImageSrc($this->_base.$imageSrc); |
101 | 104 | $image->setImageAlt($imageAlt); |
@@ -87,6 +87,9 @@ |
||
87 | 87 | return $result; |
88 | 88 | } |
89 | 89 | |
90 | + /** |
|
91 | + * @return string |
|
92 | + */ |
|
90 | 93 | private function getPrefix($element) { |
91 | 94 | $result="input_text"; |
92 | 95 | foreach ( $this->formElementsPrefix as $k => $v ) { |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | public function __construct($identifier) { |
16 | 16 | parent::__construct($identifier, "form"); |
17 | 17 | $this->_template='<form id="%identifier%" name="%identifier%" %properties%>%content%</form>'; |
18 | - $this->futureElements=array (); |
|
19 | - $this->formGroups=array (); |
|
18 | + $this->futureElements=array(); |
|
19 | + $this->formGroups=array(); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /* |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
27 | 27 | if (isset($js)) { |
28 | 28 | $this->formElementsPrefix=$js->config()->getVar("formElementsPrefix"); |
29 | - foreach ( $this->futureElements as $futureElement ) { |
|
29 | + foreach ($this->futureElements as $futureElement) { |
|
30 | 30 | $futureElementValue=$this->getPrefix($futureElement); |
31 | 31 | $futureElementValues=explode("_", $futureElementValue); |
32 | - switch($futureElementValues [0]) { |
|
32 | + switch ($futureElementValues [0]) { |
|
33 | 33 | case "input": |
34 | 34 | $control=new HtmlInput($futureElement); |
35 | 35 | $control->setClass("form-control"); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $this->addElement($control); |
62 | 62 | } |
63 | 63 | } |
64 | - foreach ( $this->formGroups as $group ) { |
|
64 | + foreach ($this->formGroups as $group) { |
|
65 | 65 | $this->addContent($group); |
66 | 66 | } |
67 | 67 | return parent::compile($js, $view); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $result=preg_split('/(?=[A-Z])/', $str); |
72 | 72 | if (sizeof($result)>$part) { |
73 | 73 | $result=$result [$part]; |
74 | - } else { |
|
74 | + }else { |
|
75 | 75 | $result=$str; |
76 | 76 | } |
77 | 77 | return $result; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $result=preg_split('/(?=[A-Z])/', $str); |
82 | 82 | if (sizeof($result)>2) { |
83 | 83 | $result=$result [2]; |
84 | - } else { |
|
84 | + }else { |
|
85 | 85 | $result=$str; |
86 | 86 | } |
87 | 87 | return $result; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | private function getPrefix($element) { |
91 | 91 | $result="input_text"; |
92 | - foreach ( $this->formElementsPrefix as $k => $v ) { |
|
92 | + foreach ($this->formElementsPrefix as $k => $v) { |
|
93 | 93 | if (Text::startsWith($element, $k)) { |
94 | 94 | $result=$v; |
95 | 95 | break; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | public function getElement($name) { |
121 | 121 | $element=null; |
122 | - foreach ( $this->formGroups as $group ) { |
|
122 | + foreach ($this->formGroups as $group) { |
|
123 | 123 | } |
124 | 124 | return $element; |
125 | 125 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @see \Ajax\bootstrap\html\base\HtmlSingleElement::fromArray() |
130 | 130 | */ |
131 | 131 | public function fromArray($array) { |
132 | - foreach ( $array as $value ) { |
|
132 | + foreach ($array as $value) { |
|
133 | 133 | if (is_string($value)) { |
134 | 134 | $this->futureElements []=$value; |
135 | 135 | } |
@@ -99,8 +99,9 @@ |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | public function addGroup($identifier="") { |
102 | - if ($identifier==="") |
|
103 | - $identifier="form-".$this->identifier; |
|
102 | + if ($identifier==="") { |
|
103 | + $identifier="form-".$this->identifier; |
|
104 | + } |
|
104 | 105 | $group=new HtmlDoubleElement($identifier); |
105 | 106 | $group->setTagName("div"); |
106 | 107 | $group->setClass("form-group"); |
@@ -208,7 +208,7 @@ |
||
208 | 208 | * Includes a modal-backdrop element. |
209 | 209 | * Alternatively, specify static for a backdrop which doesn't close the modal on click. |
210 | 210 | * @param Boolean $value default : true |
211 | - * @return HtmlModal |
|
211 | + * @return boolean |
|
212 | 212 | */ |
213 | 213 | public function setBackdrop($value) { |
214 | 214 | return $this->backdrop=$value; |
@@ -5,7 +5,6 @@ |
||
5 | 5 | use Phalcon\Mvc\View; |
6 | 6 | use Ajax\JsUtils; |
7 | 7 | use Ajax\bootstrap\html\base\BaseHtml; |
8 | -use Phalcon\Mvc\Dispatcher; |
|
9 | 8 | use Phalcon\Mvc\Controller; |
10 | 9 | |
11 | 10 | /** |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | class HtmlModal extends BaseHtml { |
17 | 17 | protected $title="Titre de ma boîte"; |
18 | 18 | protected $content=""; |
19 | - protected $buttons=array (); |
|
19 | + protected $buttons=array(); |
|
20 | 20 | protected $showOnStartup=false; |
21 | 21 | protected $draggable=false; |
22 | 22 | protected $validCondition=NULL; |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | public function __construct($identifier, $title="", $content="", $buttonCaptions=array()) { |
30 | 30 | parent::__construct($identifier); |
31 | 31 | $this->_template=include 'templates/tplModal.php'; |
32 | - $this->buttons=array (); |
|
32 | + $this->buttons=array(); |
|
33 | 33 | $this->title=$title; |
34 | 34 | $this->content=$content; |
35 | - foreach ( $buttonCaptions as $button ) { |
|
35 | + foreach ($buttonCaptions as $button) { |
|
36 | 36 | $this->addButton($button); |
37 | 37 | } |
38 | 38 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param string $value |
68 | 68 | * @return HtmlButton |
69 | 69 | */ |
70 | - public function addOkayButton($value="Okay",$jsCode="") { |
|
70 | + public function addOkayButton($value="Okay", $jsCode="") { |
|
71 | 71 | $btn=$this->addButton($value, "btn-primary"); |
72 | 72 | $btn->onClick("if(".$this->getValidCondition()."){ ".$jsCode."$('#".$this->identifier."').modal('hide');}"); |
73 | 73 | return $btn; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | public function getValidCondition() { |
85 | 85 | if ($this->validCondition==NULL) { |
86 | 86 | return $this->getDefaultValidCondition(); |
87 | - } else { |
|
87 | + }else { |
|
88 | 88 | return $this->validCondition; |
89 | 89 | } |
90 | 90 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param $params The parameters to pass to the view |
118 | 118 | */ |
119 | 119 | public function renderContent($view, $controller, $action, $params=NULL) { |
120 | - $template=$view->getRender($controller, $action, $params, function ($view) { |
|
120 | + $template=$view->getRender($controller, $action, $params, function($view) { |
|
121 | 121 | $view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
122 | 122 | }); |
123 | 123 | $this->content=$template; |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | * @param string $controller a Phalcon controller |
130 | 130 | * @param string $action a Phalcon action |
131 | 131 | */ |
132 | - public function forward($initialController,$controller,$action){ |
|
133 | - $dispatcher = $initialController->dispatcher; |
|
132 | + public function forward($initialController, $controller, $action) { |
|
133 | + $dispatcher=$initialController->dispatcher; |
|
134 | 134 | $dispatcher->setControllerName($controller); |
135 | 135 | $dispatcher->setActionName($action); |
136 | 136 | $dispatcher->dispatch(); |
137 | - $template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(),$dispatcher->getParams(), function ($view) { |
|
137 | + $template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(), $dispatcher->getParams(), function($view) { |
|
138 | 138 | $view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
139 | 139 | }); |
140 | 140 | $this->content=$template; |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | * @see BaseHtml::run() |
146 | 146 | */ |
147 | 147 | public function run(JsUtils $js) { |
148 | - if($this->content instanceof BaseHtml){ |
|
148 | + if ($this->content instanceof BaseHtml) { |
|
149 | 149 | $this->content->run($js); |
150 | 150 | } |
151 | - $this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array ( |
|
151 | + $this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array( |
|
152 | 152 | "show" => $this->showOnStartup |
153 | 153 | )); |
154 | 154 | if ($this->draggable) |
@@ -151,18 +151,20 @@ discard block |
||
151 | 151 | $this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array ( |
152 | 152 | "show" => $this->showOnStartup |
153 | 153 | )); |
154 | - if ($this->draggable) |
|
155 | - $this->_bsComponent->setDraggable(true); |
|
154 | + if ($this->draggable) { |
|
155 | + $this->_bsComponent->setDraggable(true); |
|
156 | + } |
|
156 | 157 | $this->_bsComponent->setBackdrop($this->backdrop); |
157 | 158 | $this->addEventsOnRun($js); |
158 | 159 | return $this->_bsComponent; |
159 | 160 | } |
160 | 161 | |
161 | 162 | public function getButton($index) { |
162 | - if (is_int($index)) |
|
163 | - return $this->buttons [$index]; |
|
164 | - else |
|
165 | - return $this->getElementById($index, $this->buttons); |
|
163 | + if (is_int($index)) { |
|
164 | + return $this->buttons [$index]; |
|
165 | + } else { |
|
166 | + return $this->getElementById($index, $this->buttons); |
|
167 | + } |
|
166 | 168 | } |
167 | 169 | |
168 | 170 | public function showOnCreate() { |
@@ -188,8 +190,9 @@ discard block |
||
188 | 190 | |
189 | 191 | public function jsHideButton($index) { |
190 | 192 | $btn=$this->getButton($index); |
191 | - if ($btn) |
|
192 | - return "$('#".$btn->getIdentifier()."').hide();"; |
|
193 | + if ($btn) { |
|
194 | + return "$('#".$btn->getIdentifier()."').hide();"; |
|
195 | + } |
|
193 | 196 | } |
194 | 197 | |
195 | 198 | /** |