[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonmenu.pm
raeburn
raeburn at source.lon-capa.org
Sun May 26 18:42:07 EDT 2013
raeburn Sun May 26 22:42:07 2013 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface lonmenu.pm
Log:
- For 2.11
-Backport 1.415
-------------- next part --------------
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.369.2.41 loncom/interface/lonmenu.pm:1.369.2.42
--- loncom/interface/lonmenu.pm:1.369.2.41 Mon May 13 20:37:58 2013
+++ loncom/interface/lonmenu.pm Sun May 26 22:42:06 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.369.2.41 2013/05/13 20:37:58 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.42 2013/05/26 22:42:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -106,10 +106,11 @@
=item primary_menu()
-This routine evaluates @primary_menu and returns XHTML for the menu
-that contains following links: About, Message, Roles, Help, Logout
+This routine evaluates @primary_menu and returns a two item array,
+with the array elements containing XHTML for the left and right sides of
+the menu that contains the following links: About, Message, Roles, Help, Logout
@primary_menu is filled within the BEGIN block of this module with
-entries from mydesk.tab
+entries from mydesk.tab
=item secondary_menu()
@@ -223,15 +224,16 @@
. qq| href="$$menuitem[0]" target="_top">$link</a></li>|;
}
-# primary_menu() evaluates @primary_menu and returns XHTML for the menu
-# that contains following links:
-# About, Message, Personal, Roles, Help, Logout
+# primary_menu() evaluates @primary_menu and returns a two item array,
+# with the array elements containing XHTML for the left and right sides of
+# the menu that contains the following links:
+# Personal, About, Message, Roles, Help, Logout
# @primary_menu is filled within the BEGIN block of this module with
# entries from mydesk.tab
sub primary_menu {
- my $menu;
+ my %menu;
# each element of @primary contains following array:
- # (link url, icon path, alt text, link text, condition)
+ # (link url, icon path, alt text, link text, condition, position)
my $public;
if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
|| (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
@@ -256,6 +258,10 @@
&& !&Apache::loncommon::show_course(); ##
my $title = $menuitem->[3];
+ my $position = $menuitem->[5];
+ if ($position eq '') {
+ $position = 'right';
+ }
if (defined($primary_submenu{$title})) {
my ($link,$target);
if ($menuitem->[0] ne '') {
@@ -275,9 +281,9 @@
push(@primsub,$item);
}
if (@primsub > 0) {
- $menu .= &create_submenu($link,$target,$title,\@primsub);
+ $menu{$position} .= &create_submenu($link,$target,$title,\@primsub);
} elsif ($link) {
- $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
+ $menu{$position} .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
}
}
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
@@ -288,19 +294,17 @@
'helpdeskmail',
$defdom,$origmail);
if ($to ne '') {
- $menu .= &prep_menuitem($menuitem);
+ $menu{$position} .= &prep_menuitem($menuitem);
}
} else {
- $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
+ $menu{$position} .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
}
} else {
- $menu .= prep_menuitem($menuitem);
+ $menu{$position} .= prep_menuitem($menuitem);
}
}
- $menu =~ s/\[domain\]/$env{'user.domain'}/g;
- $menu =~ s/\[user\]/$env{'user.name'}/g;
-
- return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
+ return ("<ol class=\"LC_primary_menu LC_floatleft\">$menu{'left'}</ol>",
+ "<ol class=\"LC_primary_menu LC_floatright LC_right\">$menu{'right'}</ol>");
}
#returns hashref {user=>'',dom=>''} containing:
@@ -510,9 +514,19 @@
if ($target ne '') {
$disptarget = ' target="'.$target.'"';
}
+ my $name;
+ if ($title eq 'Personal') {
+ if ($env{'user.name'} && $env{'user.domain'}) {
+ $name = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ } else {
+ $name = &mt($title);
+ }
+ } else {
+ $name = &mt($title);
+ }
my $menu = '<li class="LC_hoverable">'.
- '<a href="'.$link.'"'.$disptarget.'>'.
- '<span class="LC_nobreak">'.&mt($title).
+ '<a href="'.$link.'"'.$disptarget.'>'.
+ '<span class="LC_nobreak">'.$name.
'<span class="LC_fontsize_small" style="font-weight:normal;">'.
' ▼</span></span></a>'.
'<ul>';
@@ -525,6 +539,10 @@
if ($count == $numsub) {
$borderbot = 'border-bottom:1px solid black;';
}
+ if ($item->[0] =~ /(aboutme|rss\.html)$/) {
+ $item->[0] =~ s/\[domain\]/$env{'user.domain'}/g;
+ $item->[0] =~ s/\[user\]/$env{'user.name'}/g;
+ }
$menu .= '<li style="margin:0;padding:0;'.
$borderbot.'"><a href="'.$item->[0].'">'.
&mt($item->[1]).'</a></li>';
@@ -1391,7 +1409,7 @@
unless (&Apache::lonnet::is_course($sdom,$sname)) {
&switch('','',6,4,'mail-message-new-22x22.png','Message to user',
'',
- "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
+ "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
'Send message to specific user','','',1);
}
my $hideprivileged = 1;
@@ -1413,13 +1431,13 @@
if ($perms{'vgr'}) {
&switch('','',6,6,'rsrv-22x22.png','Reservations',
'',
- "go('/adm/slotrequest?command=showresv&origin=aboutme&uname=$sname&udom=$sdom')",
+ "go('/adm/slotrequest?command=showresv&origin=aboutme&uname=$sname&udom=$sdom')",
'Slot reservation history','','',1);
}
if ($perms{'srm'}) {
&switch('','',6,7,'contact-new-22x22.png','Records',
'',
- "go('/adm/email?recordftf=retrieve&recname=$sname&recdom=$sdom')",
+ "go('/adm/email?recordftf=retrieve&recname=$sname&recdom=$sdom')",
'Add records','','',1);
}
}
@@ -1435,7 +1453,7 @@
if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
&switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
- "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
+ "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
'Folder/Page Content','','',1);
}
}
@@ -2630,7 +2648,7 @@
$category_positions{$entries[2]}=$entries[1];
$category_names{$entries[2]}=$entries[3];
} elsif ($configline=~/^prim\:/) {
- my @entries = (split(/\:/, $configline))[1..5];
+ my @entries = (split(/\:/, $configline))[1..6];
push(@primary_menu,\@entries);
} elsif ($configline=~/^primsub\:/) {
my ($parent, at entries) = (split(/\:/, $configline))[1..4];
More information about the LON-CAPA-cvs
mailing list