This commit is contained in:
AlexBa16
2026-06-08 15:29:52 +02:00
commit 27903eed4a
9931 changed files with 1535659 additions and 0 deletions
+168
View File
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="module" client="site" method="upgrade">
<name>mod_menu</name>
<author>Joomla! Project</author>
<creationDate>2004-07</creationDate>
<copyright>(C) 2005 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>MOD_MENU_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Module\Menu</namespace>
<files>
<folder module="mod_menu">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/mod_menu.ini</language>
<language tag="en-GB">language/en-GB/mod_menu.sys.ini</language>
</languages>
<help key="Site_Modules:_Menu" />
<config>
<fields name="params">
<fieldset name="basic" addfieldprefix="Joomla\Component\Menus\Administrator\Field">
<field
name="menutype"
type="menu"
label="MOD_MENU_FIELD_MENUTYPE_LABEL"
clientid="0"
/>
<field
name="base"
type="modal_menu"
label="MOD_MENU_FIELD_ACTIVE_LABEL"
select="true"
new="true"
edit="true"
clear="true"
filter="integer"
>
<option value="">JCURRENT</option>
</field>
<field
name="startLevel"
type="list"
label="MOD_MENU_FIELD_STARTLEVEL_LABEL"
default="1"
filter="integer"
validate="options"
>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
<option value="6">J6</option>
<option value="7">J7</option>
<option value="8">J8</option>
<option value="9">J9</option>
<option value="10">J10</option>
</field>
<field
name="endLevel"
type="list"
label="MOD_MENU_FIELD_ENDLEVEL_LABEL"
default="0"
filter="integer"
validate="options"
>
<option value="0">JALL</option>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
<option value="6">J6</option>
<option value="7">J7</option>
<option value="8">J8</option>
<option value="9">J9</option>
<option value="10">J10</option>
</field>
<field
name="showAllChildren"
type="radio"
layout="joomla.form.field.radio.switcher"
label="MOD_MENU_FIELD_ALLCHILDREN_LABEL"
default="1"
filter="integer"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="advanced">
<field
name="tag_id"
type="text"
label="MOD_MENU_FIELD_TAG_ID_LABEL"
/>
<field
name="class_sfx"
type="text"
label="MOD_MENU_FIELD_CLASS_LABEL"
validate="CssIdentifier"
/>
<field
name="window_open"
type="text"
label="MOD_MENU_FIELD_TARGET_LABEL"
description="MOD_MENU_FIELD_TARGET_DESC"
/>
<field
name="layout"
type="modulelayout"
label="JFIELD_ALT_LAYOUT_LABEL"
class="form-select"
default="_:default"
validate="moduleLayout"
/>
<field
name="moduleclass_sfx"
type="textarea"
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
rows="3"
validate="CssIdentifier"
/>
<field
name="cache"
type="list"
label="COM_MODULES_FIELD_CACHING_LABEL"
default="1"
filter="integer"
validate="options"
>
<option value="1">JGLOBAL_USE_GLOBAL</option>
<option value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
</field>
<field
name="cache_time"
type="number"
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
default="900"
filter="integer"
/>
<field
name="cachemode"
type="hidden"
default="itemid"
>
<option value="itemid"></option>
</field>
</fieldset>
</fields>
</config>
</extension>
@@ -0,0 +1,41 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_menu
*
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
\defined('_JEXEC') or die;
use Joomla\CMS\Extension\Service\Provider\HelperFactory;
use Joomla\CMS\Extension\Service\Provider\Module;
use Joomla\CMS\Extension\Service\Provider\ModuleDispatcherFactory;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
/**
* The menu module service provider.
*
* @since 5.4.0
*/
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 5.4.0
*/
public function register(Container $container)
{
$container->registerServiceProvider(new ModuleDispatcherFactory('\\Joomla\\Module\\Menu'));
$container->registerServiceProvider(new HelperFactory('\\Joomla\\Module\\Menu\\Site\\Helper'));
$container->registerServiceProvider(new Module());
}
};
@@ -0,0 +1,73 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_menu
*
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Module\Menu\Site\Dispatcher;
use Joomla\CMS\Dispatcher\AbstractModuleDispatcher;
use Joomla\CMS\Helper\HelperFactoryAwareInterface;
use Joomla\CMS\Helper\HelperFactoryAwareTrait;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Dispatcher class for mod_menu
*
* @since 5.4.0
*/
class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface
{
use HelperFactoryAwareTrait;
/**
* Runs the dispatcher.
*
* @return void
*
* @since 5.4.0
*/
public function dispatch()
{
$displayData = $this->getLayoutData();
if (!$displayData['list']) {
return;
}
parent::dispatch();
}
/**
* Returns the layout data.
*
* @return array
*
* @since 5.4.0
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
$menuHelper = $this->getHelperFactory()->getHelper('MenuHelper');
$data['list'] = $menuHelper->getItems($data['params'], $data['app']);
$data['base'] = $menuHelper->getBaseItem($data['params'], $data['app']);
$data['active'] = $menuHelper->getActiveItem($data['app']);
$data['default'] = $menuHelper->getDefaultItem($data['app']);
$data['active_id'] = $data['active']->id;
$data['default_id'] = $data['default']->id;
$data['path'] = $data['base']->tree;
$data['showAll'] = $data['params']->get('showAllChildren', 1);
$data['class_sfx'] = htmlspecialchars($data['params']->get('class_sfx', ''), ENT_COMPAT, 'UTF-8');
return $data;
}
}
@@ -0,0 +1,325 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_menu
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Module\Menu\Site\Helper;
use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\Cache\CacheControllerFactoryInterface;
use Joomla\CMS\Cache\Controller\OutputController;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Router\Route;
use Joomla\Registry\Registry;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Helper for mod_menu
*
* @since 1.5
*/
class MenuHelper
{
/**
* Get a list of the menu items.
*
* @param Registry &$params The module options.
* @param CMSApplicationInterface $app The application
*
* @return array
*
* @since 5.4.0
*/
public function getItems(Registry &$params, CMSApplicationInterface $app): array
{
$menu = $app->getMenu();
// Get active menu item
$base = $this->getBaseItem($params, $app);
$levels = $app->getIdentity()->getAuthorisedViewLevels();
asort($levels);
// Compose cache key
$cacheKey = 'menu_items' . $params . implode(',', $levels) . '.' . $base->id;
/** @var OutputController $cache */
$cache = Factory::getContainer()->get(CacheControllerFactoryInterface::class)
->createCacheController('output', ['defaultgroup' => 'mod_menu']);
if ($cache->contains($cacheKey)) {
$items = $cache->get($cacheKey);
} else {
$path = $base->tree;
$start = (int) $params->get('startLevel', 1);
$end = (int) $params->get('endLevel', 0);
$showAll = $params->get('showAllChildren', 1);
$items = $menu->getItems('menutype', $params->get('menutype'));
$hidden_parents = [];
$lastitem = 0;
if ($items) {
$inputVars = $app->getInput()->getArray();
foreach ($items as $i => $item) {
$item->parent = false;
$itemParams = $item->getParams();
if (isset($items[$lastitem]) && $items[$lastitem]->id == $item->parent_id && $itemParams->get('menu_show', 1) == 1) {
$items[$lastitem]->parent = true;
}
if (
($start && $start > $item->level)
|| ($end && $item->level > $end)
|| (!$showAll && $item->level > 1 && !\in_array($item->parent_id, $path))
|| ($start > 1 && !\in_array($item->tree[$start - 2], $path))
) {
unset($items[$i]);
continue;
}
// Exclude item with menu item option set to exclude from menu modules
if (($itemParams->get('menu_show', 1) == 0) || \in_array($item->parent_id, $hidden_parents)) {
$hidden_parents[] = $item->id;
unset($items[$i]);
continue;
}
$item->current = true;
foreach ($item->query as $key => $value) {
if (!isset($inputVars[$key]) || $inputVars[$key] !== $value) {
$item->current = false;
break;
}
}
$item->deeper = false;
$item->shallower = false;
$item->level_diff = 0;
if (isset($items[$lastitem])) {
$items[$lastitem]->deeper = ($item->level > $items[$lastitem]->level);
$items[$lastitem]->shallower = ($item->level < $items[$lastitem]->level);
$items[$lastitem]->level_diff = ($items[$lastitem]->level - $item->level);
}
$lastitem = $i;
$item->active = false;
$item->flink = $item->link;
// Reverted back for CMS version 2.5.6
switch ($item->type) {
case 'separator':
break;
case 'heading':
// No further action needed.
break;
case 'url':
if ((str_starts_with($item->link, 'index.php?')) && (!str_contains($item->link, 'Itemid='))) {
// If this is an internal Joomla link, ensure the Itemid is set.
$item->flink = $item->link . '&Itemid=' . $item->id;
}
break;
case 'alias':
$item->flink = 'index.php?Itemid=' . $itemParams->get('aliasoptions');
// Get the language of the target menu item when site is multilingual
if (Multilanguage::isEnabled()) {
$newItem = $app->getMenu()->getItem((int) $itemParams->get('aliasoptions'));
// Use language code if not set to ALL
if ($newItem != null && $newItem->language && $newItem->language !== '*') {
$item->flink .= '&lang=' . $newItem->language;
}
}
break;
default:
$item->flink = 'index.php?Itemid=' . $item->id;
break;
}
if ((str_contains($item->flink, 'index.php?')) && strcasecmp(substr($item->flink, 0, 4), 'http')) {
$item->flink = Route::_($item->flink, true, $itemParams->get('secure'));
} else {
$item->flink = Route::_($item->flink);
}
// We prevent the double encoding because for some reason the $item is shared for menu modules and we get double encoding
// when the cause of that is found the argument should be removed
$item->title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8', false);
$item->menu_icon = htmlspecialchars($itemParams->get('menu_icon_css', ''), ENT_COMPAT, 'UTF-8', false);
$item->anchor_css = htmlspecialchars($itemParams->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8', false);
$item->anchor_title = htmlspecialchars($itemParams->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8', false);
$item->anchor_rel = htmlspecialchars($itemParams->get('menu-anchor_rel', ''), ENT_COMPAT, 'UTF-8', false);
$item->menu_image = htmlspecialchars($itemParams->get('menu_image', ''), ENT_COMPAT, 'UTF-8', false);
$item->menu_image_css = htmlspecialchars($itemParams->get('menu_image_css', ''), ENT_COMPAT, 'UTF-8', false);
}
if (isset($items[$lastitem])) {
$items[$lastitem]->deeper = (($start ?: 1) > $items[$lastitem]->level);
$items[$lastitem]->shallower = (($start ?: 1) < $items[$lastitem]->level);
$items[$lastitem]->level_diff = ($items[$lastitem]->level - ($start ?: 1));
}
}
$cache->store($items, $cacheKey);
}
return $items;
}
/**
* Get base menu item.
*
* @param Registry &$params The module options.
* @param CMSApplicationInterface $app The application
*
* @return object
*
* @since 5.4.0
*/
public function getBaseItem(Registry &$params, CMSApplicationInterface $app): object
{
// Get base menu item from parameters
if ($params->get('base')) {
$base = $app->getMenu()->getItem($params->get('base'));
} else {
$base = false;
}
// Use active menu item if no base found
if (!$base) {
$base = $this->getActiveItem($app);
}
return $base;
}
/**
* Get active menu item.
*
* @param CMSApplicationInterface $app The application
*
* @return object
*
* @since 5.4.0
*/
public function getActiveItem(CMSApplicationInterface $app): object
{
$menu = $app->getMenu();
return $menu->getActive() ?: $this->getDefaultItem($app);
}
/**
* Get default menu item (home page) for current language.
*
* @param CMSApplicationInterface $app The application
*
* @return object
*
* @since 5.4.0
*/
public function getDefaultItem(CMSApplicationInterface $app): object
{
$menu = $app->getMenu();
// Look for the home menu
if (Multilanguage::isEnabled()) {
return $menu->getDefault($app->getLanguage()->getTag());
}
return $menu->getDefault();
}
/**
* Get a list of the menu items.
*
* @param Registry &$params The module options.
*
* @return array
*
* @since 1.5
*
* @deprecated 5.4.0 will be removed in 7.0
* Use the non-static method getItems
* Example: Factory::getApplication()->bootModule('mod_menu', 'site')
* ->getHelper('MenuHelper')
* ->getItems($params, $app)
*/
public static function getList(&$params)
{
return (new self())->getItems($params, Factory::getApplication());
}
/**
* Get base menu item.
*
* @param Registry &$params The module options.
*
* @return object
*
* @since 3.0.2
*
* @deprecated 5.4.0 will be removed in 7.0
* Use the non-static method getBaseItem
* Example: Factory::getApplication()->bootModule('mod_menu', 'site')
* ->getHelper('MenuHelper')
* ->getBaseItem($params, $app)
*/
public static function getBase(&$params)
{
return (new self())->getBaseItem($params, Factory::getApplication());
}
/**
* Get active menu item.
*
* @param Registry &$params The module options.
*
* @return object
*
* @since 3.0.2
*
* @deprecated 5.4.0 will be removed in 7.0
* Use the non-static method getActiveItem
* Example: Factory::getApplication()->bootModule('mod_menu', 'site')
* ->getHelper('MenuHelper')
* ->getActiveItem($app)
*/
public static function getActive(&$params)
{
return (new self())->getActiveItem(Factory::getApplication());
}
/**
* Get default menu item (home page) for current language.
*
* @return object
*
* @deprecated 5.4.0 will be removed in 7.0
* Use the non-static method getDefaultItem
* Example: Factory::getApplication()->bootModule('mod_menu', 'site')
* ->getHelper('MenuHelper')
* ->getDefaultItem($app)
*/
public static function getDefault()
{
return (new self())->getDefaultItem(Factory::getApplication());
}
}
@@ -0,0 +1,27 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_menu
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
HTMLHelper::_('bootstrap.collapse');
?>
<nav class="navbar navbar-expand-md" aria-label="<?php echo htmlspecialchars($module->title, ENT_QUOTES, 'UTF-8'); ?>">
<button class="navbar-toggler navbar-toggler-right" type="button" data-bs-toggle="collapse" data-bs-target="#navbar<?php echo $module->id; ?>" aria-controls="navbar<?php echo $module->id; ?>" aria-expanded="false" aria-label="<?php echo Text::_('MOD_MENU_TOGGLE'); ?>">
<span class="icon-menu" aria-hidden="true"></span>
</button>
<div class="collapse navbar-collapse" id="navbar<?php echo $module->id; ?>">
<?php require ModuleHelper::getLayoutPath(module: 'mod_menu', layout:'default'); ?>
</div>
</nav>
@@ -0,0 +1,114 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_menu
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\Language\Text;
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $app->getDocument()->getWebAssetManager();
$wa->getRegistry()->addExtensionRegistryFile('mod_menu');
$wa->usePreset('mod_menu.menu');
$tagId = $params->get('tag_id', '') ?: 'mod-menu' . $module->id;
$id = ' id="' . htmlspecialchars($tagId, ENT_QUOTES, 'UTF-8') . '"';
$startLevel = (int) $params->get('startLevel', 1);
// The menu class is deprecated. Use mod-menu instead
?>
<ul<?php echo $id; ?> class="mod-menu mod-list nav <?php echo $class_sfx; ?>">
<?php foreach ($list as $i => &$item) {
$itemParams = $item->getParams();
$class = 'nav-item item-' . $item->id;
if ($item->id == $default_id) {
$class .= ' default';
}
if ($item->id == $active_id || ($item->type === 'alias' && $itemParams->get('aliasoptions') == $active_id)) {
$class .= ' current';
}
if (in_array($item->id, $path)) {
$class .= ' active';
} elseif ($item->type === 'alias') {
$aliasToId = $itemParams->get('aliasoptions');
if (count($path) > 0 && $aliasToId == $path[count($path) - 1]) {
$class .= ' active';
} elseif (in_array($aliasToId, $path)) {
$class .= ' alias-parent-active';
}
}
if ($item->type === 'separator') {
$class .= ' divider';
}
if ($item->deeper) {
$class .= ' deeper';
}
if ($item->parent) {
$class .= ' parent';
}
echo '<li class="' . $class . '">';
// The next item is deeper - add toggle only here it is a heading or separator
if ($item->deeper && (int) $item->level === $startLevel && in_array($item->type, ['separator', 'heading'])) {
// Add a toggle button.
echo '<button class="mod-menu__toggle-sub" aria-expanded="false">';
}
switch ($item->type) :
case 'separator':
case 'component':
case 'heading':
case 'url':
require ModuleHelper::getLayoutPath('mod_menu', 'default_' . $item->type);
break;
default:
require ModuleHelper::getLayoutPath('mod_menu', 'default_url');
break;
endswitch;
// The next item is deeper.
if ($item->deeper) {
// Check type - add only on first level
// @todo aria-label - set in menu item ???
if ((int) $item->level === $startLevel) {
switch ($item->type) {
case 'heading':
case 'separator':
echo '<span class="icon-chevron-down" aria-hidden="true">' .
'</span></button>';
break;
default:
echo '<button class="mod-menu__toggle-sub" aria-expanded="false">' .
'<span class="icon-chevron-down" aria-hidden="true"></span>' .
'<span class="visually-hidden">' . Text::sprintf('MOD_MENU_TOGGLE_SUBMENU_LABEL', $item->title) . '</span>' .
'</button>';
}
}
echo '<ul class="mod-menu__sub list-unstyled small">';
} elseif ($item->shallower) {
// The next item is shallower.
echo '</li>';
echo str_repeat('</ul></li>', $item->level_diff);
} else {
// The next item is on the same level.
echo '</li>';
}
}
?></ul>
@@ -0,0 +1,70 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_menu
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\Filter\OutputFilter;
$attributes = [];
if ($item->anchor_title) {
$attributes['title'] = $item->anchor_title;
}
if ($item->anchor_css) {
$attributes['class'] = $item->anchor_css;
}
if ($item->anchor_rel) {
$attributes['rel'] = $item->anchor_rel;
}
if ($item->id == $active_id) {
$attributes['aria-current'] = 'location';
if ($item->current) {
$attributes['aria-current'] = 'page';
}
}
$linktype = $item->title;
if ($item->menu_icon) {
// The link is an icon
if ($itemParams->get('menu_text', 1)) {
// If the link text is to be displayed, the icon is added with aria-hidden
$linktype = '<span class="p-2 pt-0 ' . $item->menu_icon . '" aria-hidden="true"></span>' . $item->title;
} else {
// If the icon itself is the link, it needs a visually hidden text
$linktype = '<span class="p-2 pt-0 ' . $item->menu_icon . '" aria-hidden="true"></span><span class="visually-hidden">' . $item->title . '</span>';
}
} elseif ($item->menu_image) {
// The link is an image, maybe with its own class
$image_attributes = [];
if ($item->menu_image_css) {
$image_attributes['class'] = $item->menu_image_css;
}
$linktype = HTMLHelper::_('image', $item->menu_image, '', $image_attributes);
$linktype .= '<span class="image-title' . ($itemParams->get('menu_text', 1) ? '' : ' visually-hidden') . '">' . $item->title . '</span>';
}
if ($item->browserNav == 1) {
$attributes['target'] = '_blank';
} elseif ($item->browserNav == 2) {
$options = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
$attributes['onclick'] = "window.open(this.href, 'targetWindow', '" . $options . "'); return false;";
}
echo HTMLHelper::_('link', OutputFilter::ampReplace(htmlspecialchars($item->flink, ENT_COMPAT, 'UTF-8', false)), $linktype, $attributes);
@@ -0,0 +1,44 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_menu
*
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
$title = $item->anchor_title ? ' title="' . $item->anchor_title . '"' : '';
$anchor_css = $item->anchor_css ?: '';
$linktype = $item->title;
if ($item->menu_icon) {
// The link is an icon
if ($itemParams->get('menu_text', 1)) {
// If the link text is to be displayed, the icon is added with aria-hidden
$linktype = '<span class="p-2 pt-0 ' . $item->menu_icon . '" aria-hidden="true"></span>' . $item->title;
} else {
// If the icon itself is the link, it needs a visually hidden text
$linktype = '<span class="p-2 pt-0 ' . $item->menu_icon . '" aria-hidden="true"></span><span class="visually-hidden">' . $item->title . '</span>';
}
} elseif ($item->menu_image) {
// The link is an image, maybe with its own class
$image_attributes = [];
if ($item->menu_image_css) {
$image_attributes['class'] = $item->menu_image_css;
}
$linktype = HTMLHelper::_('image', $item->menu_image, '', $image_attributes);
if ($itemParams->get('menu_text', 1)) {
$linktype .= '<span class="image-title">' . $item->title . '</span>';
}
}
?>
<span class="mod-menu__heading nav-header <?php echo $anchor_css; ?>"<?php echo $title; ?>><?php echo $linktype; ?></span>
@@ -0,0 +1,44 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_menu
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
$title = $item->anchor_title ? ' title="' . $item->anchor_title . '"' : '';
$anchor_css = $item->anchor_css ?: '';
$linktype = $item->title;
if ($item->menu_icon) {
// The link is an icon
if ($itemParams->get('menu_text', 1)) {
// If the link text is to be displayed, the icon is added with aria-hidden
$linktype = '<span class="p-2 pt-0 ' . $item->menu_icon . '" aria-hidden="true"></span>' . $item->title;
} else {
// If the icon itself is the link, it needs a visually hidden text
$linktype = '<span class="p-2 pt-0 ' . $item->menu_icon . '" aria-hidden="true"></span><span class="visually-hidden">' . $item->title . '</span>';
}
} elseif ($item->menu_image) {
// The link is an image, maybe with its own class
$image_attributes = [];
if ($item->menu_image_css) {
$image_attributes['class'] = $item->menu_image_css;
}
$linktype = HTMLHelper::_('image', $item->menu_image, '', $image_attributes);
if ($itemParams->get('menu_text', 1)) {
$linktype .= '<span class="image-title">' . $item->title . '</span>';
}
}
?>
<span class="mod-menu__separator separator <?php echo $anchor_css; ?>"<?php echo $title; ?>><?php echo $linktype; ?></span>
@@ -0,0 +1,67 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_menu
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\Filter\OutputFilter;
$attributes = [];
if ($item->anchor_title) {
$attributes['title'] = $item->anchor_title;
}
if ($item->anchor_css) {
$attributes['class'] = $item->anchor_css;
}
if ($item->anchor_rel) {
$attributes['rel'] = $item->anchor_rel;
}
$linktype = $item->title;
if ($item->menu_icon) {
// The link is an icon
if ($itemParams->get('menu_text', 1)) {
// If the link text is to be displayed, the icon is added with aria-hidden
$linktype = '<span class="p-2 pt-0 ' . $item->menu_icon . '" aria-hidden="true"></span>' . $item->title;
} else {
// If the icon itself is the link, it needs a visually hidden text
$linktype = '<span class="p-2 pt-0 ' . $item->menu_icon . '" aria-hidden="true"></span><span class="visually-hidden">' . $item->title . '</span>';
}
} elseif ($item->menu_image) {
// The link is an image, maybe with an own class
$image_attributes = [];
if ($item->menu_image_css) {
$image_attributes['class'] = $item->menu_image_css;
}
$linktype = HTMLHelper::_('image', $item->menu_image, '', $image_attributes);
$linktype .= '<span class="image-title' . ($itemParams->get('menu_text', 1) ? '' : ' visually-hidden') . '">' . $item->title . '</span>';
}
if ($item->browserNav == 1) {
$attributes['target'] = '_blank';
$attributes['rel'] = 'noopener noreferrer';
if ($item->anchor_rel == 'nofollow') {
$attributes['rel'] .= ' nofollow';
}
} elseif ($item->browserNav == 2) {
$options = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $params->get('window_open');
$attributes['onclick'] = "window.open(this.href, 'targetWindow', '" . $options . "'); return false;";
}
echo HTMLHelper::_('link', OutputFilter::ampReplace(htmlspecialchars($item->flink, ENT_COMPAT, 'UTF-8', false)), $linktype, $attributes);