@@ -6,20 +6,20 @@ discard block |
||
6 | 6 | use Ajax\semantic\html\base\HtmlSemCollection; |
7 | 7 | use Ajax\semantic\html\base\constants\Sens; |
8 | 8 | |
9 | -class HtmlSegmentGroups extends HtmlSemCollection{ |
|
9 | +class HtmlSegmentGroups extends HtmlSemCollection { |
|
10 | 10 | |
11 | 11 | |
12 | - public function __construct( $identifier, $items=array()){ |
|
13 | - parent::__construct( $identifier, "div","ui segments"); |
|
12 | + public function __construct($identifier, $items=array()) { |
|
13 | + parent::__construct($identifier, "div", "ui segments"); |
|
14 | 14 | $this->addItems($items); |
15 | 15 | } |
16 | 16 | |
17 | 17 | |
18 | - protected function createItem($value){ |
|
19 | - return new HtmlSegment("segment-".$this->count(),$value); |
|
18 | + protected function createItem($value) { |
|
19 | + return new HtmlSegment("segment-".$this->count(), $value); |
|
20 | 20 | } |
21 | 21 | |
22 | - protected function createCondition($value){ |
|
22 | + protected function createCondition($value) { |
|
23 | 23 | return !($value instanceof HtmlSegment); |
24 | 24 | } |
25 | 25 | |
@@ -28,16 +28,16 @@ discard block |
||
28 | 28 | * @param string $type one of "raised","stacked","piled" default : "" |
29 | 29 | * @return \Ajax\semantic\html\elements\HtmlSegmentGroups |
30 | 30 | */ |
31 | - public function setType($type){ |
|
31 | + public function setType($type) { |
|
32 | 32 | return $this->addToPropertyCtrl("class", $type, SegmentType::getConstants()); |
33 | 33 | } |
34 | 34 | |
35 | - public function setSens($sens=Sens::VERTICAL){ |
|
35 | + public function setSens($sens=Sens::VERTICAL) { |
|
36 | 36 | return $this->addToPropertyCtrl("class", $sens, Sens::getConstants()); |
37 | 37 | } |
38 | 38 | |
39 | - public static function group($identifier,$items=array(),$type="",$sens=Sens::VERTICAL){ |
|
40 | - $group=new HtmlSegmentGroups($identifier,$items); |
|
39 | + public static function group($identifier, $items=array(), $type="", $sens=Sens::VERTICAL) { |
|
40 | + $group=new HtmlSegmentGroups($identifier, $items); |
|
41 | 41 | $group->setSens($sens); |
42 | 42 | return $group->setType($type); |
43 | 43 | } |
@@ -13,29 +13,29 @@ 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 | |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * @param HtmlDoubleElement|string $item |
45 | 45 | * @return \Ajax\common\html\HtmlDoubleElement |
46 | 46 | */ |
47 | - public function addItem($item){ |
|
47 | + public function addItem($item) { |
|
48 | 48 | $itemO=$item; |
49 | - if($this->createCondition($item)===true){ |
|
49 | + if ($this->createCondition($item)===true) { |
|
50 | 50 | $itemO=$this->createItem($item); |
51 | 51 | } |
52 | 52 | $this->addContent($itemO); |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | return $this; |
73 | 73 | } |
74 | 74 | |
75 | - public function removeItem($index){ |
|
75 | + public function removeItem($index) { |
|
76 | 76 | return array_splice($this->content, $index, 1); |
77 | 77 | } |
78 | 78 | |
79 | - public function count(){ |
|
79 | + public function count() { |
|
80 | 80 | return \sizeof($this->content); |
81 | 81 | } |
82 | 82 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | $this->addItem($function($object)); |
88 | 88 | } |
89 | 89 | |
90 | - public function apply($callBack){ |
|
91 | - foreach ($this->content as $item){ |
|
90 | + public function apply($callBack) { |
|
91 | + foreach ($this->content as $item) { |
|
92 | 92 | $callBack($item); |
93 | 93 | } |
94 | 94 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected abstract function createItem($value); |
108 | 108 | |
109 | - protected function createCondition($value){ |
|
109 | + protected function createCondition($value) { |
|
110 | 110 | return \is_object($value)===false; |
111 | 111 | } |
112 | 112 | |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | return $this->_bsComponent; |
122 | 122 | } |
123 | 123 | |
124 | - protected function contentAs($tagName){ |
|
125 | - foreach ($this->content as $item){ |
|
124 | + protected function contentAs($tagName) { |
|
125 | + foreach ($this->content as $item) { |
|
126 | 126 | $item->setTagName($tagName); |
127 | 127 | } |
128 | 128 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @author jc |
15 | 15 | * @version 1.001 |
16 | 16 | */ |
17 | -class HtmlBreadcrumb extends HtmlSemNavElement{ |
|
17 | +class HtmlBreadcrumb extends HtmlSemNavElement { |
|
18 | 18 | /** |
19 | 19 | * @var integer the start index for href generation |
20 | 20 | */ |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | * @param boolean $autoActive sets the last element's class to <b>active</b> if true |
41 | 41 | * @param function $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()} |
42 | 42 | */ |
43 | - public function __construct( $identifier,$items=array(),$autoActive=true,$startIndex=0,$hrefFunction=NULL){ |
|
44 | - parent::__construct( $identifier, "div", "ui breadcrumb"); |
|
43 | + public function __construct($identifier, $items=array(), $autoActive=true, $startIndex=0, $hrefFunction=NULL) { |
|
44 | + parent::__construct($identifier, "div", "ui breadcrumb"); |
|
45 | 45 | $this->startIndex=$startIndex; |
46 | 46 | $this->autoActive=$autoActive; |
47 | 47 | $this->_contentSeparator="<div class='divider'> / </div>"; |
48 | - $this->_hrefFunction=function ($e){return $e->getContent();}; |
|
49 | - if(isset($hrefFunction)){ |
|
48 | + $this->_hrefFunction=function($e) {return $e->getContent(); }; |
|
49 | + if (isset($hrefFunction)) { |
|
50 | 50 | $this->_hrefFunction=$hrefFunction; |
51 | 51 | } |
52 | 52 | $this->addItems($items); |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * @param string $attr the html attribute used to build the elements url |
60 | 60 | * @return HtmlBreadcrumbs |
61 | 61 | */ |
62 | - public function autoGetOnClick($targetSelector){ |
|
63 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
62 | + public function autoGetOnClick($targetSelector) { |
|
63 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
64 | 64 | } |
65 | 65 | |
66 | - public function contentAsString(){ |
|
67 | - if($this->autoActive){ |
|
66 | + public function contentAsString() { |
|
67 | + if ($this->autoActive) { |
|
68 | 68 | $this->setActive(); |
69 | 69 | } |
70 | 70 | return parent::contentAsString(); |
71 | 71 | } |
72 | 72 | |
73 | - public function setActive($index=null){ |
|
74 | - if(!isset($index)){ |
|
73 | + public function setActive($index=null) { |
|
74 | + if (!isset($index)) { |
|
75 | 75 | $index=sizeof($this->content)-1; |
76 | 76 | } |
77 | 77 | $activeItem=$this->content[$index]; |
78 | - $activeItem->addToProperty("class","active"); |
|
78 | + $activeItem->addToProperty("class", "active"); |
|
79 | 79 | $activeItem->setTagName("div"); |
80 | 80 | } |
81 | 81 | |
@@ -84,15 +84,15 @@ discard block |
||
84 | 84 | * @param Dispatcher $dispatcher the request dispatcher |
85 | 85 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
86 | 86 | */ |
87 | - public function fromDispatcher($dispatcher,$startIndex=0){ |
|
87 | + public function fromDispatcher($dispatcher, $startIndex=0) { |
|
88 | 88 | $this->startIndex=$startIndex; |
89 | 89 | $params=$dispatcher->getParams(); |
90 | 90 | $action=$dispatcher->getActionName(); |
91 | 91 | $items=array($dispatcher->getControllerName()); |
92 | - if(\sizeof($params)>0 || \strtolower($action)!="index" ){ |
|
92 | + if (\sizeof($params)>0 || \strtolower($action)!="index") { |
|
93 | 93 | $items[]=$action; |
94 | - foreach ($params as $p){ |
|
95 | - if(\is_object($p)===false) |
|
94 | + foreach ($params as $p) { |
|
95 | + if (\is_object($p)===false) |
|
96 | 96 | $items[]=$p; |
97 | 97 | } |
98 | 98 | } |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | * @param string $separator |
106 | 106 | * @return string |
107 | 107 | */ |
108 | - public function getHref($index=null,$separator="/"){ |
|
109 | - if(!isset($index)){ |
|
108 | + public function getHref($index=null, $separator="/") { |
|
109 | + if (!isset($index)) { |
|
110 | 110 | $index=sizeof($this->content); |
111 | 111 | } |
112 | - if($this->absolutePaths===true){ |
|
112 | + if ($this->absolutePaths===true) { |
|
113 | 113 | return $this->_hrefFunction($this->content[$index]); |
114 | - }else{ |
|
115 | - return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),$this->startIndex,$index+1)); |
|
114 | + }else { |
|
115 | + return $this->root.implode($separator, array_slice(array_map(function($e) {return $this->_hrefFunction($e); }, $this->content), $this->startIndex, $index+1)); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
123 | 123 | */ |
124 | 124 | public function setHrefFunction($_hrefFunction) { |
125 | - $this->_hrefFunction = $_hrefFunction; |
|
125 | + $this->_hrefFunction=$_hrefFunction; |
|
126 | 126 | return $this; |
127 | 127 | } |
128 | 128 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | public function setAutoActive($autoActive) { |
135 | - $this->autoActive = $autoActive; |
|
135 | + $this->autoActive=$autoActive; |
|
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 | |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | * @see \Ajax\bootstrap\html\BaseHtml::compile() |
142 | 142 | */ |
143 | 143 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
144 | - if($this->autoActive){ |
|
144 | + if ($this->autoActive) { |
|
145 | 145 | $this->setActive(); |
146 | 146 | } |
147 | 147 | $count=$this->count(); |
148 | - for($i=1;$i<$count;$i++){ |
|
148 | + for ($i=1; $i<$count; $i++) { |
|
149 | 149 | $this->content[$i]->wrap($this->getContentDivider($i-1)); |
150 | 150 | } |
151 | 151 | return parent::compile($js, $view); |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
157 | 157 | */ |
158 | 158 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
159 | - foreach ($this->content as $element){ |
|
160 | - $element->on($event,$jsCode,$stopPropagation,$preventDefault); |
|
159 | + foreach ($this->content as $element) { |
|
160 | + $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
|
161 | 161 | } |
162 | 162 | return $this; |
163 | 163 | } |
164 | 164 | |
165 | 165 | |
166 | 166 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
167 | - foreach ($this->content as $element){ |
|
168 | - if($element->getProperty($this->attr)!=NULL) |
|
167 | + foreach ($this->content as $element) { |
|
168 | + if ($element->getProperty($this->attr)!=NULL) |
|
169 | 169 | $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
170 | 170 | } |
171 | 171 | return $this; |
@@ -177,35 +177,35 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function createItem($value) { |
179 | 179 | $count=$this->count(); |
180 | - $itemO=new HtmlSemDoubleElement("item-".$this->identifier."-".$count,"a","section"); |
|
181 | - if(\is_array($value)) |
|
180 | + $itemO=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "a", "section"); |
|
181 | + if (\is_array($value)) |
|
182 | 182 | $itemO->fromArray($value); |
183 | - else{ |
|
183 | + else { |
|
184 | 184 | $itemO->setContent($value); |
185 | 185 | $itemO->setProperty($this->attr, $this->getHref($count)); |
186 | 186 | } |
187 | 187 | return $itemO; |
188 | 188 | } |
189 | 189 | |
190 | - public function addIcon($icon,$index){ |
|
190 | + public function addIcon($icon, $index) { |
|
191 | 191 | $item=$this->getItem($index); |
192 | - if(isset($item)){ |
|
192 | + if (isset($item)) { |
|
193 | 193 | $icon=new HtmlIcon("icon-".$this->identifier, $icon); |
194 | 194 | $item->wrapContent($icon); |
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | - public function addItem($item){ |
|
198 | + public function addItem($item) { |
|
199 | 199 | $itemO=parent::addItem($item); |
200 | 200 | $this->addToPropertyCtrl("class", "section", array("section")); |
201 | 201 | return $itemO; |
202 | 202 | } |
203 | 203 | |
204 | - public function asLinks(){ |
|
204 | + public function asLinks() { |
|
205 | 205 | $this->contentAs("a"); |
206 | 206 | } |
207 | 207 | |
208 | - public function asTexts(){ |
|
208 | + public function asTexts() { |
|
209 | 209 | $this->contentAs("div"); |
210 | 210 | } |
211 | 211 |
@@ -8,53 +8,53 @@ |
||
8 | 8 | use Ajax\semantic\html\base\constants\Variation; |
9 | 9 | use Ajax\semantic\html\base\traits\IconTrait; |
10 | 10 | |
11 | -class HtmlInput extends HtmlSemDoubleElement{ |
|
11 | +class HtmlInput extends HtmlSemDoubleElement { |
|
12 | 12 | use IconTrait; |
13 | - public function __construct($identifier,$type="text",$value="",$placeholder=""){ |
|
14 | - parent::__construct("div-".$identifier,"div","ui input"); |
|
15 | - $this->content=new \Ajax\common\html\html5\HtmlInput($identifier,$type,$value,$placeholder); |
|
16 | - $this->_states=[State::DISABLED,State::FOCUS,State::ERROR]; |
|
13 | + public function __construct($identifier, $type="text", $value="", $placeholder="") { |
|
14 | + parent::__construct("div-".$identifier, "div", "ui input"); |
|
15 | + $this->content=new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder); |
|
16 | + $this->_states=[State::DISABLED, State::FOCUS, State::ERROR]; |
|
17 | 17 | $this->_variations=[Variation::TRANSPARENT]; |
18 | 18 | } |
19 | 19 | |
20 | - public function setFocus(){ |
|
20 | + public function setFocus() { |
|
21 | 21 | $this->addToProperty("class", State::FOCUS); |
22 | 22 | } |
23 | 23 | |
24 | - public function addLoading(){ |
|
25 | - if($this->_hasIcon===false){ |
|
24 | + public function addLoading() { |
|
25 | + if ($this->_hasIcon===false) { |
|
26 | 26 | throw new \Exception("Input must have an icon for showing a loader, use addIcon before"); |
27 | 27 | } |
28 | 28 | return $this->addToProperty("class", State::LOADING); |
29 | 29 | } |
30 | 30 | |
31 | - public function addLabel($label,$direction=Direction::LEFT,$icon=NULL){ |
|
31 | + public function addLabel($label, $direction=Direction::LEFT, $icon=NULL) { |
|
32 | 32 | $labelO=$label; |
33 | - if(\is_object($label)===false){ |
|
34 | - $labelO=new HtmlLabel("label-".$this->identifier,$label); |
|
35 | - if(isset($icon)) |
|
33 | + if (\is_object($label)===false) { |
|
34 | + $labelO=new HtmlLabel("label-".$this->identifier, $label); |
|
35 | + if (isset($icon)) |
|
36 | 36 | $labelO->addIcon($icon); |
37 | - }else{ |
|
37 | + }else { |
|
38 | 38 | $labelO->addToPropertyCtrl("class", "label", array("label")); |
39 | 39 | } |
40 | 40 | $this->addToProperty("class", $direction." labeled"); |
41 | - $this->addContent($labelO,\strstr($direction,Direction::LEFT)!==false); |
|
41 | + $this->addContent($labelO, \strstr($direction, Direction::LEFT)!==false); |
|
42 | 42 | return $labelO; |
43 | 43 | } |
44 | 44 | |
45 | - public function addLabelToCorner($label,$direction=Direction::LEFT,$icon=NULL){ |
|
46 | - return $this->addLabel($label,$direction." corner",$icon)->toCorner($direction); |
|
45 | + public function addLabelToCorner($label, $direction=Direction::LEFT, $icon=NULL) { |
|
46 | + return $this->addLabel($label, $direction." corner", $icon)->toCorner($direction); |
|
47 | 47 | } |
48 | 48 | |
49 | - public function addAction($action,$direction=Direction::LEFT,$icon=NULL,$labeled=false){ |
|
49 | + public function addAction($action, $direction=Direction::LEFT, $icon=NULL, $labeled=false) { |
|
50 | 50 | $actionO=$action; |
51 | - if(\is_object($action)===false){ |
|
52 | - $actionO=new HtmlButton("action-".$this->identifier,$action); |
|
53 | - if(isset($icon)) |
|
54 | - $actionO->addIcon($icon,true,$labeled); |
|
51 | + if (\is_object($action)===false) { |
|
52 | + $actionO=new HtmlButton("action-".$this->identifier, $action); |
|
53 | + if (isset($icon)) |
|
54 | + $actionO->addIcon($icon, true, $labeled); |
|
55 | 55 | } |
56 | 56 | $this->addToProperty("class", $direction." action"); |
57 | - $this->addContent($actionO,\strstr($direction,Direction::LEFT)!==false); |
|
57 | + $this->addContent($actionO, \strstr($direction, Direction::LEFT)!==false); |
|
58 | 58 | return $actionO; |
59 | 59 | } |
60 | 60 |
@@ -7,16 +7,16 @@ discard block |
||
7 | 7 | trait IconTrait { |
8 | 8 | private $_hasIcon=false; |
9 | 9 | |
10 | - public function addIcon($icon,$direction=Direction::LEFT){ |
|
11 | - if($this->_hasIcon===false){ |
|
10 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
11 | + if ($this->_hasIcon===false) { |
|
12 | 12 | $iconO=$icon; |
13 | - if(\is_string($icon)){ |
|
13 | + if (\is_string($icon)) { |
|
14 | 14 | $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
15 | 15 | } |
16 | 16 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
17 | - $this->addContent($iconO,false); |
|
17 | + $this->addContent($iconO, false); |
|
18 | 18 | $this->_hasIcon=true; |
19 | - }else{ |
|
19 | + }else { |
|
20 | 20 | $iconO=$this->getIcon(); |
21 | 21 | $iconO->setIcon($icon); |
22 | 22 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | return $iconO; |
25 | 25 | } |
26 | 26 | |
27 | - public function getIcon(){ |
|
28 | - if(\is_array($this->content)){ |
|
29 | - foreach ($this->content as $item){ |
|
30 | - if($item instanceof HtmlIcon) |
|
27 | + public function getIcon() { |
|
28 | + if (\is_array($this->content)) { |
|
29 | + foreach ($this->content as $item) { |
|
30 | + if ($item instanceof HtmlIcon) |
|
31 | 31 | return $item; |
32 | 32 | } |
33 | 33 | } |
@@ -5,5 +5,5 @@ |
||
5 | 5 | use Ajax\common\BaseEnum; |
6 | 6 | |
7 | 7 | abstract class Emphasis extends BaseEnum { |
8 | - const PRIMARY="primary",SECONDARY="secondary",TERTIARY="tertiary"; |
|
8 | + const PRIMARY="primary", SECONDARY="secondary", TERTIARY="tertiary"; |
|
9 | 9 | } |
10 | 10 | \ No newline at end of file |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | protected $_contentSeparator=""; |
23 | 23 | |
24 | 24 | |
25 | - public function __construct($identifier,$tagName,$baseClass){ |
|
26 | - parent::__construct($identifier,$tagName,$baseClass); |
|
25 | + public function __construct($identifier, $tagName, $baseClass) { |
|
26 | + parent::__construct($identifier, $tagName, $baseClass); |
|
27 | 27 | $this->root=""; |
28 | 28 | $this->attr="data-ajax"; |
29 | 29 | } |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | * @param string $attr the html attribute used to build the elements url |
36 | 36 | * @return HtmlNavElement |
37 | 37 | */ |
38 | - public function autoGetOnClick($targetSelector){ |
|
39 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
38 | + public function autoGetOnClick($targetSelector) { |
|
39 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
40 | 40 | } |
41 | 41 | |
42 | - public function contentAsString(){ |
|
42 | + public function contentAsString() { |
|
43 | 43 | return JArray::implode($this->_contentSeparator, $this->content); |
44 | 44 | } |
45 | 45 | |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | * Generate the jquery script to set the elements to the HtmlNavElement |
48 | 48 | * @param JsUtils $jsUtils |
49 | 49 | */ |
50 | - public function jsSetContent(JsUtils $jsUtils){ |
|
51 | - $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
|
50 | + public function jsSetContent(JsUtils $jsUtils) { |
|
51 | + $jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function getRoot() { |
55 | 55 | return $this->root; |
56 | 56 | } |
57 | 57 | public function setRoot($root) { |
58 | - $this->root = $root; |
|
58 | + $this->root=$root; |
|
59 | 59 | return $this; |
60 | 60 | } |
61 | 61 | public function getAttr() { |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * @return HtmlNavElement |
69 | 69 | */ |
70 | 70 | public function setAttr($attr) { |
71 | - $this->attr = $attr; |
|
71 | + $this->attr=$attr; |
|
72 | 72 | return $this; |
73 | 73 | } |
74 | 74 | |
75 | 75 | public function __call($method, $args) { |
76 | - if(isset($this->$method) && is_callable($this->$method)) { |
|
76 | + if (isset($this->$method) && is_callable($this->$method)) { |
|
77 | 77 | return call_user_func_array( |
78 | 78 | $this->$method, |
79 | 79 | $args |
@@ -81,32 +81,32 @@ discard block |
||
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | - public abstract function fromDispatcher($dispatcher,$startIndex=0); |
|
84 | + public abstract function fromDispatcher($dispatcher, $startIndex=0); |
|
85 | 85 | |
86 | 86 | |
87 | - public function setContentDivider($divider,$index=NULL) { |
|
87 | + public function setContentDivider($divider, $index=NULL) { |
|
88 | 88 | $divider="<div class='divider'> {$divider} </div>"; |
89 | 89 | return $this->setDivider($divider, $index); |
90 | 90 | } |
91 | 91 | |
92 | - public function setIconContentDivider($iconContentDivider,$index=NULL) { |
|
92 | + public function setIconContentDivider($iconContentDivider, $index=NULL) { |
|
93 | 93 | $contentDivider="<i class='".$iconContentDivider." icon divider'></i>"; |
94 | 94 | return $this->setDivider($contentDivider, $index); |
95 | 95 | } |
96 | 96 | |
97 | - protected function setDivider($divider,$index){ |
|
98 | - if(isset($index)){ |
|
99 | - if(\is_array($this->_contentSeparator)===false) |
|
100 | - $this->_contentSeparator=array_fill (0, $this->count()-1,$this->_contentSeparator); |
|
97 | + protected function setDivider($divider, $index) { |
|
98 | + if (isset($index)) { |
|
99 | + if (\is_array($this->_contentSeparator)===false) |
|
100 | + $this->_contentSeparator=array_fill(0, $this->count()-1, $this->_contentSeparator); |
|
101 | 101 | $this->_contentSeparator[$index]=$divider; |
102 | - }else{ |
|
102 | + }else { |
|
103 | 103 | $this->_contentSeparator=$divider; |
104 | 104 | } |
105 | 105 | return $this; |
106 | 106 | } |
107 | 107 | |
108 | - protected function getContentDivider($index){ |
|
109 | - if(\is_array($this->_contentSeparator)===true){ |
|
108 | + protected function getContentDivider($index) { |
|
109 | + if (\is_array($this->_contentSeparator)===true) { |
|
110 | 110 | return @$this->_contentSeparator[$index]; |
111 | 111 | } |
112 | 112 | return $this->_contentSeparator; |
@@ -20,21 +20,21 @@ |
||
20 | 20 | public static function getDefaultValue($array, $key, $default) { |
21 | 21 | if (array_key_exists($key, $array)) { |
22 | 22 | return $array [$key]; |
23 | - } else |
|
23 | + }else |
|
24 | 24 | return $default; |
25 | 25 | } |
26 | 26 | |
27 | - public static function implode($glue,$pieces){ |
|
27 | + public static function implode($glue, $pieces) { |
|
28 | 28 | $result=""; |
29 | - if(\is_array($glue)){ |
|
29 | + if (\is_array($glue)) { |
|
30 | 30 | $size=\sizeof($pieces); |
31 | - if($size>0){ |
|
32 | - for($i=0;$i<$size-1;$i++){ |
|
31 | + if ($size>0) { |
|
32 | + for ($i=0; $i<$size-1; $i++) { |
|
33 | 33 | $result.=$pieces[$i].@$glue[$i]; |
34 | 34 | } |
35 | 35 | $result.=$pieces[$size-1]; |
36 | 36 | } |
37 | - }else{ |
|
37 | + }else { |
|
38 | 38 | $result=\implode($glue, $pieces); |
39 | 39 | } |
40 | 40 | return $result; |
@@ -17,31 +17,31 @@ discard block |
||
17 | 17 | } |
18 | 18 | protected $mClass="menu"; |
19 | 19 | protected $mTagName="div"; |
20 | - protected $items=array (); |
|
21 | - protected $params=array("action"=>"nothing","on"=>"hover"); |
|
20 | + protected $items=array(); |
|
21 | + protected $params=array("action"=>"nothing", "on"=>"hover"); |
|
22 | 22 | protected $input; |
23 | 23 | |
24 | 24 | public function __construct($identifier, $value="", $items=array()) { |
25 | 25 | parent::__construct($identifier, "div"); |
26 | 26 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
27 | 27 | $this->setProperty("class", "ui dropdown"); |
28 | - $content=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
28 | + $content=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
29 | 29 | $content->setClass("text"); |
30 | 30 | $content->setContent($value); |
31 | - $content->wrap("",new HtmlIcon("", "dropdown")); |
|
31 | + $content->wrap("", new HtmlIcon("", "dropdown")); |
|
32 | 32 | $this->content=array($content); |
33 | 33 | $this->tagName="div"; |
34 | 34 | $this->addItems($items); |
35 | 35 | } |
36 | 36 | |
37 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
38 | - $itemO=$this->beforeAddItem($item,$value,$image); |
|
37 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
38 | + $itemO=$this->beforeAddItem($item, $value, $image); |
|
39 | 39 | $this->items[]=$itemO; |
40 | 40 | return $itemO; |
41 | 41 | } |
42 | 42 | |
43 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
44 | - $this->addIconP($icon,$before,$labeled); |
|
43 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
44 | + $this->addIconP($icon, $before, $labeled); |
|
45 | 45 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
46 | 46 | } |
47 | 47 | /** |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | * @param number $position |
51 | 51 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
52 | 52 | */ |
53 | - public function insertItem($item,$position=0){ |
|
53 | + public function insertItem($item, $position=0) { |
|
54 | 54 | $itemO=$this->beforeAddItem($item); |
55 | - $start = array_slice($this->items, 0, $position); |
|
56 | - $end = array_slice($this->items, $position); |
|
57 | - $start[] = $item; |
|
55 | + $start=array_slice($this->items, 0, $position); |
|
56 | + $end=array_slice($this->items, $position); |
|
57 | + $start[]=$item; |
|
58 | 58 | $this->items=array_merge($start, $end); |
59 | 59 | return $itemO; |
60 | 60 | } |
61 | 61 | |
62 | - protected function beforeAddItem($item,$value=NULL,$image=NULL){ |
|
62 | + protected function beforeAddItem($item, $value=NULL, $image=NULL) { |
|
63 | 63 | $itemO=$item; |
64 | - if(!$item instanceof HtmlDropdownItem){ |
|
65 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
|
66 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
64 | + if (!$item instanceof HtmlDropdownItem) { |
|
65 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image); |
|
66 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
67 | 67 | $this->addToProperty("class", "vertical"); |
68 | 68 | } |
69 | 69 | return $itemO; |
@@ -76,76 +76,76 @@ discard block |
||
76 | 76 | $this->addItem($function($object)); |
77 | 77 | } |
78 | 78 | |
79 | - public function addInput($name){ |
|
80 | - if(!isset($name)) |
|
79 | + public function addInput($name) { |
|
80 | + if (!isset($name)) |
|
81 | 81 | $name="input-".$this->identifier; |
82 | 82 | $this->setAction("activate"); |
83 | - $this->input=new HtmlInput($name,"hidden"); |
|
83 | + $this->input=new HtmlInput($name, "hidden"); |
|
84 | 84 | } |
85 | 85 | |
86 | - public function addItems($items){ |
|
87 | - if(JArray::isAssociative($items)){ |
|
88 | - foreach ($items as $k=>$v){ |
|
86 | + public function addItems($items) { |
|
87 | + if (JArray::isAssociative($items)) { |
|
88 | + foreach ($items as $k=>$v) { |
|
89 | 89 | $this->addItem($v)->setData($k); |
90 | 90 | } |
91 | - }else{ |
|
92 | - foreach ($items as $item){ |
|
91 | + }else { |
|
92 | + foreach ($items as $item) { |
|
93 | 93 | $this->addItem($item); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - public function count(){ |
|
98 | + public function count() { |
|
99 | 99 | return \sizeof($this->items); |
100 | 100 | } |
101 | 101 | /** |
102 | 102 | * @param boolean $dropdown |
103 | 103 | */ |
104 | - public function asDropdown($dropdown){ |
|
105 | - if($dropdown===false){ |
|
104 | + public function asDropdown($dropdown) { |
|
105 | + if ($dropdown===false) { |
|
106 | 106 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
107 | 107 | $dropdown="menu"; |
108 | - }else{ |
|
108 | + }else { |
|
109 | 109 | $dropdown="dropdown"; |
110 | 110 | $this->mClass="menu"; |
111 | 111 | } |
112 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
112 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
113 | 113 | } |
114 | 114 | |
115 | - public function setVertical(){ |
|
116 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
115 | + public function setVertical() { |
|
116 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
117 | 117 | } |
118 | 118 | |
119 | - public function setSimple(){ |
|
120 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
119 | + public function setSimple() { |
|
120 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
121 | 121 | } |
122 | 122 | |
123 | - public function asButton($floating=false){ |
|
124 | - if($floating) |
|
123 | + public function asButton($floating=false) { |
|
124 | + if ($floating) |
|
125 | 125 | $this->addToProperty("class", "floating"); |
126 | 126 | return $this->addToProperty("class", "button"); |
127 | 127 | } |
128 | 128 | |
129 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
130 | - if(isset($name)) |
|
129 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
130 | + if (isset($name)) |
|
131 | 131 | $this->addInput($name); |
132 | - if($multiple) |
|
132 | + if ($multiple) |
|
133 | 133 | $this->addToProperty("class", "multiple"); |
134 | 134 | if ($selection) |
135 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
135 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 | |
139 | - public function asSearch($name=NULL,$multiple=false,$selection=false){ |
|
140 | - $this->asSelect($name,$multiple,$selection); |
|
139 | + public function asSearch($name=NULL, $multiple=false, $selection=false) { |
|
140 | + $this->asSelect($name, $multiple, $selection); |
|
141 | 141 | return $this->addToProperty("class", "search"); |
142 | 142 | } |
143 | 143 | |
144 | - public function setSelect($name=NULL,$multiple=false){ |
|
145 | - if(!isset($name)) |
|
144 | + public function setSelect($name=NULL, $multiple=false) { |
|
145 | + if (!isset($name)) |
|
146 | 146 | $name="select-".$this->identifier; |
147 | 147 | $this->input=null; |
148 | - if($multiple){ |
|
148 | + if ($multiple) { |
|
149 | 149 | $this->setProperty("multiple", true); |
150 | 150 | $this->addToProperty("class", "multiple"); |
151 | 151 | } |
@@ -153,32 +153,32 @@ discard block |
||
153 | 153 | $this->tagName="select"; |
154 | 154 | $this->setProperty("name", $name); |
155 | 155 | $this->content=null; |
156 | - foreach ($this->items as $item){ |
|
156 | + foreach ($this->items as $item) { |
|
157 | 157 | $item->asOption(); |
158 | 158 | } |
159 | 159 | return $this; |
160 | 160 | } |
161 | 161 | |
162 | - public function asSubmenu($pointing=NULL){ |
|
162 | + public function asSubmenu($pointing=NULL) { |
|
163 | 163 | $this->setClass("ui dropdown link item"); |
164 | - if(isset($pointing)){ |
|
164 | + if (isset($pointing)) { |
|
165 | 165 | $this->setPointing($pointing); |
166 | 166 | } |
167 | 167 | return $this; |
168 | 168 | } |
169 | 169 | |
170 | - public function setPointing($value=Direction::NONE){ |
|
171 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
170 | + public function setPointing($value=Direction::NONE) { |
|
171 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function setValue($value){ |
|
175 | - if(isset($this->input)){ |
|
174 | + public function setValue($value) { |
|
175 | + if (isset($this->input)) { |
|
176 | 176 | $this->input->setProperty("value", $value); |
177 | - }else{ |
|
177 | + }else { |
|
178 | 178 | $this->setProperty("value", $value); |
179 | 179 | } |
180 | 180 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
181 | - if(isset($textElement)) |
|
181 | + if (isset($textElement)) |
|
182 | 182 | $textElement->setContent($value); |
183 | 183 | return $this; |
184 | 184 | } |
@@ -188,19 +188,19 @@ discard block |
||
188 | 188 | * @see BaseHtml::run() |
189 | 189 | */ |
190 | 190 | public function run(JsUtils $js) { |
191 | - if($this->propertyContains("class", "simple")===false){ |
|
192 | - if(isset($this->_bsComponent)===false) |
|
193 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->params); |
|
191 | + if ($this->propertyContains("class", "simple")===false) { |
|
192 | + if (isset($this->_bsComponent)===false) |
|
193 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->params); |
|
194 | 194 | $this->addEventsOnRun($js); |
195 | 195 | return $this->_bsComponent; |
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - public function setAction($action){ |
|
199 | + public function setAction($action) { |
|
200 | 200 | $this->params["action"]=$action; |
201 | 201 | } |
202 | 202 | |
203 | - public function setFullTextSearch($value){ |
|
203 | + public function setFullTextSearch($value) { |
|
204 | 204 | $this->params["fullTextSearch"]=$value; |
205 | 205 | } |
206 | 206 | } |
207 | 207 | \ No newline at end of file |