2017-08-20 17:52:35 +00:00
|
|
|
<?php
|
2018-05-18 06:28:27 +00:00
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 30th April, 2015
|
|
|
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
|
|
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
2019-02-23 13:28:54 +00:00
|
|
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
2018-05-18 06:28:27 +00:00
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
|
|
*/
|
2017-08-20 17:52:35 +00:00
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Componentbuilder View class for the Api
|
|
|
|
*/
|
|
|
|
class ComponentbuilderViewApi extends JViewLegacy
|
|
|
|
{
|
|
|
|
// Overwriting JView display method
|
|
|
|
function display($tpl = null)
|
2017-10-14 17:18:29 +00:00
|
|
|
{
|
2017-08-20 17:52:35 +00:00
|
|
|
// get combined params of both component and menu
|
|
|
|
$this->app = JFactory::getApplication();
|
|
|
|
$this->params = $this->app->getParams();
|
|
|
|
$this->menu = $this->app->getMenu()->getActive();
|
|
|
|
// get the user object
|
|
|
|
$this->user = JFactory::getUser();
|
|
|
|
// Initialise variables.
|
2017-12-15 01:10:10 +00:00
|
|
|
$this->item = $this->get('Item');
|
2018-02-20 20:46:29 +00:00
|
|
|
// do not load the display
|
|
|
|
jexit('Access Denied!');
|
2017-08-20 17:52:35 +00:00
|
|
|
|
|
|
|
// Set the toolbar
|
|
|
|
$this->addToolBar();
|
|
|
|
|
|
|
|
// set the document
|
|
|
|
$this->_prepareDocument();
|
|
|
|
|
2017-10-14 17:18:29 +00:00
|
|
|
// Check for errors.
|
|
|
|
if (count($errors = $this->get('Errors')))
|
|
|
|
{
|
2017-10-14 18:07:23 +00:00
|
|
|
throw new Exception(implode("\n", $errors), 500);
|
2017-10-14 17:18:29 +00:00
|
|
|
}
|
|
|
|
|
2017-08-20 17:52:35 +00:00
|
|
|
parent::display($tpl);
|
|
|
|
}
|
|
|
|
|
2017-12-14 23:10:47 +00:00
|
|
|
/**
|
2017-08-20 17:52:35 +00:00
|
|
|
* Prepares the document
|
|
|
|
*/
|
|
|
|
protected function _prepareDocument()
|
|
|
|
{
|
|
|
|
|
|
|
|
// always make sure jquery is loaded.
|
|
|
|
JHtml::_('jquery.framework');
|
|
|
|
// Load the header checker class.
|
|
|
|
require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' );
|
|
|
|
// Initialize the header checker.
|
2018-09-11 20:28:17 +00:00
|
|
|
$HeaderCheck = new componentbuilderHeaderCheck;
|
2017-08-20 17:52:35 +00:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
2018-01-15 15:54:05 +00:00
|
|
|
$this->document->addStyleSheet(JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit'.$style.$size.'.css', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
|
2017-08-20 17:52:35 +00:00
|
|
|
}
|
|
|
|
// The uikit js.
|
|
|
|
if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
|
|
|
|
{
|
2018-01-15 15:54:05 +00:00
|
|
|
$this->document->addScript(JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
|
2018-09-11 20:28:17 +00:00
|
|
|
}
|
2017-08-20 17:52:35 +00:00
|
|
|
// add the document default css file
|
2018-09-11 20:28:17 +00:00
|
|
|
$this->document->addStyleSheet(JURI::root(true) .'/components/com_componentbuilder/assets/css/api.css', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
|
2017-12-14 23:10:47 +00:00
|
|
|
}
|
2017-08-20 17:52:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Setting the toolbar
|
|
|
|
*/
|
|
|
|
protected function addToolBar()
|
|
|
|
{
|
|
|
|
// adding the joomla toolbar to the front
|
|
|
|
JLoader::register('JToolbarHelper', JPATH_ADMINISTRATOR.'/includes/toolbar.php');
|
2017-12-14 23:10:47 +00:00
|
|
|
|
2017-08-20 17:52:35 +00:00
|
|
|
// set help url for this view if found
|
|
|
|
$help_url = ComponentbuilderHelper::getHelpUrl('api');
|
|
|
|
if (ComponentbuilderHelper::checkString($help_url))
|
|
|
|
{
|
|
|
|
JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $help_url);
|
|
|
|
}
|
|
|
|
// now initiate the toolbar
|
|
|
|
$this->toolbar = JToolbar::getInstance();
|
|
|
|
}
|
|
|
|
|
2017-12-14 23:10:47 +00:00
|
|
|
/**
|
2017-08-20 17:52:35 +00:00
|
|
|
* 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, $sorten = false, $length = 40)
|
|
|
|
{
|
2017-12-14 23:10:47 +00:00
|
|
|
// use the helper htmlEscape method instead.
|
2017-08-20 17:52:35 +00:00
|
|
|
return ComponentbuilderHelper::htmlEscape($var, $this->_charset, $sorten, $length);
|
|
|
|
}
|
|
|
|
}
|