--- loncom/interface/lonmenu.pm 2013/05/09 05:24:36 1.414 +++ loncom/interface/lonmenu.pm 2013/05/26 12:39:23 1.415 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.414 2013/05/09 05:24:36 raeburn Exp $ +# $Id: lonmenu.pm,v 1.415 2013/05/26 12:39:23 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -106,10 +106,11 @@ secondary_menu(). =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() @@ -203,15 +204,16 @@ sub prep_menuitem { . qq| href="$$menuitem[0]" target="_top">$link|; } -# 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 ''))) { @@ -236,6 +238,10 @@ sub primary_menu { && !&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 '') { @@ -255,9 +261,9 @@ sub primary_menu { push(@primsub,$item); } if (@primsub > 0) { - $menu .= &create_submenu($link,$target,$title,\@primsub); + $menu{$position} .= &create_submenu($link,$target,$title,\@primsub); } elsif ($link) { - $menu .= '
  • '.&mt($title).'
  • '; + $menu{$position} .= '
  • '.&mt($title).'
  • '; } } } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink @@ -268,19 +274,17 @@ sub primary_menu { 'helpdeskmail', $defdom,$origmail); if ($to ne '') { - $menu .= &prep_menuitem($menuitem); + $menu{$position} .= &prep_menuitem($menuitem); } } else { - $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; + $menu{$position} .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; } } 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 "
      $menu
    "; + return ("
      $menu{'left'}
    ", + "
      $menu{'right'}
    "); } #returns hashref {user=>'',dom=>''} containing: @@ -462,9 +466,19 @@ sub create_submenu { 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 = '
  • '. ''. - ''.&mt($title). + ''.$name. ''. ' ▼'. '