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

raeburn raeburn at source.lon-capa.org
Fri May 18 12:54:56 EDT 2012


raeburn		Fri May 18 16:54:56 2012 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonmenu.pm 
  Log:
  - For 2.11.
    - Backport 1.371.
  
  
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.369.2.2 loncom/interface/lonmenu.pm:1.369.2.3
--- loncom/interface/lonmenu.pm:1.369.2.2	Mon May 14 13:58:04 2012
+++ loncom/interface/lonmenu.pm	Fri May 18 16:54:56 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.369.2.2 2012/05/14 13:58:04 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.3 2012/05/18 16:54:56 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -26,8 +26,6 @@
 # http://www.lon-capa.org/
 #
 #
-# There is one parameter controlling the action of this module:
-#
 
 =head1 NAME
 
@@ -35,7 +33,8 @@
 
 =head1 SYNOPSIS
 
-Coordinates the response to clicking an image.
+Loads contents of /home/httpd/lonTabs/mydesk.tab, 
+used to generate inline menu, and Main Menu page. 
 
 This is part of the LearningOnline Network with CAPA project
 described at http://www.lon-capa.org.
@@ -74,10 +73,19 @@
 =item @primary_menu
 
 The elements of this array reference arrays that are made up of the components
-of those lines of mydesk.tab that start with prim.
+of those lines of mydesk.tab that start with prim:.
 It is used by primary_menu() to generate the corresponding menu.
 It gets filled in the BEGIN block of this module.
 
+=item %primary_sub_menu
+
+The keys of this hash reference are the names of items in the primary_menu array 
+which have sub-menus.  For each key, the corresponding value is a reference to
+an array containing components extracted from lines in mydesk.tab which begin
+with primsub:.
+This hash, which is used by primary_menu to generate sub-menus, is populated in
+the BEGIN block.
+
 =item @secondary_menu
 
 The elements of this array reference arrays that are made up of the components
@@ -158,7 +166,7 @@
 use HTML::Entities();
 
 use vars qw(@desklines %category_names %category_members %category_positions 
-            $readdesk @primary_menu @secondary_menu);
+            $readdesk @primary_menu %primary_submenu @secondary_menu);
 
 my @inlineremote;
 
@@ -181,7 +189,7 @@
 
 # primary_menu() evaluates @primary_menu and returns XHTML for the menu
 # that contains following links:
-# About, Message, Roles, Help, Logout
+# About, Message, Personal, Roles, Help, Logout
 # @primary_menu is filled within the BEGIN block of this module with 
 # entries from mydesk.tab
 sub primary_menu {
@@ -211,8 +219,53 @@
         next if    $$menuitem[4]        eq 'courses'   ##'Roles' wanted
                 && !&Apache::loncommon::show_course(); ##
         
-            
-        if ($$menuitem[3] eq 'Help') { # special treatment for helplink
+        my $title = $menuitem->[3];
+        if (defined($primary_submenu{$title})) {
+            my ($link,$target,$numsub);
+            if ($menuitem->[0] ne '') {
+                $link = $menuitem->[0];
+                $target = '_top';
+            } else {
+                $link = '#';
+            }
+            if (ref($primary_submenu{$title}) eq 'ARRAY') {
+                $numsub = @{$primary_submenu{$title}};
+                if ($numsub) {
+                    $title =
+                        '<span class="LC_nobreak">'.$title.
+                        '<span class="LC_fontsize_small">'.
+                        '▼</span></span>';
+                }
+            }
+            $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.$title.'</a>';
+            if ($numsub) {
+                $menu .= '<ul>';
+                foreach my $item (@{$primary_submenu{$menuitem->[3]}}) {
+                    if (ref($item) eq 'ARRAY') {
+                        if ($item->[2] eq 'wishlist') {
+                            next unless ((&Apache::lonnet::allowed('bre',"/res/$env{'user.domain'}/")) ||
+                                         (&Apache::lonnet::allowed('bro',"/res/$env{'user.domain'}/")));
+                        } elsif ($item->[2] eq 'reqcrs') {
+                            next unless(&check_for_rcrs());
+                        } elsif (($item->[2] eq 'portfolio') ||
+                                 ($item->[2] eq 'blog')) {
+                            if (!&Apache::lonnet::usertools_access(
+                                    $env{'user.name'},
+                                    $env{'user.domain'},
+                                    $item->[2],undef,'tools')) {
+                                next;
+                            }
+                        }
+                        $menu .= '<li style="margin:0;padding:0">'.
+                                 '<a href="'.$item->[0].
+                                 '" style="padding:0 0 0 10px">'.
+                                 $item->[1].'</a></li>';
+                    }
+                }
+                $menu .= '</ul>';
+            }
+            $menu .= '</li>';
+        } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
             if ($public) {
                 my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
                 my $defdom = &Apache::lonnet::default_login_domain();
@@ -1880,6 +1933,9 @@
                     } elsif ($configline=~/^prim\:/) {
                         my @entries = (split(/\:/, $configline))[1..5];
                         push @primary_menu, \@entries;
+                    } elsif ($configline=~/^primsub\:/) {
+                        my ($parent, at entries) = (split(/\:/, $configline))[1..4];
+                        push (@{$primary_submenu{$parent}},\@entries);
                     } elsif ($configline=~/^scnd\:/) {
                         my @entries = (split(/\:/, $configline))[1..5];
                         push @secondary_menu, \@entries; 




More information about the LON-CAPA-cvs mailing list