@@ -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 | } |
@@ -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 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
31 | 31 | $result=""; |
32 | - foreach ( $this->_elements as $element ) { |
|
32 | + foreach ($this->_elements as $element) { |
|
33 | 33 | if ($element instanceof PhBsElement) |
34 | 34 | $result.=$element->compile($js, $view); |
35 | 35 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | public function run(JsUtils $js) { |
40 | - foreach ( $this->_elements as $element ) { |
|
40 | + foreach ($this->_elements as $element) { |
|
41 | 41 | if ($element instanceof PhBsElement) |
42 | 42 | $element->run($js); |
43 | 43 | } |
@@ -30,16 +30,18 @@ |
||
30 | 30 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
31 | 31 | $result=""; |
32 | 32 | foreach ( $this->_elements as $element ) { |
33 | - if ($element instanceof PhBsElement) |
|
34 | - $result.=$element->compile($js, $view); |
|
33 | + if ($element instanceof PhBsElement) { |
|
34 | + $result.=$element->compile($js, $view); |
|
35 | + } |
|
35 | 36 | } |
36 | 37 | return $result; |
37 | 38 | } |
38 | 39 | |
39 | 40 | public function run(JsUtils $js) { |
40 | 41 | foreach ( $this->_elements as $element ) { |
41 | - if ($element instanceof PhBsElement) |
|
42 | - $element->run($js); |
|
42 | + if ($element instanceof PhBsElement) { |
|
43 | + $element->run($js); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | } |
45 | 47 | } |
46 | 48 | \ No newline at end of file |
@@ -51,7 +51,7 @@ |
||
51 | 51 | |
52 | 52 | public function render($attributes=null) { |
53 | 53 | $attrs=$this->element->getAttributes(); |
54 | - foreach ( $attrs as $key => $value ) { |
|
54 | + foreach ($attrs as $key => $value) { |
|
55 | 55 | $this->htmlElement->setProperty($key, $value); |
56 | 56 | } |
57 | 57 | if (isset($attributes)) |
@@ -54,8 +54,9 @@ |
||
54 | 54 | foreach ( $attrs as $key => $value ) { |
55 | 55 | $this->htmlElement->setProperty($key, $value); |
56 | 56 | } |
57 | - if (isset($attributes)) |
|
58 | - $this->htmlElement->addProperties($attributes); |
|
57 | + if (isset($attributes)) { |
|
58 | + $this->htmlElement->addProperties($attributes); |
|
59 | + } |
|
59 | 60 | $this->htmlElement->setIdentifier($this->element->getName()); |
60 | 61 | $this->htmlElement->setValue($this->element->getValue()); |
61 | 62 |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | * @version 1.001 |
11 | 11 | */ |
12 | 12 | abstract class BaseComponent { |
13 | - public $jquery_code_for_compile=array (); |
|
14 | - protected $params=array (); |
|
13 | + public $jquery_code_for_compile=array(); |
|
14 | + protected $params=array(); |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (is_array($typeCtrl)) { |
60 | 60 | if (array_search($value, $typeCtrl)===false) |
61 | 61 | throw new \Exception("La valeur passée a propriété `".$key."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
62 | - } else { |
|
62 | + }else { |
|
63 | 63 | if (!$typeCtrl($value)) { |
64 | 64 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key); |
65 | 65 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | public function setParams($params) { |
71 | - foreach ( $params as $k => $v ) { |
|
71 | + foreach ($params as $k => $v) { |
|
72 | 72 | $method="set".ucfirst($k); |
73 | 73 | if (method_exists($this, $method)) |
74 | 74 | $this->$method($v); |
@@ -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 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | public static function getConstants() { |
15 | 15 | if (self::$constCacheArray==NULL) { |
16 | - self::$constCacheArray=[ ]; |
|
16 | + self::$constCacheArray=[]; |
|
17 | 17 | } |
18 | 18 | $calledClass=get_called_class(); |
19 | 19 | if (!array_key_exists($calledClass, self::$constCacheArray)) { |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __construct($autoCompile=true) { |
29 | 29 | $this->autoCompile=$autoCompile; |
30 | - $this->components=array (); |
|
31 | - $this->htmlComponents=array (); |
|
30 | + $this->components=array(); |
|
31 | + $this->htmlComponents=array(); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function isAutoCompile() { |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | public function compile($internal=false) { |
44 | - if ($internal===false&&$this->autoCompile===true) |
|
44 | + if ($internal===false && $this->autoCompile===true) |
|
45 | 45 | throw new \Exception("Impossible to compile if autoCompile is set to 'true'"); |
46 | - foreach ( $this->components as $component ) { |
|
46 | + foreach ($this->components as $component) { |
|
47 | 47 | $component->compile(); |
48 | 48 | } |
49 | 49 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | public function compileHtml(JsUtils $js=NULL, View $view=NULL) { |
73 | - foreach ( $this->htmlComponents as $htmlComponent ) { |
|
73 | + foreach ($this->htmlComponents as $htmlComponent) { |
|
74 | 74 | $htmlComponent->compile($js, $view); |
75 | 75 | } |
76 | 76 | } |
@@ -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 | } |
@@ -54,13 +55,16 @@ discard block |
||
54 | 55 | } |
55 | 56 | |
56 | 57 | public function addComponent(SimpleComponent $component, $attachTo, $params) { |
57 | - if ($this->autoCompile) |
|
58 | - $this->components []=$component; |
|
59 | - if (isset($attachTo)) |
|
60 | - $component->attach($attachTo); |
|
61 | - if (isset($params)) |
|
62 | - if (is_array($params)) |
|
58 | + if ($this->autoCompile) { |
|
59 | + $this->components []=$component; |
|
60 | + } |
|
61 | + if (isset($attachTo)) { |
|
62 | + $component->attach($attachTo); |
|
63 | + } |
|
64 | + if (isset($params)) { |
|
65 | + if (is_array($params)) |
|
63 | 66 | $component->setParams($params); |
67 | + } |
|
64 | 68 | return $component; |
65 | 69 | } |
66 | 70 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | public function compile($keyAndvalues) { |
27 | 27 | $result=$this->mask; |
28 | - foreach ( $keyAndvalues as $k => $v ) { |
|
28 | + foreach ($keyAndvalues as $k => $v) { |
|
29 | 29 | $result=str_ireplace("%{$k}%", $v, $result); |
30 | 30 | } |
31 | 31 | return $result; |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | |
17 | 17 | public function __construct(JsUtils $js) { |
18 | 18 | parent::__construct($js); |
19 | - $this->events=array (); |
|
19 | + $this->events=array(); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | protected function compileEvents() { |
23 | - foreach ( $this->events as $event => $jsCode ) { |
|
23 | + foreach ($this->events as $event => $jsCode) { |
|
24 | 24 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});"; |
25 | 25 | } |
26 | 26 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $result=implode("\n", $this->jquery_code_for_compile); |
30 | 30 | $result=str_ireplace("\"%", "", $result); |
31 | 31 | $result=str_ireplace("%\"", "", $result); |
32 | - $result=str_replace(array ( |
|
32 | + $result=str_replace(array( |
|
33 | 33 | "\\n", |
34 | 34 | "\\r", |
35 | 35 | "\\t" |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | public function getScript() { |
41 | 41 | $allParams=$this->params; |
42 | - $this->jquery_code_for_compile=array (); |
|
42 | + $this->jquery_code_for_compile=array(); |
|
43 | 43 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");"; |
44 | 44 | $this->compileEvents(); |
45 | 45 | return $this->compileJQueryCode(); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | if (is_array($typeCtrl)) { |
67 | 67 | if (array_search($value, $typeCtrl)===false) |
68 | 68 | throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
69 | - } else { |
|
69 | + }else { |
|
70 | 70 | if (!$typeCtrl($value)) { |
71 | 71 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." au composant ".$this->uiName); |
72 | 72 | } |
@@ -64,8 +64,9 @@ |
||
64 | 64 | |
65 | 65 | protected function setParamCtrl($key, $value, $typeCtrl) { |
66 | 66 | if (is_array($typeCtrl)) { |
67 | - if (array_search($value, $typeCtrl)===false) |
|
68 | - throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
67 | + if (array_search($value, $typeCtrl)===false) { |
|
68 | + throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
69 | + } |
|
69 | 70 | } else { |
70 | 71 | if (!$typeCtrl($value)) { |
71 | 72 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." au composant ".$this->uiName); |
@@ -7,8 +7,8 @@ |
||
7 | 7 | class DefaultConfig extends Config { |
8 | 8 | |
9 | 9 | public function __construct() { |
10 | - parent::__construct(array ( |
|
11 | - "formElementsPrefix" => array ( |
|
10 | + parent::__construct(array( |
|
11 | + "formElementsPrefix" => array( |
|
12 | 12 | "txt" => "input_text", |
13 | 13 | "btn" => "button", |
14 | 14 | "ck" => "checkbox", |