simplepage/html/mod_menu/lndropdown-default.php

107 lines
3.2 KiB
PHP

<?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;
if (!defined('__LNDROPDOWN')){
define('__LNDROPDOWN','');
function menu_item($item, $endlevel)
{
$attributes = array();
$hasChildren = $item->hasChildren() && ($item->level < $endlevel);
$hasParent = $item->hasParent();
$isHeading = $item->type == 'heading';
$li_classes = "ln-nav-item pe-pointer px-1 mx-2";
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;";
}
?><li class="<?=$li_classes;?>">
<?php
if (!$isHeading)
{
?><a href="<?=$item->flink;?>"<?php
foreach ($attributes as $n => $v)
{
echo ' ' . $n . '="' . $v . '"';
}
?>><?=$item->title;?></a><?php
}
if ($hasChildren)
{
?><input type="checkbox" id="lnm-cb-<?=$item->id;?>" class="ln-toggle"><label for="lnm-cb-<?=$item->id;?>" class="ln-toggler">
<?php if ($isHeading): ?><span class="ln-nav-item pe-pointer"><?=$item->title;?></span><?php endif; ?><span class="bi-caret-down pe-pointer" aria-hidden="true"></span>
</label>
<div class="ln-toggled ln-dropdown" id="">
<ul class="ln-nav"><?php
foreach ($item->getChildren() as $i => &$item)
{
menu_item($item, $endlevel);
}
unset($item);
?></ul>
</div>
<?php
}
?></li><?php
}
function menu($id, $items, $endlevel)
{
?>
<div class="ln-navbar ln-collapse">
<input type="checkbox" id="lnm-cb-<?=$id;?>" class="ln-toggle">
<label for="lnm-cb-<?=$id;?>" class="ln-toggler">
<span class="bi-list pe-pointer fs-2r5" aria-hidden="true"></span>
</label>
<div class="ln-toggled" id="">
<ul class="ln-nav"><?php
foreach ($items as $i => &$item)
{
menu_item($item, $endlevel);
}
unset($item);
?></ul>
</div>
</div>
<?php
}
}
$items = array();
foreach ($list as $i => &$item) {
if ($item->level == $params['startLevel']) {
array_push($items, $item);
}
}
unset($item);
menu('m'.$module->id, $items, $params['endLevel']);
?>