<?php
class AnUikitViewToolbar extends AnUikitViewAbstract
{
/**
* Associatives array of view names
*
* @var array
*/
protected $_views;
/**
*
* @return
* @param $options Object
*/
public function __construct($options)
{
parent::__construct($options);
// Initialize the options
$options = $this->_initialize($options);
$this->_views = $options['views'];
//Render the submenu
foreach($this->_views as $view => $title)
{
$active = ($view == strtolower($this->getName()));
$component = $this->_identifier->package;
JSubMenuHelper::addEntry(JText::_($title), 'index.php?option=com_'.$component.'&view='.$view, $active );
}
}
/**
* Initializes the options for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param array Options
* @return array Options
*/
protected function _initialize(array $options)
{
$options = parent::_initialize($options);
$defaults = array(
'views' => array(),
);
return array_merge($defaults, $options);
}
/**
*
* @return
* @param $layout Object
*/
public function prepareLayout( $layout )
{
parent::prepareLayout($layout);
$toolbar = $this->getToolbar();
$this->_document->setBuffer($toolbar->render(), 'modules', 'toolbar');
$this->_document->setBuffer($toolbar->renderTitle(), 'modules', 'title');
}
/**
* Get the identifier for the toolbar with the same name
*
* @return KIdentifierInterface
*/
public function getToolbar()
{
$identifier = clone $this->_identifier;
$identifier->path = array('toolbar');
$identifier->name = $this->getName();
return KFactory::get($identifier);
}
}