public function __construct(Container $c, array $config = array())
{
// Store the container reference in this object
$this->container = $c;
// Get a reference to some useful objects
$input = $this->container->input;
$platform = $this->container->platform;
// Get default permissions (can be overriden by the view)
$perms = (object) array('manage' => $this->container->platform->authorise('core.manage', $input->getCmd('option', 'com_foobar')), 'create' => $this->container->platform->authorise('core.create', $input->getCmd('option', 'com_foobar')), 'edit' => $this->container->platform->authorise('core.edit', $input->getCmd('option', 'com_foobar')), 'editstate' => $this->container->platform->authorise('core.edit.state', $input->getCmd('option', 'com_foobar')), 'delete' => $this->container->platform->authorise('core.delete', $input->getCmd('option', 'com_foobar')));
// Save front-end toolbar and submenu rendering flags if present in the config
if (array_key_exists('renderFrontendButtons', $config)) {
$this->renderFrontendButtons = $config['renderFrontendButtons'];
}
if (array_key_exists('renderFrontendSubmenu', $config)) {
$this->renderFrontendSubmenu = $config['renderFrontendSubmenu'];
}
// If not in the administrative area, load the JToolbarHelper
if (!$platform->isBackend()) {
// Needed for tests, so we can inject our "special" helper class
if (!class_exists('\\JToolbarHelper')) {
$platformDirs = $platform->getPlatformBaseDirs();
$path = $platformDirs['root'] . '/administrator/includes/toolbar.php';
require_once $path;
}
// Things to do if we have to render a front-end toolbar
if ($this->renderFrontendButtons) {
// Load back-end toolbar language files in front-end
$platform->loadTranslations('');
// Needed for tests (we can fake we're not in the backend, but we are still in CLI!)
if (!$platform->isCli()) {
// Load the core Javascript
\JHtml::_('behavior.core');
\JHtml::_('jquery.framework', true);
}
}
}
// Store permissions in the local toolbar object
$this->perms = $perms;
}