[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/modules/mod_menu/tmpl/ -> default_submenu.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  mod_menu
   6   *
   7   * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Language\Text;
  14  use Joomla\CMS\Router\Route;
  15  use Joomla\CMS\Uri\Uri;
  16  
  17  /**
  18   * =========================================================================================================
  19   * IMPORTANT: The scope of this layout file is the `var  \Joomla\Module\Menu\Administrator\Menu\CssMenu` object
  20   * and NOT the module context.
  21   * =========================================================================================================
  22   */
  23  /** @var  \Joomla\Module\Menu\Administrator\Menu\CssMenu  $this */
  24  $class         = 'item';
  25  $currentParams = $current->getParams();
  26  
  27  // Build the CSS class suffix
  28  if (!$this->enabled) {
  29      $class .= ' disabled';
  30  } elseif ($current->type == 'separator') {
  31      $class = $current->title ? 'menuitem-group' : 'divider';
  32  } elseif ($current->hasChildren()) {
  33      $class .= ' parent';
  34  }
  35  
  36  if ($current->level == 1) {
  37      $class .= ' item-level-1';
  38  } elseif ($current->level == 2) {
  39      $class .= ' item-level-2';
  40  } elseif ($current->level == 3) {
  41      $class .= ' item-level-3';
  42  }
  43  
  44  // Set the correct aria role and print the item
  45  if ($current->type == 'separator') {
  46      echo '<li class="' . $class . '" role="presentation">';
  47  } else {
  48      echo '<li class="' . $class . '">';
  49  }
  50  
  51  // Print a link if it exists
  52  $linkClass  = [];
  53  $dataToggle = '';
  54  $iconClass  = '';
  55  $itemIconClass = '';
  56  $itemImage  = '';
  57  
  58  if ($current->hasChildren()) {
  59      $linkClass[] = 'has-arrow';
  60  
  61      if ($current->level > 2) {
  62          $dataToggle  = ' data-bs-toggle="dropdown"';
  63      }
  64  } else {
  65      $linkClass[] = 'no-dropdown';
  66  }
  67  
  68  // Implode out $linkClass for rendering
  69  $linkClass = ' class="' . implode(' ', $linkClass) . '" ';
  70  
  71  // Get the menu link
  72  $link = $current->link;
  73  
  74  // Get the menu image class
  75  $itemIconClass = $currentParams->get('menu_icon');
  76  
  77  // Get the menu image
  78  $itemImage = $currentParams->get('menu_image');
  79  
  80  // Get the menu icon
  81  $icon      = $this->getIconClass($current);
  82  $iconClass = ($icon != '' && $current->level == 1) ? '<span class="' . $icon . '" aria-hidden="true"></span>' : '';
  83  $ajax      = !empty($current->ajaxbadge) ? '<span class="menu-badge"><span class="icon-spin icon-spinner mt-1 system-counter" data-url="' . $current->ajaxbadge . '"></span></span>' : '';
  84  $iconImage = $current->icon;
  85  $homeImage = '';
  86  
  87  if ($iconClass === '' && $itemIconClass) {
  88      $iconClass = '<span class="' . $itemIconClass . '" aria-hidden="true"></span>';
  89  }
  90  
  91  if ($iconImage) {
  92      if (substr($iconImage, 0, 6) == 'class:' && substr($iconImage, 6) == 'icon-home') {
  93          $iconImage = '<span class="home-image icon-home" aria-hidden="true"></span>';
  94          $iconImage .= '<span class="visually-hidden">' . Text::_('JDEFAULT') . '</span>';
  95      } elseif (substr($iconImage, 0, 6) == 'image:') {
  96          $iconImage = '&nbsp;<span class="badge">' . substr($iconImage, 6) . '</span>';
  97      } else {
  98          $iconImage = '';
  99      }
 100  }
 101  
 102  $itemImage = (empty($itemIconClass) && $itemImage) ? '&nbsp;<img src="' . Uri::root() . $itemImage . '" alt="">&nbsp;' : '';
 103  
 104  // If the item image is not set, the item title would not have margin. Here we add it.
 105  if ($icon == '' && $iconClass == '' && $current->level == 1 && $current->target == '') {
 106      $iconClass = '<span aria-hidden="true" class="icon-fw"></span>';
 107  }
 108  
 109  if ($link != '' && $current->target != '') {
 110      echo '<a' . $linkClass . $dataToggle . ' href="' . $link . '" target="' . $current->target . '">'
 111          . $iconClass
 112          . '<span class="sidebar-item-title">' . $itemImage . Text::_($current->title) . '</span>' . $ajax . '</a>';
 113  } elseif ($link != '' && $current->type !== 'separator') {
 114      echo '<a' . $linkClass . $dataToggle . ' href="' . $link . '" aria-label="' . Text::_($current->title) . '">'
 115          . $iconClass
 116          . '<span class="sidebar-item-title">' . $itemImage . Text::_($current->title) . '</span>' . $iconImage . '</a>';
 117  } elseif ($current->title != '' && $current->type !== 'separator') {
 118      echo '<a' . $linkClass . $dataToggle . ' href="#">'
 119          . $iconClass
 120          . '<span class="sidebar-item-title">' . $itemImage . Text::_($current->title) . '</span>' . $ajax . '</a>';
 121  } elseif ($current->title != '' && $current->type === 'separator') {
 122      echo '<span class="sidebar-item-title">' . Text::_($current->title) . '</span>' . $ajax;
 123  } else {
 124      echo '<span>' . Text::_($current->title) . '</span>' . $ajax;
 125  }
 126  
 127  if ($currentParams->get('menu-quicktask') && (int) $this->params->get('shownew', 1) === 1) {
 128      $params = $current->getParams();
 129      $user = $this->application->getIdentity();
 130      $link = $params->get('menu-quicktask');
 131      $icon = $params->get('menu-quicktask-icon', 'plus');
 132      $title = $params->get('menu-quicktask-title', 'MOD_MENU_QUICKTASK_NEW');
 133      $permission = $params->get('menu-quicktask-permission');
 134      $scope = $current->scope !== 'default' ? $current->scope : null;
 135  
 136      if (!$permission || $user->authorise($permission, $scope)) {
 137          echo '<span class="menu-quicktask"><a href="' . $link . '">';
 138          echo '<span class="icon-' . $icon . '" title="' . htmlentities(Text::_($title)) . '" aria-hidden="true"></span>';
 139          echo '<span class="visually-hidden">' . Text::_($title) . '</span>';
 140          echo '</a></span>';
 141      }
 142  }
 143  
 144  if (!empty($current->dashboard)) {
 145      $titleDashboard = Text::sprintf('MOD_MENU_DASHBOARD_LINK', Text::_($current->title));
 146      echo '<span class="menu-dashboard"><a href="'
 147          . Route::_('index.php?option=com_cpanel&view=cpanel&dashboard=' . $current->dashboard) . '">'
 148          . '<span class="icon-th-large" title="' . $titleDashboard . '" aria-hidden="true"></span>'
 149          . '<span class="visually-hidden">' . $titleDashboard . '</span>'
 150          . '</a></span>';
 151  }
 152  
 153  // Recurse through children if they exist
 154  if ($this->enabled && $current->hasChildren()) {
 155      if ($current->level > 1) {
 156          $id = $current->id ? ' id="menu-' . strtolower($current->id) . '"' : '';
 157  
 158          echo '<ul' . $id . ' class="mm-collapse collapse-level-' . $current->level . '">' . "\n";
 159      } else {
 160          echo '<ul id="collapse' . $this->getCounter() . '" class="collapse-level-1 mm-collapse">' . "\n";
 161      }
 162  
 163      // WARNING: Do not use direct 'include' or 'require' as it is important to isolate the scope for each call
 164      $this->renderSubmenu(__FILE__, $current);
 165  
 166      echo "</ul>\n";
 167  }
 168  
 169  echo "</li>\n";


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