[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_banners
   6   *
   7   * @copyright   (C) 2009 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\Tracks;
  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\Router\Route;
  22  use Joomla\CMS\Toolbar\Toolbar;
  23  use Joomla\CMS\Toolbar\ToolbarHelper;
  24  use Joomla\Component\Banners\Administrator\Model\TracksModel;
  25  
  26  // phpcs:disable PSR1.Files.SideEffects
  27  \defined('_JEXEC') or die;
  28  // phpcs:enable PSR1.Files.SideEffects
  29  
  30  /**
  31   * View class for a list of tracks.
  32   *
  33   * @since  1.6
  34   */
  35  class HtmlView extends BaseHtmlView
  36  {
  37      /**
  38       * The search tools form
  39       *
  40       * @var    Form
  41       * @since  1.6
  42       */
  43      public $filterForm;
  44  
  45      /**
  46       * The active search filters
  47       *
  48       * @var    array
  49       * @since  1.6
  50       */
  51      public $activeFilters = [];
  52  
  53      /**
  54       * An array of items
  55       *
  56       * @var    array
  57       * @since  1.6
  58       */
  59      protected $items = [];
  60  
  61      /**
  62       * The pagination object
  63       *
  64       * @var    Pagination
  65       * @since  1.6
  66       */
  67      protected $pagination;
  68  
  69      /**
  70       * The model state
  71       *
  72       * @var    CMSObject
  73       * @since  1.6
  74       */
  75      protected $state;
  76  
  77      /**
  78       * Is this view an Empty State
  79       *
  80       * @var  boolean
  81       * @since 4.0.0
  82       */
  83      private $isEmptyState = false;
  84  
  85      /**
  86       * Display the view
  87       *
  88       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  89       *
  90       * @return  void
  91       *
  92       * @since   1.6
  93       * @throws  Exception
  94       */
  95      public function display($tpl = null): void
  96      {
  97          /** @var TracksModel $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', 'category', $this->state->get('filter.category_id'));
 129  
 130          ToolbarHelper::title(Text::_('COM_BANNERS_MANAGER_TRACKS'), 'bookmark banners-tracks');
 131  
 132          $bar = Toolbar::getInstance('toolbar');
 133  
 134          if (!$this->isEmptyState) {
 135              $bar->popupButton()
 136                  ->url(Route::_('index.php?option=com_banners&view=download&tmpl=component'))
 137                  ->text('JTOOLBAR_EXPORT')
 138                  ->selector('downloadModal')
 139                  ->icon('icon-download')
 140                  ->footer('<button class="btn btn-secondary" data-bs-dismiss="modal" type="button"'
 141                      . ' onclick="window.parent.Joomla.Modal.getCurrent().close();">'
 142                      . Text::_('COM_BANNERS_CANCEL') . '</button>'
 143                      . '<button class="btn btn-success" type="button"'
 144                      . ' onclick="Joomla.iframeButtonClick({iframeSelector: \'#downloadModal\', buttonSelector: \'#exportBtn\'})">'
 145                      . Text::_('COM_BANNERS_TRACKS_EXPORT') . '</button>');
 146          }
 147  
 148          if (!$this->isEmptyState && $canDo->get('core.delete')) {
 149              $bar->appendButton('Confirm', 'COM_BANNERS_DELETE_MSG', 'delete', 'COM_BANNERS_TRACKS_DELETE', 'tracks.delete', false);
 150          }
 151  
 152          if ($canDo->get('core.admin') || $canDo->get('core.options')) {
 153              ToolbarHelper::preferences('com_banners');
 154          }
 155  
 156          ToolbarHelper::help('Banners:_Tracks');
 157      }
 158  }


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