Skip to content
Snippets Groups Projects
Commit 1ec14e3b authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

set skiplinks in Sidebar::render() and restore old ids, fixes #697

parent 18574e3e
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,13 @@
*/
class Sidebar extends WidgetContainer
{
/**
* Contains an optional image for the container.
*/
protected $image = false;
protected $title = false;
protected $context_avatar = null;
/**
* Constructor, tries to automagically set the sidebar's title.
*/
......@@ -18,13 +25,6 @@ class Sidebar extends WidgetContainer
$this->setTitle();
}
/**
* Contains an optional image for the container.
*/
protected $image = false;
protected $title = false;
protected $context_avatar = null;
/**
* Set an image for the sidebar.
*
......@@ -162,6 +162,7 @@ class Sidebar extends WidgetContainer
if ($this->hasWidgets()) {
$template->widgets = $this->widgets;
array_walk($template->widgets, [$this, 'setupSkipLinks']);
} else {
$template->widgets = [];
}
......@@ -209,4 +210,39 @@ class Sidebar extends WidgetContainer
}
return $breadcrumbs;
}
/**
* Inspects a widget and will set appropriate skiplinks.
*
* @param Widget $widget
*/
protected function setupSkipLinks(Widget $widget): void
{
static $navigation_widget_added = false;
static $actions_widget_added = false;
if ($widget instanceof NavigationWidget && !$navigation_widget_added) {
SkipLinks::addIndex(
_('Dritte Navigationsebene'),
$widget->getId(),
20
);
$navigation_widget_added = true;
}
if ($widget instanceof ActionsWidget && !$actions_widget_added) {
if (!$widget->getId()) {
$widget->setId('sidebar-actions');
}
SkipLinks::addIndex(
_('Aktionen'),
$widget->getId(),
21
);
$actions_widget_added = true;
}
}
}
......@@ -6,7 +6,7 @@ if ($navigation) {
$subnavigation = $navigation->activeSubNavigation();
if ($subnavigation !== null) {
$nav_links = new NavigationWidget();
$nav_links->id = 'sidebar-navigation';
$nav_links->setId('sidebar-navigation');
if (!$navigation->getImage()) {
$nav_links->addLayoutCSSClass('show');
}
......
......@@ -20,15 +20,6 @@
</div>
<? foreach ($widgets as $index => $widget): ?>
<?
if ($widget instanceof NavigationWidget) {
$widget->setId('nav_layer_3');
SkipLinks::addIndex(_('Dritte Navigationsebene'), 'nav_layer_3', 20, false);
} elseif ($widget instanceof ActionsWidget) {
$widget->setId('sidebar_actions');
SkipLinks::addIndex(_('Aktionen'), 'sidebar_actions', 21, false);
}
?>
<?= $widget->render(['base_class' => 'sidebar']) ?>
<? endforeach; ?>
</section>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment