Commit bf6d8b64 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Pat Kira

Bug 1657565: App-style navigation

  Hide the dropdown menu site and institution level adding option
    to enable in config.php
    $cfg->dropdownmenuenabled= true

  Separate normal navigation menu from admin navigation menu
    and place it next to user menu at the top right

  Make the navigation changes in all themes but keep old raw theme
    unchanged in raw_old directory

behatnotneeded: Are added in a separate commit
Change-Id: If15680e17486f5bf607c3b0bf84d9086f4179e7d
parent dba7df2f
......@@ -42,7 +42,8 @@ $prefsform = pieform(array(
$smarty = smarty();
$smarty->assign('pagedescription', get_string('prefsdescr', 'activity'));
$smarty->assign('form', $prefsform);
$smarty->assign('PAGEHEADING', get_config('dropdownmenu') ? get_string('settings') : TITLE);
$dropdownmenu = get_config('dropdownmenu') && get_config('dropdownmenuenabled');
$smarty->assign('PAGEHEADING', $dropdownmenu ? get_string('settings') : TITLE);
$smarty->display('form.tpl');
function activityprefs_submit(Pieform $form, $values) {
......
......@@ -87,13 +87,6 @@ $siteoptionform = array(
'help' => true,
'disabled' => in_array('theme', $OVERRIDDEN),
),
'dropdownmenu' => array(
'type' => 'switchbox',
'title' => get_string('dropdownmenu', 'admin'),
'description' => get_string('dropdownmenudescription2', 'admin'),
'defaultvalue' => get_config('dropdownmenu'),
'disabled' => in_array('dropdownmenu', $OVERRIDDEN),
),
'homepageinfo' => array(
'type' => 'switchbox',
'title' => get_string('homepageinfo1', 'admin'),
......@@ -763,6 +756,16 @@ $siteoptionform = array(
)
);
if (get_config('dropdownmenuenabled')) {
$siteoptionform['elements']['sitesettings']['elements']['dropdownmenu'] = array(
'type' => 'switchbox',
'title' => get_string('dropdownmenu', 'admin'),
'description' => get_string('dropdownmenudescription2', 'admin'),
'defaultvalue' => get_config('dropdownmenu'),
'disabled' => in_array('dropdownmenu', $OVERRIDDEN),
);
}
$siteoptionform['elements']['submit'] = array(
'type' => 'button',
'usebuttontag' => true,
......@@ -781,7 +784,7 @@ function siteoptions_fail(Pieform $form, $field) {
function siteoptions_submit(Pieform $form, $values) {
$fields = array(
'sitename','lang','theme', 'dropdownmenu',
'sitename','lang','theme',
'defaultaccountlifetime', 'defaultregistrationexpirylifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
'defaultaccountlifetimeupdate', 'allowpublicviews', 'allowpublicprofiles', 'allowanonymouspages', 'generatesitemap',
'registration_sendweeklyupdates', 'mathjax', 'institutionexpirynotification', 'institutionautosuspend', 'requireregistrationconfirm',
......@@ -796,6 +799,9 @@ function siteoptions_submit(Pieform $form, $values) {
'masqueradingreasonrequired', 'masqueradingnotified', 'searchuserspublic',
'eventloglevel', 'eventlogexpiry', 'sitefilesaccess', 'exporttoqueue', 'defaultmultipleblogs',
);
if (get_config('dropdownmenuenabled')) {
$fields = array_merge($fields, array('dropdownmenu'));
}
$count = 0;
$where_sql = " WHERE admin = 0 AND id != 0";
// if default account lifetime expiry has no end date
......
......@@ -448,13 +448,15 @@ if ($institution || $add) {
'title' => get_string('resetcolours', 'admin'),
'description' => get_string('resetcoloursdesc2', 'admin'),
);
$elements['dropdownmenu'] = array(
'type' => 'switchbox',
'title' => get_string('dropdownmenu', 'admin'),
'description' => get_string('dropdownmenudescriptioninstitution2','admin'),
'defaultvalue' => $data->dropdownmenu,
'help' => true,
);
if (get_config('dropdownmenuenabled')) {
$elements['dropdownmenu'] = array(
'type' => 'switchbox',
'title' => get_string('dropdownmenu', 'admin'),
'description' => get_string('dropdownmenudescriptioninstitution2','admin'),
'defaultvalue' => $data->dropdownmenu,
'help' => true,
);
}
}
// The skins checkbox should be shown for the default institution
if (get_config('skins')) {
......
......@@ -709,6 +709,7 @@ $string['activityprefs'] = 'Activity preferences';
$string['changepassword'] = 'Change password';
$string['notifications'] = 'Notifications';
$string['inbox'] = 'Inbox';
$string['unread'] = '%s unread';
$string['gotoinbox'] = 'Go to inbox';
$string['institutionmembership'] = 'Institution membership';
$string['institutionmembershipdescription'] = 'If you are a member of any institutions, they will be listed here. You may also request membership of institutions and accept or decline pending membership invitations.';
......
......@@ -578,7 +578,7 @@ EOF;
}
// and/or disable drop-downs if a handheld device detected
$dropdownmenu = $SESSION->get('handheld_device') ? false : $dropdownmenu;
$dropdownmenu = $SESSION->get('handheld_device') ? false : $dropdownmenu && get_config('dropdownmenuenabled');
if ($dropdownmenu) {
$smarty->assign('DROPDOWNMENU', $dropdownmenu);
......@@ -660,7 +660,17 @@ EOF;
$smarty->assign('publicsearchallowed', $publicsearchallowed);
if ($USER->is_logged_in()) {
global $SELECTEDSUBNAV; // It's evil, but rightnav & mainnav stuff are now in different templates.
$smarty->assign('MAINNAV', main_nav());
if (in_array('raw_old', $THEME->inheritance)) {
$menutype = (in_admin_section() ? 'adminnav' : null);
$smarty->assign('MAINNAV', main_nav($menutype));
}
else {
$smarty->assign('MAINNAV', main_nav());
$is_admin = $USER->get('admin') || $USER->is_institutional_admin() || $USER->get('staff') || $USER->is_institutional_staff();
if ($is_admin) {
$smarty->assign('MAINNAVADMIN', main_nav('adminnav'));
}
}
$mainnavsubnav = $SELECTEDSUBNAV;
$smarty->assign('RIGHTNAV', right_nav());
if (!$mainnavsubnav && $dropdownmenu) {
......@@ -2950,7 +2960,7 @@ function mahara_standard_nav() {
*
* @return array
*/
function main_nav() {
function main_nav($type = null) {
global $USER;
$language = current_language();
......@@ -2958,7 +2968,7 @@ function main_nav() {
// Get the first institution
$institution = $USER->get_primary_institution();
$menutype = '';
if (in_admin_section()) {
if ($type == 'adminnav') {
global $USER, $SESSION;
if ($USER->get('admin')) {
$menutype = 'admin_nav';
......
......@@ -65,6 +65,7 @@ class PluginModuleMultirecipientnotification extends PluginModule {
'alt' => get_string('inbox'),
'title' => get_string('inbox'),
'count' => $unread,
'unread' => get_string('unread', 'mahara', $unread),
'countclass' => 'unreadmessagecount',
'linkid' => 'mail',
'weight' => 20,
......
style/
\ No newline at end of file
style/
......@@ -15,7 +15,7 @@
{if $USERMASQUERADING}
<div class="site-message alert alert-warning" role="alert">
<span class="icon icon-lg icon-exclamation-triangle left" role="presentation" aria-hidden="true"></span>
<span>{$masqueradedetails}</span>
<span>{$masqueradedetails}</span>
<a href="{$becomeyoulink}">{$becomeyouagain}</a>
</div>
{/if}
......@@ -49,6 +49,15 @@
<span class="icon-bar" role="presentation"></span>
</button>
{/if}
{if $MAINNAVADMIN}
<!-- Brand and toggle get grouped for better mobile display -->
<button type="button" class="menu-toggle navbar-toggle collapsed" data-toggle="collapse" data-target=".nav-main-admin">
<span class="sr-only">{str tag="show"} {str tag="menu"}</span>
<span class="icon-bar" role="presentation"></span>
<span class="icon-bar" role="presentation"></span>
<span class="icon-bar" role="presentation"></span>
</button>
{/if}
{if !$nosearch && ($LOGGEDIN || $publicsearchallowed)}
<button type="button" class="navbar-toggle search-toggle collapsed" data-toggle="collapse" data-target=".navbar-form">
<span class="icon icon-search" role="presentation" aria-hidden="true"></span>
......@@ -59,21 +68,13 @@
<a href="{$WWWROOT}" class="logo">
<img src="{$sitelogo}" alt="{$sitename}">
</a>
{if $ADMIN || $INSTITUTIONALADMIN || $STAFF || $INSTITUTIONALSTAFF}
<div class="admin-title">
<a href="{$WWWROOT}admin/" accesskey="a" class="admin-site">{str tag="administration"}</a>
</div>
{/if}
<div id="loading-box" class="loading-box" style='display:none'></div>
</div>
{include file="header/topright.tpl"}
{include file="header/navigation.tpl"}
</div>
</header>
{include file="header/navigation.tpl"}
<div class="container main-content">
<div class="row">
<main id="main" class="{if $SIDEBARS}{if $SIDEBLOCKS.right}col-md-9 {else}col-md-9 col-md-push-3{/if}{else}col-md-12{/if} main">
......
{if $MAINNAV}
<nav id="main-nav" class="no-site-messages {if $ADMIN || $INSTITUTIONALADMIN || $STAFF || $INSTITUTIONALSTAFF}{if $DROPDOWNMENU}dropdown-adminnav navbar-default{else}adminnav navbar-inverse{/if}{else}navbar-inverse{/if} nav collapse navbar-collapse nav-main main-nav ">
<nav id="main-nav" class="no-site-messages {if $ADMIN || $INSTITUTIONALADMIN || $STAFF || $INSTITUTIONALSTAFF}adminnav navbar-inverse{else}navbar-inverse{/if} nav collapse navbar-collapse nav-main main-nav ">
<div class="container">
{if $ADMIN || $INSTITUTIONALADMIN || $STAFF || $INSTITUTIONALSTAFF}
<div class="navbar-header">
<a class="navbar-text navbar-link" href="{$WWWROOT}" accesskey="h" class="return-site">
<span class="icon icon-chevron-left" role="presentation" aria-hidden="true"></span>
{str tag="returntosite"}
</a>
</div>
{/if}
<ul id="{if $DROPDOWNMENU}dropdown-nav{else}nav{/if}" class="nav navbar-nav">
<ul id="nav" class="nav navbar-nav">
{strip}
{foreach from=$MAINNAV item=item name=menu}
<li class="{if $item.path}{$item.path}{else}dashboard{/if}{if $item.selected} active{/if}{if $DROPDOWNMENU} dropdown-nav-home{/if}">
<li class="{if $item.path}{$item.path}{else}dashboard{/if}{if $item.selected} active{/if}">
<a href="{$WWWROOT}{$item.url}"{if $item.accesskey} accesskey="{$item.accesskey}"{/if} class="{if $item.path}{$item.path}{else}dashboard{/if}">
{if $item.accessibletitle && !$DROPDOWNMENU}
{if $item.accessibletitle}
<span aria-hidden="true" role="presentation" aria-hidden="true">
{/if}
{$item.title}
{if $item.accessibletitle && !$DROPDOWNMENU}
{if $item.accessibletitle}
</span> <span class="accessible-hidden sr-only">
({$item.accessibletitle})
</span>
{/if}
{if $DROPDOWNMENU && $item.submenu}
<span class="accessible-hidden sr-only">
({str tag=dropdownmenu})
</span>
{/if}
</a>
{if $item.submenu}
<button type="button" class="navbar-showchildren navbar-toggle dropdown-toggle {if !$item.selected}collapsed{/if}" data-toggle="collapse" data-target="#childmenu-{$dwoo.foreach.menu.index}">
......@@ -40,7 +25,7 @@
</button>
{/if}
{if $item.submenu}
<ul id="childmenu-{$dwoo.foreach.menu.index}" class="{if $DROPDOWNMENU}has-dropdown{else}hidden-md hidden-lg hidden-sm{/if}{if $item.selected} in{/if} collapse child-nav" role="menu">
<ul id="childmenu-{$dwoo.foreach.menu.index}" class="{if $item.selected} in{/if} collapse child-nav" role="menu">
{strip}
{foreach from=$item.submenu item=subitem}
<li class="{if $subitem.selected}active {/if}{if $subitem.submenu}has-sub {/if}">
......@@ -65,49 +50,64 @@
{/if}
</li>
{/foreach}
{if $ADMIN || $INSTITUTIONALADMIN || $STAFF || $INSTITUTIONALSTAFF}
{elseif $USER->get('admin')}
<li class="siteadmin">
<a href="{$WWWROOT}admin/" accesskey="a" class="admin-site">{str tag="administration"}</a>
</li>
{elseif $USER->is_institutional_admin()}
<li class="instituteadmin">
<a href="{$WWWROOT}admin/users/search.php" accesskey="a" class="admin-user">{str tag="administration"}</a>
</li>
{elseif $USER->get('staff')}
<li class="siteinfo">
<a href="{$WWWROOT}admin/users/search.php" accesskey="a" class="admin-user">{str tag="siteinformation"}</a>
</li>
{elseif $USER->is_institutional_staff()}
<li class="instituteinfo">
<a href="{$WWWROOT}admin/users/search.php" accesskey="a" class="admin-user">{str tag="institutioninformation"}</a>
</li>
{/if}
{/strip}
</ul>
</div>
</nav>
{if $DROPDOWNMENU}
{else}
{if $SELECTEDSUBNAV}
<div id="sub-nav" class="navbar navbar-default minor-nav hidden-xs">
<div class="container">
<ul class="nav navbar-nav">
{strip}
{foreach from=$SELECTEDSUBNAV item=item}
<li{if $item.selected} class="active"{/if}>
<a href="{$WWWROOT}{$item.url}"{if $item.accesskey} accesskey="{$item.accesskey}"{/if}>{$item.title}</a>
</li>
{/foreach}
{/strip}
</ul>