@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | class HtmlDropdown extends HtmlSemDoubleElement { |
14 | 14 | protected $mClass="menu"; |
15 | 15 | protected $mTagName="div"; |
16 | - protected $items=array (); |
|
16 | + protected $items=array(); |
|
17 | 17 | protected $params=array("action"=>"select"); |
18 | 18 | protected $input; |
19 | 19 | |
@@ -21,40 +21,40 @@ discard block |
||
21 | 21 | parent::__construct($identifier, "div"); |
22 | 22 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
23 | 23 | $this->setProperty("class", "ui dropdown"); |
24 | - $content=new HtmlSemDoubleElement("","div"); |
|
24 | + $content=new HtmlSemDoubleElement("", "div"); |
|
25 | 25 | $content->setClass("text"); |
26 | 26 | $content->setContent($value); |
27 | - $content->wrap("",new HtmlIcon("", "dropdown")); |
|
27 | + $content->wrap("", new HtmlIcon("", "dropdown")); |
|
28 | 28 | $this->content=array($content); |
29 | 29 | $this->tagName="div"; |
30 | 30 | $this->addItems($items); |
31 | 31 | } |
32 | 32 | |
33 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
33 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
34 | 34 | $itemO=$item; |
35 | - if(\is_object($item)===false){ |
|
36 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
|
37 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
35 | + if (\is_object($item)===false) { |
|
36 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image); |
|
37 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
38 | 38 | $this->addToProperty("class", "vertical"); |
39 | 39 | } |
40 | 40 | $this->items[]=$itemO; |
41 | 41 | return $itemO; |
42 | 42 | } |
43 | 43 | |
44 | - public function addInput($name){ |
|
45 | - if(!isset($name)) |
|
44 | + public function addInput($name) { |
|
45 | + if (!isset($name)) |
|
46 | 46 | $name="input-".$this->identifier; |
47 | 47 | $this->setAction("activate"); |
48 | - $this->input=new HtmlInput($name,"hidden"); |
|
48 | + $this->input=new HtmlInput($name, "hidden"); |
|
49 | 49 | } |
50 | 50 | |
51 | - public function addItems($items){ |
|
52 | - if(JArray::isAssociative($items)){ |
|
53 | - foreach ($items as $k=>$v){ |
|
51 | + public function addItems($items) { |
|
52 | + if (JArray::isAssociative($items)) { |
|
53 | + foreach ($items as $k=>$v) { |
|
54 | 54 | $this->addItem($v)->setData($k); |
55 | 55 | } |
56 | - }else{ |
|
57 | - foreach ($items as $item){ |
|
56 | + }else { |
|
57 | + foreach ($items as $item) { |
|
58 | 58 | $this->addItem($item); |
59 | 59 | } |
60 | 60 | } |
@@ -63,51 +63,51 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @param boolean $dropdown |
65 | 65 | */ |
66 | - public function asDropdown($dropdown){ |
|
67 | - if($dropdown===false){ |
|
66 | + public function asDropdown($dropdown) { |
|
67 | + if ($dropdown===false) { |
|
68 | 68 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
69 | 69 | $dropdown="menu"; |
70 | - }else{ |
|
70 | + }else { |
|
71 | 71 | $dropdown="dropdown"; |
72 | 72 | $this->mClass="menu"; |
73 | 73 | } |
74 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
74 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
75 | 75 | } |
76 | 76 | |
77 | - public function setVertical(){ |
|
78 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
77 | + public function setVertical() { |
|
78 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
79 | 79 | } |
80 | 80 | |
81 | - public function setSimple(){ |
|
82 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
81 | + public function setSimple() { |
|
82 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
83 | 83 | } |
84 | 84 | |
85 | - public function asButton($floating=false){ |
|
86 | - if($floating) |
|
85 | + public function asButton($floating=false) { |
|
86 | + if ($floating) |
|
87 | 87 | $this->addToProperty("class", "floating"); |
88 | 88 | return $this->addToProperty("class", "button"); |
89 | 89 | } |
90 | 90 | |
91 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
92 | - if(isset($name)) |
|
91 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
92 | + if (isset($name)) |
|
93 | 93 | $this->addInput($name); |
94 | - if($multiple) |
|
94 | + if ($multiple) |
|
95 | 95 | $this->addToProperty("class", "multiple"); |
96 | 96 | if ($selection) |
97 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
97 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
98 | 98 | return $this; |
99 | 99 | } |
100 | 100 | |
101 | - public function asSearch($name=NULL,$multiple=false,$selection=false){ |
|
102 | - $this->asSelect($name,$multiple,$selection); |
|
101 | + public function asSearch($name=NULL, $multiple=false, $selection=false) { |
|
102 | + $this->asSelect($name, $multiple, $selection); |
|
103 | 103 | return $this->addToProperty("class", "search"); |
104 | 104 | } |
105 | 105 | |
106 | - public function setSelect($name=NULL,$multiple=false){ |
|
107 | - if(!isset($name)) |
|
106 | + public function setSelect($name=NULL, $multiple=false) { |
|
107 | + if (!isset($name)) |
|
108 | 108 | $name="select-".$this->identifier; |
109 | 109 | $this->input=null; |
110 | - if($multiple){ |
|
110 | + if ($multiple) { |
|
111 | 111 | $this->setProperty("multiple", true); |
112 | 112 | $this->addToProperty("class", "multiple"); |
113 | 113 | } |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | $this->tagName="select"; |
116 | 116 | $this->setProperty("name", $name); |
117 | 117 | $this->content=null; |
118 | - foreach ($this->items as $item){ |
|
118 | + foreach ($this->items as $item) { |
|
119 | 119 | $item->asOption(); |
120 | 120 | } |
121 | 121 | return $this; |
122 | 122 | } |
123 | 123 | |
124 | - public function asSubmenu($pointing=false,$sens=""){ |
|
124 | + public function asSubmenu($pointing=false, $sens="") { |
|
125 | 125 | $this->setClass("ui dropdown link item"); |
126 | - if($pointing===true){ |
|
126 | + if ($pointing===true) { |
|
127 | 127 | $this->setPointing($sens); |
128 | 128 | } |
129 | 129 | return $this; |
130 | 130 | } |
131 | 131 | |
132 | - public function setPointing($sens=""){ |
|
132 | + public function setPointing($sens="") { |
|
133 | 133 | $this->addToProperty("class", "pointing"); |
134 | - if(JString::isNotNull($sens)) |
|
135 | - $this->addToPropertyCtrl("class", $sens, array("left","right")); |
|
134 | + if (JString::isNotNull($sens)) |
|
135 | + $this->addToPropertyCtrl("class", $sens, array("left", "right")); |
|
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 | |
139 | - public function setValue($value){ |
|
140 | - if(isset($this->input)){ |
|
139 | + public function setValue($value) { |
|
140 | + if (isset($this->input)) { |
|
141 | 141 | $this->input->setProperty("value", $value); |
142 | - }else{ |
|
142 | + }else { |
|
143 | 143 | $this->setProperty("value", $value); |
144 | 144 | } |
145 | 145 | return $this; |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | * @see BaseHtml::run() |
151 | 151 | */ |
152 | 152 | public function run(JsUtils $js) { |
153 | - if($this->propertyContains("class", "simple")===false){ |
|
154 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->params); |
|
153 | + if ($this->propertyContains("class", "simple")===false) { |
|
154 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->params); |
|
155 | 155 | $this->addEventsOnRun($js); |
156 | 156 | return $this->_bsComponent; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - public function setAction($action){ |
|
160 | + public function setAction($action) { |
|
161 | 161 | $this->params["action"]=$action; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | \ No newline at end of file |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $itemO=$item; |
35 | 35 | if(\is_object($item)===false){ |
36 | 36 | $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
37 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
37 | + } elseif($itemO instanceof HtmlDropdownItem){ |
|
38 | 38 | $this->addToProperty("class", "vertical"); |
39 | 39 | } |
40 | 40 | $this->items[]=$itemO; |
@@ -42,8 +42,9 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | public function addInput($name){ |
45 | - if(!isset($name)) |
|
46 | - $name="input-".$this->identifier; |
|
45 | + if(!isset($name)) { |
|
46 | + $name="input-".$this->identifier; |
|
47 | + } |
|
47 | 48 | $this->setAction("activate"); |
48 | 49 | $this->input=new HtmlInput($name,"hidden"); |
49 | 50 | } |
@@ -53,7 +54,7 @@ discard block |
||
53 | 54 | foreach ($items as $k=>$v){ |
54 | 55 | $this->addItem($v)->setData($k); |
55 | 56 | } |
56 | - }else{ |
|
57 | + } else{ |
|
57 | 58 | foreach ($items as $item){ |
58 | 59 | $this->addItem($item); |
59 | 60 | } |
@@ -67,7 +68,7 @@ discard block |
||
67 | 68 | if($dropdown===false){ |
68 | 69 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
69 | 70 | $dropdown="menu"; |
70 | - }else{ |
|
71 | + } else{ |
|
71 | 72 | $dropdown="dropdown"; |
72 | 73 | $this->mClass="menu"; |
73 | 74 | } |
@@ -83,18 +84,22 @@ discard block |
||
83 | 84 | } |
84 | 85 | |
85 | 86 | public function asButton($floating=false){ |
86 | - if($floating) |
|
87 | - $this->addToProperty("class", "floating"); |
|
87 | + if($floating) { |
|
88 | + $this->addToProperty("class", "floating"); |
|
89 | + } |
|
88 | 90 | return $this->addToProperty("class", "button"); |
89 | 91 | } |
90 | 92 | |
91 | 93 | public function asSelect($name=NULL,$multiple=false,$selection=true){ |
92 | - if(isset($name)) |
|
93 | - $this->addInput($name); |
|
94 | - if($multiple) |
|
95 | - $this->addToProperty("class", "multiple"); |
|
96 | - if ($selection) |
|
97 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
94 | + if(isset($name)) { |
|
95 | + $this->addInput($name); |
|
96 | + } |
|
97 | + if($multiple) { |
|
98 | + $this->addToProperty("class", "multiple"); |
|
99 | + } |
|
100 | + if ($selection) { |
|
101 | + $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
102 | + } |
|
98 | 103 | return $this; |
99 | 104 | } |
100 | 105 | |
@@ -104,8 +109,9 @@ discard block |
||
104 | 109 | } |
105 | 110 | |
106 | 111 | public function setSelect($name=NULL,$multiple=false){ |
107 | - if(!isset($name)) |
|
108 | - $name="select-".$this->identifier; |
|
112 | + if(!isset($name)) { |
|
113 | + $name="select-".$this->identifier; |
|
114 | + } |
|
109 | 115 | $this->input=null; |
110 | 116 | if($multiple){ |
111 | 117 | $this->setProperty("multiple", true); |
@@ -131,15 +137,16 @@ discard block |
||
131 | 137 | |
132 | 138 | public function setPointing($sens=""){ |
133 | 139 | $this->addToProperty("class", "pointing"); |
134 | - if(JString::isNotNull($sens)) |
|
135 | - $this->addToPropertyCtrl("class", $sens, array("left","right")); |
|
140 | + if(JString::isNotNull($sens)) { |
|
141 | + $this->addToPropertyCtrl("class", $sens, array("left","right")); |
|
142 | + } |
|
136 | 143 | return $this; |
137 | 144 | } |
138 | 145 | |
139 | 146 | public function setValue($value){ |
140 | 147 | if(isset($this->input)){ |
141 | 148 | $this->input->setProperty("value", $value); |
142 | - }else{ |
|
149 | + } else{ |
|
143 | 150 | $this->setProperty("value", $value); |
144 | 151 | } |
145 | 152 | return $this; |
@@ -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 |
@@ -5,5 +5,5 @@ |
||
5 | 5 | use Ajax\common\BaseEnum; |
6 | 6 | |
7 | 7 | class Style extends BaseEnum { |
8 | - const INFO="info",SUCCESS="success",POSITIVE="positive",WARNING="warning",ERROR="error",NEGATIVE="negative"; |
|
8 | + const INFO="info", SUCCESS="success", POSITIVE="positive", WARNING="warning", ERROR="error", NEGATIVE="negative"; |
|
9 | 9 | } |
10 | 10 | \ 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 |
@@ -5,23 +5,23 @@ discard block |
||
5 | 5 | use Ajax\common\html\HtmlDoubleElement; |
6 | 6 | |
7 | 7 | abstract class HtmlCollection extends HtmlDoubleElement { |
8 | - public function __construct($identifier,$tagName="div"){ |
|
9 | - parent::__construct($identifier,$tagName); |
|
8 | + public function __construct($identifier, $tagName="div") { |
|
9 | + parent::__construct($identifier, $tagName); |
|
10 | 10 | $this->content=array(); |
11 | 11 | } |
12 | 12 | |
13 | - public function addItems($items){ |
|
14 | - foreach ($items as $item){ |
|
13 | + public function addItems($items) { |
|
14 | + foreach ($items as $item) { |
|
15 | 15 | $this->addItem($item); |
16 | 16 | } |
17 | 17 | } |
18 | 18 | |
19 | - public function setItems($items){ |
|
19 | + public function setItems($items) { |
|
20 | 20 | $this->content=$items; |
21 | 21 | return $this; |
22 | 22 | } |
23 | 23 | |
24 | - public function getItems(){ |
|
24 | + public function getItems() { |
|
25 | 25 | return $this->content; |
26 | 26 | } |
27 | 27 | |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * @param HtmlDoubleElement|string $item |
31 | 31 | * @return \Ajax\common\html\HtmlDoubleElement |
32 | 32 | */ |
33 | - public function addItem($item){ |
|
33 | + public function addItem($item) { |
|
34 | 34 | $itemO=$item; |
35 | - if(\is_string($item)){ |
|
35 | + if (\is_string($item)) { |
|
36 | 36 | $itemO=$this->createItem($item); |
37 | 37 | } |
38 | 38 | $this->addContent($itemO); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | return $this; |
59 | 59 | } |
60 | 60 | |
61 | - public function count(){ |
|
61 | + public function count() { |
|
62 | 62 | return \sizeof($this->content); |
63 | 63 | } |
64 | 64 | /** |
@@ -45,9 +45,9 @@ |
||
45 | 45 | * @return \Ajax\common\html\HtmlDoubleElement |
46 | 46 | */ |
47 | 47 | public function getItem($index) { |
48 | - if (is_int($index)) |
|
49 | - return $this->content[$index]; |
|
50 | - else { |
|
48 | + if (is_int($index)) { |
|
49 | + return $this->content[$index]; |
|
50 | + } else { |
|
51 | 51 | $elm=$this->getElementById($index, $this->content); |
52 | 52 | return $elm; |
53 | 53 | } |
@@ -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 | /** |