icon = $icon; } /** * Set's an icon class that will be used in an tag if no icon image is set * * @param string $iconCls The CSS class of the icon to use */ public function setIconCls($iconCls) { $this->iconCls = $iconCls; } /** * @param mixed $name */ public function setName($name) { $this->name = $name; } /** * @return mixed */ public function getName() { return $this->name; } /** * @param mixed $title */ public function setTitle($title) { $this->title = $title; } /** * Set the Url this tab points to * * @param string $url The Url to use for this tab */ public function setUrl($url) { if (is_string($url)) { $url = Url::fromPath($url); } $this->url = $url; } /** * Set the parameters to be set for this tabs Url * * @param array $url The Url parameters to set */ public function setUrlParams(array $urlParams) { $this->urlParams = $urlParams; } /** * Set additional a tag attributes * * @param array $tagParams */ public function setTagParams(array $tagParams) { $this->tagParams = $tagParams; } /** * Create a new Tab with the given properties * * Allowed properties are all properties for which a setter exists * * @param array $properties An array of properties */ public function __construct(array $properties = array()) { foreach ($properties as $name => $value) { $setter = 'set' . ucfirst($name); if (method_exists($this, $setter)) { $this->$setter($value); } } } /** * Set this tab active (default) or inactive * * This is usually done through the tabs container widget, therefore it * is not a good idea to directly call this function * * @param bool $active Whether the tab should be active * * @return self */ public function setActive($active = true) { $this->active = (bool) $active; return $this; } /** * @see Widget::render() */ public function render() { $view = $this->view(); $class = $this->active ? ' class="active" ' : ''; $caption = $view->escape($this->title); if ($this->icon !== null) { $caption = $view->img($this->icon, array('class' => 'icon')) . ' ' . $caption; } if ($this->url !== null) { $this->url->overwriteParams($this->urlParams); $tagParams = ''; if ($this->tagParams !== null) { $tagParams = $view->propertiesToString($this->tagParams); } $tab = sprintf( '%s', $this->url, $tagParams, $caption ); } else { $tab = $caption; } return '
  • ' . $tab . "
  • \n"; } }