joomla-component/site/views/openai/view.html.php

184 lines
5.3 KiB
PHP
Raw Normal View History

2023-07-26 09:09:42 +00:00
<?php
/*----------------------------------------------------------------------------------| io.vdm.dev |----/
Vast Development Method
/-------------------------------------------------------------------------------------------------------/
@package getBible.net
@created 3rd December, 2015
@author Llewellyn van der Merwe <https://getbible.net>
@git Get Bible <https://git.vdm.dev/getBible>
@github Get Bible <https://github.com/getBible>
@support Get Bible <https://git.vdm.dev/getBible/support>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.module.helper');
use Joomla\CMS\MVC\View\HtmlView;
/**
* Getbible Html View class for the Openai
*/
class GetbibleViewOpenai extends HtmlView
{
// 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->item = $this->get('Item');
$this->translation = $this->get('Translation');
// Set the toolbar
$this->addToolBar();
// set the document
$this->_prepareDocument();
// 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 _prepareDocument()
{
// Only load jQuery if needed. (default is true)
if ($this->params->get('add_jquery_framework', 1) == 1)
{
JHtml::_('jquery.framework');
}
// Load the header checker class.
require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' );
// Initialize the header checker.
$HeaderCheck = new getbibleHeaderCheck;
// Add View JavaScript File
JHtml::_('script', "components/com_getbible/assets/js/openai.js", ['version' => 'auto']);
// Load uikit options.
$uikit = $this->params->get('uikit_load');
// Set script size.
$size = $this->params->get('uikit_min');
// The uikit css.
if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
{
JHtml::_('stylesheet', 'media/com_getbible/uikit-v3/css/uikit'.$size.'.css', ['version' => 'auto']);
}
// The uikit js.
if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
{
JHtml::_('script', 'media/com_getbible/uikit-v3/js/uikit'.$size.'.js', ['version' => 'auto']);
JHtml::_('script', 'media/com_getbible/uikit-v3/js/uikit-icons'.$size.'.js', ['version' => 'auto']);
}
// add the document default css file
JHtml::_('stylesheet', 'components/com_getbible/assets/css/openai.css', ['version' => 'auto']);
}
/**
* Setting the toolbar
*/
protected function addToolBar()
{
// set help url for this view if found
$this->help_url = GetbibleHelper::getHelpUrl('openai');
if (GetbibleHelper::checkString($this->help_url))
{
JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url);
}
// now initiate the toolbar
$this->toolbar = JToolbar::getInstance();
}
/**
* Get the modules published in a position
*/
public function getModules($position, $seperator = '', $class = '')
{
// set default
$found = false;
// check if we aleady have these modules loaded
if (isset($this->setModules[$position]))
{
$found = true;
}
else
{
// this is where you want to load your module position
$modules = JModuleHelper::getModules($position);
if (GetbibleHelper::checkArray($modules, true))
{
// set the place holder
$this->setModules[$position] = array();
foreach($modules as $module)
{
$this->setModules[$position][] = JModuleHelper::renderModule($module);
}
$found = true;
}
}
// check if modules were found
if ($found && isset($this->setModules[$position]) && GetbibleHelper::checkArray($this->setModules[$position]))
{
// set class
if (GetbibleHelper::checkString($class))
{
$class = ' class="'.$class.'" ';
}
// set seperating return values
switch($seperator)
{
case 'none':
return implode('', $this->setModules[$position]);
break;
case 'div':
return '<div'.$class.'>'.implode('</div><div'.$class.'>', $this->setModules[$position]).'</div>';
break;
case 'list':
return '<ul'.$class.'><li>'.implode('</li><li>', $this->setModules[$position]).'</li></ul>';
break;
case 'array':
case 'Array':
return $this->setModules[$position];
break;
default:
return implode('<br />', $this->setModules[$position]);
break;
}
}
return false;
}
/**
* 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 GetbibleHelper::htmlEscape($var, $this->_charset, $sorten, $length);
}
}