Files
luxtools-template/tpl_pagetools.php
2026-01-30 14:36:07 +01:00

62 lines
2.3 KiB
PHP

<?php
/**
* Template partial for rendering page tools as a status bar
*
* This displays the page menu items in a TurboVision-style status bar
* at the bottom of the page with prominent accesskey display.
*
* @var string $menuClass The menu class to use (defaults to \dokuwiki\Menu\PageMenu)
*/
// must be run from within DokuWiki
if (!defined('DOKU_INC')) die();
// Determine which menu to use (PageMenu for main.php, DetailMenu for detail.php)
$menuClass = $menuClass ?? \dokuwiki\Menu\PageMenu::class;
try {
$menu = new $menuClass();
$items = $menu->getItems();
} catch (Exception $e) {
return;
}
if (empty($items)) return;
?>
<nav id="dokuwiki__pagetools" aria-labelledby="dokuwiki__pagetools__heading">
<h3 class="a11y" id="dokuwiki__pagetools__heading"><?php echo $lang['page_tools']; ?></h3>
<div class="tools">
<ul>
<?php foreach ($items as $item): ?>
<?php
$type = $item->getType();
$accesskey = $item->getAccesskey();
$label = hsc($item->getLabel());
// Get link attributes from the item - this allows plugins to add their own classes
$linkAttr = $item->getLinkAttributes('');
$href = $linkAttr['href'] ?? $item->getLink();
$class = $linkAttr['class'] ?? '';
$rel = isset($linkAttr['rel']) ? ' rel="' . $linkAttr['rel'] . '"' : '';
// Build title with accesskey hint
$title = hsc($item->getTitle()) . ($accesskey ? ' [' . $accesskey . ']' : '');
$accesskeyAttr = $accesskey ? ' accesskey="' . $accesskey . '"' : '';
?>
<li class="<?php echo $type; ?>">
<a href="<?php echo $href; ?>"
class="<?php echo $class; ?>"
title="<?php echo $title; ?>"
<?php echo $accesskeyAttr; ?>
<?php echo $rel; ?>>
<?php if ($accesskey): ?>
<span class="accesskey"><?php echo strtoupper(hsc($accesskey)); ?></span>
<?php endif; ?>
<span class="label"><?php echo $label; ?></span>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
</nav>