@@ -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 | } |
@@ -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 |
@@ -10,30 +10,30 @@ discard block |
||
10 | 10 | |
11 | 11 | class HtmlDropdownItem extends HtmlSemDoubleElement { |
12 | 12 | |
13 | - public function __construct($identifier, $content="",$value=NULL,$image=NULL) { |
|
13 | + public function __construct($identifier, $content="", $value=NULL, $image=NULL) { |
|
14 | 14 | parent::__construct($identifier, "div"); |
15 | 15 | $this->setClass("item"); |
16 | 16 | $this->setContent($content); |
17 | - if($value!==NULL) |
|
17 | + if ($value!==NULL) |
|
18 | 18 | $this->setData($value); |
19 | - if($image!==NULL) |
|
19 | + if ($image!==NULL) |
|
20 | 20 | $this->asMiniAvatar($image); |
21 | 21 | } |
22 | 22 | |
23 | - public function setDescription($description){ |
|
24 | - $descO=new HtmlDoubleElement("desc-".$this->identifier,"span"); |
|
23 | + public function setDescription($description) { |
|
24 | + $descO=new HtmlDoubleElement("desc-".$this->identifier, "span"); |
|
25 | 25 | $descO->setClass("description"); |
26 | 26 | $descO->setContent($description); |
27 | - return $this->addContent($descO,true); |
|
27 | + return $this->addContent($descO, true); |
|
28 | 28 | } |
29 | 29 | |
30 | - public function setData($value){ |
|
30 | + public function setData($value) { |
|
31 | 31 | $this->setProperty("data-value", $value); |
32 | 32 | } |
33 | 33 | |
34 | - public function asOption(){ |
|
34 | + public function asOption() { |
|
35 | 35 | $this->tagName="option"; |
36 | - if($this->getProperty("data-value")!==null) |
|
36 | + if ($this->getProperty("data-value")!==null) |
|
37 | 37 | $this->setProperty("value", $this->getProperty("data-value")); |
38 | 38 | } |
39 | 39 | |
@@ -41,58 +41,58 @@ discard block |
||
41 | 41 | * @param string $image the image src |
42 | 42 | * @return \Ajax\common\html\html5\HtmlImg |
43 | 43 | */ |
44 | - public function asMiniAvatar($image){ |
|
44 | + public function asMiniAvatar($image) { |
|
45 | 45 | $this->tagName="div"; |
46 | - $img=new HtmlImg("image-".$this->identifier,$image); |
|
46 | + $img=new HtmlImg("image-".$this->identifier, $image); |
|
47 | 47 | $img->setClass("ui mini avatar image"); |
48 | - $this->addContent($img,true); |
|
48 | + $this->addContent($img, true); |
|
49 | 49 | return $img; |
50 | 50 | } |
51 | 51 | |
52 | - public function asSearchInput($placeholder=NULL,$icon=NULL){ |
|
52 | + public function asSearchInput($placeholder=NULL, $icon=NULL) { |
|
53 | 53 | $this->setClass("ui icon search input"); |
54 | 54 | $input=new HtmlInput("search-".$this->identifier); |
55 | - if(isset($placeholder)) |
|
55 | + if (isset($placeholder)) |
|
56 | 56 | $input->setProperty("placeholder", $placeholder); |
57 | 57 | $this->content=$input; |
58 | - if(isset($icon)) |
|
58 | + if (isset($icon)) |
|
59 | 59 | $this->addIcon($icon); |
60 | 60 | return $this; |
61 | 61 | } |
62 | 62 | |
63 | - public function setContent($content){ |
|
64 | - if($content==="-"){ |
|
63 | + public function setContent($content) { |
|
64 | + if ($content==="-") { |
|
65 | 65 | $this->asDivider(); |
66 | - }elseif($content==="-search-"){ |
|
67 | - $values=\explode(",",$content,-1); |
|
68 | - $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."),JArray::getDefaultValue($values, 1, "search")); |
|
66 | + }elseif ($content==="-search-") { |
|
67 | + $values=\explode(",", $content, -1); |
|
68 | + $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."), JArray::getDefaultValue($values, 1, "search")); |
|
69 | 69 | }else |
70 | 70 | parent::setContent($content); |
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | - public function asDivider(){ |
|
74 | + public function asDivider() { |
|
75 | 75 | $this->content=NULL; |
76 | 76 | $this->setClass("divider"); |
77 | 77 | } |
78 | 78 | |
79 | - public function asHeader($caption=NULL,$icon=NULL){ |
|
79 | + public function asHeader($caption=NULL, $icon=NULL) { |
|
80 | 80 | $this->setClass("header"); |
81 | 81 | $this->content=$caption; |
82 | - if(isset($icon)) |
|
83 | - $this->addIcon($icon,true); |
|
82 | + if (isset($icon)) |
|
83 | + $this->addIcon($icon, true); |
|
84 | 84 | return $this; |
85 | 85 | } |
86 | 86 | |
87 | - public static function searchInput($placeholder=NULL,$icon=NULL){ |
|
88 | - return (new HtmlDropdownItem(""))->asSearchInput($placeholder,$icon); |
|
87 | + public static function searchInput($placeholder=NULL, $icon=NULL) { |
|
88 | + return (new HtmlDropdownItem(""))->asSearchInput($placeholder, $icon); |
|
89 | 89 | } |
90 | 90 | |
91 | - public static function divider($placeholder=NULL,$icon=NULL){ |
|
91 | + public static function divider($placeholder=NULL, $icon=NULL) { |
|
92 | 92 | return (new HtmlDropdownItem(""))->asDivider(); |
93 | 93 | } |
94 | 94 | |
95 | - public static function header($caption=NULL,$icon=NULL){ |
|
96 | - return (new HtmlDropdownItem(""))->asHeader($caption,$icon); |
|
95 | + public static function header($caption=NULL, $icon=NULL) { |
|
96 | + return (new HtmlDropdownItem(""))->asHeader($caption, $icon); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | \ No newline at end of file |
@@ -14,10 +14,12 @@ discard block |
||
14 | 14 | parent::__construct($identifier, "div"); |
15 | 15 | $this->setClass("item"); |
16 | 16 | $this->setContent($content); |
17 | - if($value!==NULL) |
|
18 | - $this->setData($value); |
|
19 | - if($image!==NULL) |
|
20 | - $this->asMiniAvatar($image); |
|
17 | + if($value!==NULL) { |
|
18 | + $this->setData($value); |
|
19 | + } |
|
20 | + if($image!==NULL) { |
|
21 | + $this->asMiniAvatar($image); |
|
22 | + } |
|
21 | 23 | } |
22 | 24 | |
23 | 25 | public function setDescription($description){ |
@@ -33,8 +35,9 @@ discard block |
||
33 | 35 | |
34 | 36 | public function asOption(){ |
35 | 37 | $this->tagName="option"; |
36 | - if($this->getProperty("data-value")!==null) |
|
37 | - $this->setProperty("value", $this->getProperty("data-value")); |
|
38 | + if($this->getProperty("data-value")!==null) { |
|
39 | + $this->setProperty("value", $this->getProperty("data-value")); |
|
40 | + } |
|
38 | 41 | } |
39 | 42 | |
40 | 43 | /** |
@@ -52,22 +55,25 @@ discard block |
||
52 | 55 | public function asSearchInput($placeholder=NULL,$icon=NULL){ |
53 | 56 | $this->setClass("ui icon search input"); |
54 | 57 | $input=new HtmlInput("search-".$this->identifier); |
55 | - if(isset($placeholder)) |
|
56 | - $input->setProperty("placeholder", $placeholder); |
|
58 | + if(isset($placeholder)) { |
|
59 | + $input->setProperty("placeholder", $placeholder); |
|
60 | + } |
|
57 | 61 | $this->content=$input; |
58 | - if(isset($icon)) |
|
59 | - $this->addIcon($icon); |
|
62 | + if(isset($icon)) { |
|
63 | + $this->addIcon($icon); |
|
64 | + } |
|
60 | 65 | return $this; |
61 | 66 | } |
62 | 67 | |
63 | 68 | public function setContent($content){ |
64 | 69 | if($content==="-"){ |
65 | 70 | $this->asDivider(); |
66 | - }elseif($content==="-search-"){ |
|
71 | + } elseif($content==="-search-"){ |
|
67 | 72 | $values=\explode(",",$content,-1); |
68 | 73 | $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."),JArray::getDefaultValue($values, 1, "search")); |
69 | - }else |
|
70 | - parent::setContent($content); |
|
74 | + } else { |
|
75 | + parent::setContent($content); |
|
76 | + } |
|
71 | 77 | return $this; |
72 | 78 | } |
73 | 79 | |
@@ -79,8 +85,9 @@ discard block |
||
79 | 85 | public function asHeader($caption=NULL,$icon=NULL){ |
80 | 86 | $this->setClass("header"); |
81 | 87 | $this->content=$caption; |
82 | - if(isset($icon)) |
|
83 | - $this->addIcon($icon,true); |
|
88 | + if(isset($icon)) { |
|
89 | + $this->addIcon($icon,true); |
|
90 | + } |
|
84 | 91 | return $this; |
85 | 92 | } |
86 | 93 |
@@ -11,6 +11,10 @@ discard block |
||
11 | 11 | |
12 | 12 | class HtmlDropdownItem extends HtmlSemDoubleElement { |
13 | 13 | use IconTrait; |
14 | + |
|
15 | + /** |
|
16 | + * @param string $identifier |
|
17 | + */ |
|
14 | 18 | public function __construct($identifier, $content="",$value=NULL,$image=NULL) { |
15 | 19 | parent::__construct($identifier, "a"); |
16 | 20 | $this->setClass("item"); |
@@ -61,6 +65,9 @@ discard block |
||
61 | 65 | return $this; |
62 | 66 | } |
63 | 67 | |
68 | + /** |
|
69 | + * @param string $content |
|
70 | + */ |
|
64 | 71 | public function setContent($content){ |
65 | 72 | if($content==="-"){ |
66 | 73 | $this->asDivider(); |
@@ -2,21 +2,21 @@ |
||
2 | 2 | namespace Ajax\service; |
3 | 3 | class JString { |
4 | 4 | |
5 | - public static function contains($hay,$needle){ |
|
6 | - return strpos($hay, $needle) !== false; |
|
5 | + public static function contains($hay, $needle) { |
|
6 | + return strpos($hay, $needle)!==false; |
|
7 | 7 | } |
8 | 8 | public static function startswith($hay, $needle) { |
9 | - return substr($hay, 0, strlen($needle)) === $needle; |
|
9 | + return substr($hay, 0, strlen($needle))===$needle; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | public static function endswith($hay, $needle) { |
13 | - return substr($hay, -strlen($needle)) === $needle; |
|
13 | + return substr($hay, -strlen($needle))===$needle; |
|
14 | 14 | } |
15 | 15 | |
16 | - public static function isNull($s){ |
|
16 | + public static function isNull($s) { |
|
17 | 17 | return (!isset($s) || NULL===$s || ""===$s); |
18 | 18 | } |
19 | - public static function isNotNull($s){ |
|
19 | + public static function isNotNull($s) { |
|
20 | 20 | return (isset($s) && NULL!==$s && ""!==$s); |
21 | 21 | } |
22 | 22 | } |
23 | 23 | \ No newline at end of file |
@@ -24,38 +24,38 @@ discard block |
||
24 | 24 | $this->setContent($content); |
25 | 25 | } |
26 | 26 | |
27 | - public function addHeader($header){ |
|
27 | + public function addHeader($header) { |
|
28 | 28 | $headerO=$header; |
29 | - if(\is_string($header)){ |
|
30 | - $headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div"); |
|
29 | + if (\is_string($header)) { |
|
30 | + $headerO=new HtmlSemDoubleElement("header-".$this->identifier, "div"); |
|
31 | 31 | $headerO->setClass("header"); |
32 | 32 | $headerO->setContent($header); |
33 | 33 | } |
34 | - return $this->addContent($headerO,true); |
|
34 | + return $this->addContent($headerO, true); |
|
35 | 35 | } |
36 | 36 | |
37 | - public function addList($elements,$ordered=false){ |
|
38 | - $list=new HtmlList("list-".$this->identifier,$elements); |
|
37 | + public function addList($elements, $ordered=false) { |
|
38 | + $list=new HtmlList("list-".$this->identifier, $elements); |
|
39 | 39 | $list->setOrdered($ordered); |
40 | 40 | $list->setClass("ui list"); |
41 | 41 | $this->addContent($list); |
42 | 42 | } |
43 | 43 | |
44 | - public function setIcon($icon){ |
|
44 | + public function setIcon($icon) { |
|
45 | 45 | $this->addToProperty("class", "icon"); |
46 | - $this->wrapContent("<div class='content'>","</div>"); |
|
46 | + $this->wrapContent("<div class='content'>", "</div>"); |
|
47 | 47 | $this->icon=new HtmlIcon("icon-".$this->identifier, $icon); |
48 | 48 | return $this; |
49 | 49 | } |
50 | 50 | |
51 | - public function addLoader($loaderIcon="notched circle"){ |
|
51 | + public function addLoader($loaderIcon="notched circle") { |
|
52 | 52 | $this->setIcon($loaderIcon); |
53 | 53 | $this->icon->addToIcon("loading"); |
54 | 54 | return $this; |
55 | 55 | } |
56 | 56 | |
57 | - public function setDismissable($dismiss=true){ |
|
58 | - if($dismiss===true) |
|
57 | + public function setDismissable($dismiss=true) { |
|
58 | + if ($dismiss===true) |
|
59 | 59 | $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
60 | 60 | else |
61 | 61 | $this->close=NULL; |
@@ -66,28 +66,28 @@ discard block |
||
66 | 66 | * {@inheritDoc} |
67 | 67 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
68 | 68 | */ |
69 | - public function run(JsUtils $js){ |
|
69 | + public function run(JsUtils $js) { |
|
70 | 70 | parent::run($js); |
71 | - if(isset($this->close)){ |
|
71 | + if (isset($this->close)) { |
|
72 | 72 | $js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition('fade')"); |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - public function setState($visible=true){ |
|
77 | - $visible=($visible===true)?"visible":"hidden"; |
|
78 | - return $this->addToPropertyCtrl("class", $visible, array("visible","hidden")); |
|
76 | + public function setState($visible=true) { |
|
77 | + $visible=($visible===true) ? "visible" : "hidden"; |
|
78 | + return $this->addToPropertyCtrl("class", $visible, array("visible", "hidden")); |
|
79 | 79 | } |
80 | 80 | |
81 | - public function setVariation($value="floating"){ |
|
82 | - return $this->addToPropertyCtrl("class", $value, array("floating","compact")); |
|
81 | + public function setVariation($value="floating") { |
|
82 | + return $this->addToPropertyCtrl("class", $value, array("floating", "compact")); |
|
83 | 83 | } |
84 | 84 | |
85 | - public function setStyle($style){ |
|
85 | + public function setStyle($style) { |
|
86 | 86 | return $this->addToPropertyCtrl("class", $style, Style::getConstants()); |
87 | 87 | } |
88 | 88 | |
89 | - public function setAttached(HtmlDoubleElement $toElement=NULL){ |
|
90 | - if(isset($toElement)){ |
|
89 | + public function setAttached(HtmlDoubleElement $toElement=NULL) { |
|
90 | + if (isset($toElement)) { |
|
91 | 91 | $toElement->addToProperty("class", "attached"); |
92 | 92 | } |
93 | 93 | return $this->addToProperty("class", "attached"); |
@@ -55,10 +55,11 @@ |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public function setDismissable($dismiss=true){ |
58 | - if($dismiss===true) |
|
59 | - $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
|
60 | - else |
|
61 | - $this->close=NULL; |
|
58 | + if($dismiss===true) { |
|
59 | + $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
|
60 | + } else { |
|
61 | + $this->close=NULL; |
|
62 | + } |
|
62 | 63 | return $this; |
63 | 64 | } |
64 | 65 |
@@ -13,8 +13,8 @@ |
||
13 | 13 | parent::__construct($identifier, "ul"); |
14 | 14 | $this->addItems($items); |
15 | 15 | } |
16 | - public function setOrdered($ordered=true){ |
|
17 | - $this->tagName=($ordered===true)?"ol":"ul"; |
|
16 | + public function setOrdered($ordered=true) { |
|
17 | + $this->tagName=($ordered===true) ? "ol" : "ul"; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -14,10 +14,11 @@ |
||
14 | 14 | if(isset($numCols)){ |
15 | 15 | $numCols=min(16,$numCols); |
16 | 16 | $numCols=max(1,$numCols); |
17 | - if($colSizing) |
|
18 | - $width=(int)(16/$numCols); |
|
19 | - else |
|
20 | - $this->_colSize=16/$numCols; |
|
17 | + if($colSizing) { |
|
18 | + $width=(int)(16/$numCols); |
|
19 | + } else { |
|
20 | + $this->_colSize=16/$numCols; |
|
21 | + } |
|
21 | 22 | for ($i=0;$i<$numCols;$i++){ |
22 | 23 | $this->addItem($width); |
23 | 24 | } |
@@ -22,6 +22,9 @@ discard block |
||
22 | 22 | private $_colSize; |
23 | 23 | private $_implicite=false; |
24 | 24 | |
25 | + /** |
|
26 | + * @param string $identifier |
|
27 | + */ |
|
25 | 28 | public function __construct( $identifier,$numCols=NULL,$colSizing=false,$implicite=false){ |
26 | 29 | parent::__construct( $identifier,"div","row"); |
27 | 30 | $this->_implicite=$implicite; |
@@ -55,7 +58,7 @@ discard block |
||
55 | 58 | /** |
56 | 59 | * return the col at $index |
57 | 60 | * @param int $index |
58 | - * @return \Ajax\semantic\html\collections\HtmlGridCol |
|
61 | + * @return \Ajax\common\html\HtmlDoubleElement |
|
59 | 62 | */ |
60 | 63 | public function getCol($index){ |
61 | 64 | return $this->getItem($index); |
@@ -5,7 +5,6 @@ |
||
5 | 5 | use Ajax\semantic\html\base\HtmlSemDoubleElement; |
6 | 6 | use Ajax\JsUtils; |
7 | 7 | use Ajax\service\JArray; |
8 | - |
|
9 | 8 | use Ajax\semantic\html\base\constants\State; |
10 | 9 | |
11 | 10 | class HtmlProgress extends HtmlSemDoubleElement { |
@@ -16,24 +16,24 @@ discard block |
||
16 | 16 | * @author jc |
17 | 17 | * @version 1.001 |
18 | 18 | */ |
19 | -class HtmlGridRow extends HtmlSemCollection{ |
|
19 | +class HtmlGridRow extends HtmlSemCollection { |
|
20 | 20 | use TextAlignmentTrait; |
21 | 21 | |
22 | 22 | private $_colSize; |
23 | 23 | private $_implicite=false; |
24 | 24 | |
25 | - public function __construct( $identifier,$numCols=NULL,$colSizing=false,$implicite=false){ |
|
26 | - parent::__construct( $identifier,"div","row"); |
|
25 | + public function __construct($identifier, $numCols=NULL, $colSizing=false, $implicite=false) { |
|
26 | + parent::__construct($identifier, "div", "row"); |
|
27 | 27 | $this->_implicite=$implicite; |
28 | 28 | $width=null; |
29 | - if(isset($numCols)){ |
|
30 | - $numCols=min(16,$numCols); |
|
31 | - $numCols=max(1,$numCols); |
|
32 | - if($colSizing) |
|
33 | - $width=(int)(16/$numCols); |
|
29 | + if (isset($numCols)) { |
|
30 | + $numCols=min(16, $numCols); |
|
31 | + $numCols=max(1, $numCols); |
|
32 | + if ($colSizing) |
|
33 | + $width=(int) (16 / $numCols); |
|
34 | 34 | else |
35 | - $this->_colSize=16/$numCols; |
|
36 | - for ($i=0;$i<$numCols;$i++){ |
|
35 | + $this->_colSize=16 / $numCols; |
|
36 | + for ($i=0; $i<$numCols; $i++) { |
|
37 | 37 | $this->addItem($width); |
38 | 38 | } |
39 | 39 | } |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | * @param int $width |
45 | 45 | * @return \Ajax\semantic\html\content\HtmlGridRow |
46 | 46 | */ |
47 | - public function setWidth($width){ |
|
48 | - if(\is_int($width)){ |
|
47 | + public function setWidth($width) { |
|
48 | + if (\is_int($width)) { |
|
49 | 49 | $width=Wide::getConstants()["W".$width]; |
50 | 50 | } |
51 | 51 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
52 | - return $this->addToPropertyCtrl("class", "column",array("column")); |
|
52 | + return $this->addToPropertyCtrl("class", "column", array("column")); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -57,29 +57,29 @@ discard block |
||
57 | 57 | * @param int $index |
58 | 58 | * @return \Ajax\semantic\html\collections\HtmlGridCol |
59 | 59 | */ |
60 | - public function getCol($index){ |
|
60 | + public function getCol($index) { |
|
61 | 61 | return $this->getItem($index); |
62 | 62 | } |
63 | 63 | |
64 | - public function setColsCount($colsCount,$toCreate=true){ |
|
64 | + public function setColsCount($colsCount, $toCreate=true) { |
|
65 | 65 | $this->setWidth($colsCount); |
66 | - if($toCreate===true){ |
|
66 | + if ($toCreate===true) { |
|
67 | 67 | $count=$this->count(); |
68 | - for($i=$count;$i<$colsCount;$i++){ |
|
68 | + for ($i=$count; $i<$colsCount; $i++) { |
|
69 | 69 | $this->addItem(null); |
70 | 70 | } |
71 | 71 | } |
72 | 72 | return $this; |
73 | 73 | } |
74 | 74 | |
75 | - public function addCols($colCount){ |
|
76 | - for($i=0;$i<$colCount;$i++){ |
|
75 | + public function addCols($colCount) { |
|
76 | + for ($i=0; $i<$colCount; $i++) { |
|
77 | 77 | $this->addItem(null); |
78 | 78 | } |
79 | 79 | return $this; |
80 | 80 | } |
81 | 81 | |
82 | - public function addCol($width=NULL){ |
|
82 | + public function addCol($width=NULL) { |
|
83 | 83 | return $this->addItem($width); |
84 | 84 | } |
85 | 85 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * stretch the row contents to take up the entire column height |
88 | 88 | * @return \Ajax\semantic\html\content\HtmlGridRow |
89 | 89 | */ |
90 | - public function setStretched(){ |
|
90 | + public function setStretched() { |
|
91 | 91 | return $this->addToProperty("class", "stretched"); |
92 | 92 | } |
93 | 93 | |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | * @param string $color |
96 | 96 | * @return \Ajax\semantic\html\content\HtmlGridRow |
97 | 97 | */ |
98 | - public function setColor($color){ |
|
99 | - return $this->addToPropertyCtrl("class", $color,Color::getConstants()); |
|
98 | + public function setColor($color) { |
|
99 | + return $this->addToPropertyCtrl("class", $color, Color::getConstants()); |
|
100 | 100 | } |
101 | 101 | |
102 | - public function setValues($values,$force=false){ |
|
102 | + public function setValues($values, $force=false) { |
|
103 | 103 | $count=$this->count(); |
104 | - if($force===true){ |
|
105 | - for($i=$count;$i<\sizeof($values);$i++){ |
|
106 | - $this->addItem(new HtmlGridCol($this->identifier."-col-".($this->count()+1),null)); |
|
104 | + if ($force===true) { |
|
105 | + for ($i=$count; $i<\sizeof($values); $i++) { |
|
106 | + $this->addItem(new HtmlGridCol($this->identifier."-col-".($this->count()+1), null)); |
|
107 | 107 | } |
108 | 108 | } |
109 | - $count=\min(array($this->count(),\sizeof($values))); |
|
110 | - for($i=0;$i<$count;$i++){ |
|
109 | + $count=\min(array($this->count(), \sizeof($values))); |
|
110 | + for ($i=0; $i<$count; $i++) { |
|
111 | 111 | $this->content[$i]->setValue($values[$i]); |
112 | 112 | } |
113 | 113 | return $this; |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | * {@inheritDoc} |
118 | 118 | * @see \Ajax\common\html\HtmlCollection::createItem() |
119 | 119 | */ |
120 | - protected function createItem($value){ |
|
121 | - $col=new HtmlGridCol($this->identifier."-col-".($this->count()+1),$value); |
|
120 | + protected function createItem($value) { |
|
121 | + $col=new HtmlGridCol($this->identifier."-col-".($this->count()+1), $value); |
|
122 | 122 | return $col; |
123 | 123 | } |
124 | 124 | |
125 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
126 | - if($this->_implicite===true){ |
|
125 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
126 | + if ($this->_implicite===true) { |
|
127 | 127 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
128 | 128 | } |
129 | - return parent::compile($js,$view); |
|
129 | + return parent::compile($js, $view); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | \ No newline at end of file |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | foreach ($items as $k=>$v){ |
18 | 18 | $this->addItem([$k,$v]); |
19 | 19 | } |
20 | - }else{ |
|
20 | + } else{ |
|
21 | 21 | foreach ($items as $item){ |
22 | 22 | $this->addItem($item); |
23 | 23 | } |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @return \Ajax\common\html\HtmlDoubleElement |
54 | 54 | */ |
55 | 55 | public function getItem($index) { |
56 | - if (is_int($index)) |
|
57 | - return $this->content[$index]; |
|
58 | - else { |
|
56 | + if (is_int($index)) { |
|
57 | + return $this->content[$index]; |
|
58 | + } else { |
|
59 | 59 | $elm=$this->getElementById($index, $this->content); |
60 | 60 | return $elm; |
61 | 61 | } |
@@ -13,35 +13,35 @@ discard block |
||
13 | 13 | */ |
14 | 14 | abstract class HtmlCollection extends HtmlDoubleElement { |
15 | 15 | |
16 | - public function __construct($identifier,$tagName="div"){ |
|
17 | - parent::__construct($identifier,$tagName); |
|
16 | + public function __construct($identifier, $tagName="div") { |
|
17 | + parent::__construct($identifier, $tagName); |
|
18 | 18 | $this->content=array(); |
19 | 19 | } |
20 | 20 | |
21 | - public function addItems($items){ |
|
22 | - if(JArray::isAssociative($items)){ |
|
23 | - foreach ($items as $k=>$v){ |
|
24 | - $this->addItem([$k,$v]); |
|
21 | + public function addItems($items) { |
|
22 | + if (JArray::isAssociative($items)) { |
|
23 | + foreach ($items as $k=>$v) { |
|
24 | + $this->addItem([$k, $v]); |
|
25 | 25 | } |
26 | - }else{ |
|
27 | - foreach ($items as $item){ |
|
26 | + }else { |
|
27 | + foreach ($items as $item) { |
|
28 | 28 | $this->addItem($item); |
29 | 29 | } |
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | - public function setItems($items){ |
|
33 | + public function setItems($items) { |
|
34 | 34 | $this->content=$items; |
35 | 35 | return $this; |
36 | 36 | } |
37 | 37 | |
38 | - public function getItems(){ |
|
38 | + public function getItems() { |
|
39 | 39 | return $this->content; |
40 | 40 | } |
41 | 41 | |
42 | - protected function getItemToAdd($item){ |
|
42 | + protected function getItemToAdd($item) { |
|
43 | 43 | $itemO=$item; |
44 | - if($this->createCondition($item)===true){ |
|
44 | + if ($this->createCondition($item)===true) { |
|
45 | 45 | $itemO=$this->createItem($item); |
46 | 46 | } |
47 | 47 | return $itemO; |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | * @param HtmlDoubleElement|string $item |
53 | 53 | * @return \Ajax\common\html\HtmlDoubleElement |
54 | 54 | */ |
55 | - public function addItem($item){ |
|
55 | + public function addItem($item) { |
|
56 | 56 | $itemO=$this->getItemToAdd($item); |
57 | 57 | $this->addContent($itemO); |
58 | 58 | return $itemO; |
59 | 59 | } |
60 | 60 | |
61 | - public function insertItem($item,$position=0){ |
|
61 | + public function insertItem($item, $position=0) { |
|
62 | 62 | $itemO=$this->getItemToAdd($item); |
63 | - \array_splice( $this->content, $position, 0, array($itemO)); |
|
63 | + \array_splice($this->content, $position, 0, array($itemO)); |
|
64 | 64 | return $itemO; |
65 | 65 | } |
66 | 66 | |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | return $this; |
84 | 84 | } |
85 | 85 | |
86 | - public function removeItem($index){ |
|
86 | + public function removeItem($index) { |
|
87 | 87 | return array_splice($this->content, $index, 1); |
88 | 88 | } |
89 | 89 | |
90 | - public function count(){ |
|
90 | + public function count() { |
|
91 | 91 | return \sizeof($this->content); |
92 | 92 | } |
93 | 93 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | $this->addItem($function($object)); |
99 | 99 | } |
100 | 100 | |
101 | - public function apply($callBack){ |
|
102 | - foreach ($this->content as $item){ |
|
101 | + public function apply($callBack) { |
|
102 | + foreach ($this->content as $item) { |
|
103 | 103 | $callBack($item); |
104 | 104 | } |
105 | 105 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected abstract function createItem($value); |
119 | 119 | |
120 | - protected function createCondition($value){ |
|
120 | + protected function createCondition($value) { |
|
121 | 121 | return \is_object($value)===false; |
122 | 122 | } |
123 | 123 | |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | return $this->_bsComponent; |
133 | 133 | } |
134 | 134 | |
135 | - protected function contentAs($tagName){ |
|
136 | - foreach ($this->content as $item){ |
|
135 | + protected function contentAs($tagName) { |
|
136 | + foreach ($this->content as $item) { |
|
137 | 137 | $item->setTagName($tagName); |
138 | 138 | } |
139 | 139 | } |
@@ -84,6 +84,9 @@ discard block |
||
84 | 84 | return $this; |
85 | 85 | } |
86 | 86 | |
87 | + /** |
|
88 | + * @param integer $index |
|
89 | + */ |
|
87 | 90 | public function removeItem($index){ |
88 | 91 | return array_splice($this->content, $index, 1); |
89 | 92 | } |
@@ -99,6 +102,9 @@ discard block |
||
99 | 102 | return $this->addItem($function($object)); |
100 | 103 | } |
101 | 104 | |
105 | + /** |
|
106 | + * @param \Closure $callBack |
|
107 | + */ |
|
102 | 108 | public function apply($callBack){ |
103 | 109 | foreach ($this->content as $item){ |
104 | 110 | $callBack($item); |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Ajax\common\html\HtmlDoubleElement; |
6 | 6 | use Ajax\service\JArray; |
7 | -use Ajax\JsUtils; |
|
8 | 7 | |
9 | 8 | /** |
10 | 9 | * Base class for Html collections |