@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | * @author jc |
16 | 16 | * @version 1.02 |
17 | 17 | */ |
18 | -class HtmlTab extends HtmlSemCollection{ |
|
18 | +class HtmlTab extends HtmlSemCollection { |
|
19 | 19 | |
20 | 20 | protected $params=[]; |
21 | 21 | protected $_activated=false; |
22 | 22 | |
23 | - public function __construct( $identifier, $tabs=array()){ |
|
24 | - parent::__construct( $identifier, "div", ""); |
|
23 | + public function __construct($identifier, $tabs=array()) { |
|
24 | + parent::__construct($identifier, "div", ""); |
|
25 | 25 | $menu=new HtmlMenu("menu".$this->identifier); |
26 | - $menu->asTab(false)->setAttachment(NULL,Side::TOP); |
|
26 | + $menu->asTab(false)->setAttachment(NULL, Side::TOP); |
|
27 | 27 | $this->content["menu"]=$menu; |
28 | 28 | $this->addItems($tabs); |
29 | 29 | } |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | * @see \Ajax\common\html\HtmlCollection::createItem() |
34 | 34 | * @return HtmlSegment |
35 | 35 | */ |
36 | - protected function createItem($value){ |
|
36 | + protected function createItem($value) { |
|
37 | 37 | $count=$this->count(); |
38 | 38 | $title=$value; |
39 | 39 | $content=NULL; |
40 | - if(\is_array($value)){ |
|
41 | - $title=@$value[0];$content=@$value[1]; |
|
40 | + if (\is_array($value)) { |
|
41 | + $title=@$value[0]; $content=@$value[1]; |
|
42 | 42 | } |
43 | 43 | $menuItem=$this->content["menu"]->addItem($title); |
44 | 44 | $menuItem->addToProperty("data-tab", $menuItem->getIdentifier()); |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param string $datatab |
55 | 55 | * @return \Ajax\semantic\html\elements\HtmlSegment |
56 | 56 | */ |
57 | - private function createSegment($count,$content,$datatab){ |
|
57 | + private function createSegment($count, $content, $datatab) { |
|
58 | 58 | $segment=new HtmlSegment("item-".$this->identifier."-".$count, $content); |
59 | - $segment->setAttachment(NULL,Side::BOTTOM)->addToProperty("class", "tab")->addToProperty("data-tab",$datatab); |
|
59 | + $segment->setAttachment(NULL, Side::BOTTOM)->addToProperty("class", "tab")->addToProperty("data-tab", $datatab); |
|
60 | 60 | return $segment; |
61 | 61 | } |
62 | 62 | |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * @param String $content new content |
67 | 67 | * @return \Ajax\semantic\html\modules\HtmlTab |
68 | 68 | */ |
69 | - public function setTabContent($index,$content){ |
|
69 | + public function setTabContent($index, $content) { |
|
70 | 70 | $menu=$this->content["menu"]; |
71 | - if($index<$menu->count()){ |
|
72 | - if(isset($this->content[$index])===false){ |
|
71 | + if ($index<$menu->count()) { |
|
72 | + if (isset($this->content[$index])===false) { |
|
73 | 73 | $this->content[$index]=$this->createSegment($index, $content, $menu->getItem($index)->getIdentifier()); |
74 | - }else |
|
74 | + } else |
|
75 | 75 | $this->content[$index]->setContent($content); |
76 | 76 | } |
77 | 77 | return $this; |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @param array $contents |
83 | 83 | * @return \Ajax\semantic\html\modules\HtmlTab |
84 | 84 | */ |
85 | - public function setTabsContent($contents){ |
|
85 | + public function setTabsContent($contents) { |
|
86 | 86 | $size=\sizeof($contents); |
87 | - for($i=0;$i<$size;$i++){ |
|
87 | + for ($i=0; $i<$size; $i++) { |
|
88 | 88 | $this->setTabContent($i, $contents[$i]); |
89 | 89 | } |
90 | 90 | return $this; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param int $index |
96 | 96 | * @return \Ajax\semantic\html\modules\HtmlTab |
97 | 97 | */ |
98 | - public function activate($index){ |
|
98 | + public function activate($index) { |
|
99 | 99 | $this->content["menu"]->getItem($index)->setActive(true); |
100 | 100 | $this->content[$index]->setActive(true); |
101 | 101 | $this->_activated=true; |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @param string $content |
109 | 109 | * @return \Ajax\semantic\html\elements\HtmlSegment |
110 | 110 | */ |
111 | - public function addTab($title,$content){ |
|
112 | - return $this->addItem([$title,$content]); |
|
111 | + public function addTab($title, $content) { |
|
112 | + return $this->addItem([$title, $content]); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | * @param array $params |
124 | 124 | * @return \Ajax\semantic\html\elements\HtmlSegment |
125 | 125 | */ |
126 | - public function forwardTab($index,JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
|
127 | - if(\array_key_exists($index, $this->content)){ |
|
128 | - $this->content[$index]=$js->forward($initialController, $controller, $action,$params); |
|
126 | + public function forwardTab($index, JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
127 | + if (\array_key_exists($index, $this->content)) { |
|
128 | + $this->content[$index]=$js->forward($initialController, $controller, $action, $params); |
|
129 | 129 | return $this->content[$index]; |
130 | 130 | } |
131 | 131 | |
132 | - return $this->addAndForwardTab($js, $title, $initialController, $controller, $action,$params); |
|
132 | + return $this->addAndForwardTab($js, $title, $initialController, $controller, $action, $params); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | * @param array $params The parameters to pass to the view |
143 | 143 | * @return \Ajax\semantic\html\elements\HtmlSegment |
144 | 144 | */ |
145 | - public function renderViewTab($index,JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
|
146 | - if(\array_key_exists($index, $this->content)){ |
|
147 | - $this->content[$index]=$js->renderContent($initialController, $viewName,$params); |
|
145 | + public function renderViewTab($index, JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
146 | + if (\array_key_exists($index, $this->content)) { |
|
147 | + $this->content[$index]=$js->renderContent($initialController, $viewName, $params); |
|
148 | 148 | return $this->content[$index]; |
149 | 149 | } |
150 | - return $this->addAndRenderViewTab($js, $title, $initialController, $viewName,$params); |
|
150 | + return $this->addAndRenderViewTab($js, $title, $initialController, $viewName, $params); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | * @param array $params |
162 | 162 | * @return \Ajax\semantic\html\elements\HtmlSegment |
163 | 163 | */ |
164 | - public function addAndForwardTab(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
|
164 | + public function addAndForwardTab(JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
165 | 165 | \ob_start(); |
166 | - $js->forward($initialController, $controller, $action,$params); |
|
166 | + $js->forward($initialController, $controller, $action, $params); |
|
167 | 167 | $content=\ob_get_clean(); |
168 | - return $this->addTab($title,$content); |
|
168 | + return $this->addTab($title, $content); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | * @param array $params The parameters to pass to the view |
178 | 178 | * @return \Ajax\semantic\html\elements\HtmlSegment |
179 | 179 | */ |
180 | - public function addAndRenderViewTab(JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
|
181 | - return $this->addTab($title, $js->renderContent($initialController, $viewName,$params)); |
|
180 | + public function addAndRenderViewTab(JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
181 | + return $this->addTab($title, $js->renderContent($initialController, $viewName, $params)); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | public function setPointing($value=Direction::NONE) { |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param int $index |
195 | 195 | * @return HtmlMenuItem |
196 | 196 | */ |
197 | - public function getMenuTab($index){ |
|
197 | + public function getMenuTab($index) { |
|
198 | 198 | return $this->content["menu"]->getItem($index); |
199 | 199 | } |
200 | 200 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param int $index |
204 | 204 | * @return HtmlSegment |
205 | 205 | */ |
206 | - public function getTab($index){ |
|
206 | + public function getTab($index) { |
|
207 | 207 | return $this->content[$index]; |
208 | 208 | } |
209 | 209 | |
@@ -212,22 +212,22 @@ discard block |
||
212 | 212 | * @param HtmlMenu $menu |
213 | 213 | * @return \Ajax\semantic\html\modules\HtmlTab |
214 | 214 | */ |
215 | - public function setMenu($menu){ |
|
215 | + public function setMenu($menu) { |
|
216 | 216 | $contentSize=\sizeof($this->content); |
217 | - for($i=0;$i<$contentSize;$i++){ |
|
218 | - if($menu->getItem($i)!==NULL){ |
|
219 | - if(isset($this->content[$i])){ |
|
220 | - $menu->getItem($i)->addToProperty("data-tab",$this->content[$i]->getProperty("data-tab")); |
|
217 | + for ($i=0; $i<$contentSize; $i++) { |
|
218 | + if ($menu->getItem($i)!==NULL) { |
|
219 | + if (isset($this->content[$i])) { |
|
220 | + $menu->getItem($i)->addToProperty("data-tab", $this->content[$i]->getProperty("data-tab")); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | } |
224 | 224 | $menuSize=$menu->count(); |
225 | - for($i=0;$i<$menuSize;$i++){ |
|
225 | + for ($i=0; $i<$menuSize; $i++) { |
|
226 | 226 | $menu->getItem($i)->removeProperty("href"); |
227 | - if(isset($this->content[$i])===false){ |
|
227 | + if (isset($this->content[$i])===false) { |
|
228 | 228 | $this->content[$i]=$this->createSegment($i, "New content", $menu->getItem($i)->getIdentifier()); |
229 | 229 | } |
230 | - $menu->getItem($i)->addToProperty("data-tab",$this->content[$i]->getProperty("data-tab")); |
|
230 | + $menu->getItem($i)->addToProperty("data-tab", $this->content[$i]->getProperty("data-tab")); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | $this->content["menu"]=$menu; |
@@ -239,15 +239,15 @@ discard block |
||
239 | 239 | * @see BaseHtml::run() |
240 | 240 | */ |
241 | 241 | public function run(JsUtils $js) { |
242 | - if(isset($this->_bsComponent)===false) |
|
243 | - $this->_bsComponent=$js->semantic()->tab("#".$this->identifier." .item",$this->params); |
|
242 | + if (isset($this->_bsComponent)===false) |
|
243 | + $this->_bsComponent=$js->semantic()->tab("#".$this->identifier." .item", $this->params); |
|
244 | 244 | $this->addEventsOnRun($js); |
245 | 245 | return $this->_bsComponent; |
246 | 246 | } |
247 | 247 | |
248 | 248 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
249 | - if(!$this->_activated && $this->content["menu"]->count()>0 && \sizeof($this->content)>1) |
|
249 | + if (!$this->_activated && $this->content["menu"]->count()>0 && \sizeof($this->content)>1) |
|
250 | 250 | $this->activate(0); |
251 | - return parent::compile($js,$view); |
|
251 | + return parent::compile($js, $view); |
|
252 | 252 | } |
253 | 253 | } |
@@ -71,8 +71,9 @@ discard block |
||
71 | 71 | if($index<$menu->count()){ |
72 | 72 | if(isset($this->content[$index])===false){ |
73 | 73 | $this->content[$index]=$this->createSegment($index, $content, $menu->getItem($index)->getIdentifier()); |
74 | - }else |
|
75 | - $this->content[$index]->setContent($content); |
|
74 | + } else { |
|
75 | + $this->content[$index]->setContent($content); |
|
76 | + } |
|
76 | 77 | } |
77 | 78 | return $this; |
78 | 79 | } |
@@ -239,15 +240,17 @@ discard block |
||
239 | 240 | * @see BaseHtml::run() |
240 | 241 | */ |
241 | 242 | public function run(JsUtils $js) { |
242 | - if(isset($this->_bsComponent)===false) |
|
243 | - $this->_bsComponent=$js->semantic()->tab("#".$this->identifier." .item",$this->params); |
|
243 | + if(isset($this->_bsComponent)===false) { |
|
244 | + $this->_bsComponent=$js->semantic()->tab("#".$this->identifier." .item",$this->params); |
|
245 | + } |
|
244 | 246 | $this->addEventsOnRun($js); |
245 | 247 | return $this->_bsComponent; |
246 | 248 | } |
247 | 249 | |
248 | 250 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
249 | - if(!$this->_activated && $this->content["menu"]->count()>0 && \sizeof($this->content)>1) |
|
250 | - $this->activate(0); |
|
251 | + if(!$this->_activated && $this->content["menu"]->count()>0 && \sizeof($this->content)>1) { |
|
252 | + $this->activate(0); |
|
253 | + } |
|
251 | 254 | return parent::compile($js,$view); |
252 | 255 | } |
253 | 256 | } |