@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use Ajax\common\JsCode; |
7 | 7 | |
8 | 8 | class SimpleBsComponent extends SimpleComponent { |
9 | - protected $events=array (); |
|
10 | - protected $jsCodes=array (); |
|
9 | + protected $events=array(); |
|
10 | + protected $jsCodes=array(); |
|
11 | 11 | |
12 | 12 | public function addEvent($event, $jsCode) { |
13 | 13 | $this->events [$event]=$jsCode; |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | |
16 | 16 | public function getScript() { |
17 | 17 | parent::getScript(); |
18 | - foreach ( $this->jsCodes as $jsCode ) { |
|
19 | - $this->jquery_code_for_compile []=$jsCode->compile(array ( |
|
18 | + foreach ($this->jsCodes as $jsCode) { |
|
19 | + $this->jquery_code_for_compile []=$jsCode->compile(array( |
|
20 | 20 | "identifier" => $this->attachTo |
21 | 21 | )); |
22 | 22 | } |
@@ -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 | } |
@@ -9,9 +9,9 @@ |
||
9 | 9 | * @see \Ajax\bootstrap\components\SimpleBsComponent::getScript() |
10 | 10 | */ |
11 | 11 | public function getScript() { |
12 | - $this->jquery_code_for_compile=array (); |
|
13 | - foreach ( $this->jsCodes as $jsCode ) { |
|
14 | - $this->jquery_code_for_compile []=$jsCode->compile(array ( |
|
12 | + $this->jquery_code_for_compile=array(); |
|
13 | + foreach ($this->jsCodes as $jsCode) { |
|
14 | + $this->jquery_code_for_compile []=$jsCode->compile(array( |
|
15 | 15 | "identifier" => $this->attachTo |
16 | 16 | )); |
17 | 17 | } |
@@ -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); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | public function __construct($identifier, $items=array()) { |
12 | 12 | parent::__construct($identifier, "div"); |
13 | 13 | $this->setClass("ui menu"); |
14 | - foreach ($items as $item){ |
|
14 | + foreach ($items as $item) { |
|
15 | 15 | $this->addItem($item); |
16 | 16 | } |
17 | 17 | } |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * @param string $type one of text,item |
22 | 22 | * @return \Ajax\semantic\html\collections\HtmlMenu |
23 | 23 | */ |
24 | - public function setType($type=""){ |
|
25 | - return $this->addToPropertyCtrl("class", $type, array("","item","text")); |
|
24 | + public function setType($type="") { |
|
25 | + return $this->addToPropertyCtrl("class", $type, array("", "item", "text")); |
|
26 | 26 | } |
27 | 27 | |
28 | - public function addItem($item){ |
|
28 | + public function addItem($item) { |
|
29 | 29 | $itemO=$item; |
30 | - if(\is_string($item)){ |
|
31 | - $itemO=new HtmlLink("item-".\sizeof($this->content),"",$item); |
|
30 | + if (\is_string($item)) { |
|
31 | + $itemO=new HtmlLink("item-".\sizeof($this->content), "", $item); |
|
32 | 32 | $itemO->setClass("item"); |
33 | 33 | } |
34 | 34 | $this->addContent($itemO); |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - public function setActiveItem($index){ |
|
51 | + public function setActiveItem($index) { |
|
52 | 52 | $item=$this->getItem($index); |
53 | - if($item!==null){ |
|
53 | + if ($item!==null) { |
|
54 | 54 | $item->addToProperty("class", "active"); |
55 | 55 | } |
56 | 56 | return $this; |
@@ -40,9 +40,9 @@ |
||
40 | 40 | * @return HtmlDoubleElement |
41 | 41 | */ |
42 | 42 | public function getItem($index) { |
43 | - if (is_int($index)) |
|
44 | - return $this->content[$index]; |
|
45 | - else { |
|
43 | + if (is_int($index)) { |
|
44 | + return $this->content[$index]; |
|
45 | + } else { |
|
46 | 46 | $elm=$this->getElementById($index, $this->content); |
47 | 47 | return $elm; |
48 | 48 | } |
@@ -11,22 +11,22 @@ |
||
11 | 11 | */ |
12 | 12 | class HtmlIconGroups extends HtmlSemDoubleElement { |
13 | 13 | |
14 | - public function __construct($identifier,$size="") { |
|
14 | + public function __construct($identifier, $size="") { |
|
15 | 15 | parent::__construct($identifier, "i"); |
16 | 16 | $this->setProperty("class", "icons"); |
17 | 17 | $this->setSize($size); |
18 | 18 | } |
19 | 19 | |
20 | - public function add($icon,$size=""){ |
|
20 | + public function add($icon, $size="") { |
|
21 | 21 | $iconO=$icon; |
22 | - if(\is_string($icon)){ |
|
22 | + if (\is_string($icon)) { |
|
23 | 23 | $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
24 | 24 | $iconO->setSize($size); |
25 | 25 | } |
26 | 26 | $this->addContent($iconO); |
27 | 27 | } |
28 | 28 | |
29 | - public function getIcon($index){ |
|
29 | + public function getIcon($index) { |
|
30 | 30 | return $this->content[$index]; |
31 | 31 | } |
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | protected $variation; |
12 | 12 | protected $params; |
13 | 13 | protected $semElement; |
14 | - public function __construct($semElement,$title="",$content="",$variation=NULL,$params=array()){ |
|
14 | + public function __construct($semElement, $title="", $content="", $variation=NULL, $params=array()) { |
|
15 | 15 | $this->semElement=$semElement; |
16 | 16 | $this->title=$title; |
17 | 17 | $this->content=$content; |
18 | - $this->setAttributes($variation,$params); |
|
18 | + $this->setAttributes($variation, $params); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function setHtml($html) { |
@@ -23,32 +23,32 @@ discard block |
||
23 | 23 | return $this; |
24 | 24 | } |
25 | 25 | |
26 | - public function setAttributes($variation=NULL,$params=array()){ |
|
26 | + public function setAttributes($variation=NULL, $params=array()) { |
|
27 | 27 | $this->variation=$variation; |
28 | 28 | $this->params=$params; |
29 | 29 | } |
30 | 30 | |
31 | - public function onShow($jsCode){ |
|
31 | + public function onShow($jsCode) { |
|
32 | 32 | $this->params["onShow"]=$jsCode; |
33 | 33 | } |
34 | 34 | |
35 | - public function compile(){ |
|
36 | - if(JString::isNotNull($this->title)){ |
|
35 | + public function compile() { |
|
36 | + if (JString::isNotNull($this->title)) { |
|
37 | 37 | $this->semElement->addToProperty("data-title", $this->title); |
38 | 38 | } |
39 | - if(JString::isNotNull($this->content)){ |
|
39 | + if (JString::isNotNull($this->content)) { |
|
40 | 40 | $this->semElement->addToProperty("data-content", $this->content); |
41 | 41 | } |
42 | - if(JString::isNotNull($this->html)){ |
|
42 | + if (JString::isNotNull($this->html)) { |
|
43 | 43 | $this->semElement->addToProperty("data-html", $this->html); |
44 | 44 | } |
45 | - if(JString::isNotNull($this->variation)){ |
|
45 | + if (JString::isNotNull($this->variation)) { |
|
46 | 46 | $this->semElement->addToProperty("data-variation", $this->variation); |
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | - public function run(JsUtils $js){ |
|
51 | - $js->semantic()->popup("#".$this->semElement->getIdentifier(),$this->params); |
|
50 | + public function run(JsUtils $js) { |
|
51 | + $js->semantic()->popup("#".$this->semElement->getIdentifier(), $this->params); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | } |
55 | 55 | \ No newline at end of file |
@@ -30,7 +30,7 @@ |
||
30 | 30 | return $this->setParam("onShow", "%function(){".$jsCode."}%"); |
31 | 31 | } |
32 | 32 | |
33 | - public function setExclusive($value){ |
|
33 | + public function setExclusive($value) { |
|
34 | 34 | return $this->setParam("exclusive", $value); |
35 | 35 | } |
36 | 36 | //TODO other events implementation |
@@ -17,7 +17,7 @@ |
||
17 | 17 | * @param string $action one of "select","auto","activate","combo","nothing","hide" |
18 | 18 | * @return \Ajax\semantic\components\Dropdown |
19 | 19 | */ |
20 | - public function setAction($action){ |
|
21 | - return $this->setParamCtrl("action", $action,array("select","auto","activate","combo","nothing","hide")); |
|
20 | + public function setAction($action) { |
|
21 | + return $this->setParamCtrl("action", $action, array("select", "auto", "activate", "combo", "nothing", "hide")); |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | \ No newline at end of file |