@@ -39,8 +39,9 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function getParam($key) { |
| 41 | 41 | $value=null; |
| 42 | - if (array_key_exists($key, $this->params)) |
|
| 43 | - $value=$this->params [$key]; |
|
| 42 | + if (array_key_exists($key, $this->params)) { |
|
| 43 | + $value=$this->params [$key]; |
|
| 44 | + } |
|
| 44 | 45 | return $value; |
| 45 | 46 | } |
| 46 | 47 | |
@@ -49,16 +50,18 @@ discard block |
||
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | public function compile(JsUtils $js=NULL) { |
| 52 | - if ($js==NULL) |
|
| 53 | - $js=$this->js; |
|
| 53 | + if ($js==NULL) { |
|
| 54 | + $js=$this->js; |
|
| 55 | + } |
|
| 54 | 56 | $script=$this->getScript(); |
| 55 | 57 | $js->addToCompile($script); |
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | protected function setParamCtrl($key, $value, $typeCtrl) { |
| 59 | 61 | if (is_array($typeCtrl)) { |
| 60 | - if (array_search($value, $typeCtrl)===false) |
|
| 61 | - throw new \Exception("La valeur passée a propriété `".$key."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
| 62 | + if (array_search($value, $typeCtrl)===false) { |
|
| 63 | + throw new \Exception("La valeur passée a propriété `".$key."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
| 64 | + } |
|
| 62 | 65 | } else { |
| 63 | 66 | if (!$typeCtrl($value)) { |
| 64 | 67 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key); |
@@ -70,9 +73,9 @@ discard block |
||
| 70 | 73 | public function setParams($params) { |
| 71 | 74 | foreach ( $params as $k => $v ) { |
| 72 | 75 | $method="set".ucfirst($k); |
| 73 | - if (method_exists($this, $method)) |
|
| 74 | - $this->$method($v); |
|
| 75 | - else { |
|
| 76 | + if (method_exists($this, $method)) { |
|
| 77 | + $this->$method($v); |
|
| 78 | + } else { |
|
| 76 | 79 | $this->setParam($k, $v); |
| 77 | 80 | trigger_error("`".$k."` property n'existe pas", E_USER_NOTICE); |
| 78 | 81 | } |
@@ -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 |
@@ -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 | |
@@ -14,8 +14,9 @@ |
||
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function compile(JsUtils $js=null) { |
| 17 | - if ($js==null) |
|
| 18 | - return; |
|
| 17 | + if ($js==null) { |
|
| 18 | + return; |
|
| 19 | + } |
|
| 19 | 20 | $result=""; |
| 20 | 21 | $params="{}"; |
| 21 | 22 | $callback=NULL; |