[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_menus
   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\Menus\Administrator\View\Menutypes;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Language\Text;
  15  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  16  use Joomla\CMS\Object\CMSObject;
  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   * The HTML Menus Menu Item Types View.
  26   *
  27   * @since  1.6
  28   */
  29  class HtmlView extends BaseHtmlView
  30  {
  31      /**
  32       * The menu type id
  33       *
  34       * @var    integer
  35       * @since  4.0.0
  36       */
  37      protected $recordId;
  38  
  39      /**
  40       * Array of menu types
  41       *
  42       * @var    CMSObject[]
  43       *
  44       * @since  3.7.0
  45       */
  46      protected $types;
  47  
  48      /**
  49       * Display the view
  50       *
  51       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  52       *
  53       * @return  void
  54       *
  55       * @since   1.6
  56       */
  57      public function display($tpl = null)
  58      {
  59          $app            = Factory::getApplication();
  60          $this->recordId = $app->input->getInt('recordId');
  61  
  62          $types = $this->get('TypeOptions');
  63  
  64          $this->addCustomTypes($types);
  65  
  66          $sortedTypes = array();
  67  
  68          foreach ($types as $name => $list) {
  69              $tmp = array();
  70  
  71              foreach ($list as $item) {
  72                  $tmp[Text::_($item->title)] = $item;
  73              }
  74  
  75              uksort($tmp, 'strcasecmp');
  76              $sortedTypes[Text::_($name)] = $tmp;
  77          }
  78  
  79          uksort($sortedTypes, 'strcasecmp');
  80  
  81          $this->types = $sortedTypes;
  82  
  83          $this->addToolbar();
  84  
  85          parent::display($tpl);
  86      }
  87  
  88      /**
  89       * Add the page title and toolbar.
  90       *
  91       * @return  void
  92       *
  93       * @since   3.0
  94       */
  95      protected function addToolbar()
  96      {
  97          // Add page title
  98          ToolbarHelper::title(Text::_('COM_MENUS'), 'list menumgr');
  99  
 100          // Get the toolbar object instance
 101          $bar = Toolbar::getInstance('toolbar');
 102  
 103          // Cancel
 104          $title = Text::_('JTOOLBAR_CANCEL');
 105          $dhtml = "<button onClick=\"location.href='index.php?option=com_menus&view=items'\" class=\"btn\">
 106                      <span class=\"icon-times\" title=\"$title\"></span>
 107                      $title</button>";
 108          $bar->appendButton('Custom', $dhtml, 'new');
 109      }
 110  
 111      /**
 112       * Method to add system link types to the link types array
 113       *
 114       * @param   array  $types  The list of link types
 115       *
 116       * @return  void
 117       *
 118       * @since   3.7.0
 119       */
 120      protected function addCustomTypes(&$types)
 121      {
 122          if (empty($types)) {
 123              $types = array();
 124          }
 125  
 126          // Adding System Links
 127          $list           = array();
 128          $o              = new CMSObject();
 129          $o->title       = 'COM_MENUS_TYPE_EXTERNAL_URL';
 130          $o->type        = 'url';
 131          $o->description = 'COM_MENUS_TYPE_EXTERNAL_URL_DESC';
 132          $o->request     = null;
 133          $list[]         = $o;
 134  
 135          $o              = new CMSObject();
 136          $o->title       = 'COM_MENUS_TYPE_ALIAS';
 137          $o->type        = 'alias';
 138          $o->description = 'COM_MENUS_TYPE_ALIAS_DESC';
 139          $o->request     = null;
 140          $list[]         = $o;
 141  
 142          $o              = new CMSObject();
 143          $o->title       = 'COM_MENUS_TYPE_SEPARATOR';
 144          $o->type        = 'separator';
 145          $o->description = 'COM_MENUS_TYPE_SEPARATOR_DESC';
 146          $o->request     = null;
 147          $list[]         = $o;
 148  
 149          $o              = new CMSObject();
 150          $o->title       = 'COM_MENUS_TYPE_HEADING';
 151          $o->type        = 'heading';
 152          $o->description = 'COM_MENUS_TYPE_HEADING_DESC';
 153          $o->request     = null;
 154          $list[]         = $o;
 155  
 156          if ($this->get('state')->get('client_id') == 1) {
 157              $o              = new CMSObject();
 158              $o->title       = 'COM_MENUS_TYPE_CONTAINER';
 159              $o->type        = 'container';
 160              $o->description = 'COM_MENUS_TYPE_CONTAINER_DESC';
 161              $o->request     = null;
 162              $list[]         = $o;
 163          }
 164  
 165          $types['COM_MENUS_TYPE_SYSTEM'] = $list;
 166      }
 167  }


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