Joomla-Sermon-Distributor-Fork/site/views/api/view.html.php

150 lines
5.3 KiB
PHP
Raw Normal View History

<?php
2021-08-16 17:11:22 +00:00
/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
____ ____ __ __ __
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __
\/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\
/\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/
\ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\
\/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/
/------------------------------------------------------------------------------------------------------------------------------------/
2022-05-27 05:37:27 +00:00
@version 2.1.x
2021-08-16 17:11:22 +00:00
@created 22nd October, 2015
@package Sermon Distributor
@subpackage view.html.php
@author Llewellyn van der Merwe <https://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
A sermon distributor that links to Dropbox.
/----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
2022-05-27 05:37:27 +00:00
use Joomla\CMS\MVC\View\HtmlView;
2021-08-16 17:11:22 +00:00
/**
2022-05-27 05:37:27 +00:00
* Sermondistributor Html View class for the Api
2021-08-16 17:11:22 +00:00
*/
2022-05-27 05:37:27 +00:00
class SermondistributorViewApi extends HtmlView
2021-08-16 17:11:22 +00:00
{
// Overwriting JView display method
function display($tpl = null)
{
// 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.
$this->items = $this->get('Items');
2018-05-04 16:36:08 +00:00
// do not load the display
jexit('Access Denied!');
// Set the toolbar
$this->addToolBar();
// set the document
$this->_prepareDocument();
// Check for errors.
if (count($errors = $this->get('Errors')))
{
2020-01-05 22:53:13 +00:00
throw new Exception(implode(PHP_EOL, $errors), 500);
}
2021-08-16 17:11:22 +00:00
parent::display($tpl);
}
/**
* 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.
2019-04-04 11:52:38 +00:00
$HeaderCheck = new sermondistributorHeaderCheck;
// Load uikit options.
$uikit = $this->params->get('uikit_load');
// Set script size.
$size = $this->params->get('uikit_min');
// Load uikit version.
2018-09-06 08:34:13 +00:00
$this->uikitVersion = $this->params->get('uikit_version', 2);
// Use Uikit Version 2
2018-09-06 08:34:13 +00:00
if (2 == $this->uikitVersion)
{
// Set css style.
$style = $this->params->get('uikit_style');
// The uikit css.
if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
{
2022-05-27 05:37:27 +00:00
JHtml::_('stylesheet', 'media/com_sermondistributor/uikit-v2/css/uikit'.$style.$size.'.css', ['version' => 'auto']);
}
// The uikit js.
if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
{
2022-05-27 05:37:27 +00:00
JHtml::_('script', 'media/com_sermondistributor/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']);
}
}
// Use Uikit Version 3
2018-09-06 08:34:13 +00:00
elseif (3 == $this->uikitVersion)
{
// The uikit css.
if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
{
2022-05-27 05:37:27 +00:00
JHtml::_('stylesheet', 'media/com_sermondistributor/uikit-v3/css/uikit'.$size.'.css', ['version' => 'auto']);
}
// The uikit js.
if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
{
2022-05-27 05:37:27 +00:00
JHtml::_('script', 'media/com_sermondistributor/uikit-v3/js/uikit'.$size.'.js', ['version' => 'auto']);
JHtml::_('script', 'media/com_sermondistributor/uikit-v3/js/uikit-icons'.$size.'.js', ['version' => 'auto']);
}
2021-08-16 17:11:22 +00:00
}
// add the document default css file
$this->document->addStyleSheet(JURI::root(true) .'/components/com_sermondistributor/assets/css/api.css', (SermondistributorHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
}
/**
* Setting the toolbar
*/
protected function addToolBar()
{
// set help url for this view if found
2022-03-03 03:49:35 +00:00
$this->help_url = SermondistributorHelper::getHelpUrl('api');
if (SermondistributorHelper::checkString($this->help_url))
2021-08-16 17:11:22 +00:00
{
2022-03-03 03:49:35 +00:00
JToolbarHelper::help('COM_SERMONDISTRIBUTOR_HELP_MANAGER', false, $this->help_url);
2021-08-16 17:11:22 +00:00
}
// now initiate the toolbar
$this->toolbar = JToolbar::getInstance();
}
/**
* 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)
{
// use the helper htmlEscape method instead.
return SermondistributorHelper::htmlEscape($var, $this->_charset, $sorten, $length);
}
}