@@ -41,8 +41,9 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function compile($internal=false) { |
| 44 | - if ($internal===false&&$this->autoCompile===true) |
|
| 45 | - throw new \Exception("Impossible to compile if autoCompile is set to 'true'"); |
|
| 44 | + if ($internal===false&&$this->autoCompile===true) { |
|
| 45 | + throw new \Exception("Impossible to compile if autoCompile is set to 'true'"); |
|
| 46 | + } |
|
| 46 | 47 | foreach ( $this->components as $component ) { |
| 47 | 48 | $component->compile(); |
| 48 | 49 | } |
@@ -53,13 +54,16 @@ discard block |
||
| 53 | 54 | } |
| 54 | 55 | |
| 55 | 56 | public function addComponent(SimpleComponent $component, $attachTo, $params) { |
| 56 | - if ($this->autoCompile) |
|
| 57 | - $this->components []=$component; |
|
| 58 | - if (isset($attachTo)) |
|
| 59 | - $component->attach($attachTo); |
|
| 60 | - if (isset($params)) |
|
| 61 | - if (is_array($params)) |
|
| 57 | + if ($this->autoCompile) { |
|
| 58 | + $this->components []=$component; |
|
| 59 | + } |
|
| 60 | + if (isset($attachTo)) { |
|
| 61 | + $component->attach($attachTo); |
|
| 62 | + } |
|
| 63 | + if (isset($params)) { |
|
| 64 | + if (is_array($params)) |
|
| 62 | 65 | $component->setParams($params); |
| 66 | + } |
|
| 63 | 67 | return $component; |
| 64 | 68 | } |
| 65 | 69 | |
@@ -24,14 +24,14 @@ |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public static function getConstantValues($postFix="",$prefixBefore=false) { |
| 27 | - if ($postFix == "") |
|
| 28 | - return \array_values(self::getConstants()); |
|
| 29 | - else { |
|
| 27 | + if ($postFix == "") { |
|
| 28 | + return \array_values(self::getConstants()); |
|
| 29 | + } else { |
|
| 30 | 30 | if($prefixBefore===false){ |
| 31 | 31 | return \array_map(function ($elem) use($postFix) { |
| 32 | 32 | return $elem . " " . $postFix; |
| 33 | 33 | }, \array_values(self::getConstants())); |
| 34 | - }else{ |
|
| 34 | + } else{ |
|
| 35 | 35 | return \array_map(function ($elem) use($postFix) { |
| 36 | 36 | return $postFix." ".$elem; |
| 37 | 37 | }, \array_values(self::getConstants())); |
@@ -16,8 +16,9 @@ discard block |
||
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function setValue($value) { |
| 19 | - if(isset($value)) |
|
| 20 | - $this->setProperty("value", $value); |
|
| 19 | + if(isset($value)) { |
|
| 20 | + $this->setProperty("value", $value); |
|
| 21 | + } |
|
| 21 | 22 | return $this; |
| 22 | 23 | } |
| 23 | 24 | |
@@ -27,11 +28,13 @@ discard block |
||
| 27 | 28 | |
| 28 | 29 | public function setPlaceholder($value){ |
| 29 | 30 | if(JString::isNull($value)){ |
| 30 | - if(JString::isNotNull($this->identifier)) |
|
| 31 | - $value=\ucfirst($this->identifier); |
|
| 31 | + if(JString::isNotNull($this->identifier)) { |
|
| 32 | + $value=\ucfirst($this->identifier); |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | + if(JString::isNotNull($value)) { |
|
| 36 | + $this->setProperty("placeholder", $value); |
|
| 32 | 37 | } |
| 33 | - if(JString::isNotNull($value)) |
|
| 34 | - $this->setProperty("placeholder", $value); |
|
| 35 | 38 | return $this; |
| 36 | 39 | } |
| 37 | 40 | } |
| 38 | 41 | \ No newline at end of file |
@@ -11,18 +11,21 @@ |
||
| 11 | 11 | parent::__construct($identifier, "textarea"); |
| 12 | 12 | $this->setValue($value); |
| 13 | 13 | $this->setPlaceholder($placeholder); |
| 14 | - if(isset($rows)) |
|
| 15 | - $this->setRows($rows); |
|
| 14 | + if(isset($rows)) { |
|
| 15 | + $this->setRows($rows); |
|
| 16 | + } |
|
| 16 | 17 | } |
| 17 | 18 | public function setValue($value) { |
| 18 | - if(isset($value)) |
|
| 19 | - $this->setContent($value); |
|
| 19 | + if(isset($value)) { |
|
| 20 | + $this->setContent($value); |
|
| 21 | + } |
|
| 20 | 22 | return $this; |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | 25 | public function setPlaceholder($value){ |
| 24 | - if(JString::isNotNull($value)) |
|
| 25 | - $this->setProperty("placeholder", $value); |
|
| 26 | + if(JString::isNotNull($value)) { |
|
| 27 | + $this->setProperty("placeholder", $value); |
|
| 28 | + } |
|
| 26 | 29 | return $this; |
| 27 | 30 | } |
| 28 | 31 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | public function addOption($element,$value="",$selected=false){ |
| 26 | 26 | if($element instanceof HtmlOption){ |
| 27 | 27 | $option=$element; |
| 28 | - }else{ |
|
| 28 | + } else{ |
|
| 29 | 29 | $option=new HtmlOption($this->identifier."-".count($this->options), $element,$value); |
| 30 | 30 | } |
| 31 | 31 | if($selected || $option->getValue()==$this->getProperty("value")){ |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | foreach ($array as $k=>$v){ |
| 65 | 65 | $this->addOption($v, $k); |
| 66 | 66 | } |
| 67 | - }else{ |
|
| 67 | + } else{ |
|
| 68 | 68 | foreach ($array as $v){ |
| 69 | 69 | $this->addOption($v, $v); |
| 70 | 70 | } |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | private static function containsElement($input) { |
| 27 | 27 | foreach ( $input as $v ) { |
| 28 | - if (\is_object($v) === true || \is_array($v)) |
|
| 29 | - return true; |
|
| 28 | + if (\is_object($v) === true || \is_array($v)) { |
|
| 29 | + return true; |
|
| 30 | + } |
|
| 30 | 31 | } |
| 31 | 32 | return false; |
| 32 | 33 | } |
@@ -44,12 +45,13 @@ discard block |
||
| 44 | 45 | |
| 45 | 46 | public static function wrapObjects($input, $js=NULL, $separator=' ', $valueQuote='"') { |
| 46 | 47 | return implode($separator, array_map(function ($v) use($js, $separator, $valueQuote) { |
| 47 | - if (is_object($v)) |
|
| 48 | - return $v->compile($js); |
|
| 49 | - elseif (\is_array($v)) { |
|
| 48 | + if (is_object($v)) { |
|
| 49 | + return $v->compile($js); |
|
| 50 | + } elseif (\is_array($v)) { |
|
| 50 | 51 | return self::wrap($v, $js, $separator, $valueQuote); |
| 51 | - } else |
|
| 52 | - return $v; |
|
| 52 | + } else { |
|
| 53 | + return $v; |
|
| 54 | + } |
|
| 53 | 55 | }, $input)); |
| 54 | 56 | } |
| 55 | 57 | } |
| 56 | 58 | \ No newline at end of file |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | foreach ($items as $k=>$v){ |
| 24 | 24 | $this->addItem([$k,$v]); |
| 25 | 25 | } |
| 26 | - }else{ |
|
| 26 | + } else{ |
|
| 27 | 27 | foreach ($items as $item){ |
| 28 | 28 | $this->addItem($item); |
| 29 | 29 | } |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | * @return \Ajax\common\html\HtmlDoubleElement |
| 72 | 72 | */ |
| 73 | 73 | public function getItem($index) { |
| 74 | - if (is_int($index)) |
|
| 75 | - return $this->content[$index]; |
|
| 76 | - else { |
|
| 74 | + if (is_int($index)) { |
|
| 75 | + return $this->content[$index]; |
|
| 76 | + } else { |
|
| 77 | 77 | $elm=$this->getElementById($index, $this->content); |
| 78 | 78 | return $elm; |
| 79 | 79 | } |
@@ -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 | } |
@@ -358,15 +363,18 @@ discard block |
||
| 358 | 363 | $flag=false; |
| 359 | 364 | $index=0; |
| 360 | 365 | while ( !$flag && $index < sizeof($elements) ) { |
| 361 | - if ($elements[$index] instanceof BaseHtml) |
|
| 362 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
| 366 | + if ($elements[$index] instanceof BaseHtml) { |
|
| 367 | + $flag=($elements[$index]->getIdentifier() === $identifier); |
|
| 368 | + } |
|
| 363 | 369 | $index++; |
| 364 | 370 | } |
| 365 | - if ($flag === true) |
|
| 366 | - return $elements[$index - 1]; |
|
| 371 | + if ($flag === true) { |
|
| 372 | + return $elements[$index - 1]; |
|
| 373 | + } |
|
| 367 | 374 | } elseif ($elements instanceof BaseHtml) { |
| 368 | - if ($elements->getIdentifier() === $identifier) |
|
| 369 | - return $elements; |
|
| 375 | + if ($elements->getIdentifier() === $identifier) { |
|
| 376 | + return $elements; |
|
| 377 | + } |
|
| 370 | 378 | } |
| 371 | 379 | return null; |
| 372 | 380 | } |
@@ -376,15 +384,18 @@ discard block |
||
| 376 | 384 | $flag=false; |
| 377 | 385 | $index=0; |
| 378 | 386 | while ( !$flag && $index < sizeof($elements) ) { |
| 379 | - if ($elements[$index] instanceof BaseHtml) |
|
| 380 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
| 387 | + if ($elements[$index] instanceof BaseHtml) { |
|
| 388 | + $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
| 389 | + } |
|
| 381 | 390 | $index++; |
| 382 | 391 | } |
| 383 | - if ($flag === true) |
|
| 384 | - return $elements[$index - 1]; |
|
| 392 | + if ($flag === true) { |
|
| 393 | + return $elements[$index - 1]; |
|
| 394 | + } |
|
| 385 | 395 | } elseif ($elements instanceof BaseHtml) { |
| 386 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
| 387 | - return $elements; |
|
| 396 | + if ($elements->propertyContains($propertyName, $value) === true) { |
|
| 397 | + return $elements; |
|
| 398 | + } |
|
| 388 | 399 | } |
| 389 | 400 | return null; |
| 390 | 401 | } |
@@ -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 | |