[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_languages/src/View/Overrides/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_languages
   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\Languages\Administrator\View\Overrides;
  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\ToolbarHelper;
  18  
  19  // phpcs:disable PSR1.Files.SideEffects
  20  \defined('_JEXEC') or die;
  21  // phpcs:enable PSR1.Files.SideEffects
  22  
  23  /**
  24   * View for language overrides list.
  25   *
  26   * @since  2.5
  27   */
  28  class HtmlView extends BaseHtmlView
  29  {
  30      /**
  31       * The items to list.
  32       *
  33       * @var     array
  34       * @since   2.5
  35       */
  36      protected $items;
  37  
  38      /**
  39       * The pagination object.
  40       *
  41       * @var     object
  42       * @since   2.5
  43       */
  44      protected $pagination;
  45  
  46      /**
  47       * The model state.
  48       *
  49       * @var     object
  50       * @since   2.5
  51       */
  52      protected $state;
  53  
  54      /**
  55       * An array containing all frontend and backend languages
  56       *
  57       * @var    array
  58       * @since  4.0.0
  59       */
  60      protected $languages;
  61  
  62      /**
  63       * Displays the view.
  64       *
  65       * @param   string  $tpl  The name of the template file to parse.
  66       *
  67       * @return  void
  68       *
  69       * @since   2.5
  70       */
  71      public function display($tpl = null)
  72      {
  73          $this->state         = $this->get('State');
  74          $this->items         = $this->get('Overrides');
  75          $this->languages     = $this->get('Languages');
  76          $this->pagination    = $this->get('Pagination');
  77          $this->filterForm    = $this->get('FilterForm');
  78          $this->activeFilters = $this->get('ActiveFilters');
  79  
  80          // Check for errors.
  81          if (count($errors = $this->get('Errors'))) {
  82              throw new GenericDataException(implode("\n", $errors));
  83          }
  84  
  85          $this->addToolbar();
  86          parent::display($tpl);
  87      }
  88  
  89      /**
  90       * Adds the page title and toolbar.
  91       *
  92       * @return  void
  93       *
  94       * @since   2.5
  95       */
  96      protected function addToolbar()
  97      {
  98          // Get the results for each action
  99          $canDo = ContentHelper::getActions('com_languages');
 100  
 101          ToolbarHelper::title(Text::_('COM_LANGUAGES_VIEW_OVERRIDES_TITLE'), 'comments langmanager');
 102  
 103          if ($canDo->get('core.create')) {
 104              ToolbarHelper::addNew('override.add');
 105          }
 106  
 107          if ($canDo->get('core.delete') && $this->pagination->total) {
 108              ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'overrides.delete', 'JTOOLBAR_DELETE');
 109          }
 110  
 111          if ($this->getCurrentUser()->authorise('core.admin')) {
 112              ToolbarHelper::custom('overrides.purge', 'refresh', '', 'COM_LANGUAGES_VIEW_OVERRIDES_PURGE', false);
 113          }
 114  
 115          if ($canDo->get('core.admin')) {
 116              ToolbarHelper::preferences('com_languages');
 117          }
 118  
 119          ToolbarHelper::divider();
 120          ToolbarHelper::help('Languages:_Overrides');
 121      }
 122  }


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