[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_menus/src/View/Menus/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_menus
   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\Menus\Administrator\View\Menus;
  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   * The HTML Menus Menu Menus View.
  25   *
  26   * @since  1.6
  27   */
  28  class HtmlView extends BaseHtmlView
  29  {
  30      /**
  31       * An array of items
  32       *
  33       * @var  array
  34       */
  35      protected $items;
  36  
  37      /**
  38       * List of all mod_mainmenu modules collated by menutype
  39       *
  40       * @var  array
  41       */
  42      protected $modules;
  43  
  44      /**
  45       * The pagination object
  46       *
  47       * @var  \Joomla\CMS\Pagination\Pagination
  48       */
  49      protected $pagination;
  50  
  51      /**
  52       * The model state
  53       *
  54       * @var  \Joomla\CMS\Object\CMSObject
  55       */
  56      protected $state;
  57  
  58      /**
  59       * Form object for search filters
  60       *
  61       * @var    \Joomla\CMS\Form\Form
  62       *
  63       * @since  4.0.0
  64       */
  65      public $filterForm;
  66  
  67      /**
  68       * The active search filters
  69       *
  70       * @var    array
  71       * @since  4.0.0
  72       */
  73      public $activeFilters;
  74  
  75      /**
  76       * Display the view
  77       *
  78       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  79       *
  80       * @return  void
  81       *
  82       * @since   1.6
  83       */
  84      public function display($tpl = null)
  85      {
  86          $this->items      = $this->get('Items');
  87          $this->modules    = $this->get('Modules');
  88          $this->pagination = $this->get('Pagination');
  89          $this->state      = $this->get('State');
  90  
  91          if ($this->getLayout() == 'default') {
  92              $this->filterForm    = $this->get('FilterForm');
  93              $this->activeFilters = $this->get('ActiveFilters');
  94          }
  95  
  96          // Check for errors.
  97          if (count($errors = $this->get('Errors'))) {
  98              throw new GenericDataException(implode("\n", $errors), 500);
  99          }
 100  
 101          $this->addToolbar();
 102  
 103          parent::display($tpl);
 104      }
 105  
 106      /**
 107       * Add the page title and toolbar.
 108       *
 109       * @return  void
 110       *
 111       * @since   1.6
 112       */
 113      protected function addToolbar()
 114      {
 115          $canDo = ContentHelper::getActions('com_menus');
 116  
 117          ToolbarHelper::title(Text::_('COM_MENUS_VIEW_MENUS_TITLE'), 'list menumgr');
 118  
 119          if ($canDo->get('core.create')) {
 120              ToolbarHelper::addNew('menu.add');
 121          }
 122  
 123          if ($canDo->get('core.delete')) {
 124              ToolbarHelper::divider();
 125              ToolbarHelper::deleteList('COM_MENUS_MENU_CONFIRM_DELETE', 'menus.delete', 'JTOOLBAR_DELETE');
 126          }
 127  
 128          if ($canDo->get('core.admin') && $this->state->get('client_id') == 1) {
 129              ToolbarHelper::custom('menu.exportXml', 'download', '', 'COM_MENUS_MENU_EXPORT_BUTTON', true);
 130          }
 131  
 132          if ($canDo->get('core.admin') || $canDo->get('core.options')) {
 133              ToolbarHelper::divider();
 134              ToolbarHelper::preferences('com_menus');
 135          }
 136  
 137          ToolbarHelper::divider();
 138          ToolbarHelper::help('Menus');
 139      }
 140  }


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