Component-Builder/admin/views/search/view.html.php

151 lines
4.4 KiB
PHP

<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\MVC\View\HtmlView;
/**
* Componentbuilder Html View class for the Search
*/
class ComponentbuilderViewSearch extends HtmlView
{
// Overwriting JView display method
function display($tpl = null)
{
// get component params
$this->params = JComponentHelper::getParams('com_componentbuilder');
// get the application
$this->app = JFactory::getApplication();
// get the user object
$this->user = JFactory::getUser();
// get global action permissions
$this->canDo = ComponentbuilderHelper::getActions('search');
// Initialise variables.
$this->item = $this->get('Item');
if ($this->getLayout() !== 'modal')
{
// Include helper submenu
ComponentbuilderHelper::addSubmenu('search');
JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=search');
$this->sidebar = JHtmlSidebar::render();
}
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')
{
// add the tool bar
$this->addToolBar();
}
// set the document
$this->setDocument();
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode(PHP_EOL, $errors), 500);
}
parent::display($tpl);
}
/**
* Prepares the document
*/
protected function setDocument()
{
// always make sure jquery is loaded.
JHtml::_('jquery.framework');
// Load the header checker class.
require_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' );
// Initialize the header checker.
$HeaderCheck = new componentbuilderHeaderCheck;
// Load uikit options.
$uikit = $this->params->get('uikit_load');
// Set script size.
$size = $this->params->get('uikit_min');
// Set css style.
$style = $this->params->get('uikit_style');
// The uikit css.
if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
{
JHtml::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit'.$style.$size.'.css', ['version' => 'auto']);
}
// The uikit js.
if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
{
JHtml::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']);
}
// add the document default css file
$this->document->addStyleSheet(JURI::root(true) .'/administrator/components/com_componentbuilder/assets/css/search.css', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
}
/**
* Setting the toolbar
*/
protected function addToolBar()
{
// hide the main menu
$this->app->input->set('hidemainmenu', true);
// set the title
if (isset($this->item->name) && $this->item->name)
{
$title = $this->item->name;
}
// Check for empty title and add view name if param is set
if (empty($title))
{
$title = JText::_('COM_COMPONENTBUILDER_SEARCH');
}
// add title to the page
JToolbarHelper::title($title,'search');
// add cpanel button
JToolBarHelper::custom('search.dashboard', 'grid-2', '', 'COM_COMPONENTBUILDER_DASH', false);
if ($this->canDo->get('search.compiler'))
{
// add Compiler button.
JToolBarHelper::custom('search.openCompiler', 'cogs custom-button-opencompiler', '', 'COM_COMPONENTBUILDER_COMPILER', false);
}
// set help url for this view if found
$this->help_url = ComponentbuilderHelper::getHelpUrl('search');
if (ComponentbuilderHelper::checkString($this->help_url))
{
JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url);
}
// add the options comp button
if ($this->canDo->get('core.admin') || $this->canDo->get('core.options'))
{
JToolBarHelper::preferences('com_componentbuilder');
}
}
/**
* Escapes a value for output in a view script.
*
* @param mixed $var The output to escape.
*
* @return mixed The escaped value.
*/
public function escape($var)
{
// use the helper htmlEscape method instead.
return ComponentbuilderHelper::htmlEscape($var, $this->_charset);
}
}
?>