@copyright Copyright (C) 2015. All Rights Reserved @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) .-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( \____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) /------------------------------------------------------------------------------------------------------*/ namespace JCB\Component\Subformpower\Administrator\View\Subformpower; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Toolbar\ToolbarHelper; use Joomla\CMS\Document\Document; use JCB\Component\Subformpower\Administrator\Helper\SubformpowerHelper; use JCB\Joomla\Utilities\StringHelper; // No direct access to this file \defined('_JEXEC') or die; /** * Subformpower View class * * @since 1.6 */ class HtmlView extends BaseHtmlView { /** * View display method * @return void */ function display($tpl = null) { // Assign data to the view $this->icons = $this->get('Icons'); $this->styles = $this->get('Styles'); $this->scripts = $this->get('Scripts'); $this->contributors = SubformpowerHelper::getContributors(); // get the manifest details of the component $this->manifest = SubformpowerHelper::manifest(); // Set the toolbar $this->addToolBar(); // Check for errors. if (count($errors = $this->get('Errors'))) { throw new \Exception(implode("\n", $errors), 500); } // Set the html view document stuff $this->_prepareDocument(); // Display the template parent::display($tpl); } /** * Add the page title and toolbar. * * @return void * @since 1.6 */ protected function addToolbar(): void { $canDo = SubformpowerHelper::getActions('subformpower'); ToolbarHelper::title(Text::_('COM_SUBFORMPOWER_DASHBOARD'), 'grid-2'); // set help url for this view if found $this->help_url = SubformpowerHelper::getHelpUrl('subformpower'); if (StringHelper::check($this->help_url)) { ToolbarHelper::help('COM_SUBFORMPOWER_HELP_MANAGER', false, $this->help_url); } if ($canDo->get('core.admin') || $canDo->get('core.options')) { ToolbarHelper::preferences('com_subformpower'); } } /** * Prepare some document related stuff. * * @return void * @since 1.6 */ protected function _prepareDocument(): void { // set page title $this->getDocument()->setTitle(Text::_('COM_SUBFORMPOWER_DASHBOARD')); // add manifest to page JavaScript $this->getDocument()->addScriptDeclaration("var manifest = JSON.parse('" . json_encode($this->manifest) . "');", "text/javascript"); // add styles foreach ($this->styles as $style) { Html::_('stylesheet', $style, ['version' => 'auto']); } // add scripts foreach ($this->scripts as $script) { Html::_('script', $script, ['version' => 'auto']); } } }