@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | public function onCreate($jsCode){ |
| 53 | 53 | if(isset($this->_events["_create"])){ |
| 54 | 54 | $this->_events["_create"][]=$jsCode; |
| 55 | - }else{ |
|
| 55 | + } else{ |
|
| 56 | 56 | $this->_events["_create"]=[$jsCode]; |
| 57 | 57 | } |
| 58 | 58 | return $this; |
@@ -87,8 +87,9 @@ discard block |
||
| 87 | 87 | if(\is_array($create)){ |
| 88 | 88 | $create=\implode("", $create); |
| 89 | 89 | } |
| 90 | - if(isset($js) && $create!=="") |
|
| 91 | - $js->exec($create,true); |
|
| 90 | + if(isset($js) && $create!=="") { |
|
| 91 | + $js->exec($create,true); |
|
| 92 | + } |
|
| 92 | 93 | unset($this->_events["_create"]); |
| 93 | 94 | } |
| 94 | 95 | } |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | $this->widgetIdentifier=$identifier; |
| 21 | 21 | $this->values=[]; |
| 22 | 22 | $this->afterCompile=[]; |
| 23 | - if(isset($instance)) |
|
| 24 | - $this->setInstance($instance); |
|
| 23 | + if(isset($instance)) { |
|
| 24 | + $this->setInstance($instance); |
|
| 25 | + } |
|
| 25 | 26 | $this->setCaptions($captions); |
| 26 | 27 | $this->captionCallback=NULL; |
| 27 | 28 | } |
@@ -38,8 +39,9 @@ discard block |
||
| 38 | 39 | |
| 39 | 40 | public function getIdentifier(){ |
| 40 | 41 | $value=self::$index; |
| 41 | - if(isset($this->values["identifier"])) |
|
| 42 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 42 | + if(isset($this->values["identifier"])) { |
|
| 43 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 44 | + } |
|
| 43 | 45 | return $value; |
| 44 | 46 | } |
| 45 | 47 | |
@@ -62,19 +64,19 @@ discard block |
||
| 62 | 64 | $value=$property->getValue($this->instance); |
| 63 | 65 | if(isset($this->values[$index])){ |
| 64 | 66 | $value= $this->values[$index]($value,$this->instance,$index); |
| 65 | - }else{ |
|
| 67 | + } else{ |
|
| 66 | 68 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
| 67 | 69 | } |
| 68 | - }else{ |
|
| 69 | - if(\is_callable($property)) |
|
| 70 | - $value=$property($this->instance); |
|
| 71 | - elseif(\is_array($property)){ |
|
| 70 | + } else{ |
|
| 71 | + if(\is_callable($property)) { |
|
| 72 | + $value=$property($this->instance); |
|
| 73 | + } elseif(\is_array($property)){ |
|
| 72 | 74 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
| 73 | 75 | $value=\implode("", $values); |
| 74 | - }else{ |
|
| 76 | + } else{ |
|
| 75 | 77 | if(isset($this->values[$index])){ |
| 76 | 78 | $value= $this->values[$index]($property,$this->instance,$index); |
| 77 | - }else{ |
|
| 79 | + } else{ |
|
| 78 | 80 | $value=$property; |
| 79 | 81 | } |
| 80 | 82 | } |
@@ -97,10 +99,10 @@ discard block |
||
| 97 | 99 | if(isset($vb[$index])){ |
| 98 | 100 | if(\is_array($vb[$index])){ |
| 99 | 101 | $this->visibleProperties[$index][]=$field; |
| 100 | - }else{ |
|
| 102 | + } else{ |
|
| 101 | 103 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
| 102 | 104 | } |
| 103 | - }else{ |
|
| 105 | + } else{ |
|
| 104 | 106 | return $this->insertField($index, $field); |
| 105 | 107 | } |
| 106 | 108 | return $this; |
@@ -136,7 +138,7 @@ discard block |
||
| 136 | 138 | $this->reflect=new \ReflectionClass($instance); |
| 137 | 139 | if(\sizeof($this->visibleProperties)===0){ |
| 138 | 140 | $this->properties=$this->getDefaultProperties(); |
| 139 | - }else{ |
|
| 141 | + } else{ |
|
| 140 | 142 | foreach ($this->visibleProperties as $property){ |
| 141 | 143 | $this->setInstanceProperty($property); |
| 142 | 144 | } |
@@ -147,22 +149,23 @@ discard block |
||
| 147 | 149 | private function setInstanceProperty($property){ |
| 148 | 150 | if(\is_callable($property)){ |
| 149 | 151 | $this->properties[]=$property; |
| 150 | - }elseif(\is_string($property)){ |
|
| 152 | + } elseif(\is_string($property)){ |
|
| 151 | 153 | try{ |
| 152 | 154 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 153 | 155 | $rProperty=$this->reflect->getProperty($property); |
| 154 | 156 | $this->properties[]=$rProperty; |
| 155 | - }catch(\Exception $e){ |
|
| 157 | + } catch(\Exception $e){ |
|
| 156 | 158 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 157 | 159 | $this->properties[]=$property; |
| 158 | 160 | } |
| 159 | - }elseif(\is_int($property)){ |
|
| 161 | + } elseif(\is_int($property)){ |
|
| 160 | 162 | $props=$this->getDefaultProperties(); |
| 161 | - if(isset($props[$property])) |
|
| 162 | - $this->properties[]=$props[$property]; |
|
| 163 | - else |
|
| 164 | - $this->properties[]=$property; |
|
| 165 | - }else{ |
|
| 163 | + if(isset($props[$property])) { |
|
| 164 | + $this->properties[]=$props[$property]; |
|
| 165 | + } else { |
|
| 166 | + $this->properties[]=$property; |
|
| 167 | + } |
|
| 168 | + } else{ |
|
| 166 | 169 | $this->properties[]=$property; |
| 167 | 170 | } |
| 168 | 171 | } |
@@ -206,12 +209,13 @@ discard block |
||
| 206 | 209 | if(isset($this->captions[$index])){ |
| 207 | 210 | return $this->captions[$index]; |
| 208 | 211 | } |
| 209 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 210 | - return $this->properties[$index]->getName(); |
|
| 211 | - elseif(\is_callable($this->properties[$index])) |
|
| 212 | - return ""; |
|
| 213 | - else |
|
| 214 | - return $this->properties[$index]; |
|
| 212 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
| 213 | + return $this->properties[$index]->getName(); |
|
| 214 | + } elseif(\is_callable($this->properties[$index])) { |
|
| 215 | + return ""; |
|
| 216 | + } else { |
|
| 217 | + return $this->properties[$index]; |
|
| 218 | + } |
|
| 215 | 219 | } |
| 216 | 220 | |
| 217 | 221 | public function getCaptions(){ |
@@ -220,7 +224,7 @@ discard block |
||
| 220 | 224 | for($i=\sizeof($captions);$i<$this->count();$i++){ |
| 221 | 225 | $captions[]=""; |
| 222 | 226 | } |
| 223 | - }else{ |
|
| 227 | + } else{ |
|
| 224 | 228 | $captions=[]; |
| 225 | 229 | $index=0; |
| 226 | 230 | $count=$this->count(); |
@@ -236,8 +240,9 @@ discard block |
||
| 236 | 240 | } |
| 237 | 241 | |
| 238 | 242 | public function setCaption($index,$caption){ |
| 239 | - if(isset($this->captions)===false) |
|
| 240 | - $this->captions=[]; |
|
| 243 | + if(isset($this->captions)===false) { |
|
| 244 | + $this->captions=[]; |
|
| 245 | + } |
|
| 241 | 246 | $this->captions[$index]=$caption; |
| 242 | 247 | return $this; |
| 243 | 248 | } |
@@ -50,8 +50,9 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function getProperty($name) { |
| 53 | - if (array_key_exists($name, $this->properties)) |
|
| 54 | - return $this->properties[$name]; |
|
| 53 | + if (array_key_exists($name, $this->properties)) { |
|
| 54 | + return $this->properties[$name]; |
|
| 55 | + } |
|
| 55 | 56 | } |
| 56 | 57 | |
| 57 | 58 | public function addToProperty($name, $value, $separator=" ") { |
@@ -61,10 +62,11 @@ discard block |
||
| 61 | 62 | } |
| 62 | 63 | } else if ($value !== "" && $this->propertyContains($name, $value) === false) { |
| 63 | 64 | $v=@$this->properties[$name]; |
| 64 | - if (isset($v) && $v !== "") |
|
| 65 | - $v=$v . $separator . $value; |
|
| 66 | - else |
|
| 67 | - $v=$value; |
|
| 65 | + if (isset($v) && $v !== "") { |
|
| 66 | + $v=$v . $separator . $value; |
|
| 67 | + } else { |
|
| 68 | + $v=$value; |
|
| 69 | + } |
|
| 68 | 70 | |
| 69 | 71 | return $this->setProperty($name, $v); |
| 70 | 72 | } |
@@ -119,8 +121,9 @@ discard block |
||
| 119 | 121 | } |
| 120 | 122 | |
| 121 | 123 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
| 122 | - if ($this->ctrl($name, $value, $typeCtrl) === true) |
|
| 123 | - return $this->setProperty($name, $value); |
|
| 124 | + if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
| 125 | + return $this->setProperty($name, $value); |
|
| 126 | + } |
|
| 124 | 127 | return $this; |
| 125 | 128 | } |
| 126 | 129 | |
@@ -150,8 +153,9 @@ discard block |
||
| 150 | 153 | } |
| 151 | 154 | |
| 152 | 155 | public function removeProperty($name) { |
| 153 | - if (\array_key_exists($name, $this->properties)) |
|
| 154 | - unset($this->properties[$name]); |
|
| 156 | + if (\array_key_exists($name, $this->properties)) { |
|
| 157 | + unset($this->properties[$name]); |
|
| 158 | + } |
|
| 155 | 159 | return $this; |
| 156 | 160 | } |
| 157 | 161 | |
@@ -171,8 +175,9 @@ discard block |
||
| 171 | 175 | } |
| 172 | 176 | |
| 173 | 177 | protected function addToPropertyUnique($name, $value, $typeCtrl) { |
| 174 | - if (@class_exists($typeCtrl, true)) |
|
| 175 | - $typeCtrl=$typeCtrl::getConstants(); |
|
| 178 | + if (@class_exists($typeCtrl, true)) { |
|
| 179 | + $typeCtrl=$typeCtrl::getConstants(); |
|
| 180 | + } |
|
| 176 | 181 | if (is_array($typeCtrl)) { |
| 177 | 182 | $this->removeOldValues($this->properties[$name], $typeCtrl); |
| 178 | 183 | } |
@@ -213,8 +218,9 @@ discard block |
||
| 213 | 218 | |
| 214 | 219 | public function fromArray($array) { |
| 215 | 220 | foreach ( $this as $key => $value ) { |
| 216 | - if(array_key_exists($key, $array)===true) |
|
| 217 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
| 221 | + if(array_key_exists($key, $array)===true) { |
|
| 222 | + $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
| 223 | + } |
|
| 218 | 224 | } |
| 219 | 225 | foreach ( $array as $key => $value ) { |
| 220 | 226 | if($this->_callSetter($key, $key, $value, $array)===false){ |
@@ -265,15 +271,18 @@ discard block |
||
| 265 | 271 | $flag=false; |
| 266 | 272 | $index=0; |
| 267 | 273 | while ( !$flag && $index < sizeof($elements) ) { |
| 268 | - if ($elements[$index] instanceof BaseHtml) |
|
| 269 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
| 274 | + if ($elements[$index] instanceof BaseHtml) { |
|
| 275 | + $flag=($elements[$index]->getIdentifier() === $identifier); |
|
| 276 | + } |
|
| 270 | 277 | $index++; |
| 271 | 278 | } |
| 272 | - if ($flag === true) |
|
| 273 | - return $elements[$index - 1]; |
|
| 279 | + if ($flag === true) { |
|
| 280 | + return $elements[$index - 1]; |
|
| 281 | + } |
|
| 274 | 282 | } elseif ($elements instanceof BaseHtml) { |
| 275 | - if ($elements->getIdentifier() === $identifier) |
|
| 276 | - return $elements; |
|
| 283 | + if ($elements->getIdentifier() === $identifier) { |
|
| 284 | + return $elements; |
|
| 285 | + } |
|
| 277 | 286 | } |
| 278 | 287 | return null; |
| 279 | 288 | } |
@@ -283,15 +292,18 @@ discard block |
||
| 283 | 292 | $flag=false; |
| 284 | 293 | $index=0; |
| 285 | 294 | while ( !$flag && $index < sizeof($elements) ) { |
| 286 | - if ($elements[$index] instanceof BaseHtml) |
|
| 287 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
| 295 | + if ($elements[$index] instanceof BaseHtml) { |
|
| 296 | + $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
| 297 | + } |
|
| 288 | 298 | $index++; |
| 289 | 299 | } |
| 290 | - if ($flag === true) |
|
| 291 | - return $elements[$index - 1]; |
|
| 300 | + if ($flag === true) { |
|
| 301 | + return $elements[$index - 1]; |
|
| 302 | + } |
|
| 292 | 303 | } elseif ($elements instanceof BaseHtml) { |
| 293 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
| 294 | - return $elements; |
|
| 304 | + if ($elements->propertyContains($propertyName, $value) === true) { |
|
| 305 | + return $elements; |
|
| 306 | + } |
|
| 295 | 307 | } |
| 296 | 308 | return null; |
| 297 | 309 | } |
@@ -14,8 +14,9 @@ |
||
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function asAvatar($caption=NULL) { |
| 17 | - if (isset($caption)) |
|
| 18 | - $this->wrap("", $caption); |
|
| 17 | + if (isset($caption)) { |
|
| 18 | + $this->wrap("", $caption); |
|
| 19 | + } |
|
| 19 | 20 | return $this->addToProperty("class", "avatar"); |
| 20 | 21 | } |
| 21 | 22 | |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | public function asIcon($icon, $title, $subHeader=NULL) { |
| 26 | 26 | $header=new HtmlHeader("header-" . $this->identifier); |
| 27 | 27 | $header->asIcon($icon, $title, $subHeader); |
| 28 | - if ($this->_inverted === false) |
|
| 29 | - $header->setInverted(); |
|
| 28 | + if ($this->_inverted === false) { |
|
| 29 | + $header->setInverted(); |
|
| 30 | + } |
|
| 30 | 31 | return $this->setContent($header); |
| 31 | 32 | } |
| 32 | 33 | |
@@ -41,14 +42,16 @@ discard block |
||
| 41 | 42 | } |
| 42 | 43 | |
| 43 | 44 | public function run(JsUtils $js) { |
| 44 | - if ($this->_container instanceof HtmlSingleElement) |
|
| 45 | - $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
| 45 | + if ($this->_container instanceof HtmlSingleElement) { |
|
| 46 | + $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
| 47 | + } |
|
| 46 | 48 | return parent::run($js); |
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | public function jsShow() { |
| 50 | - if (isset($this->_container)) |
|
| 51 | - return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
| 52 | + if (isset($this->_container)) { |
|
| 53 | + return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
| 54 | + } |
|
| 52 | 55 | } |
| 53 | 56 | |
| 54 | 57 | public function setBlurring() { |
@@ -21,10 +21,12 @@ |
||
| 21 | 21 | |
| 22 | 22 | private function createField($placeholder=NULL, $icon=NULL) { |
| 23 | 23 | $field=new HtmlInput($this->identifier); |
| 24 | - if (isset($placeholder)) |
|
| 25 | - $field->setPlaceholder($placeholder); |
|
| 26 | - if (isset($icon)) |
|
| 27 | - $field->addIcon($icon, Direction::RIGHT); |
|
| 24 | + if (isset($placeholder)) { |
|
| 25 | + $field->setPlaceholder($placeholder); |
|
| 26 | + } |
|
| 27 | + if (isset($icon)) { |
|
| 28 | + $field->addIcon($icon, Direction::RIGHT); |
|
| 29 | + } |
|
| 28 | 30 | //TODO check getField |
| 29 | 31 | $field->getDataField()->setClass("prompt"); |
| 30 | 32 | $this->content["field"]=$field; |
@@ -12,11 +12,13 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function __construct($identifier, $value=NULL, $label=NULL, $attributes=array()) { |
| 14 | 14 | parent::__construct($identifier, "div", "ui progress"); |
| 15 | - if (isset($value)) |
|
| 16 | - $this->setProperty("data-percent", $value); |
|
| 15 | + if (isset($value)) { |
|
| 16 | + $this->setProperty("data-percent", $value); |
|
| 17 | + } |
|
| 17 | 18 | $this->createBar(); |
| 18 | - if (isset($label)) |
|
| 19 | - $this->setLabel($label); |
|
| 19 | + if (isset($label)) { |
|
| 20 | + $this->setLabel($label); |
|
| 21 | + } |
|
| 20 | 22 | $this->_states=[ State::SUCCESS,State::WARNING,State::ERROR,State::ACTIVE,State::DISABLED ]; |
| 21 | 23 | $this->addToProperty("class", $attributes); |
| 22 | 24 | } |
@@ -111,8 +113,9 @@ discard block |
||
| 111 | 113 | * @see BaseHtml::run() |
| 112 | 114 | */ |
| 113 | 115 | public function run(JsUtils $js) { |
| 114 | - if (isset($this->_bsComponent) === false) |
|
| 115 | - $this->_bsComponent=$js->semantic()->progress("#" . $this->identifier, $this->_params); |
|
| 116 | + if (isset($this->_bsComponent) === false) { |
|
| 117 | + $this->_bsComponent=$js->semantic()->progress("#" . $this->identifier, $this->_params); |
|
| 118 | + } |
|
| 116 | 119 | $this->addEventsOnRun($js); |
| 117 | 120 | return $this->_bsComponent; |
| 118 | 121 | } |
@@ -25,8 +25,9 @@ |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function setDisabled($disable=true) { |
| 28 | - if($disable) |
|
| 29 | - $this->addState(State::DISABLED); |
|
| 28 | + if($disable) { |
|
| 29 | + $this->addState(State::DISABLED); |
|
| 30 | + } |
|
| 30 | 31 | return $this; |
| 31 | 32 | } |
| 32 | 33 | } |
| 33 | 34 | \ No newline at end of file |
@@ -45,8 +45,9 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function setVariations($variations) { |
| 47 | 47 | $this->setProperty("class", $this->_baseClass); |
| 48 | - if (\is_string($variations)) |
|
| 49 | - $variations=\explode(" ", $variations); |
|
| 48 | + if (\is_string($variations)) { |
|
| 49 | + $variations=\explode(" ", $variations); |
|
| 50 | + } |
|
| 50 | 51 | foreach ( $variations as $variation ) { |
| 51 | 52 | $this->addVariation($variation); |
| 52 | 53 | } |
@@ -59,8 +60,9 @@ discard block |
||
| 59 | 60 | } |
| 60 | 61 | |
| 61 | 62 | public function addVariations($variations=array()) { |
| 62 | - if (\is_string($variations)) |
|
| 63 | - $variations=\explode(" ", $variations); |
|
| 63 | + if (\is_string($variations)) { |
|
| 64 | + $variations=\explode(" ", $variations); |
|
| 65 | + } |
|
| 64 | 66 | foreach ( $variations as $variation ) { |
| 65 | 67 | $this->addVariation($variation); |
| 66 | 68 | } |
@@ -68,8 +70,9 @@ discard block |
||
| 68 | 70 | } |
| 69 | 71 | |
| 70 | 72 | public function addStates($states=array()) { |
| 71 | - if (\is_string($states)) |
|
| 72 | - $states=\explode(" ", $states); |
|
| 73 | + if (\is_string($states)) { |
|
| 74 | + $states=\explode(" ", $states); |
|
| 75 | + } |
|
| 73 | 76 | foreach ( $states as $state ) { |
| 74 | 77 | $this->addState($state); |
| 75 | 78 | } |
@@ -78,8 +81,9 @@ discard block |
||
| 78 | 81 | |
| 79 | 82 | public function setStates($states) { |
| 80 | 83 | $this->setProperty("class", $this->_baseClass); |
| 81 | - if (\is_string($states)) |
|
| 82 | - $states=\explode(" ", $states); |
|
| 84 | + if (\is_string($states)) { |
|
| 85 | + $states=\explode(" ", $states); |
|
| 86 | + } |
|
| 83 | 87 | foreach ( $states as $state ) { |
| 84 | 88 | $this->addState($state); |
| 85 | 89 | } |
@@ -111,8 +115,9 @@ discard block |
||
| 111 | 115 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
| 112 | 116 | */ |
| 113 | 117 | public function setDisabled($disable=true) { |
| 114 | - if($disable) |
|
| 115 | - $this->addToProperty("class", "disabled"); |
|
| 118 | + if($disable) { |
|
| 119 | + $this->addToProperty("class", "disabled"); |
|
| 120 | + } |
|
| 116 | 121 | return $this; |
| 117 | 122 | } |
| 118 | 123 | |