@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | * @author jc |
| 15 | 15 | * @version 1.001 |
| 16 | 16 | */ |
| 17 | -class HtmlTab extends HtmlSemCollection{ |
|
| 17 | +class HtmlTab extends HtmlSemCollection { |
|
| 18 | 18 | |
| 19 | 19 | protected $params=array("debug"=>true); |
| 20 | 20 | |
| 21 | - public function __construct( $identifier, $tabs=array()){ |
|
| 22 | - parent::__construct( $identifier, "div", ""); |
|
| 21 | + public function __construct($identifier, $tabs=array()) { |
|
| 22 | + parent::__construct($identifier, "div", ""); |
|
| 23 | 23 | $menu=new HtmlMenu("menu".$this->identifier); |
| 24 | - $menu->asTab(false)->setAttachment(NULL,Side::TOP); |
|
| 24 | + $menu->asTab(false)->setAttachment(NULL, Side::TOP); |
|
| 25 | 25 | $this->content["menu"]=$menu; |
| 26 | 26 | $this->addItems($tabs); |
| 27 | 27 | } |
@@ -31,12 +31,12 @@ discard block |
||
| 31 | 31 | * @see \Ajax\common\html\HtmlCollection::createItem() |
| 32 | 32 | * @return HtmlSegment |
| 33 | 33 | */ |
| 34 | - protected function createItem($value){ |
|
| 34 | + protected function createItem($value) { |
|
| 35 | 35 | $count=$this->count(); |
| 36 | 36 | $title=$value; |
| 37 | 37 | $content=NULL; |
| 38 | - if(\is_array($value)){ |
|
| 39 | - $title=@$value[0];$content=@$value[1]; |
|
| 38 | + if (\is_array($value)) { |
|
| 39 | + $title=@$value[0]; $content=@$value[1]; |
|
| 40 | 40 | } |
| 41 | 41 | $menuItem=$this->content["menu"]->addItem($title); |
| 42 | 42 | $menuItem->addToProperty("data-tab", $menuItem->getIdentifier()); |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | * @param string $datatab |
| 51 | 51 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 52 | 52 | */ |
| 53 | - private function createSegment($count,$content,$datatab){ |
|
| 53 | + private function createSegment($count, $content, $datatab) { |
|
| 54 | 54 | $segment=new HtmlSegment("item-".$this->identifier."-".$count, $content); |
| 55 | - $segment->setAttachment(NULL,Side::BOTTOM)->addToProperty("class", "tab")->addToProperty("data-tab",$datatab); |
|
| 55 | + $segment->setAttachment(NULL, Side::BOTTOM)->addToProperty("class", "tab")->addToProperty("data-tab", $datatab); |
|
| 56 | 56 | return $segment; |
| 57 | 57 | } |
| 58 | 58 | |
@@ -62,12 +62,12 @@ discard block |
||
| 62 | 62 | * @param String $content new content |
| 63 | 63 | * @return \Ajax\semantic\html\modules\HtmlTab |
| 64 | 64 | */ |
| 65 | - public function setTabContent($index,$content){ |
|
| 65 | + public function setTabContent($index, $content) { |
|
| 66 | 66 | $menu=$this->content["menu"]; |
| 67 | - if($index<$menu->count()){ |
|
| 68 | - if(isset($this->content[$index])===false){ |
|
| 67 | + if ($index<$menu->count()) { |
|
| 68 | + if (isset($this->content[$index])===false) { |
|
| 69 | 69 | $this->content[$index]=$this->createSegment($index, $content, $menu->getItem($index)->getIdentifier()); |
| 70 | - }else |
|
| 70 | + } else |
|
| 71 | 71 | $this->content[$index]->setContent($content); |
| 72 | 72 | } |
| 73 | 73 | return $this; |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * @param array $contents |
| 79 | 79 | * @return \Ajax\semantic\html\modules\HtmlTab |
| 80 | 80 | */ |
| 81 | - public function setTabsContent($contents){ |
|
| 82 | - for($i=0;$i<\sizeof($contents);$i++){ |
|
| 81 | + public function setTabsContent($contents) { |
|
| 82 | + for ($i=0; $i<\sizeof($contents); $i++) { |
|
| 83 | 83 | $this->setTabContent($i, $contents[$i]); |
| 84 | 84 | } |
| 85 | 85 | return $this; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param int $index |
| 91 | 91 | * @return \Ajax\semantic\html\modules\HtmlTab |
| 92 | 92 | */ |
| 93 | - public function activate($index){ |
|
| 93 | + public function activate($index) { |
|
| 94 | 94 | $this->content["menu"]->getItem($index)->setActive(true); |
| 95 | 95 | $this->content[$index]->setActive(true); |
| 96 | 96 | return $this; |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | * @param string $content |
| 103 | 103 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 104 | 104 | */ |
| 105 | - public function addTab($title,$content){ |
|
| 106 | - return $this->addItem([$title,$content]); |
|
| 105 | + public function addTab($title, $content) { |
|
| 106 | + return $this->addItem([$title, $content]); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -117,13 +117,13 @@ discard block |
||
| 117 | 117 | * @param array $params |
| 118 | 118 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 119 | 119 | */ |
| 120 | - public function forwardTab($index,JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
|
| 121 | - if(\array_key_exists($index, $this->content)){ |
|
| 122 | - $this->content[$index]=$js->forward($initialController, $controller, $action,$params); |
|
| 120 | + public function forwardTab($index, JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
| 121 | + if (\array_key_exists($index, $this->content)) { |
|
| 122 | + $this->content[$index]=$js->forward($initialController, $controller, $action, $params); |
|
| 123 | 123 | return $this->content[$index]; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - return $this->addAndForwardTab($js, $title, $initialController, $controller, $action,$params); |
|
| 126 | + return $this->addAndForwardTab($js, $title, $initialController, $controller, $action, $params); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -136,12 +136,12 @@ discard block |
||
| 136 | 136 | * @param $params The parameters to pass to the view |
| 137 | 137 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 138 | 138 | */ |
| 139 | - public function renderViewTab($index,JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
|
| 140 | - if(\array_key_exists($index, $this->content)){ |
|
| 141 | - $this->content[$index]=$js->renderContent($initialController, $viewName,$params); |
|
| 139 | + public function renderViewTab($index, JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
| 140 | + if (\array_key_exists($index, $this->content)) { |
|
| 141 | + $this->content[$index]=$js->renderContent($initialController, $viewName, $params); |
|
| 142 | 142 | return $this->content[$index]; |
| 143 | 143 | } |
| 144 | - return $this->addAndRenderViewTab($js, $title, $initialController, $viewName,$params); |
|
| 144 | + return $this->addAndRenderViewTab($js, $title, $initialController, $viewName, $params); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | * @param array $params |
| 156 | 156 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 157 | 157 | */ |
| 158 | - public function addAndForwardTab(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
|
| 159 | - return $this->addTab($title, $js->forward($initialController, $controller, $action,$params)); |
|
| 158 | + public function addAndForwardTab(JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
| 159 | + return $this->addTab($title, $js->forward($initialController, $controller, $action, $params)); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | * @param $params The parameters to pass to the view |
| 169 | 169 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 170 | 170 | */ |
| 171 | - public function addAndRenderViewTab(JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
|
| 172 | - return $this->addTab($title, $js->renderContent($initialController, $viewName,$params)); |
|
| 171 | + public function addAndRenderViewTab(JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
| 172 | + return $this->addTab($title, $js->renderContent($initialController, $viewName, $params)); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | public function setPointing($value=Direction::NONE) { |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * @param int $index |
| 186 | 186 | * @return Ajax\semantic\html\content\HtmlMenuItem |
| 187 | 187 | */ |
| 188 | - public function getMenuTab($index){ |
|
| 188 | + public function getMenuTab($index) { |
|
| 189 | 189 | return $this->content["menu"]->getItem($index); |
| 190 | 190 | } |
| 191 | 191 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @param int $index |
| 195 | 195 | * @return HtmlSegment |
| 196 | 196 | */ |
| 197 | - public function getTab($index){ |
|
| 197 | + public function getTab($index) { |
|
| 198 | 198 | return $this->content[$index]; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -203,20 +203,20 @@ discard block |
||
| 203 | 203 | * @param HtmlMenu $menu |
| 204 | 204 | * @return \Ajax\semantic\html\modules\HtmlTab |
| 205 | 205 | */ |
| 206 | - public function setMenu($menu){ |
|
| 207 | - for($i=0;$i<\sizeof($this->content);$i++){ |
|
| 208 | - if($menu->getItem($i)!==NULL){ |
|
| 209 | - if(isset($this->content[$i])===true){ |
|
| 210 | - $menu->getItem($i)->addToProperty("data-tab",$this->content[$i]->getProperty("data-tab")); |
|
| 206 | + public function setMenu($menu) { |
|
| 207 | + for ($i=0; $i<\sizeof($this->content); $i++) { |
|
| 208 | + if ($menu->getItem($i)!==NULL) { |
|
| 209 | + if (isset($this->content[$i])===true) { |
|
| 210 | + $menu->getItem($i)->addToProperty("data-tab", $this->content[$i]->getProperty("data-tab")); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | - for($i=0;$i<$menu->count();$i++){ |
|
| 214 | + for ($i=0; $i<$menu->count(); $i++) { |
|
| 215 | 215 | $menu->getItem($i)->removeProperty("href"); |
| 216 | - if(isset($this->content[$i])===false){ |
|
| 216 | + if (isset($this->content[$i])===false) { |
|
| 217 | 217 | $this->content[$i]=$this->createSegment($i, "New content", $menu->getItem($i)->getIdentifier()); |
| 218 | 218 | } |
| 219 | - $menu->getItem($i)->addToProperty("data-tab",$this->content[$i]->getProperty("data-tab")); |
|
| 219 | + $menu->getItem($i)->addToProperty("data-tab", $this->content[$i]->getProperty("data-tab")); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | $this->content["menu"]=$menu; |
@@ -228,15 +228,15 @@ discard block |
||
| 228 | 228 | * @see BaseHtml::run() |
| 229 | 229 | */ |
| 230 | 230 | public function run(JsUtils $js) { |
| 231 | - if(isset($this->_bsComponent)===false) |
|
| 232 | - $this->_bsComponent=$js->semantic()->tab("#".$this->identifier." .item",$this->params); |
|
| 231 | + if (isset($this->_bsComponent)===false) |
|
| 232 | + $this->_bsComponent=$js->semantic()->tab("#".$this->identifier." .item", $this->params); |
|
| 233 | 233 | $this->addEventsOnRun($js); |
| 234 | 234 | return $this->_bsComponent; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 238 | - if($this->content["menu"]->count()>0 && \sizeof($this->content)>1) |
|
| 238 | + if ($this->content["menu"]->count()>0 && \sizeof($this->content)>1) |
|
| 239 | 239 | $this->activate(0); |
| 240 | - return parent::compile($js,$view); |
|
| 240 | + return parent::compile($js, $view); |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | \ No newline at end of file |