priority = 60;
$this->enabled = class_exists('AkeebaStrapper');
}
/**
* Echoes any HTML to show before the view template
*
* @param string $view The current view
* @param string $task The current task
* @param F0FInput $input The input array (request parameters)
* @param array $config The view configuration array
*
* @return void
*/
public function preRender($view, $task, $input, $config = array())
{
$format = $input->getCmd('format', 'html');
if (empty($format))
{
$format = 'html';
}
if ($format != 'html')
{
return;
}
$platform = F0FPlatform::getInstance();
if ($platform->isCli())
{
return;
}
if (version_compare(JVERSION, '3.0.0', 'lt'))
{
JHtml::_('behavior.framework');
}
else
{
if (version_compare(JVERSION, '3.3.0', 'ge'))
{
JHtml::_('behavior.core');
}
else
{
JHtml::_('behavior.framework', true);
}
JHtml::_('jquery.framework');
}
// Wrap output in various classes
$version = new JVersion;
$versionParts = explode('.', $version->RELEASE);
$minorVersion = str_replace('.', '', $version->RELEASE);
$majorVersion = array_shift($versionParts);
if ($platform->isBackend())
{
$area = $platform->isBackend() ? 'admin' : 'site';
$option = $input->getCmd('option', '');
$view = $input->getCmd('view', '');
$layout = $input->getCmd('layout', '');
$task = $input->getCmd('task', '');
$classes = array(
'joomla-version-' . $majorVersion,
'joomla-version-' . $minorVersion,
$area,
$option,
'view-' . $view,
'layout-' . $layout,
'task-' . $task,
// We have a floating sidebar, they said. It looks great, they said. They must've been blind, I say!
'j-toggle-main',
'j-toggle-transition',
'span12',
);
}
elseif ($platform->isFrontend())
{
// @TODO: Remove the frontend Joomla! version classes in FOF 3
$classes = array(
'joomla-version-' . $majorVersion,
'joomla-version-' . $minorVersion,
);
}
// Wrap output in divs
echo '
\n";
echo "
\n";
echo "
\n";
// Render submenu and toolbar (only if asked to)
if ($input->getBool('render_toolbar', true))
{
$this->renderButtons($view, $task, $input, $config);
$this->renderLinkbar($view, $task, $input, $config);
}
}
/**
* Echoes any HTML to show after the view template
*
* @param string $view The current view
* @param string $task The current task
* @param F0FInput $input The input array (request parameters)
* @param array $config The view configuration array
*
* @return void
*/
public function postRender($view, $task, $input, $config = array())
{
$format = $input->getCmd('format', 'html');
if ($format != 'html' || F0FPlatform::getInstance()->isCli())
{
return;
}
if (!F0FPlatform::getInstance()->isCli() && version_compare(JVERSION, '3.0', 'ge'))
{
$sidebarEntries = JHtmlSidebar::getEntries();
if (!empty($sidebarEntries))
{
echo '
';
}
}
echo "
\n"; // Closes row-fluid div
echo "
\n"; // Closes akeeba-bootstrap div
echo "\n"; // Closes joomla-version div
}
/**
* Loads the validation script for an edit form
*
* @param F0FForm &$form The form we are rendering
*
* @return void
*/
protected function loadValidationScript(F0FForm &$form)
{
$message = $form->getView()->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));
$js = <<getDocument();
if ($document instanceof JDocument)
{
$document->addScriptDeclaration($js);
}
}
/**
* Renders the submenu (link bar)
*
* @param string $view The active view name
* @param string $task The current task
* @param F0FInput $input The input object
* @param array $config Extra configuration variables for the toolbar
*
* @return void
*/
protected function renderLinkbar($view, $task, $input, $config = array())
{
$style = 'classic';
if (array_key_exists('linkbar_style', $config))
{
$style = $config['linkbar_style'];
}
if (!version_compare(JVERSION, '3.0', 'ge'))
{
$style = 'classic';
}
switch ($style)
{
case 'joomla':
$this->renderLinkbar_joomla($view, $task, $input);
break;
case 'classic':
default:
$this->renderLinkbar_classic($view, $task, $input);
break;
}
}
/**
* Renders the submenu (link bar) in F0F's classic style, using a Bootstrapped
* tab bar.
*
* @param string $view The active view name
* @param string $task The current task
* @param F0FInput $input The input object
* @param array $config Extra configuration variables for the toolbar
*
* @return void
*/
protected function renderLinkbar_classic($view, $task, $input, $config = array())
{
if (F0FPlatform::getInstance()->isCli())
{
return;
}
// Do not render a submenu unless we are in the the admin area
$toolbar = F0FToolbar::getAnInstance($input->getCmd('option', 'com_foobar'), $config);
$renderFrontendSubmenu = $toolbar->getRenderFrontendSubmenu();
if (!F0FPlatform::getInstance()->isBackend() && !$renderFrontendSubmenu)
{
return;
}
$links = $toolbar->getLinks();
if (!empty($links))
{
echo "
\n";
foreach ($links as $link)
{
$dropdown = false;
if (array_key_exists('dropdown', $link))
{
$dropdown = $link['dropdown'];
}
if ($dropdown)
{
echo "
\n";
}
}
/**
* Renders the submenu (link bar) using Joomla!'s style. On Joomla! 2.5 this
* is a list of bar separated links, on Joomla! 3 it's a sidebar at the
* left-hand side of the page.
*
* @param string $view The active view name
* @param string $task The current task
* @param F0FInput $input The input object
* @param array $config Extra configuration variables for the toolbar
*
* @return void
*/
protected function renderLinkbar_joomla($view, $task, $input, $config = array())
{
// On command line don't do anything
if (F0FPlatform::getInstance()->isCli())
{
return;
}
// Do not render a submenu unless we are in the the admin area
$toolbar = F0FToolbar::getAnInstance($input->getCmd('option', 'com_foobar'), $config);
$renderFrontendSubmenu = $toolbar->getRenderFrontendSubmenu();
if (!F0FPlatform::getInstance()->isBackend() && !$renderFrontendSubmenu)
{
return;
}
$this->renderLinkbarItems($toolbar);
}
/**
* do the rendering job for the linkbar
*
* @param F0FToolbar $toolbar A toolbar object
*
* @return void
*/
protected function renderLinkbarItems($toolbar)
{
$links = $toolbar->getLinks();
if (!empty($links))
{
foreach ($links as $link)
{
JHtmlSidebar::addEntry($link['name'], $link['link'], $link['active']);
$dropdown = false;
if (array_key_exists('dropdown', $link))
{
$dropdown = $link['dropdown'];
}
if ($dropdown)
{
foreach ($link['items'] as $item)
{
JHtmlSidebar::addEntry('– ' . $item['name'], $item['link'], $item['active']);
}
}
}
}
}
/**
* Renders the toolbar buttons
*
* @param string $view The active view name
* @param string $task The current task
* @param F0FInput $input The input object
* @param array $config Extra configuration variables for the toolbar
*
* @return void
*/
protected function renderButtons($view, $task, $input, $config = array())
{
if (F0FPlatform::getInstance()->isCli())
{
return;
}
// Do not render buttons unless we are in the the frontend area and we are asked to do so
$toolbar = F0FToolbar::getAnInstance($input->getCmd('option', 'com_foobar'), $config);
$renderFrontendButtons = $toolbar->getRenderFrontendButtons();
// Load main backend language, in order to display toolbar strings
// (JTOOLBAR_BACK, JTOOLBAR_PUBLISH etc etc)
F0FPlatform::getInstance()->loadTranslations('joomla');
if (F0FPlatform::getInstance()->isBackend() || !$renderFrontendButtons)
{
return;
}
$bar = JToolBar::getInstance('toolbar');
$items = $bar->getItems();
$substitutions = array(
'icon-32-new' => 'icon-plus',
'icon-32-publish' => 'icon-eye-open',
'icon-32-unpublish' => 'icon-eye-close',
'icon-32-delete' => 'icon-trash',
'icon-32-edit' => 'icon-edit',
'icon-32-copy' => 'icon-th-large',
'icon-32-cancel' => 'icon-remove',
'icon-32-back' => 'icon-circle-arrow-left',
'icon-32-apply' => 'icon-ok',
'icon-32-save' => 'icon-hdd',
'icon-32-save-new' => 'icon-repeat',
);
if(isset(JFactory::getApplication()->JComponentTitle))
{
$title = JFactory::getApplication()->JComponentTitle;
}
else
{
$title = '';
}
$html = array();
$actions = array();
// For BC we have to use the same id we're using inside other renderers (F0FHeaderHolder)
//$html[] = '