@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | $this->widgetIdentifier=$identifier; |
| 26 | 26 | $this->values=[]; |
| 27 | 27 | $this->afterCompile=[]; |
| 28 | - if(isset($instance)) |
|
| 29 | - $this->setInstance($instance); |
|
| 28 | + if(isset($instance)) { |
|
| 29 | + $this->setInstance($instance); |
|
| 30 | + } |
|
| 30 | 31 | $this->setCaptions($captions); |
| 31 | 32 | $this->captionCallback=NULL; |
| 32 | 33 | $this->defaultValueFunction=function($name,$value){return $value;}; |
@@ -62,7 +63,7 @@ discard block |
||
| 62 | 63 | while($index<$count){ |
| 63 | 64 | $values[]=$this->getValue($index++); |
| 64 | 65 | } |
| 65 | - }else{ |
|
| 66 | + } else{ |
|
| 66 | 67 | while($index<$count){ |
| 67 | 68 | if(array_search($index, $this->groupByFields)===false){ |
| 68 | 69 | $values[]=$this->getValue($index); |
@@ -74,14 +75,16 @@ discard block |
||
| 74 | 75 | } |
| 75 | 76 | |
| 76 | 77 | public function getIdentifier($index=NULL){ |
| 77 | - if(!isset($index)) |
|
| 78 | - $index=self::$index; |
|
| 78 | + if(!isset($index)) { |
|
| 79 | + $index=self::$index; |
|
| 80 | + } |
|
| 79 | 81 | $value=$index; |
| 80 | 82 | if(isset($this->values["identifier"])){ |
| 81 | - if(\is_string($this->values["identifier"])) |
|
| 82 | - $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
| 83 | - else |
|
| 84 | - $value=$this->values["identifier"]($index,$this->instance); |
|
| 83 | + if(\is_string($this->values["identifier"])) { |
|
| 84 | + $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
| 85 | + } else { |
|
| 86 | + $value=$this->values["identifier"]($index,$this->instance); |
|
| 87 | + } |
|
| 85 | 88 | } |
| 86 | 89 | return $value; |
| 87 | 90 | } |
@@ -111,16 +114,16 @@ discard block |
||
| 111 | 114 | if($property instanceof \ReflectionProperty){ |
| 112 | 115 | $value=$this->_getPropertyValue($property); |
| 113 | 116 | $propertyName=$property->getName(); |
| 114 | - }elseif(\is_callable($property) && array_search($property, ["system"])===false) |
|
| 115 | - $value=$property($this->instance); |
|
| 116 | - elseif(\is_array($property)){ |
|
| 117 | + } elseif(\is_callable($property) && array_search($property, ["system"])===false) { |
|
| 118 | + $value=$property($this->instance); |
|
| 119 | + } elseif(\is_array($property)){ |
|
| 117 | 120 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
| 118 | 121 | $value=\implode("", $values); |
| 119 | - }elseif(\is_string($property)){ |
|
| 122 | + } elseif(\is_string($property)){ |
|
| 120 | 123 | $value=$property; |
| 121 | 124 | if(isset($this->instance->{$property})){ |
| 122 | 125 | $value=$this->instance->{$property}; |
| 123 | - }elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
| 126 | + } elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
| 124 | 127 | $value=JReflection::callMethod($this->instance, $getter, []); |
| 125 | 128 | } |
| 126 | 129 | } |
@@ -130,7 +133,7 @@ discard block |
||
| 130 | 133 | protected function _postGetValue($index,$propertyName,$value){ |
| 131 | 134 | if(isset($this->values[$index])){ |
| 132 | 135 | $value= $this->values[$index]($value,$this->instance,$index,self::$index); |
| 133 | - }else{ |
|
| 136 | + } else{ |
|
| 134 | 137 | $value=$this->_getDefaultValue($propertyName,$value, $index); |
| 135 | 138 | } |
| 136 | 139 | if(isset($this->afterCompile[$index])){ |
@@ -144,7 +147,7 @@ discard block |
||
| 144 | 147 | public function insertField($index,$field,$key=null){ |
| 145 | 148 | if(isset($key)){ |
| 146 | 149 | array_splice( $this->visibleProperties, $index, 0, [$key=>$field] ); |
| 147 | - }else{ |
|
| 150 | + } else{ |
|
| 148 | 151 | array_splice( $this->visibleProperties, $index, 0, $field ); |
| 149 | 152 | } |
| 150 | 153 | return $this; |
@@ -165,17 +168,17 @@ discard block |
||
| 165 | 168 | if(isset($key)){ |
| 166 | 169 | if(\is_array($vb[$index])){ |
| 167 | 170 | $this->visibleProperties[$index][$key]=$field; |
| 168 | - }else{ |
|
| 171 | + } else{ |
|
| 169 | 172 | $this->visibleProperties[$index]=[$vb[$index],$key=>$field]; |
| 170 | 173 | } |
| 171 | - }else{ |
|
| 174 | + } else{ |
|
| 172 | 175 | if(\is_array($vb[$index])){ |
| 173 | 176 | $this->visibleProperties[$index][]=$field; |
| 174 | - }else{ |
|
| 177 | + } else{ |
|
| 175 | 178 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
| 176 | 179 | } |
| 177 | 180 | } |
| 178 | - }else{ |
|
| 181 | + } else{ |
|
| 179 | 182 | return $this->insertField($index, $field); |
| 180 | 183 | } |
| 181 | 184 | return $this; |
@@ -184,7 +187,7 @@ discard block |
||
| 184 | 187 | public function addField($field,$key=null){ |
| 185 | 188 | if(isset($key)){ |
| 186 | 189 | $this->visibleProperties[]=[$key=>$field]; |
| 187 | - }else{ |
|
| 190 | + } else{ |
|
| 188 | 191 | $this->visibleProperties[]=$field; |
| 189 | 192 | } |
| 190 | 193 | return $this; |
@@ -211,9 +214,9 @@ discard block |
||
| 211 | 214 | $property=$this->getProperty($index); |
| 212 | 215 | if($property instanceof \ReflectionProperty){ |
| 213 | 216 | $result=$property->getName(); |
| 214 | - }elseif(\is_callable($property)){ |
|
| 217 | + } elseif(\is_callable($property)){ |
|
| 215 | 218 | $result=$this->visibleProperties[$index]; |
| 216 | - }else{ |
|
| 219 | + } else{ |
|
| 217 | 220 | $result=$property; |
| 218 | 221 | } |
| 219 | 222 | return $result; |
@@ -233,7 +236,7 @@ discard block |
||
| 233 | 236 | $this->reflect=new \ReflectionClass($instance); |
| 234 | 237 | if(JArray::count($this->visibleProperties)===0){ |
| 235 | 238 | $this->properties=$this->getDefaultProperties(); |
| 236 | - }else{ |
|
| 239 | + } else{ |
|
| 237 | 240 | foreach ($this->visibleProperties as $property){ |
| 238 | 241 | $this->setInstanceProperty($property); |
| 239 | 242 | } |
@@ -244,22 +247,23 @@ discard block |
||
| 244 | 247 | private function setInstanceProperty($property){ |
| 245 | 248 | if(\is_callable($property)){ |
| 246 | 249 | $this->properties[]=$property; |
| 247 | - }elseif(\is_string($property)){ |
|
| 250 | + } elseif(\is_string($property)){ |
|
| 248 | 251 | try{ |
| 249 | 252 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 250 | 253 | $rProperty=$this->reflect->getProperty($property); |
| 251 | 254 | $this->properties[]=$rProperty; |
| 252 | - }catch(\Exception $e){ |
|
| 255 | + } catch(\Exception $e){ |
|
| 253 | 256 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 254 | 257 | $this->properties[]=$property; |
| 255 | 258 | } |
| 256 | - }elseif(\is_int($property)){ |
|
| 259 | + } elseif(\is_int($property)){ |
|
| 257 | 260 | $props=$this->getDefaultProperties(); |
| 258 | - if(isset($props[$property])) |
|
| 259 | - $this->properties[]=$props[$property]; |
|
| 260 | - else |
|
| 261 | - $this->properties[]=$property; |
|
| 262 | - }else{ |
|
| 261 | + if(isset($props[$property])) { |
|
| 262 | + $this->properties[]=$props[$property]; |
|
| 263 | + } else { |
|
| 264 | + $this->properties[]=$property; |
|
| 265 | + } |
|
| 266 | + } else{ |
|
| 263 | 267 | $this->properties[]=$property; |
| 264 | 268 | } |
| 265 | 269 | } |
@@ -303,12 +307,13 @@ discard block |
||
| 303 | 307 | if(isset($this->captions[$index])){ |
| 304 | 308 | return $this->captions[$index]; |
| 305 | 309 | } |
| 306 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 307 | - return $this->properties[$index]->getName(); |
|
| 308 | - elseif(\is_callable($this->properties[$index])) |
|
| 309 | - return ""; |
|
| 310 | - else |
|
| 311 | - return $this->properties[$index]; |
|
| 310 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
| 311 | + return $this->properties[$index]->getName(); |
|
| 312 | + } elseif(\is_callable($this->properties[$index])) { |
|
| 313 | + return ""; |
|
| 314 | + } else { |
|
| 315 | + return $this->properties[$index]; |
|
| 316 | + } |
|
| 312 | 317 | } |
| 313 | 318 | |
| 314 | 319 | public function getCaptions(){ |
@@ -323,7 +328,7 @@ discard block |
||
| 323 | 328 | $captions[]=""; |
| 324 | 329 | $moreAdded=true; |
| 325 | 330 | } |
| 326 | - }else{ |
|
| 331 | + } else{ |
|
| 327 | 332 | $captions=[]; |
| 328 | 333 | $index=0; |
| 329 | 334 | while($index<$count){ |
@@ -341,8 +346,9 @@ discard block |
||
| 341 | 346 | } |
| 342 | 347 | |
| 343 | 348 | public function setCaption($index,$caption){ |
| 344 | - if(isset($this->captions)===false) |
|
| 345 | - $this->captions=[]; |
|
| 349 | + if(isset($this->captions)===false) { |
|
| 350 | + $this->captions=[]; |
|
| 351 | + } |
|
| 346 | 352 | $this->captions[$index]=$caption; |
| 347 | 353 | return $this; |
| 348 | 354 | } |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | private function afterInsert($item) { |
| 65 | - if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false) |
|
| 66 | - $item->addToPropertyCtrl("class", "item", array ("item" )); |
|
| 67 | - else { |
|
| 65 | + if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false) { |
|
| 66 | + $item->addToPropertyCtrl("class", "item", array ("item" )); |
|
| 67 | + } else { |
|
| 68 | 68 | $this->setSecondary(); |
| 69 | 69 | } |
| 70 | 70 | return $item; |
@@ -79,8 +79,9 @@ discard block |
||
| 79 | 79 | public function addItem($item) { |
| 80 | 80 | $number=$item; |
| 81 | 81 | $item=parent::addItem($this->getItemToInsert($item)); |
| 82 | - if(\is_int($number)) |
|
| 83 | - $item->setProperty("data-page", $number); |
|
| 82 | + if(\is_int($number)) { |
|
| 83 | + $item->setProperty("data-page", $number); |
|
| 84 | + } |
|
| 84 | 85 | return $this->afterInsert($item); |
| 85 | 86 | } |
| 86 | 87 | |
@@ -149,10 +150,11 @@ discard block |
||
| 149 | 150 | } |
| 150 | 151 | |
| 151 | 152 | public function setSecondary($value=true) { |
| 152 | - if($value) |
|
| 153 | - $this->addToProperty("class", "secondary"); |
|
| 154 | - else |
|
| 155 | - $this->removePropertyValue("class", "secondary"); |
|
| 153 | + if($value) { |
|
| 154 | + $this->addToProperty("class", "secondary"); |
|
| 155 | + } else { |
|
| 156 | + $this->removePropertyValue("class", "secondary"); |
|
| 157 | + } |
|
| 156 | 158 | return $this; |
| 157 | 159 | } |
| 158 | 160 | |
@@ -172,8 +174,9 @@ discard block |
||
| 172 | 174 | $this->apply(function (HtmlDoubleElement &$item) { |
| 173 | 175 | $item->setTagName("a"); |
| 174 | 176 | }); |
| 175 | - if ($vertical === true) |
|
| 176 | - $this->setVertical(); |
|
| 177 | + if ($vertical === true) { |
|
| 178 | + $this->setVertical(); |
|
| 179 | + } |
|
| 177 | 180 | return $this->addToProperty("class", "tabular"); |
| 178 | 181 | } |
| 179 | 182 | |
@@ -202,10 +205,11 @@ discard block |
||
| 202 | 205 | */ |
| 203 | 206 | public function fromDatabaseObject($object, $function) { |
| 204 | 207 | $return=$function($object); |
| 205 | - if (\is_array($return)) |
|
| 206 | - $this->addItems($return); |
|
| 207 | - else |
|
| 208 | - $this->addItem($return); |
|
| 208 | + if (\is_array($return)) { |
|
| 209 | + $this->addItems($return); |
|
| 210 | + } else { |
|
| 211 | + $this->addItem($return); |
|
| 212 | + } |
|
| 209 | 213 | } |
| 210 | 214 | |
| 211 | 215 | /** |
@@ -238,8 +242,9 @@ discard block |
||
| 238 | 242 | } |
| 239 | 243 | |
| 240 | 244 | public function run(JsUtils $js){ |
| 241 | - if($this->identifier!=="" && !isset($this->_bsComponent)) |
|
| 242 | - $this->onClick('if(!$(this).hasClass("dropdown")&&!$(this).hasClass("no-active")){$(this).addClass("active").siblings().removeClass("active");}',false,false); |
|
| 245 | + if($this->identifier!=="" && !isset($this->_bsComponent)) { |
|
| 246 | + $this->onClick('if(!$(this).hasClass("dropdown")&&!$(this).hasClass("no-active")){$(this).addClass("active").siblings().removeClass("active");}',false,false); |
|
| 247 | + } |
|
| 243 | 248 | $result= parent::run($js); |
| 244 | 249 | return $result->setItemSelector(">.item"); |
| 245 | 250 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | if(isset($value)){ |
| 36 | 36 | if($value instanceof HtmlSemDoubleElement){ |
| 37 | 37 | $text=$value; |
| 38 | - }else{ |
|
| 38 | + } else{ |
|
| 39 | 39 | $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
| 40 | 40 | $text->setClass("text"); |
| 41 | 41 | $this->setValue($value); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | if(!$item instanceof HtmlDropdownItem){ |
| 114 | 114 | $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
| 115 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
| 115 | + } elseif($itemO instanceof HtmlDropdownItem){ |
|
| 116 | 116 | $this->addToProperty("class", "vertical"); |
| 117 | 117 | } |
| 118 | 118 | return $itemO; |
@@ -126,8 +126,9 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public function addInput($name){ |
| 129 | - if(!isset($name)) |
|
| 130 | - $name="input-".$this->identifier; |
|
| 129 | + if(!isset($name)) { |
|
| 130 | + $name="input-".$this->identifier; |
|
| 131 | + } |
|
| 131 | 132 | $this->setAction("activate"); |
| 132 | 133 | $this->input=new HtmlInput($name,"hidden"); |
| 133 | 134 | $this->input->setIdentifier("input-".$this->identifier); |
@@ -186,7 +187,7 @@ discard block |
||
| 186 | 187 | foreach ($items as $k=>$v){ |
| 187 | 188 | $this->addItem($v)->setData($k); |
| 188 | 189 | } |
| 189 | - }else{ |
|
| 190 | + } else{ |
|
| 190 | 191 | foreach ($items as $item){ |
| 191 | 192 | $this->addItem($item); |
| 192 | 193 | } |
@@ -208,8 +209,7 @@ discard block |
||
| 208 | 209 | $c=$this->items[$i++]; |
| 209 | 210 | if(isset($c)){ |
| 210 | 211 | $c->setProperty($property,$value); |
| 211 | - } |
|
| 212 | - else{ |
|
| 212 | + } else{ |
|
| 213 | 213 | return $this; |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | if($dropdown===false){ |
| 241 | 241 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
| 242 | 242 | $dropdown="menu"; |
| 243 | - }else{ |
|
| 243 | + } else{ |
|
| 244 | 244 | $dropdown="dropdown"; |
| 245 | 245 | $this->mClass="menu"; |
| 246 | 246 | } |
@@ -261,22 +261,25 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | public function asButton($floating=false){ |
| 263 | 263 | $this->removeArrow(); |
| 264 | - if($floating) |
|
| 265 | - $this->addToProperty("class", "floating"); |
|
| 264 | + if($floating) { |
|
| 265 | + $this->addToProperty("class", "floating"); |
|
| 266 | + } |
|
| 266 | 267 | $this->removePropertyValue("class", "selection"); |
| 267 | 268 | return $this->addToProperty("class", "button"); |
| 268 | 269 | } |
| 269 | 270 | |
| 270 | 271 | public function asSelect($name=NULL,$multiple=false,$selection=true){ |
| 271 | 272 | $this->_multiple=$multiple; |
| 272 | - if(isset($name)) |
|
| 273 | - $this->addInput($name); |
|
| 273 | + if(isset($name)) { |
|
| 274 | + $this->addInput($name); |
|
| 275 | + } |
|
| 274 | 276 | if($multiple){ |
| 275 | 277 | $this->addToProperty("class", "multiple"); |
| 276 | 278 | } |
| 277 | 279 | if ($selection){ |
| 278 | - if($this->propertyContains("class", "button")===false) |
|
| 279 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 280 | + if($this->propertyContains("class", "button")===false) { |
|
| 281 | + $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 282 | + } |
|
| 280 | 283 | } |
| 281 | 284 | return $this; |
| 282 | 285 | } |
@@ -288,8 +291,9 @@ discard block |
||
| 288 | 291 | |
| 289 | 292 | public function setSelect($name=NULL,$multiple=false){ |
| 290 | 293 | $this->_template='<%tagName% id="%identifier%" %properties%>%items%</%tagName%>'; |
| 291 | - if(!isset($name)) |
|
| 292 | - $name="select-".$this->identifier; |
|
| 294 | + if(!isset($name)) { |
|
| 295 | + $name="select-".$this->identifier; |
|
| 296 | + } |
|
| 293 | 297 | $this->input=null; |
| 294 | 298 | if($multiple){ |
| 295 | 299 | $this->setProperty("multiple", true); |
@@ -330,12 +334,13 @@ discard block |
||
| 330 | 334 | $value=$this->value; |
| 331 | 335 | if(isset($this->input) && isset($value)){ |
| 332 | 336 | $this->input->setProperty("value", $value); |
| 333 | - }else{ |
|
| 337 | + } else{ |
|
| 334 | 338 | $this->setProperty("value", $value); |
| 335 | 339 | } |
| 336 | 340 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
| 337 | - if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) |
|
| 338 | - $textElement->setContent($value); |
|
| 341 | + if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) { |
|
| 342 | + $textElement->setContent($value); |
|
| 343 | + } |
|
| 339 | 344 | return $this; |
| 340 | 345 | } |
| 341 | 346 | |