CoreFiles by mySites.guru
HtmlView.php159 lines, 3,870 bytes, from Joomla_4.0.0-alpha7-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha6
md5
d26a1b029743d4eacabe6060dd82d747
sha1
fa6f20cd900d3b240c8cbaea3c577f7c6956f8a6
sha256
698ecfbcb682a0844042161a1ccae78f3a39dd2ffdbf5be0147f524c6573490c
<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_banners
 *
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Component\Banners\Administrator\View\Clients;

defined('_JEXEC') or die;

use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\Component\Banners\Administrator\Helper\BannersHelper;

/**
 * View class for a list of clients.
 *
 * @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  object
	 */
	protected $state;

	/**
	 * 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.
	 */
	public function display($tpl = null)
	{
		$this->items         = $this->get('Items');
		$this->pagination    = $this->get('Pagination');
		$this->state         = $this->get('State');
		$this->filterForm    = $this->get('FilterForm');
		$this->activeFilters = $this->get('ActiveFilters');

		// Check for errors.
		if (count($errors = $this->get('Errors')))
		{
			throw new \JViewGenericdataexception(implode("\n", $errors), 500);
		}

		BannersHelper::addSubmenu('clients');

		$this->addToolbar();
		$this->sidebar = \JHtmlSidebar::render();

		return parent::display($tpl);
	}

	/**
	 * Add the page title and toolbar.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function addToolbar()
	{
		$canDo = ContentHelper::getActions('com_banners');

		ToolbarHelper::title(Text::_('COM_BANNERS_MANAGER_CLIENTS'), 'bookmark banners-clients');

		// Get the toolbar object instance
		$toolbar = Toolbar::getInstance('toolbar');

		if ($canDo->get('core.create'))
		{
			$toolbar->addNew('client.add');
		}

		if ($canDo->get('core.edit.state') || $canDo->get('core.admin'))
		{		
			$dropdown = $toolbar->dropdownButton('status')
				->text('JTOOLBAR_CHANGE_STATUS')
				->toggleSplit(false)
				->icon('fa fa-globe')
				->buttonClass('btn btn-info')
				->listCheck(true);

			$childBar = $dropdown->getChildToolbar();

			$childBar->publish('clients.publish')->listCheck(true);
			$childBar->unpublish('clients.unpublish')->listCheck(true);
			$childBar->archive('clients.archive')->listCheck(true);

			if ($canDo->get('core.admin'))
			{
				$childBar->checkin('clients.checkin')->listCheck(true);
			}

			if (!$this->state->get('filter.state') == -2)
			{
				$childBar->trash('clients.trash')->listCheck(true);
			}
		}

		if ($this->state->get('filter.state') == -2 && $canDo->get('core.delete'))
		{
			$toolbar->delete('clients.delete')
				->text('JTOOLBAR_EMPTY_TRASH')
				->message('JGLOBAL_CONFIRM_DELETE')
				->listCheck(true);
		}

		if ($canDo->get('core.admin') || $canDo->get('core.options'))
		{
			$toolbar->preferences('com_banners');
		}

		$toolbar->help('JHELP_COMPONENTS_BANNERS_CLIENTS');
	}

	/**
	 * 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()
	{
		return array(
			'a.status'    => Text::_('JSTATUS'),
			'a.name'      => Text::_('COM_BANNERS_HEADING_CLIENT'),
			'contact'     => Text::_('COM_BANNERS_HEADING_CONTACT'),
			'client_name' => Text::_('COM_BANNERS_HEADING_CLIENT'),
			'nbanners'    => Text::_('COM_BANNERS_HEADING_ACTIVE'),
			'a.id'        => Text::_('JGRID_HEADING_ID')
		);
	}
}

No other release has this exact content. See every version of this file.