Skip to content
Permalink
Browse files

Added ":usermenu" hook and some optimizations

  • Loading branch information...
LotarProject committed Mar 11, 2019
1 parent be5f11e commit 0f51da3ead94bdbfebdb2c25004ed4e927801f73
Showing with 68 additions and 24 deletions.
  1. +4 −4 tpl/admin.php
  2. +3 −2 tpl/translation.php
  3. +61 −18 tpl/user_menu.php
@@ -55,10 +55,10 @@
if (! $label) continue;
echo sprintf('<li class="%s"><a href="%s" title="%s" class="admin %s">%s</a></li>',
(($INPUT->str('page') == $item) ? 'active' : ''),
wl($ID, array('do' => 'admin', 'page' => $item)),
$label, $item, $label);
echo '<li class="' . (($INPUT->str('page') == $item) ? 'active' : '') . '">' .
'<a href="'. wl($ID, array('do' => 'admin', 'page' => $item)) .'" title="'. $label .'" class="admin '. $item .'">' .
$label .
'</a></li>';
}
@@ -32,12 +32,13 @@
<a href="<?php wl($ID) ?>" class="dropdown-toggle" data-target="#" data-toggle="dropdown" title="<?php echo $trans_label ?>" role="button" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-fw fa-flag"></i> <span class="hidden-lg hidden-md hidden-sm"><?php echo $trans_label ?></span><span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<ul class="dropdown-menu" role="menu">
<li class="dropdown-header hidden-xs hidden-sm">
<i class="fa fa-fw fa-flag"></i> <?php echo $trans_label ?>
</li>
<?php echo $trans_items ?>
</ul>
</ul>
</li>
</ul>
<!-- /translation -->
<?php endif; ?>
@@ -27,6 +27,19 @@
$avatar_img = tpl_getMediaFile(array('images/avatar.png'));
}
$label_type = 'info';
$user_type = 'User';
if ($INFO['ismanager']) {
$label_type = 'warning';
$user_type = 'Manager';
}
if ($INFO['isadmin']) {
$label_type = 'danger';
$user_type = 'Admin';
}
?>
<!-- user-menu -->
<ul class="nav navbar-nav" id="dw__user_menu">
@@ -47,24 +60,9 @@
<div class="container-fluid">

<p class="text-right">
<?php
$label_type = 'info';
$user_type = 'User';
if ($INFO['ismanager']) {
$label_type = 'warning';
$user_type = 'Manager';
}
if ($INFO['isadmin']) {
$label_type = 'danger';
$user_type = 'Admin';
}
echo '<span style="cursor:help" class="label label-' . $label_type . '" title="Groups: '. join(', ', $INFO['userinfo']['grps']) .'">' . $user_type . '</span>';
?>
<span style="cursor:help" class="label label-<?php echo $label_type; ?>" title="Groups: <?php echo join(', ', $INFO['userinfo']['grps']); ?>">
<?php echo $user_type; ?>
</span>
</p>

<p class="text-center">
@@ -117,6 +115,51 @@

<li class="divider"></li>

<?php
// Add the user menu
$page = null;
$interwiki = getInterwiki();
$user_url = str_replace('{NAME}', $_SERVER['REMOTE_USER'], $interwiki['user']);
foreach (array("$user_url:usermenu", 'usermenu') as $page_id) {
$page = page_findnearest($page_id, bootstrap3_conf('useACL'));
if ($page) break;
}
if ($page) {
$html = new simple_html_dom;
$html->load(bootstrap3_lists(tpl_include_page($page, 0, 1, bootstrap3_conf('useACL'))), true, false);
foreach ($html->find('h1,h2,h3,h4,h5,h6') as $elm) {
$elm->outertext = '<li class="dropdown-header">' . $elm->innertext . '</li>';
}
foreach ($html->find('hr') as $elm) {
$elm->outertext = '<li class="divider"></li>';
}
foreach ($html->find('ul') as $elm) {
$elm->outertext = '' . $elm->innertext;
}
foreach ($html->find('div') as $elm) {
$elm->outertext = $elm->innertext;
}
$content = $html->save();
$html->clear();
unset($html);
$content = str_replace('urlextern', '', $content);
echo $content;
echo '<li class="divider"></li>';
}
?>

<?php echo bootstrap3_action_item('login', 'fa fa-fw fa-power-off text-danger'); ?>

</ul>

0 comments on commit 0f51da3

Please sign in to comment.
You can’t perform that action at this time.