[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_finder/src/View/Maps/ -> 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\Maps;
  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  use Joomla\Component\Finder\Administrator\Helper\LanguageHelper;
  20  
  21  // phpcs:disable PSR1.Files.SideEffects
  22  \defined('_JEXEC') or die;
  23  // phpcs:enable PSR1.Files.SideEffects
  24  
  25  /**
  26   * Groups view class for Finder.
  27   *
  28   * @since  2.5
  29   */
  30  class HtmlView extends BaseHtmlView
  31  {
  32      /**
  33       * An array of items
  34       *
  35       * @var  array
  36       *
  37       * @since  3.6.1
  38       */
  39      protected $items;
  40  
  41      /**
  42       * The pagination object
  43       *
  44       * @var    \Joomla\CMS\Pagination\Pagination
  45       *
  46       * @since  3.6.1
  47       */
  48      protected $pagination;
  49  
  50      /**
  51       * The model state
  52       *
  53       * @var    \Joomla\CMS\Object\CMSObject
  54       *
  55       * @since  3.6.1
  56       */
  57      protected $state;
  58  
  59      /**
  60       * The total number of items
  61       *
  62       * @var  integer
  63       *
  64       * @since  3.6.1
  65       */
  66      protected $total;
  67  
  68      /**
  69       * Form object for search filters
  70       *
  71       * @var    \Joomla\CMS\Form\Form
  72       *
  73       * @since  4.0.0
  74       */
  75      public $filterForm;
  76  
  77      /**
  78       * The active search filters
  79       *
  80       * @var    array
  81       *
  82       * @since  4.0.0
  83       */
  84      public $activeFilters;
  85  
  86      /**
  87       * @var   boolean
  88       *
  89       * @since 4.0.0
  90       */
  91      private $isEmptyState = false;
  92  
  93      /**
  94       * Method to display the view.
  95       *
  96       * @param   string  $tpl  A template file to load. [optional]
  97       *
  98       * @return  void
  99       *
 100       * @since   2.5
 101       */
 102      public function display($tpl = null)
 103      {
 104          // Load plugin language files.
 105          LanguageHelper::loadPluginLanguage();
 106  
 107          // Load the view data.
 108          $this->items         = $this->get('Items');
 109          $this->total         = $this->get('Total');
 110          $this->pagination    = $this->get('Pagination');
 111          $this->state         = $this->get('State');
 112          $this->filterForm    = $this->get('FilterForm');
 113          $this->activeFilters = $this->get('ActiveFilters');
 114  
 115          if ($this->total === 0 && $this->isEmptyState = $this->get('isEmptyState')) {
 116              $this->setLayout('emptystate');
 117          }
 118  
 119          // Check for errors.
 120          if (count($errors = $this->get('Errors'))) {
 121              throw new GenericDataException(implode("\n", $errors), 500);
 122          }
 123  
 124          // Prepare the view.
 125          $this->addToolbar();
 126  
 127          parent::display($tpl);
 128      }
 129  
 130      /**
 131       * Method to configure the toolbar for this view.
 132       *
 133       * @return  void
 134       *
 135       * @since   2.5
 136       */
 137      protected function addToolbar()
 138      {
 139          $canDo = ContentHelper::getActions('com_finder');
 140  
 141          ToolbarHelper::title(Text::_('COM_FINDER_MAPS_TOOLBAR_TITLE'), 'search-plus finder');
 142  
 143          // Get the toolbar object instance
 144          $toolbar = Toolbar::getInstance('toolbar');
 145  
 146          if (!$this->isEmptyState) {
 147              if ($canDo->get('core.edit.state')) {
 148                  $dropdown = $toolbar->dropdownButton('status-group')
 149                      ->text('JTOOLBAR_CHANGE_STATUS')
 150                      ->toggleSplit(false)
 151                      ->icon('icon-ellipsis-h')
 152                      ->buttonClass('btn btn-action')
 153                      ->listCheck(true);
 154  
 155                  $childBar = $dropdown->getChildToolbar();
 156  
 157                  $childBar->publish('maps.publish')->listCheck(true);
 158                  $childBar->unpublish('maps.unpublish')->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('', 'maps.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:_Content_Maps');
 176      }
 177  }


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