@@ -108,6 +108,10 @@ discard block |
||
108 | 108 | return true; |
109 | 109 | } |
110 | 110 | |
111 | + /** |
|
112 | + * @param string $propertyName |
|
113 | + * @param string $value |
|
114 | + */ |
|
111 | 115 | protected function propertyContains($propertyName,$value){ |
112 | 116 | $values=$this->getProperty($propertyName); |
113 | 117 | if(isset($values)){ |
@@ -137,6 +141,10 @@ discard block |
||
137 | 141 | return $this; |
138 | 142 | } |
139 | 143 | |
144 | + /** |
|
145 | + * @param string $name |
|
146 | + * @param string[] $typeCtrl |
|
147 | + */ |
|
140 | 148 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
141 | 149 | if ($this->ctrl($name, $value, $typeCtrl)===true) { |
142 | 150 | if (is_array($typeCtrl)) { |
@@ -161,6 +169,9 @@ discard block |
||
161 | 169 | return $this->addToProperty($name, $value); |
162 | 170 | } |
163 | 171 | |
172 | + /** |
|
173 | + * @param string $name |
|
174 | + */ |
|
164 | 175 | public function addToPropertyCtrl($name, $value, $typeCtrl) { |
165 | 176 | // if($this->ctrl($name, $value, $typeCtrl)===true){ |
166 | 177 | return $this->addToPropertyUnique($name, $value, $typeCtrl); |
@@ -228,6 +239,9 @@ discard block |
||
228 | 239 | |
229 | 240 | } |
230 | 241 | |
242 | + /** |
|
243 | + * @param string $before |
|
244 | + */ |
|
231 | 245 | public function wrap($before, $after="") { |
232 | 246 | if(isset($before)){ |
233 | 247 | $this->wrapBefore.=$before; |
@@ -296,6 +310,9 @@ discard block |
||
296 | 310 | } |
297 | 311 | } |
298 | 312 | |
313 | + /** |
|
314 | + * @param string $operation |
|
315 | + */ |
|
299 | 316 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
300 | 317 | $params=array ( |
301 | 318 | "url" => $url, |
@@ -306,14 +323,23 @@ discard block |
||
306 | 323 | return $this; |
307 | 324 | } |
308 | 325 | |
326 | + /** |
|
327 | + * @param string $event |
|
328 | + */ |
|
309 | 329 | public function getOn($event, $url, $responseElement="", $parameters=array()) { |
310 | 330 | return $this->_ajaxOn("get", $event, $url, $responseElement, $parameters); |
311 | 331 | } |
312 | 332 | |
333 | + /** |
|
334 | + * @param string $url |
|
335 | + */ |
|
313 | 336 | public function getOnClick($url, $responseElement="", $parameters=array()) { |
314 | 337 | return $this->getOn("click", $url, $responseElement, $parameters); |
315 | 338 | } |
316 | 339 | |
340 | + /** |
|
341 | + * @param string $event |
|
342 | + */ |
|
317 | 343 | public function postOn($event, $url, $params="{}", $responseElement="", $parameters=array()) { |
318 | 344 | $parameters ["params"]=$params; |
319 | 345 | return $this->_ajaxOn("post", $event, $url, $responseElement, $parameters); |
@@ -323,6 +349,9 @@ discard block |
||
323 | 349 | return $this->postOn("click", $url, $params, $responseElement, $parameters); |
324 | 350 | } |
325 | 351 | |
352 | + /** |
|
353 | + * @param string $event |
|
354 | + */ |
|
326 | 355 | public function postFormOn($event, $url, $form, $responseElement="", $parameters=array()) { |
327 | 356 | $parameters ["form"]=$form; |
328 | 357 | return $this->_ajaxOn("postForm", $event, $url, $responseElement, $parameters); |
@@ -372,6 +401,9 @@ discard block |
||
372 | 401 | return $value; |
373 | 402 | } |
374 | 403 | |
404 | + /** |
|
405 | + * @param string $jqueryCall |
|
406 | + */ |
|
375 | 407 | public function jsDoJquery($jqueryCall, $param=""){ |
376 | 408 | return "$('#".$this->identifier."').".$jqueryCall."(".$this->_prep_value($param).");"; |
377 | 409 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | abstract class BaseHtml extends BaseWidget { |
17 | 17 | protected $_template; |
18 | 18 | protected $tagName; |
19 | - protected $properties=array (); |
|
20 | - protected $events=array (); |
|
19 | + protected $properties=array(); |
|
20 | + protected $events=array(); |
|
21 | 21 | protected $wrapBefore=""; |
22 | 22 | protected $wrapAfter=""; |
23 | 23 | protected $_bsComponent; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | public function addToProperty($name, $value, $separator=" ") { |
58 | 58 | $v=@$this->properties[$name]; |
59 | - if (isset($v)&&$v!=="") |
|
59 | + if (isset($v) && $v!=="") |
|
60 | 60 | $v=$v.$separator.$value; |
61 | 61 | else |
62 | 62 | $v=$value; |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | |
72 | 72 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
73 | 73 | $result=$this->getTemplate(); |
74 | - foreach ( $this as $key => $value ) { |
|
75 | - if (PhalconUtils::startsWith($key, "_")===false&&$key!=="events") { |
|
74 | + foreach ($this as $key => $value) { |
|
75 | + if (PhalconUtils::startsWith($key, "_")===false && $key!=="events") { |
|
76 | 76 | if (is_array($value)) { |
77 | 77 | $v=PropertyWrapper::wrap($value, $js); |
78 | - } else { |
|
78 | + }else { |
|
79 | 79 | $v=$value; |
80 | 80 | } |
81 | 81 | $result=str_ireplace("%".$key."%", $v, $result); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | if (isset($view)===true) { |
88 | 88 | $controls=$view->getVar("q"); |
89 | 89 | if (isset($controls)===false) { |
90 | - $controls=array (); |
|
90 | + $controls=array(); |
|
91 | 91 | } |
92 | 92 | $controls [$this->identifier]=$result; |
93 | 93 | $view->setVar("q", $controls); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | if (array_search($value, $typeCtrl)===false) { |
101 | 101 | throw new \Exception("La valeur passée a propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
102 | 102 | } |
103 | - } else { |
|
103 | + }else { |
|
104 | 104 | if (!$typeCtrl($value)) { |
105 | 105 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
106 | 106 | } |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | return true; |
109 | 109 | } |
110 | 110 | |
111 | - protected function propertyContains($propertyName,$value){ |
|
111 | + protected function propertyContains($propertyName, $value) { |
|
112 | 112 | $values=$this->getProperty($propertyName); |
113 | - if(isset($values)){ |
|
113 | + if (isset($values)) { |
|
114 | 114 | return JString::contains($values, $value); |
115 | 115 | } |
116 | 116 | return false; |
@@ -185,28 +185,28 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | public function fromArray($array) { |
188 | - foreach ( $this as $key => $value ) { |
|
188 | + foreach ($this as $key => $value) { |
|
189 | 189 | if (array_key_exists($key, $array) && !PhalconUtils::startsWith($key, "_")) { |
190 | 190 | $setter="set".ucfirst($key); |
191 | 191 | $this->$setter($array [$key]); |
192 | 192 | unset($array [$key]); |
193 | 193 | } |
194 | 194 | } |
195 | - foreach ( $array as $key => $value ) { |
|
195 | + foreach ($array as $key => $value) { |
|
196 | 196 | if (method_exists($this, $key)) { |
197 | 197 | try { |
198 | 198 | $this->$key($value); |
199 | 199 | unset($array [$key]); |
200 | - } catch ( \Exception $e ) { |
|
200 | + } catch (\Exception $e) { |
|
201 | 201 | // Nothing to do |
202 | 202 | } |
203 | - } else { |
|
203 | + }else { |
|
204 | 204 | $setter="set".ucfirst($key); |
205 | 205 | if (method_exists($this, $setter)) { |
206 | 206 | try { |
207 | 207 | $this->$setter($value); |
208 | 208 | unset($array [$key]); |
209 | - } catch ( \Exception $e ) { |
|
209 | + } catch (\Exception $e) { |
|
210 | 210 | // Nothing to do |
211 | 211 | } |
212 | 212 | } |
@@ -215,21 +215,21 @@ discard block |
||
215 | 215 | return $array; |
216 | 216 | } |
217 | 217 | |
218 | - public function fromDatabaseObjects($objects,$function) { |
|
219 | - if(isset($objects)){ |
|
220 | - foreach ($objects as $object){ |
|
221 | - $this->fromDatabaseObject($object,$function); |
|
218 | + public function fromDatabaseObjects($objects, $function) { |
|
219 | + if (isset($objects)) { |
|
220 | + foreach ($objects as $object) { |
|
221 | + $this->fromDatabaseObject($object, $function); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | return $this; |
225 | 225 | } |
226 | 226 | |
227 | - public function fromDatabaseObject($object,$function){ |
|
227 | + public function fromDatabaseObject($object, $function) { |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
231 | 231 | public function wrap($before, $after="") { |
232 | - if(isset($before)){ |
|
232 | + if (isset($before)) { |
|
233 | 233 | $this->wrapBefore.=$before; |
234 | 234 | } |
235 | 235 | $this->wrapAfter=$after.$this->wrapAfter; |
@@ -251,13 +251,13 @@ discard block |
||
251 | 251 | if (array_key_exists($event, $this->events)) { |
252 | 252 | if (is_array($this->events [$event])) { |
253 | 253 | $this->events [$event] []=$jsCode; |
254 | - } else { |
|
255 | - $this->events [$event]=array ( |
|
254 | + }else { |
|
255 | + $this->events [$event]=array( |
|
256 | 256 | $this->events [$event], |
257 | 257 | $jsCode |
258 | 258 | ); |
259 | 259 | } |
260 | - } else { |
|
260 | + }else { |
|
261 | 261 | $this->events [$event]=$jsCode; |
262 | 262 | } |
263 | 263 | } |
@@ -276,14 +276,14 @@ discard block |
||
276 | 276 | |
277 | 277 | public function addEventsOnRun(JsUtils $js) { |
278 | 278 | if (isset($this->_bsComponent)) { |
279 | - foreach ( $this->events as $event => $jsCode ) { |
|
279 | + foreach ($this->events as $event => $jsCode) { |
|
280 | 280 | $code=$jsCode; |
281 | 281 | if (is_array($jsCode)) { |
282 | 282 | $code=""; |
283 | - foreach ( $jsCode as $jsC ) { |
|
283 | + foreach ($jsCode as $jsC) { |
|
284 | 284 | if ($jsC instanceof AjaxCall) { |
285 | 285 | $code.="\n".$jsC->compile($js); |
286 | - } else { |
|
286 | + }else { |
|
287 | 287 | $code.="\n".$jsC; |
288 | 288 | } |
289 | 289 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
300 | - $params=array ( |
|
300 | + $params=array( |
|
301 | 301 | "url" => $url, |
302 | 302 | "responseElement" => $responseElement |
303 | 303 | ); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | if (is_array($elements)) { |
337 | 337 | $flag=false; |
338 | 338 | $index=0; |
339 | - while ( !$flag&&$index<sizeof($elements) ) { |
|
339 | + while (!$flag && $index<sizeof($elements)) { |
|
340 | 340 | if ($elements [$index] instanceof BaseHtml) |
341 | 341 | $flag=($elements [$index]->getIdentifier()===$identifier); |
342 | 342 | $index++; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | return null; |
351 | 351 | } |
352 | 352 | |
353 | - public function __toString(){ |
|
353 | + public function __toString() { |
|
354 | 354 | return $this->compile(); |
355 | 355 | } |
356 | 356 | |
@@ -366,25 +366,25 @@ discard block |
||
366 | 366 | if (is_array($value)) { |
367 | 367 | $value=implode(",", $value); |
368 | 368 | } |
369 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false) { |
|
369 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false) { |
|
370 | 370 | $value='"'.$value.'"'; |
371 | 371 | } |
372 | 372 | return $value; |
373 | 373 | } |
374 | 374 | |
375 | - public function jsDoJquery($jqueryCall, $param=""){ |
|
375 | + public function jsDoJquery($jqueryCall, $param="") { |
|
376 | 376 | return "$('#".$this->identifier."').".$jqueryCall."(".$this->_prep_value($param).");"; |
377 | 377 | } |
378 | 378 | |
379 | - public function jsHtml($content=""){ |
|
380 | - return $this->jsDoJquery("html",$content); |
|
379 | + public function jsHtml($content="") { |
|
380 | + return $this->jsDoJquery("html", $content); |
|
381 | 381 | } |
382 | 382 | |
383 | - public function jsShow(){ |
|
383 | + public function jsShow() { |
|
384 | 384 | return $this->jsDoJquery("show"); |
385 | 385 | } |
386 | 386 | |
387 | - public function jsHide(){ |
|
387 | + public function jsHide() { |
|
388 | 388 | return $this->jsDoJquery("hide"); |
389 | 389 | } |
390 | 390 | } |
391 | 391 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | class HtmlDropdown extends HtmlSemDoubleElement { |
14 | 14 | protected $mClass="menu"; |
15 | 15 | protected $mTagName="div"; |
16 | - protected $items=array (); |
|
16 | + protected $items=array(); |
|
17 | 17 | protected $params=array("action"=>"select"); |
18 | 18 | protected $input; |
19 | 19 | |
@@ -21,40 +21,40 @@ discard block |
||
21 | 21 | parent::__construct($identifier, "div"); |
22 | 22 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
23 | 23 | $this->setProperty("class", "ui dropdown"); |
24 | - $content=new HtmlSemDoubleElement("","div"); |
|
24 | + $content=new HtmlSemDoubleElement("", "div"); |
|
25 | 25 | $content->setClass("text"); |
26 | 26 | $content->setContent($value); |
27 | - $content->wrap("",new HtmlIcon("", "dropdown")); |
|
27 | + $content->wrap("", new HtmlIcon("", "dropdown")); |
|
28 | 28 | $this->content=array($content); |
29 | 29 | $this->tagName="div"; |
30 | 30 | $this->addItems($items); |
31 | 31 | } |
32 | 32 | |
33 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
33 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
34 | 34 | $itemO=$item; |
35 | - if(\is_object($item)===false){ |
|
36 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
|
37 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
35 | + if (\is_object($item)===false) { |
|
36 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image); |
|
37 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
38 | 38 | $this->addToProperty("class", "vertical"); |
39 | 39 | } |
40 | 40 | $this->items[]=$itemO; |
41 | 41 | return $itemO; |
42 | 42 | } |
43 | 43 | |
44 | - public function addInput($name){ |
|
45 | - if(!isset($name)) |
|
44 | + public function addInput($name) { |
|
45 | + if (!isset($name)) |
|
46 | 46 | $name="input-".$this->identifier; |
47 | 47 | $this->setAction("activate"); |
48 | - $this->input=new HtmlInput($name,"hidden"); |
|
48 | + $this->input=new HtmlInput($name, "hidden"); |
|
49 | 49 | } |
50 | 50 | |
51 | - public function addItems($items){ |
|
52 | - if(JArray::isAssociative($items)){ |
|
53 | - foreach ($items as $k=>$v){ |
|
51 | + public function addItems($items) { |
|
52 | + if (JArray::isAssociative($items)) { |
|
53 | + foreach ($items as $k=>$v) { |
|
54 | 54 | $this->addItem($v)->setData($k); |
55 | 55 | } |
56 | - }else{ |
|
57 | - foreach ($items as $item){ |
|
56 | + }else { |
|
57 | + foreach ($items as $item) { |
|
58 | 58 | $this->addItem($item); |
59 | 59 | } |
60 | 60 | } |
@@ -63,51 +63,51 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @param boolean $dropdown |
65 | 65 | */ |
66 | - public function asDropdown($dropdown){ |
|
67 | - if($dropdown===false){ |
|
66 | + public function asDropdown($dropdown) { |
|
67 | + if ($dropdown===false) { |
|
68 | 68 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
69 | 69 | $dropdown="menu"; |
70 | - }else{ |
|
70 | + }else { |
|
71 | 71 | $dropdown="dropdown"; |
72 | 72 | $this->mClass="menu"; |
73 | 73 | } |
74 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
74 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
75 | 75 | } |
76 | 76 | |
77 | - public function setVertical(){ |
|
78 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
77 | + public function setVertical() { |
|
78 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
79 | 79 | } |
80 | 80 | |
81 | - public function setSimple(){ |
|
82 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
81 | + public function setSimple() { |
|
82 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
83 | 83 | } |
84 | 84 | |
85 | - public function asButton($floating=false){ |
|
86 | - if($floating) |
|
85 | + public function asButton($floating=false) { |
|
86 | + if ($floating) |
|
87 | 87 | $this->addToProperty("class", "floating"); |
88 | 88 | return $this->addToProperty("class", "button"); |
89 | 89 | } |
90 | 90 | |
91 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
92 | - if(isset($name)) |
|
91 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
92 | + if (isset($name)) |
|
93 | 93 | $this->addInput($name); |
94 | - if($multiple) |
|
94 | + if ($multiple) |
|
95 | 95 | $this->addToProperty("class", "multiple"); |
96 | 96 | if ($selection) |
97 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
97 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
98 | 98 | return $this; |
99 | 99 | } |
100 | 100 | |
101 | - public function asSearch($name=NULL,$multiple=false,$selection=false){ |
|
102 | - $this->asSelect($name,$multiple,$selection); |
|
101 | + public function asSearch($name=NULL, $multiple=false, $selection=false) { |
|
102 | + $this->asSelect($name, $multiple, $selection); |
|
103 | 103 | return $this->addToProperty("class", "search"); |
104 | 104 | } |
105 | 105 | |
106 | - public function setSelect($name=NULL,$multiple=false){ |
|
107 | - if(!isset($name)) |
|
106 | + public function setSelect($name=NULL, $multiple=false) { |
|
107 | + if (!isset($name)) |
|
108 | 108 | $name="select-".$this->identifier; |
109 | 109 | $this->input=null; |
110 | - if($multiple){ |
|
110 | + if ($multiple) { |
|
111 | 111 | $this->setProperty("multiple", true); |
112 | 112 | $this->addToProperty("class", "multiple"); |
113 | 113 | } |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | $this->tagName="select"; |
116 | 116 | $this->setProperty("name", $name); |
117 | 117 | $this->content=null; |
118 | - foreach ($this->items as $item){ |
|
118 | + foreach ($this->items as $item) { |
|
119 | 119 | $item->asOption(); |
120 | 120 | } |
121 | 121 | return $this; |
122 | 122 | } |
123 | 123 | |
124 | - public function asSubmenu($pointing=false,$sens=""){ |
|
124 | + public function asSubmenu($pointing=false, $sens="") { |
|
125 | 125 | $this->setClass("ui dropdown link item"); |
126 | - if($pointing===true){ |
|
126 | + if ($pointing===true) { |
|
127 | 127 | $this->setPointing($sens); |
128 | 128 | } |
129 | 129 | return $this; |
130 | 130 | } |
131 | 131 | |
132 | - public function setPointing($sens=""){ |
|
132 | + public function setPointing($sens="") { |
|
133 | 133 | $this->addToProperty("class", "pointing"); |
134 | - if(JString::isNotNull($sens)) |
|
135 | - $this->addToPropertyCtrl("class", $sens, array("left","right")); |
|
134 | + if (JString::isNotNull($sens)) |
|
135 | + $this->addToPropertyCtrl("class", $sens, array("left", "right")); |
|
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 | |
139 | - public function setValue($value){ |
|
140 | - if(isset($this->input)){ |
|
139 | + public function setValue($value) { |
|
140 | + if (isset($this->input)) { |
|
141 | 141 | $this->input->setProperty("value", $value); |
142 | - }else{ |
|
142 | + }else { |
|
143 | 143 | $this->setProperty("value", $value); |
144 | 144 | } |
145 | 145 | return $this; |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | * @see BaseHtml::run() |
151 | 151 | */ |
152 | 152 | public function run(JsUtils $js) { |
153 | - if($this->propertyContains("class", "simple")===false){ |
|
154 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->params); |
|
153 | + if ($this->propertyContains("class", "simple")===false) { |
|
154 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->params); |
|
155 | 155 | $this->addEventsOnRun($js); |
156 | 156 | return $this->_bsComponent; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - public function setAction($action){ |
|
160 | + public function setAction($action) { |
|
161 | 161 | $this->params["action"]=$action; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | \ No newline at end of file |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $itemO=$item; |
35 | 35 | if(\is_object($item)===false){ |
36 | 36 | $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
37 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
37 | + } elseif($itemO instanceof HtmlDropdownItem){ |
|
38 | 38 | $this->addToProperty("class", "vertical"); |
39 | 39 | } |
40 | 40 | $this->items[]=$itemO; |
@@ -42,8 +42,9 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | public function addInput($name){ |
45 | - if(!isset($name)) |
|
46 | - $name="input-".$this->identifier; |
|
45 | + if(!isset($name)) { |
|
46 | + $name="input-".$this->identifier; |
|
47 | + } |
|
47 | 48 | $this->setAction("activate"); |
48 | 49 | $this->input=new HtmlInput($name,"hidden"); |
49 | 50 | } |
@@ -53,7 +54,7 @@ discard block |
||
53 | 54 | foreach ($items as $k=>$v){ |
54 | 55 | $this->addItem($v)->setData($k); |
55 | 56 | } |
56 | - }else{ |
|
57 | + } else{ |
|
57 | 58 | foreach ($items as $item){ |
58 | 59 | $this->addItem($item); |
59 | 60 | } |
@@ -67,7 +68,7 @@ discard block |
||
67 | 68 | if($dropdown===false){ |
68 | 69 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
69 | 70 | $dropdown="menu"; |
70 | - }else{ |
|
71 | + } else{ |
|
71 | 72 | $dropdown="dropdown"; |
72 | 73 | $this->mClass="menu"; |
73 | 74 | } |
@@ -83,18 +84,22 @@ discard block |
||
83 | 84 | } |
84 | 85 | |
85 | 86 | public function asButton($floating=false){ |
86 | - if($floating) |
|
87 | - $this->addToProperty("class", "floating"); |
|
87 | + if($floating) { |
|
88 | + $this->addToProperty("class", "floating"); |
|
89 | + } |
|
88 | 90 | return $this->addToProperty("class", "button"); |
89 | 91 | } |
90 | 92 | |
91 | 93 | public function asSelect($name=NULL,$multiple=false,$selection=true){ |
92 | - if(isset($name)) |
|
93 | - $this->addInput($name); |
|
94 | - if($multiple) |
|
95 | - $this->addToProperty("class", "multiple"); |
|
96 | - if ($selection) |
|
97 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
94 | + if(isset($name)) { |
|
95 | + $this->addInput($name); |
|
96 | + } |
|
97 | + if($multiple) { |
|
98 | + $this->addToProperty("class", "multiple"); |
|
99 | + } |
|
100 | + if ($selection) { |
|
101 | + $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
102 | + } |
|
98 | 103 | return $this; |
99 | 104 | } |
100 | 105 | |
@@ -104,8 +109,9 @@ discard block |
||
104 | 109 | } |
105 | 110 | |
106 | 111 | public function setSelect($name=NULL,$multiple=false){ |
107 | - if(!isset($name)) |
|
108 | - $name="select-".$this->identifier; |
|
112 | + if(!isset($name)) { |
|
113 | + $name="select-".$this->identifier; |
|
114 | + } |
|
109 | 115 | $this->input=null; |
110 | 116 | if($multiple){ |
111 | 117 | $this->setProperty("multiple", true); |
@@ -131,15 +137,16 @@ discard block |
||
131 | 137 | |
132 | 138 | public function setPointing($sens=""){ |
133 | 139 | $this->addToProperty("class", "pointing"); |
134 | - if(JString::isNotNull($sens)) |
|
135 | - $this->addToPropertyCtrl("class", $sens, array("left","right")); |
|
140 | + if(JString::isNotNull($sens)) { |
|
141 | + $this->addToPropertyCtrl("class", $sens, array("left","right")); |
|
142 | + } |
|
136 | 143 | return $this; |
137 | 144 | } |
138 | 145 | |
139 | 146 | public function setValue($value){ |
140 | 147 | if(isset($this->input)){ |
141 | 148 | $this->input->setProperty("value", $value); |
142 | - }else{ |
|
149 | + } else{ |
|
143 | 150 | $this->setProperty("value", $value); |
144 | 151 | } |
145 | 152 | return $this; |
@@ -2,21 +2,21 @@ |
||
2 | 2 | namespace Ajax\service; |
3 | 3 | class JString { |
4 | 4 | |
5 | - public static function contains($hay,$needle){ |
|
6 | - return strpos($hay, $needle) !== false; |
|
5 | + public static function contains($hay, $needle) { |
|
6 | + return strpos($hay, $needle)!==false; |
|
7 | 7 | } |
8 | 8 | public static function startswith($hay, $needle) { |
9 | - return substr($hay, 0, strlen($needle)) === $needle; |
|
9 | + return substr($hay, 0, strlen($needle))===$needle; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | public static function endswith($hay, $needle) { |
13 | - return substr($hay, -strlen($needle)) === $needle; |
|
13 | + return substr($hay, -strlen($needle))===$needle; |
|
14 | 14 | } |
15 | 15 | |
16 | - public static function isNull($s){ |
|
16 | + public static function isNull($s) { |
|
17 | 17 | return (!isset($s) || NULL===$s || ""===$s); |
18 | 18 | } |
19 | - public static function isNotNull($s){ |
|
19 | + public static function isNotNull($s) { |
|
20 | 20 | return (isset($s) && NULL!==$s && ""!==$s); |
21 | 21 | } |
22 | 22 | } |
23 | 23 | \ No newline at end of file |