2024-03-02 20:10:30 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 4th September 2022
|
|
|
|
* @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 JCB template file (EVER)
|
|
|
|
defined('_JCB_TEMPLATE') or die;
|
|
|
|
?>
|
|
|
|
###BOM###
|
2024-03-11 14:56:07 +00:00
|
|
|
namespace ###NAMESPACEPREFIX###\Component\###ComponentNamespace###\Site\View\###View###;
|
2024-03-02 20:10:30 +00:00
|
|
|
|
|
|
|
###SITE_ADMIN_VIEW_HTML_HEADER###
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
\defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED###
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ###View### Html View class
|
|
|
|
*
|
|
|
|
* @since 1.6
|
|
|
|
*/
|
|
|
|
class HtmlView extends BaseHtmlView
|
|
|
|
{
|
|
|
|
/**
|
2024-03-09 19:41:29 +00:00
|
|
|
* ###View### view display method
|
2024-03-02 20:10:30 +00:00
|
|
|
*
|
|
|
|
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @since 1.6
|
|
|
|
*/
|
|
|
|
public function display($tpl = null)
|
|
|
|
{
|
|
|
|
// set params
|
|
|
|
$this->params = ComponentHelper::getParams('com_###component###');
|
|
|
|
// Assign the variables
|
|
|
|
$this->form = $this->get('Form');
|
|
|
|
$this->item = $this->get('Item');
|
|
|
|
$this->state = $this->get('State');
|
2024-03-09 19:41:29 +00:00
|
|
|
$this->styles = $this->get('Styles');
|
|
|
|
$this->scripts = $this->get('Scripts');
|
2024-03-02 20:10:30 +00:00
|
|
|
// get action permissions
|
|
|
|
$this->canDo = ###Component###Helper::getActions('###view###', $this->item);
|
|
|
|
// get input
|
|
|
|
$jinput = Factory::getApplication()->input;
|
|
|
|
$this->ref = $jinput->get('ref', 0, 'word');
|
|
|
|
$this->refid = $jinput->get('refid', 0, 'int');
|
|
|
|
$return = $jinput->get('return', null, 'base64');
|
|
|
|
// set the referral string
|
|
|
|
$this->referral = '';
|
|
|
|
if ($this->refid && $this->ref)
|
|
|
|
{
|
|
|
|
// return to the item that referred to this item
|
|
|
|
$this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid;
|
|
|
|
}
|
|
|
|
elseif($this->ref)
|
|
|
|
{
|
|
|
|
// return to the list view that referred to this item
|
|
|
|
$this->referral = '&ref=' . (string)$this->ref;
|
|
|
|
}
|
|
|
|
// check return value
|
|
|
|
if (!is_null($return))
|
|
|
|
{
|
|
|
|
// add the return value
|
|
|
|
$this->referral .= '&return=' . (string)$return;
|
|
|
|
}###LINKEDVIEWITEMS###
|
|
|
|
|
|
|
|
// 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
|
2024-03-09 19:41:29 +00:00
|
|
|
{
|
|
|
|
###ADDTOOLBAR###
|
2024-03-02 20:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Escapes a value for output in a view script.
|
|
|
|
*
|
|
|
|
* @param mixed $var The output to escape.
|
|
|
|
* @param bool $shorten The switch to shorten.
|
|
|
|
* @param int $length The shorting length.
|
|
|
|
*
|
|
|
|
* @return mixed The escaped value.
|
|
|
|
* @since 1.6
|
|
|
|
*/
|
|
|
|
public function escape($var, bool $shorten = true, int $length = 30)
|
|
|
|
{
|
|
|
|
if (!is_string($var))
|
|
|
|
{
|
|
|
|
return $var;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset ?? 'UTF-8', $shorten, $length);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare some document related stuff.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @since 1.6
|
|
|
|
*/
|
|
|
|
protected function _prepareDocument(): void
|
2024-03-09 19:41:29 +00:00
|
|
|
{###JQUERY###
|
2024-03-02 20:10:30 +00:00
|
|
|
$isNew = ($this->item->id < 1);
|
|
|
|
$this->getDocument()->setTitle(Text::_($isNew ? 'COM_###COMPONENT###_###VIEW###_NEW' : 'COM_###COMPONENT###_###VIEW###_EDIT'));
|
2024-03-09 19:41:29 +00:00
|
|
|
// add styles
|
|
|
|
foreach ($this->styles as $style)
|
|
|
|
{
|
|
|
|
Html::_('stylesheet', $style, ['version' => 'auto']);
|
|
|
|
}###AJAXTOKE######LINKEDVIEWTABLESCRIPTS###
|
|
|
|
// add scripts
|
|
|
|
foreach ($this->scripts as $script)
|
|
|
|
{
|
|
|
|
Html::_('script', $script, ['version' => 'auto']);
|
|
|
|
}###DOCUMENT_CUSTOM_PHP###
|
2024-03-02 20:10:30 +00:00
|
|
|
}
|
|
|
|
}
|