Skip to content

Instantly share code, notes, and snippets.

@romaninsh
Created January 7, 2016 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romaninsh/03c2eba627c07b49ba7d to your computer and use it in GitHub Desktop.
Save romaninsh/03c2eba627c07b49ba7d to your computer and use it in GitHub Desktop.
This is implementation of "Tabs" that also support icons in the tab
<?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.'&nbsp;'.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.'&nbsp;'.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