@@ -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)) { |
@@ -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 @@ discard block |
||
| 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; |
@@ -37,10 +38,11 @@ discard block |
||
| 37 | 38 | |
| 38 | 39 | public static function wrapObjects($input, $js=NULL, $separator=' ') { |
| 39 | 40 | return implode($separator, array_map(function ($v) use($js) { |
| 40 | - if (is_object($v)) |
|
| 41 | - return $v->compile($js); |
|
| 42 | - else |
|
| 43 | - return $v; |
|
| 41 | + if (is_object($v)) { |
|
| 42 | + return $v->compile($js); |
|
| 43 | + } else { |
|
| 44 | + return $v; |
|
| 45 | + } |
|
| 44 | 46 | }, $input)); |
| 45 | 47 | } |
| 46 | 48 | } |
| 47 | 49 | \ No newline at end of file |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | foreach ($icons as $icon=>$size){ |
| 37 | 37 | $group->addIcon($icon,$size); |
| 38 | 38 | } |
| 39 | - }else{ |
|
| 39 | + } else{ |
|
| 40 | 40 | foreach ($icons as $icon){ |
| 41 | 41 | $group->addIcon($icon); |
| 42 | 42 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @param string $identifier |
| 54 | 54 | * @param string $icon |
| 55 | 55 | */ |
| 56 | - public function htmlIcon($identifier,$icon){ |
|
| 56 | + public function htmlIcon($identifier, $icon) { |
|
| 57 | 57 | return $this->addHtmlComponent(new HtmlIcon($identifier, $icon)); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | * @param string $size |
| 63 | 63 | * @param array $icons |
| 64 | 64 | */ |
| 65 | - public function htmlIconGroups($identifier,$size="",$icons=array()){ |
|
| 66 | - $group=new HtmlIconGroups($identifier,$size); |
|
| 67 | - if(JArray::isAssociative($icons)){ |
|
| 68 | - foreach ($icons as $icon=>$size){ |
|
| 69 | - $group->add($icon,$size); |
|
| 65 | + public function htmlIconGroups($identifier, $size="", $icons=array()) { |
|
| 66 | + $group=new HtmlIconGroups($identifier, $size); |
|
| 67 | + if (JArray::isAssociative($icons)) { |
|
| 68 | + foreach ($icons as $icon=>$size) { |
|
| 69 | + $group->add($icon, $size); |
|
| 70 | 70 | } |
| 71 | - }else{ |
|
| 72 | - foreach ($icons as $icon){ |
|
| 71 | + }else { |
|
| 72 | + foreach ($icons as $icon) { |
|
| 73 | 73 | $group->add($icon); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | * @param array $elements |
| 82 | 82 | * @param boolean $asIcons |
| 83 | 83 | */ |
| 84 | - public function htmlButtonGroups($identifier,$elements=array(),$asIcons=false){ |
|
| 85 | - return $this->addHtmlComponent(new HtmlButtonGroups($identifier, $elements,$asIcons)); |
|
| 84 | + public function htmlButtonGroups($identifier, $elements=array(), $asIcons=false) { |
|
| 85 | + return $this->addHtmlComponent(new HtmlButtonGroups($identifier, $elements, $asIcons)); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param string $identifier |
| 91 | 91 | * @param string $content |
| 92 | 92 | */ |
| 93 | - public function htmlContainer($identifier,$content=""){ |
|
| 93 | + public function htmlContainer($identifier, $content="") { |
|
| 94 | 94 | return $this->addHtmlComponent(new HtmlContainer($identifier, $content)); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | * @param string $identifier |
| 99 | 99 | * @param string $content |
| 100 | 100 | */ |
| 101 | - public function htmlDivider($identifier,$content="",$tagName="div"){ |
|
| 102 | - return $this->addHtmlComponent(new HtmlDivider($identifier, $content,$tagName)); |
|
| 101 | + public function htmlDivider($identifier, $content="", $tagName="div") { |
|
| 102 | + return $this->addHtmlComponent(new HtmlDivider($identifier, $content, $tagName)); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -107,16 +107,16 @@ discard block |
||
| 107 | 107 | * @param string $content |
| 108 | 108 | * @param string $tagName |
| 109 | 109 | */ |
| 110 | - public function htmlLabel($identifier,$content="",$tagName="div"){ |
|
| 111 | - return $this->addHtmlComponent(new HtmlLabel($identifier, $content,$tagName)); |
|
| 110 | + public function htmlLabel($identifier, $content="", $tagName="div") { |
|
| 111 | + return $this->addHtmlComponent(new HtmlLabel($identifier, $content, $tagName)); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * @param string $identifier |
| 116 | 116 | * @param array $items |
| 117 | 117 | */ |
| 118 | - public function htmlMenu($identifier,$items=array()){ |
|
| 119 | - return $this->addHtmlComponent(new HtmlMenu($identifier,$items)); |
|
| 118 | + public function htmlMenu($identifier, $items=array()) { |
|
| 119 | + return $this->addHtmlComponent(new HtmlMenu($identifier, $items)); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | * @param string $value |
| 125 | 125 | * @param array $items |
| 126 | 126 | */ |
| 127 | - public function htmlDropdown($identifier, $value="", $items=array()){ |
|
| 128 | - return $this->addHtmlComponent(new HtmlDropdown($identifier,$value,$items)); |
|
| 127 | + public function htmlDropdown($identifier, $value="", $items=array()) { |
|
| 128 | + return $this->addHtmlComponent(new HtmlDropdown($identifier, $value, $items)); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | 132 | * @param string $identifier |
| 133 | 133 | * @param string $content |
| 134 | 134 | */ |
| 135 | - public function htmlMessage($identifier, $content=""){ |
|
| 136 | - return $this->addHtmlComponent(new HtmlMessage($identifier,$content)); |
|
| 135 | + public function htmlMessage($identifier, $content="") { |
|
| 136 | + return $this->addHtmlComponent(new HtmlMessage($identifier, $content)); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | \ No newline at end of file |
@@ -23,19 +23,19 @@ |
||
| 23 | 23 | return $this; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function addGlyph($glyphicon,$before=true){ |
|
| 26 | + public function addGlyph($glyphicon, $before=true) { |
|
| 27 | 27 | $glyph=new HtmlGlyphicon(""); |
| 28 | 28 | $glyph->setGlyphicon($glyphicon); |
| 29 | - $this->addContent($glyph,$before); |
|
| 29 | + $this->addContent($glyph, $before); |
|
| 30 | 30 | return $this; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function wrapContentWithGlyph($glyphBefore,$glyphAfter=""){ |
|
| 33 | + public function wrapContentWithGlyph($glyphBefore, $glyphAfter="") { |
|
| 34 | 34 | $before=HtmlGlyphicon::getGlyphicon($glyphBefore)." "; |
| 35 | 35 | $after=""; |
| 36 | - if($glyphAfter!==""){ |
|
| 36 | + if ($glyphAfter!=="") { |
|
| 37 | 37 | $after=" ".HtmlGlyphicon::getGlyphicon($glyphAfter); |
| 38 | 38 | } |
| 39 | - return $this->wrapContent($before,$after); |
|
| 39 | + return $this->wrapContent($before, $after); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file |
@@ -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 | } |
@@ -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 |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | return $this->content; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function addContent($content,$before=false) { |
|
| 30 | + public function addContent($content, $before=false) { |
|
| 31 | 31 | if (is_array($this->content)===false) { |
| 32 | - if(isset($this->content)) |
|
| 33 | - $this->content=array ($this->content); |
|
| 32 | + if (isset($this->content)) |
|
| 33 | + $this->content=array($this->content); |
|
| 34 | 34 | else |
| 35 | 35 | $this->content=array(); |
| 36 | 36 | } |
| 37 | - if($before) |
|
| 38 | - array_unshift($this->content,$content); |
|
| 37 | + if ($before) |
|
| 38 | + array_unshift($this->content, $content); |
|
| 39 | 39 | else |
| 40 | 40 | $this->content []=$content; |
| 41 | 41 | return $this; |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | parent::run($js); |
| 50 | 50 | if ($this->content instanceof HtmlDoubleElement) { |
| 51 | 51 | $this->content->run($js); |
| 52 | - } else if (is_array($this->content)) { |
|
| 53 | - foreach ( $this->content as $itemContent ) { |
|
| 52 | + }else if (is_array($this->content)) { |
|
| 53 | + foreach ($this->content as $itemContent) { |
|
| 54 | 54 | if ($itemContent instanceof HtmlDoubleElement) { |
| 55 | 55 | $itemContent->run($js); |
| 56 | 56 | } |
@@ -29,15 +29,17 @@ |
||
| 29 | 29 | |
| 30 | 30 | public function addContent($content,$before=false) { |
| 31 | 31 | if (is_array($this->content)===false) { |
| 32 | - if(isset($this->content)) |
|
| 33 | - $this->content=array ($this->content); |
|
| 34 | - else |
|
| 35 | - $this->content=array(); |
|
| 32 | + if(isset($this->content)) { |
|
| 33 | + $this->content=array ($this->content); |
|
| 34 | + } else { |
|
| 35 | + $this->content=array(); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + if($before) { |
|
| 39 | + array_unshift($this->content,$content); |
|
| 40 | + } else { |
|
| 41 | + $this->content []=$content; |
|
| 36 | 42 | } |
| 37 | - if($before) |
|
| 38 | - array_unshift($this->content,$content); |
|
| 39 | - else |
|
| 40 | - $this->content []=$content; |
|
| 41 | 43 | return $this; |
| 42 | 44 | } |
| 43 | 45 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public function setClass($classNames) { |
| 16 | - if(is_array($classNames)){ |
|
| 16 | + if (is_array($classNames)) { |
|
| 17 | 17 | $classNames=implode(" ", $classNames); |
| 18 | 18 | } |
| 19 | 19 | $this->setProperty("class", $classNames); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function fromArray($array) { |
| 42 | 42 | $array=parent::fromArray($array); |
| 43 | - foreach ( $array as $key => $value ) { |
|
| 43 | + foreach ($array as $key => $value) { |
|
| 44 | 44 | $this->setProperty($key, $value); |
| 45 | 45 | } |
| 46 | 46 | return $array; |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Ajax\bootstrap\html\html5; |
| 3 | 3 | /** |
| 4 | - * HTML Select |
|
| 5 | - * @author jc |
|
| 6 | - * @version 1.002 |
|
| 7 | - */ |
|
| 4 | + * HTML Select |
|
| 5 | + * @author jc |
|
| 6 | + * @version 1.002 |
|
| 7 | + */ |
|
| 8 | 8 | use Ajax\bootstrap\html\base\HtmlDoubleElement; |
| 9 | 9 | |
| 10 | 10 | class HtmlOption extends HtmlDoubleElement { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | class HtmlOption extends HtmlDoubleElement { |
| 11 | 11 | protected $value; |
| 12 | 12 | protected $selected; |
| 13 | - public function __construct($identifier,$caption,$value="") { |
|
| 13 | + public function __construct($identifier, $caption, $value="") { |
|
| 14 | 14 | parent::__construct($identifier, "option"); |
| 15 | 15 | $this->_template='<option id="%identifier%" value="%value%" %selected% %properties%>%content%</option>'; |
| 16 | 16 | $this->content=$caption; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $this->selected=""; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function select(){ |
|
| 21 | + public function select() { |
|
| 22 | 22 | $this->selected="selected"; |
| 23 | 23 | return $this; |
| 24 | 24 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | return $this->value; |
| 28 | 28 | } |
| 29 | 29 | public function setValue($value) { |
| 30 | - $this->value = $value; |
|
| 30 | + $this->value=$value; |
|
| 31 | 31 | return $this; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | private $default; |
| 17 | 17 | private $options; |
| 18 | 18 | |
| 19 | - public function __construct($identifier, $caption,$default=NULL) { |
|
| 19 | + public function __construct($identifier, $caption, $default=NULL) { |
|
| 20 | 20 | parent::__construct($identifier, "select"); |
| 21 | 21 | $this->setProperty("name", $identifier); |
| 22 | 22 | $this->setProperty("class", "form-control"); |
@@ -25,21 +25,21 @@ discard block |
||
| 25 | 25 | $this->options=array(); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public function addOption($element,$value="",$selected=false){ |
|
| 29 | - if($element instanceof HtmlOption){ |
|
| 28 | + public function addOption($element, $value="", $selected=false) { |
|
| 29 | + if ($element instanceof HtmlOption) { |
|
| 30 | 30 | $option=$element; |
| 31 | - }else{ |
|
| 32 | - $option=new HtmlOption($this->identifier."-".count($this->options), $element,$value); |
|
| 31 | + }else { |
|
| 32 | + $option=new HtmlOption($this->identifier."-".count($this->options), $element, $value); |
|
| 33 | 33 | } |
| 34 | - if($selected || $option->getValue()==$this->getProperty("value")){ |
|
| 34 | + if ($selected || $option->getValue()==$this->getProperty("value")) { |
|
| 35 | 35 | $option->select(); |
| 36 | 36 | } |
| 37 | 37 | $this->options[]=$option; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function setValue($value) { |
| 41 | - foreach ( $this->options as $option ) { |
|
| 42 | - if (strcasecmp($option->getValue(),$value)===0) { |
|
| 41 | + foreach ($this->options as $option) { |
|
| 42 | + if (strcasecmp($option->getValue(), $value)===0) { |
|
| 43 | 43 | $option->setProperty("selected", ""); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -52,23 +52,23 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
| 54 | 54 | $this->content=array(); |
| 55 | - if(isset($this->default)){ |
|
| 55 | + if (isset($this->default)) { |
|
| 56 | 56 | $default=new HtmlOption("", $this->default); |
| 57 | 57 | $this->content[]=$default; |
| 58 | 58 | } |
| 59 | - foreach ($this->options as $option){ |
|
| 59 | + foreach ($this->options as $option) { |
|
| 60 | 60 | $this->content[]=$option; |
| 61 | 61 | } |
| 62 | 62 | return parent::compile($js, $view); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function fromArray($array){ |
|
| 66 | - if(JArray::isAssociative($array)){ |
|
| 67 | - foreach ($array as $k=>$v){ |
|
| 65 | + public function fromArray($array) { |
|
| 66 | + if (JArray::isAssociative($array)) { |
|
| 67 | + foreach ($array as $k=>$v) { |
|
| 68 | 68 | $this->addOption($v, $k); |
| 69 | 69 | } |
| 70 | - }else{ |
|
| 71 | - foreach ($array as $v){ |
|
| 70 | + }else { |
|
| 71 | + foreach ($array as $v) { |
|
| 72 | 72 | $this->addOption($v, $v); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $this->addOption($function($object)); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - public function setSize($size){ |
|
| 104 | + public function setSize($size) { |
|
| 105 | 105 | return $this->setProperty("size", $size); |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | public function addOption($element,$value="",$selected=false){ |
| 29 | 29 | if($element instanceof HtmlOption){ |
| 30 | 30 | $option=$element; |
| 31 | - }else{ |
|
| 31 | + } else{ |
|
| 32 | 32 | $option=new HtmlOption($this->identifier."-".count($this->options), $element,$value); |
| 33 | 33 | } |
| 34 | 34 | if($selected || $option->getValue()==$this->getProperty("value")){ |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | foreach ($array as $k=>$v){ |
| 68 | 68 | $this->addOption($v, $k); |
| 69 | 69 | } |
| 70 | - }else{ |
|
| 70 | + } else{ |
|
| 71 | 71 | foreach ($array as $v){ |
| 72 | 72 | $this->addOption($v, $v); |
| 73 | 73 | } |
@@ -5,8 +5,8 @@ |
||
| 5 | 5 | use Ajax\common\BaseEnum; |
| 6 | 6 | |
| 7 | 7 | class Color extends BaseEnum { |
| 8 | - const RED="red",ORANGE="orange",YELLOW="yellow", |
|
| 9 | - OLIVE="olive",GREEN="green",TEAL="teal", |
|
| 10 | - BLUE="blue",VIOLET="violet",PURPLE="purple", |
|
| 11 | - PINK="pink",BROWN="brown",GREY="grey",BLACK="black"; |
|
| 8 | + const RED="red", ORANGE="orange", YELLOW="yellow", |
|
| 9 | + OLIVE="olive", GREEN="green", TEAL="teal", |
|
| 10 | + BLUE="blue", VIOLET="violet", PURPLE="purple", |
|
| 11 | + PINK="pink", BROWN="brown", GREY="grey", BLACK="black"; |
|
| 12 | 12 | } |
| 13 | 13 | \ No newline at end of file |