Created
January 7, 2016 11:53
-
-
Save romaninsh/03c2eba627c07b49ba7d to your computer and use it in GitHub Desktop.
This is implementation of "Tabs" that also support icons in the tab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Tabs extends View_Tabs_jUItabs { | |
function addTab($title,$name=null){ | |
$container=$this->add('View_HtmlElement',$name); | |
$this->tab_template->set(array( | |
'url'=>'#'.$container->name, | |
'tab_id'=>$container->short_name, | |
)); | |
if(is_array($title)){ | |
if($title['icon']){ | |
$icon = '<span class="icon-'.$title['icon'].'"></span>'; | |
$this->tab_template->setHTML('tab_name', $icon.' '.htmlspecialchars($title[0],ENT_NOQUOTES,'UTF-8')); | |
} else $title = $title[0]; | |
} | |
if(!is_array($title)){ | |
$this->tab_template->setHTML('tab_name', $title); | |
} | |
$this->template->appendHTML('tabs',$this->tab_template->render()); | |
return $container; | |
} | |
function addTabURL($page,$title=null){ | |
if(is_null($title)){ | |
$title=ucwords(preg_replace('/[_\/\.]+/',' ',$page)); | |
} | |
$this->tab_template->set(array( | |
'url'=>$this->api->url($page,array('cut_page'=>1)), | |
'tab_name'=>$title, | |
'tab_id'=>basename($page), | |
)); | |
if(is_array($title)){ | |
if($title['icon']){ | |
$icon = '<span class="icon-'.$title['icon'].'"></span>'; | |
$this->tab_template->setHTML('tab_name', $icon.' '.htmlspecialchars($title[0],ENT_NOQUOTES,'UTF-8')); | |
} else $title = $title[0]; | |
} | |
if(!is_array($title)){ | |
$this->tab_template->setHTML('tab_name', $title); | |
} | |
$this->template->appendHTML('tabs',$this->tab_template->render()); | |
return $this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment