[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_banners/src/View/Clients/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_banners
   6   *
   7   * @copyright   (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Component\Banners\Administrator\View\Clients;
  12  
  13  use Exception;
  14  use Joomla\CMS\Form\Form;
  15  use Joomla\CMS\Helper\ContentHelper;
  16  use Joomla\CMS\Language\Text;
  17  use Joomla\CMS\MVC\View\GenericDataException;
  18  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  19  use Joomla\CMS\Object\CMSObject;
  20  use Joomla\CMS\Pagination\Pagination;
  21  use Joomla\CMS\Toolbar\Toolbar;
  22  use Joomla\CMS\Toolbar\ToolbarHelper;
  23  use Joomla\Component\Banners\Administrator\Model\ClientsModel;
  24  
  25  // phpcs:disable PSR1.Files.SideEffects
  26  \defined('_JEXEC') or die;
  27  // phpcs:enable PSR1.Files.SideEffects
  28  
  29  /**
  30   * View class for a list of clients.
  31   *
  32   * @since  1.6
  33   */
  34  class HtmlView extends BaseHtmlView
  35  {
  36      /**
  37       * The search tools form
  38       *
  39       * @var    Form
  40       * @since  1.6
  41       */
  42      public $filterForm;
  43  
  44      /**
  45       * The active search filters
  46       *
  47       * @var    array
  48       * @since  1.6
  49       */
  50      public $activeFilters = [];
  51  
  52      /**
  53       * An array of items
  54       *
  55       * @var    array
  56       * @since  1.6
  57       */
  58      protected $items = [];
  59  
  60      /**
  61       * The pagination object
  62       *
  63       * @var    Pagination
  64       * @since  1.6
  65       */
  66      protected $pagination;
  67  
  68      /**
  69       * The model state
  70       *
  71       * @var    CMSObject
  72       * @since  1.6
  73       */
  74      protected $state;
  75  
  76      /**
  77       * Is this view an Empty State
  78       *
  79       * @var  boolean
  80       * @since 4.0.0
  81       */
  82      private $isEmptyState = false;
  83  
  84      /**
  85       * Display the view
  86       *
  87       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  88       *
  89       * @return  void
  90       *
  91       * @since   1.6
  92       *
  93       * @throws  Exception
  94       */
  95      public function display($tpl = null): void
  96      {
  97          /** @var ClientsModel $model */
  98          $model               = $this->getModel();
  99          $this->items         = $model->getItems();
 100          $this->pagination    = $model->getPagination();
 101          $this->state         = $model->getState();
 102          $this->filterForm    = $model->getFilterForm();
 103          $this->activeFilters = $model->getActiveFilters();
 104  
 105          if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
 106              $this->setLayout('emptystate');
 107          }
 108  
 109          // Check for errors.
 110          if (\count($errors = $this->get('Errors'))) {
 111              throw new GenericDataException(implode("\n", $errors), 500);
 112          }
 113  
 114          $this->addToolbar();
 115  
 116          parent::display($tpl);
 117      }
 118  
 119      /**
 120       * Add the page title and toolbar.
 121       *
 122       * @return  void
 123       *
 124       * @since   1.6
 125       */
 126      protected function addToolbar(): void
 127      {
 128          $canDo = ContentHelper::getActions('com_banners');
 129  
 130          ToolbarHelper::title(Text::_('COM_BANNERS_MANAGER_CLIENTS'), 'bookmark banners-clients');
 131  
 132          // Get the toolbar object instance
 133          $toolbar = Toolbar::getInstance('toolbar');
 134  
 135          if ($canDo->get('core.create')) {
 136              $toolbar->addNew('client.add');
 137          }
 138  
 139          if (!$this->isEmptyState && ($canDo->get('core.edit.state') || $canDo->get('core.admin'))) {
 140              $dropdown = $toolbar->dropdownButton('status-group')
 141                  ->text('JTOOLBAR_CHANGE_STATUS')
 142                  ->toggleSplit(false)
 143                  ->icon('icon-ellipsis-h')
 144                  ->buttonClass('btn btn-action')
 145                  ->listCheck(true);
 146  
 147              $childBar = $dropdown->getChildToolbar();
 148  
 149              $childBar->publish('clients.publish')->listCheck(true);
 150              $childBar->unpublish('clients.unpublish')->listCheck(true);
 151              $childBar->archive('clients.archive')->listCheck(true);
 152  
 153              if ($canDo->get('core.admin')) {
 154                  $childBar->checkin('clients.checkin')->listCheck(true);
 155              }
 156  
 157              if (!$this->state->get('filter.state') == -2) {
 158                  $childBar->trash('clients.trash')->listCheck(true);
 159              }
 160          }
 161  
 162          if (!$this->isEmptyState && $this->state->get('filter.state') == -2 && $canDo->get('core.delete')) {
 163              $toolbar->delete('clients.delete')
 164                  ->text('JTOOLBAR_EMPTY_TRASH')
 165                  ->message('JGLOBAL_CONFIRM_DELETE')
 166                  ->listCheck(true);
 167          }
 168  
 169          if ($canDo->get('core.admin') || $canDo->get('core.options')) {
 170              $toolbar->preferences('com_banners');
 171          }
 172  
 173          $toolbar->help('Banners:_Clients');
 174      }
 175  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer