/administrator/modules/mod_submenu/tmpl/default.php

https://github.com/joomla/joomla-cms · PHP · 106 lines · 90 code · 8 blank · 8 comment · 11 complexity · 79b60c644041dc2294bca0e84ef67fc8 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Administrator
  4. * @subpackage mod_submenu
  5. *
  6. * @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. defined('_JEXEC') or die;
  10. use Joomla\CMS\HTML\HTMLHelper;
  11. use Joomla\CMS\Language\Text;
  12. use Joomla\CMS\Router\Route;
  13. /** @var \Joomla\CMS\Menu\MenuItem $root */
  14. ?>
  15. <?php foreach ($root->getChildren() as $child) : ?>
  16. <?php if ($child->hasChildren()) : ?>
  17. <div class="module-wrapper">
  18. <div class="card">
  19. <?php
  20. $child->img = $child->img ?? '';
  21. if (substr($child->img, 0, 6) === 'class:') {
  22. $iconImage = '<span class="icon-' . substr($child->img, 6) . '" aria-hidden="true"></span>';
  23. } elseif (substr($child->img, 0, 6) === 'image:') {
  24. $iconImage = '<img src="' . substr($child->img, 6) . '" aria-hidden="true">';
  25. } elseif (!empty($child->img)) {
  26. $iconImage = '<img src="' . $child->img . '" aria-hidden="true">';
  27. } elseif ($child->icon) {
  28. $iconImage = '<span class="icon-' . $child->icon . '" aria-hidden="true"></span>';
  29. } else {
  30. $iconImage = '';
  31. }
  32. ?>
  33. <h2 class="card-header">
  34. <?php echo $iconImage; ?>
  35. <?php echo Text::_($child->title); ?>
  36. </h2>
  37. <ul class="list-group list-group-flush">
  38. <?php foreach ($child->getChildren() as $item) : ?>
  39. <?php $params = $item->getParams(); ?>
  40. <?php // Only if Menu-show = true ?>
  41. <?php if ($params->get('menu_show', 1)) : ?>
  42. <li class="list-group-item d-flex align-items-center">
  43. <?php $class = $params->get('menu-quicktask') ? '' : 'class="flex-grow-1"'; ?>
  44. <a <?php echo $class; ?> href="<?php echo $item->link; ?>"
  45. <?php echo $item->target === '_blank' ? ' title="' . Text::sprintf('JBROWSERTARGET_NEW_TITLE', Text::_($item->title)) . '"' : ''; ?>
  46. <?php echo $item->target ? ' target="' . $item->target . '"' : ''; ?>>
  47. <?php if (!empty($params->get('menu_image'))) : ?>
  48. <?php
  49. $image = htmlspecialchars($params->get('menu_image'), ENT_QUOTES, 'UTF-8');
  50. $class = htmlspecialchars($params->get('menu_image_css'), ENT_QUOTES, 'UTF-8');
  51. $alt = $params->get('menu_text') ? '' : htmlspecialchars(Text::_($item->title), ENT_QUOTES, 'UTF-8');
  52. ?>
  53. <?php echo HTMLHelper::_('image', $image, $alt, 'class="' . $class . '"'); ?>
  54. <?php endif; ?>
  55. <?php echo ($params->get('menu_text', 1)) ? htmlspecialchars(Text::_($item->title), ENT_QUOTES, 'UTF-8') : ''; ?>
  56. <?php if ($item->ajaxbadge) : ?>
  57. <span class="menu-badge">
  58. <span class="icon-spin icon-spinner mt-1 system-counter float-end" data-url="<?php echo $item->ajaxbadge; ?>"></span>
  59. </span>
  60. <?php endif; ?>
  61. </a>
  62. <?php echo $item->iconImage; ?>
  63. <?php if ($params->get('menu-quicktask')) : ?>
  64. <?php $permission = $params->get('menu-quicktask-permission'); ?>
  65. <?php $scope = $item->scope !== 'default' ? $item->scope : null; ?>
  66. <?php if (!$permission || $user->authorise($permission, $scope)) : ?>
  67. <span class="menu-quicktask">
  68. <?php
  69. $link = $params->get('menu-quicktask');
  70. $icon = $params->get('menu-quicktask-icon', 'plus');
  71. $title = Text::_($params->get('menu-quicktask-title'));
  72. if (empty($params->get('menu-quicktask-title'))) {
  73. $title = Text::_('MOD_MENU_QUICKTASK_NEW');
  74. }
  75. $sronly = Text::_($item->title) . ' - ' . $title;
  76. ?>
  77. <a href="<?php echo $link; ?>">
  78. <span class="icon-<?php echo $icon; ?>" title="<?php echo htmlentities($title); ?>" aria-hidden="true"></span>
  79. <span class="visually-hidden"><?php echo htmlentities($sronly); ?></span>
  80. </a>
  81. </span>
  82. <?php endif; ?>
  83. <?php endif; ?>
  84. <?php if ($item->dashboard) : ?>
  85. <span class="menu-dashboard">
  86. <a href="<?php echo Route::_('index.php?option=com_cpanel&view=cpanel&dashboard=' . $item->dashboard); ?>">
  87. <span class="icon-th-large" title="<?php echo htmlentities(Text::sprintf('MOD_MENU_DASHBOARD_LINK', Text::_($child->title))); ?>"></span>
  88. </a>
  89. </span>
  90. <?php endif; ?>
  91. </li>
  92. <?php endif; ?>
  93. <?php endforeach; ?>
  94. </ul>
  95. </div>
  96. </div>
  97. <?php endif; ?>
  98. <?php endforeach; ?>