Skip to content
Snippets Groups Projects
Commit 5b675519 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Jan-Hendrik Willms
Browse files

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

parent a9b3e142
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,13 @@ ...@@ -8,6 +8,13 @@
*/ */
class Sidebar extends WidgetContainer 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. * Constructor, tries to automagically set the sidebar's title.
*/ */
...@@ -18,13 +25,6 @@ class Sidebar extends WidgetContainer ...@@ -18,13 +25,6 @@ class Sidebar extends WidgetContainer
$this->setTitle(); $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. * Set an image for the sidebar.
* *
...@@ -162,6 +162,7 @@ class Sidebar extends WidgetContainer ...@@ -162,6 +162,7 @@ class Sidebar extends WidgetContainer
if ($this->hasWidgets()) { if ($this->hasWidgets()) {
$template->widgets = $this->widgets; $template->widgets = $this->widgets;
array_walk($template->widgets, [$this, 'setupSkipLinks']);
} else { } else {
$template->widgets = []; $template->widgets = [];
} }
...@@ -209,4 +210,39 @@ class Sidebar extends WidgetContainer ...@@ -209,4 +210,39 @@ class Sidebar extends WidgetContainer
} }
return $breadcrumbs; 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) { ...@@ -6,7 +6,7 @@ if ($navigation) {
$subnavigation = $navigation->activeSubNavigation(); $subnavigation = $navigation->activeSubNavigation();
if ($subnavigation !== null) { if ($subnavigation !== null) {
$nav_links = new NavigationWidget(); $nav_links = new NavigationWidget();
$nav_links->id = 'sidebar-navigation'; $nav_links->setId('sidebar-navigation');
if (!$navigation->getImage()) { if (!$navigation->getImage()) {
$nav_links->addLayoutCSSClass('show'); $nav_links->addLayoutCSSClass('show');
} }
......
...@@ -20,15 +20,6 @@ ...@@ -20,15 +20,6 @@
</div> </div>
<? foreach ($widgets as $index => $widget): ?> <? 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']) ?> <?= $widget->render(['base_class' => 'sidebar']) ?>
<? endforeach; ?> <? endforeach; ?>
</section> </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