Do not focus logout menu item after a recurring login

Implement new MenuItemRenderer made for pages that are not part
of the regular site navigation and should trigger a complete site reload
instead of handling it via XHR.
This commit is contained in:
Matthias Jentsch 2014-12-29 13:30:54 +01:00
parent cfb52eeadb
commit 4cf8da4bb9
2 changed files with 26 additions and 1 deletions

View File

@ -248,7 +248,8 @@ class Menu implements RecursiveIterator
$section->add(t('Logout'), array(
'url' => 'authentication/logout',
'priority' => 700
'priority' => 700,
'renderer' => 'ForeignMenuItemRenderer'
));
}
}

View File

@ -0,0 +1,24 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Web\Menu;
use Icinga\Web\Menu;
use Icinga\Web\Url;
/**
* A menu item with a link that surpasses the regular navigation link behavior
*/
class ForeignMenuItemRenderer implements MenuItemRenderer {
public function render(Menu $menu)
{
return sprintf(
'<a href="%s" target="_self">%s%s<span></span></a>',
$menu->getUrl() ?: '#',
$menu->getIcon() ? '<img src="' . Url::fromPath($menu->getIcon()) . '" class="icon" /> ' : '',
htmlspecialchars($menu->getTitle())
);
}
}