2021-03-05 03:08:47 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 30th April, 2015
|
2024-03-02 20:10:30 +00:00
|
|
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
|
|
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
2021-03-05 03:08:47 +00:00
|
|
|
* @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');
|
|
|
|
?>
|
|
|
|
###BOM###
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED###
|
2022-05-25 08:30:55 +00:00
|
|
|
|
2021-03-08 22:36:30 +00:00
|
|
|
###ADMIN_VIEWS_HTML_HEADER###
|
2022-05-25 08:30:55 +00:00
|
|
|
|
2021-03-05 03:08:47 +00:00
|
|
|
/**
|
2022-05-25 08:30:55 +00:00
|
|
|
* ###Component### Html View class for the ###Views###
|
2021-03-05 03:08:47 +00:00
|
|
|
*/
|
2022-05-25 08:30:55 +00:00
|
|
|
class ###Component###View###Views### extends HtmlView
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* ###Views### view display method
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function display($tpl = null)
|
|
|
|
{
|
|
|
|
if ($this->getLayout() !== 'modal')
|
|
|
|
{
|
|
|
|
// Include helper submenu
|
|
|
|
###Component###Helper::addSubmenu('###views###');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assign data to the view
|
|
|
|
$this->items = $this->get('Items');
|
|
|
|
$this->pagination = $this->get('Pagination');
|
|
|
|
$this->state = $this->get('State');
|
2024-03-02 20:10:30 +00:00
|
|
|
$this->user = Factory::getUser();###ADMIN_DIPLAY_METHOD###
|
2021-03-05 03:08:47 +00:00
|
|
|
$this->saveOrder = $this->listOrder == 'a.ordering';
|
|
|
|
// set the return here value
|
2024-03-02 20:10:30 +00:00
|
|
|
$this->return_here = urlencode(base64_encode((string) Uri::getInstance()));
|
2021-03-05 03:08:47 +00:00
|
|
|
// get global action permissions
|
|
|
|
$this->canDo = ###Component###Helper::getActions('###view###');###JVIEWLISTCANDO###
|
|
|
|
|
|
|
|
// We don't need toolbar in the modal window.
|
|
|
|
if ($this->getLayout() !== 'modal')
|
|
|
|
{
|
|
|
|
$this->addToolbar();
|
|
|
|
$this->sidebar = JHtmlSidebar::render();
|
|
|
|
// load the batch html
|
|
|
|
if ($this->canCreate && $this->canEdit && $this->canState)
|
|
|
|
{
|
|
|
|
$this->batchDisplay = JHtmlBatch_::render();
|
|
|
|
}
|
|
|
|
}
|
2024-03-02 20:10:30 +00:00
|
|
|
|
2021-03-05 03:08:47 +00:00
|
|
|
// Check for errors.
|
|
|
|
if (count($errors = $this->get('Errors')))
|
|
|
|
{
|
|
|
|
throw new Exception(implode("\n", $errors), 500);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display the template
|
|
|
|
parent::display($tpl);
|
|
|
|
|
|
|
|
// Set the document
|
|
|
|
$this->setDocument();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setting the toolbar
|
|
|
|
*/
|
|
|
|
protected function addToolBar()
|
|
|
|
{
|
|
|
|
JHtmlSidebar::setAction('index.php?option=com_###component###&view=###views###');
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::title(Text::_('COM_###COMPONENT###_###VIEWS###'), '###ICOMOON###');
|
|
|
|
FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');
|
2021-03-05 03:08:47 +00:00
|
|
|
|
|
|
|
if ($this->canCreate)
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::addNew('###view###.add');
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Only load if there are items
|
2024-03-02 20:10:30 +00:00
|
|
|
if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($this->items))
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
|
|
|
if ($this->canEdit)
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::editList('###view###.edit');
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->canState)
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::publishList('###views###.publish');
|
|
|
|
ToolbarHelper::unpublishList('###views###.unpublish');
|
|
|
|
ToolbarHelper::archiveList('###views###.archive');
|
2021-03-05 03:08:47 +00:00
|
|
|
|
|
|
|
if ($this->canDo->get('core.admin'))
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::checkin('###views###.checkin');
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add a batch button
|
|
|
|
if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState)
|
|
|
|
{
|
|
|
|
// Get the toolbar object instance
|
2024-03-02 20:10:30 +00:00
|
|
|
$bar = Toolbar::getInstance('toolbar');
|
2021-03-05 03:08:47 +00:00
|
|
|
// set the batch button name
|
2024-03-02 20:10:30 +00:00
|
|
|
$title = Text::_('JTOOLBAR_BATCH');
|
2021-03-05 03:08:47 +00:00
|
|
|
// Instantiate a new JLayoutFile instance and render the batch button
|
2024-03-02 20:10:30 +00:00
|
|
|
$layout = new FileLayout('joomla.toolbar.batch');
|
2021-03-05 03:08:47 +00:00
|
|
|
// add the button to the page
|
|
|
|
$dhtml = $layout->render(array('title' => $title));
|
|
|
|
$bar->appendButton('Custom', $dhtml, 'batch');
|
|
|
|
}###CUSTOM_ADMIN_DYNAMIC_BUTTONS######ADMIN_CUSTOM_BUTTONS_LIST###
|
|
|
|
|
|
|
|
if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete))
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::deleteList('', '###views###.delete', 'JTOOLBAR_EMPTY_TRASH');
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
elseif ($this->canState && $this->canDelete)
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::trash('###views###.trash');
|
2021-03-05 03:08:47 +00:00
|
|
|
}###EXPORTBUTTON###
|
|
|
|
}###ADMIN_CUSTOM_FUNCTION_ONLY_BUTTONS_LIST######IMPORTBUTTON###
|
|
|
|
|
|
|
|
// set help url for this view if found
|
2022-02-12 22:28:17 +00:00
|
|
|
$this->help_url = ###Component###Helper::getHelpUrl('###views###');
|
2024-03-02 20:10:30 +00:00
|
|
|
if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url))
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url);
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// add the options comp button
|
|
|
|
if ($this->canDo->get('core.admin') || $this->canDo->get('core.options'))
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::preferences('com_###component###');
|
2021-03-05 03:08:47 +00:00
|
|
|
}###FILTERFIELDDISPLAYHELPER######BATCHDISPLAYHELPER###
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to set up the document properties
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function setDocument()
|
|
|
|
{
|
|
|
|
if (!isset($this->document))
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
$this->document = Factory::getDocument();
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
2024-03-02 20:10:30 +00:00
|
|
|
$this->document->setTitle(Text::_('COM_###COMPONENT###_###VIEWS###'));
|
|
|
|
Html::_('stylesheet', "administrator/components/com_###component###/assets/css/###views###.css", ['version' => 'auto']);###ADMIN_ADD_JAVASCRIPT_FILE###
|
2021-03-05 03:08:47 +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)
|
|
|
|
{
|
|
|
|
if(strlen($var) > 50)
|
|
|
|
{
|
|
|
|
// use the helper htmlEscape method instead and shorten the string
|
2024-03-02 20:10:30 +00:00
|
|
|
return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset, true);
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
// use the helper htmlEscape method instead.
|
2024-03-02 20:10:30 +00:00
|
|
|
return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset);
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of fields the table can be sorted by
|
|
|
|
*
|
2024-03-02 20:10:30 +00:00
|
|
|
* @return array Array containing the field name to sort by as the key and display text as value
|
2021-03-05 03:08:47 +00:00
|
|
|
*/
|
|
|
|
protected function getSortFields()
|
|
|
|
{
|
|
|
|
###SORTFIELDS###
|
2024-03-02 20:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Document (helper method toward Joomla 4 and 5)
|
|
|
|
*/
|
|
|
|
public function getDocument()
|
|
|
|
{
|
|
|
|
$this->document ??= JFactory::getDocument();
|
|
|
|
|
|
|
|
return $this->document;
|
2021-03-05 03:08:47 +00:00
|
|
|
}###FILTERFUNCTIONS###
|
|
|
|
}
|