- md5
- 96158c1d28ae6651bd52c7b9098485af
- sha1
- d3e26ba6b6a72b8d3b07d7dbf585343f7aa796c8
- sha256
- 38d9abb4a40d537096985c9ad3395a59cf7cb2bb3f306a88f9cf5c749828a44a
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Modules\Administrator\View\Modules;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
/**
* View class for a list of modules.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* An array of items
*
* @var array
*/
protected $items;
/**
* The pagination object
*
* @var \JPagination
*/
protected $pagination;
/**
* The model state
*
* @var \JObject
*/
protected $state;
/**
* Form object for search filters
*
* @var \JForm
* @since 4.0.0
*/
public $filterForm;
/**
* The active search filters
*
* @var array
* @since 4.0.0
*/
public $activeFilters;
/**
* The sidebar markup
*
* @var string
* @since 4.0.0
*/
protected $sidebar;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @since 1.6
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->total = $this->get('Total');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->clientId = $this->state->get('client_id');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new \JViewGenericdataexception(implode("\n", $errors), 500);
}
// We do not need the Language filter when modules are not filtered
if ($this->clientId == 1 && !ModuleHelper::isAdminMultilang())
{
unset($this->activeFilters['language']);
$this->filterForm->removeField('language', 'filter');
}
// We don't need the toolbar in the modal window.
if ($this->getLayout() !== 'modal')
{
$this->addToolbar();
// We do not need to filter by language when multilingual is disabled
if (!Multilanguage::isEnabled())
{
unset($this->activeFilters['language']);
$this->filterForm->removeField('language', 'filter');
}
}
// If in modal layout.
else
{
// Client id selector should not exist.
$this->filterForm->removeField('client_id', '');
// If in the frontend state and language should not activate the search tools.
if (Factory::getApplication()->isClient('site'))
{
unset($this->activeFilters['state']);
unset($this->activeFilters['language']);
}
}
return parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$state = $this->get('State');
$canDo = ContentHelper::getActions('com_modules');
$user = Factory::getUser();
// Get the toolbar object instance
$bar = Toolbar::getInstance('toolbar');
if ($state->get('client_id') == 1)
{
ToolbarHelper::title(Text::_('COM_MODULES_MANAGER_MODULES_ADMIN'), 'cube module');
}
else
{
ToolbarHelper::title(Text::_('COM_MODULES_MANAGER_MODULES_SITE'), 'cube module');
}
if ($canDo->get('core.create'))
{
// Instantiate a new FileLayout instance and render the layout
$layout = new FileLayout('toolbar.newmodule');
$bar->appendButton('Custom', $layout->render(array()), 'new');
}
if ($canDo->get('core.create'))
{
ToolbarHelper::custom('modules.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
}
if ($canDo->get('core.edit.state'))
{
ToolbarHelper::publish('modules.publish', 'JTOOLBAR_PUBLISH', true);
ToolbarHelper::unpublish('modules.unpublish', 'JTOOLBAR_UNPUBLISH', true);
ToolbarHelper::checkin('modules.checkin');
}
// Add a batch button
if ($user->authorise('core.create', 'com_modules') && $user->authorise('core.edit', 'com_modules')
&& $user->authorise('core.edit.state', 'com_modules'))
{
HTMLHelper::_('bootstrap.renderModal', 'collapseModal');
$title = Text::_('JTOOLBAR_BATCH');
// Instantiate a new FileLayout instance and render the batch button
$layout = new FileLayout('joomla.toolbar.batch');
$dhtml = $layout->render(array('title' => $title));
$bar->appendButton('Custom', $dhtml, 'batch');
}
if ($state->get('filter.state') == -2 && $canDo->get('core.delete'))
{
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'modules.delete', 'JTOOLBAR_EMPTY_TRASH');
}
elseif ($canDo->get('core.edit.state'))
{
ToolbarHelper::trash('modules.trash');
}
if ($canDo->get('core.admin'))
{
ToolbarHelper::preferences('com_modules');
}
ToolbarHelper::help('JHELP_EXTENSIONS_MODULE_MANAGER');
if (\JHtmlSidebar::getEntries())
{
$this->sidebar = \JHtmlSidebar::render();
}
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key and display text as value
*
* @since 3.0
*/
protected function getSortFields()
{
$this->state = $this->get('State');
if ($this->state->get('client_id') == 0)
{
if ($this->getLayout() == 'default')
{
return array(
'ordering' => Text::_('JGRID_HEADING_ORDERING'),
'a.published' => Text::_('JSTATUS'),
'a.title' => Text::_('JGLOBAL_TITLE'),
'position' => Text::_('COM_MODULES_HEADING_POSITION'),
'name' => Text::_('COM_MODULES_HEADING_MODULE'),
'pages' => Text::_('COM_MODULES_HEADING_PAGES'),
'a.access' => Text::_('JGRID_HEADING_ACCESS'),
'language_title' => Text::_('JGRID_HEADING_LANGUAGE'),
'a.id' => Text::_('JGRID_HEADING_ID')
);
}
return array(
'a.title' => Text::_('JGLOBAL_TITLE'),
'position' => Text::_('COM_MODULES_HEADING_POSITION'),
'name' => Text::_('COM_MODULES_HEADING_MODULE'),
'pages' => Text::_('COM_MODULES_HEADING_PAGES'),
'a.access' => Text::_('JGRID_HEADING_ACCESS'),
'language_title' => Text::_('JGRID_HEADING_LANGUAGE'),
'a.id' => Text::_('JGRID_HEADING_ID')
);
}
else
{
if ($this->getLayout() == 'default')
{
return array(
'ordering' => Text::_('JGRID_HEADING_ORDERING'),
'a.published' => Text::_('JSTATUS'),
'a.title' => Text::_('JGLOBAL_TITLE'),
'position' => Text::_('COM_MODULES_HEADING_POSITION'),
'name' => Text::_('COM_MODULES_HEADING_MODULE'),
'a.access' => Text::_('JGRID_HEADING_ACCESS'),
'a.language' => Text::_('JGRID_HEADING_LANGUAGE'),
'a.id' => Text::_('JGRID_HEADING_ID')
);
}
return array(
'a.title' => Text::_('JGLOBAL_TITLE'),
'position' => Text::_('COM_MODULES_HEADING_POSITION'),
'name' => Text::_('COM_MODULES_HEADING_MODULE'),
'a.access' => Text::_('JGRID_HEADING_ACCESS'),
'a.language' => Text::_('JGRID_HEADING_LANGUAGE'),
'a.id' => Text::_('JGRID_HEADING_ID')
);
}
}
}
No other release has this exact content. See every version of this file.