[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_finder/src/View/Filters/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_finder
   6   *
   7   * @copyright   (C) 2011 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\Finder\Administrator\View\Filters;
  12  
  13  use Joomla\CMS\Helper\ContentHelper;
  14  use Joomla\CMS\Language\Text;
  15  use Joomla\CMS\MVC\View\GenericDataException;
  16  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  17  use Joomla\CMS\Toolbar\Toolbar;
  18  use Joomla\CMS\Toolbar\ToolbarHelper;
  19  
  20  // phpcs:disable PSR1.Files.SideEffects
  21  \defined('_JEXEC') or die;
  22  // phpcs:enable PSR1.Files.SideEffects
  23  
  24  /**
  25   * Filters view class for Finder.
  26   *
  27   * @since  2.5
  28   */
  29  class HtmlView extends BaseHtmlView
  30  {
  31      /**
  32       * An array of items
  33       *
  34       * @var    array
  35       *
  36       * @since  3.6.1
  37       */
  38      protected $items;
  39  
  40      /**
  41       * The pagination object
  42       *
  43       * @var    \Joomla\CMS\Pagination\Pagination
  44       *
  45       * @since  3.6.1
  46       */
  47      protected $pagination;
  48  
  49      /**
  50       * The model state
  51       *
  52       * @var    \Joomla\CMS\Object\CMSObject
  53       *
  54       * @since  3.6.1
  55       */
  56      protected $state;
  57  
  58      /**
  59       * The total number of items
  60       *
  61       * @var  integer
  62       *
  63       * @since  3.6.1
  64       */
  65      protected $total;
  66  
  67      /**
  68       * Form object for search filters
  69       *
  70       * @var    \Joomla\CMS\Form\Form
  71       *
  72       * @since  4.0.0
  73       */
  74      public $filterForm;
  75  
  76      /**
  77       * The active search filters
  78       *
  79       * @var    array
  80       *
  81       * @since  4.0.0
  82       */
  83      public $activeFilters;
  84  
  85      /**
  86       * @var    boolean
  87       *
  88       * @since  4.0.0
  89       */
  90      private $isEmptyState = false;
  91  
  92      /**
  93       * Method to display the view.
  94       *
  95       * @param   string  $tpl  A template file to load. [optional]
  96       *
  97       * @return  void
  98       *
  99       * @since   2.5
 100       */
 101      public function display($tpl = null)
 102      {
 103          // Load the view data.
 104          $this->items         = $this->get('Items');
 105          $this->pagination    = $this->get('Pagination');
 106          $this->total         = $this->get('Total');
 107          $this->state         = $this->get('State');
 108          $this->filterForm    = $this->get('FilterForm');
 109          $this->activeFilters = $this->get('ActiveFilters');
 110  
 111          if (\count($this->items) === 0 && $this->isEmptyState = $this->get('IsEmptyState')) {
 112              $this->setLayout('emptystate');
 113          }
 114  
 115          // Check for errors.
 116          if (count($errors = $this->get('Errors'))) {
 117              throw new GenericDataException(implode("\n", $errors), 500);
 118          }
 119  
 120          // Configure the toolbar.
 121          $this->addToolbar();
 122  
 123          parent::display($tpl);
 124      }
 125  
 126      /**
 127       * Method to configure the toolbar for this view.
 128       *
 129       * @return  void
 130       *
 131       * @since   2.5
 132       */
 133      protected function addToolbar()
 134      {
 135          $canDo = ContentHelper::getActions('com_finder');
 136  
 137          ToolbarHelper::title(Text::_('COM_FINDER_FILTERS_TOOLBAR_TITLE'), 'search-plus finder');
 138          $toolbar = Toolbar::getInstance('toolbar');
 139  
 140          if ($canDo->get('core.create')) {
 141              ToolbarHelper::addNew('filter.add');
 142              ToolbarHelper::divider();
 143          }
 144  
 145          if ($this->isEmptyState === false) {
 146              if ($canDo->get('core.edit.state')) {
 147                  $dropdown = $toolbar->dropdownButton('status-group')
 148                      ->text('JTOOLBAR_CHANGE_STATUS')
 149                      ->toggleSplit(false)
 150                      ->icon('icon-ellipsis-h')
 151                      ->buttonClass('btn btn-action')
 152                      ->listCheck(true);
 153  
 154                  $childBar = $dropdown->getChildToolbar();
 155  
 156                  $childBar->publish('filters.publish')->listCheck(true);
 157                  $childBar->unpublish('filters.unpublish')->listCheck(true);
 158                  $childBar->checkin('filters.checkin')->listCheck(true);
 159              }
 160  
 161              ToolbarHelper::divider();
 162              $toolbar->appendButton('Popup', 'bars', 'COM_FINDER_STATISTICS', 'index.php?option=com_finder&view=statistics&tmpl=component', 550, 350, '', '', '', Text::_('COM_FINDER_STATISTICS_TITLE'));
 163              ToolbarHelper::divider();
 164  
 165              if ($canDo->get('core.delete')) {
 166                  ToolbarHelper::deleteList('', 'filters.delete');
 167                  ToolbarHelper::divider();
 168              }
 169          }
 170  
 171          if ($canDo->get('core.admin') || $canDo->get('core.options')) {
 172              ToolbarHelper::preferences('com_finder');
 173          }
 174  
 175          ToolbarHelper::help('Smart_Search:_Search_Filters');
 176      }
 177  }


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