[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_cache/src/View/Cache/ -> HtmlView.php (source)

   1  <?php
   2  /**
   3   * @package     Joomla.Administrator
   4   * @subpackage  com_cache
   5   *
   6   * @copyright   (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\Component\Cache\Administrator\View\Cache;
  11  
  12  \defined('_JEXEC') or die;
  13  
  14  use Joomla\CMS\Factory;
  15  use Joomla\CMS\Form\Form;
  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\Cache\Administrator\Model\CacheModel;
  24  
  25  /**
  26   * HTML View class for the Cache component
  27   *
  28   * @since  1.6
  29   */
  30  class HtmlView extends BaseHtmlView
  31  {
  32      /**
  33       * The search tools form
  34       *
  35       * @var    Form
  36       * @since  1.6
  37       */
  38      public $filterForm;
  39  
  40      /**
  41       * The active search filters
  42       *
  43       * @var    array
  44       * @since  1.6
  45       */
  46      public $activeFilters = [];
  47  
  48      /**
  49       * The cache data
  50       *
  51       * @var    array
  52       * @since  1.6
  53       */
  54      protected $data = [];
  55  
  56      /**
  57       * The pagination object
  58       *
  59       * @var    Pagination
  60       * @since  1.6
  61       */
  62      protected $pagination;
  63  
  64      /**
  65       * Total number of cache groups
  66       *
  67       * @var    integer
  68       * @since  1.6
  69       */
  70      protected $total = 0;
  71  
  72      /**
  73       * The model state
  74       *
  75       * @var    CMSObject
  76       * @since  1.6
  77       */
  78      protected $state;
  79  
  80      /**
  81       * Display a view.
  82       *
  83       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  84       *
  85       * @return  void
  86       *
  87       * @since   1.6
  88       *
  89       * @throws  GenericDataException
  90       */
  91  	public function display($tpl = null): void
  92      {
  93          /** @var CacheModel $model */
  94          $model               = $this->getModel();
  95          $this->data          = $model->getData();
  96          $this->pagination    = $model->getPagination();
  97          $this->total         = $model->getTotal();
  98          $this->state         = $model->getState();
  99          $this->filterForm    = $model->getFilterForm();
 100          $this->activeFilters = $model->getActiveFilters();
 101  
 102          // Check for errors.
 103          if (\count($errors = $this->get('Errors')))
 104          {
 105              throw new GenericDataException(implode("\n", $errors), 500);
 106          }
 107  
 108          if (!\count($this->data))
 109          {
 110              $this->setLayout('emptystate');
 111          }
 112  
 113          $this->addToolbar();
 114  
 115          parent::display($tpl);
 116      }
 117  
 118      /**
 119       * Add the page title and toolbar.
 120       *
 121       * @return  void
 122       *
 123       * @since   1.6
 124       */
 125  	protected function addToolbar(): void
 126      {
 127          ToolbarHelper::title(Text::_('COM_CACHE_CLEAR_CACHE'), 'bolt clear');
 128  
 129          // Get the toolbar object instance
 130          $toolbar = Toolbar::getInstance('toolbar');
 131  
 132          if (\count($this->data))
 133          {
 134              ToolbarHelper::custom('delete', 'delete', '', 'JTOOLBAR_DELETE', true);
 135              ToolbarHelper::custom('deleteAll', 'remove', '', 'JTOOLBAR_DELETE_ALL', false);
 136              $toolbar->appendButton('Confirm', 'COM_CACHE_RESOURCE_INTENSIVE_WARNING', 'delete', 'COM_CACHE_PURGE_EXPIRED', 'purge', false);
 137              ToolbarHelper::divider();
 138          }
 139  
 140          if ($this->getCurrentUser()->authorise('core.admin', 'com_cache'))
 141          {
 142              ToolbarHelper::preferences('com_cache');
 143              ToolbarHelper::divider();
 144          }
 145  
 146          ToolbarHelper::help('Maintenance:_Clear_Cache');
 147      }
 148  }


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