[LON-CAPA-cvs] cvs: loncom /interface lonmenu.pm

raeburn raeburn at source.lon-capa.org
Sun May 26 08:39:23 EDT 2013


raeburn		Sun May 26 12:39:23 2013 EDT

  Modified files:              
    /loncom/interface	lonmenu.pm 
  Log:
  - Items in "Personal" sub-menu in primary menu moved from a separate item 
    on right of screen to sub-menu attached to user's fullname on left of
    screen.
    - "Information" item added (points to user's personal information page)
       as first item in sub-menu.
    - xhtml for items in Functions bar, displayed when viewing a user's
       personal information page in course context. 
  
  
-------------- next part --------------
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.414 loncom/interface/lonmenu.pm:1.415
--- loncom/interface/lonmenu.pm:1.414	Thu May  9 05:24:36 2013
+++ loncom/interface/lonmenu.pm	Sun May 26 12:39:23 2013
@@ -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 @@
 
 =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 @@
            . 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 ''))) {
@@ -236,6 +238,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 '') {
@@ -255,9 +261,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
@@ -268,19 +274,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:
@@ -462,9 +466,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).
+               '<span class="LC_nobreak">'.$name.
                '<span class="LC_fontsize_small" style="font-weight:normal;">'.
                ' ▼</span></span></a>'.
                '<ul>';
@@ -477,6 +491,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>';
@@ -947,7 +965,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');
             }
             my $hideprivileged = 1;
@@ -969,13 +987,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');
                 }
                 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');
                 }
             }
@@ -991,7 +1009,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');
             }
         }
@@ -2100,7 +2118,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