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

raeburn raeburn at source.lon-capa.org
Sat Oct 29 01:29:40 EDT 2016


raeburn		Sat Oct 29 05:29:40 2016 EDT

  Modified files:              
    /loncom/interface	lonmenu.pm loncommon.pm 
    /rat	lonpage.pm 
  Log:
  - If the "buttonshide" parameter is set to "yes" for all resources in a 
    composite page, icons on the right side of the standard course inline 
    menu are now also hidden for the page itself.
  
  
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.457 loncom/interface/lonmenu.pm:1.458
--- loncom/interface/lonmenu.pm:1.457	Thu Oct 27 21:06:13 2016
+++ loncom/interface/lonmenu.pm	Sat Oct 29 05:29:28 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.457 2016/10/27 21:06:13 raeburn Exp $
+# $Id: lonmenu.pm,v 1.458 2016/10/29 05:29:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -624,7 +624,7 @@
 }
 
 sub innerregister {
-    my ($forcereg,$bread_crumbs,$group) = @_;
+    my ($forcereg,$bread_crumbs,$group,$pagebuttonshide) = @_;
     my $const_space = ($env{'request.state'} eq 'construct');
     my $is_const_dir = 0;
 
@@ -969,21 +969,23 @@
 	foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
 
     if ($addremote) {
-        my $countdown;
+        my ($countdown,$buttonshide);
         if ($env{'request.filename'} =~ /\.page$/) {
             my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools();
             if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') {
-                $countdown = $breadcrumb_tools{'tools'}[0];
+                $countdown = $breadcrumb_tools{'tools'}->[0];
             }
+            $buttonshide = $pagebuttonshide;
         } else {
             $countdown = &countdown_timer();
+            $buttonshide = &hidden_button_check();
         }
         &Apache::lonhtmlcommon::clear_breadcrumb_tools();
 
             &Apache::lonhtmlcommon::add_breadcrumb_tool(
                 'navigation', @inlineremote[21,23]);
 
-        if (&hidden_button_check() eq 'yes') {
+        if ($buttonshide eq 'yes') {
             if ($countdown) {
                 &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
             }
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1257 loncom/interface/loncommon.pm:1.1258
--- loncom/interface/loncommon.pm:1.1257	Wed Oct 12 14:54:08 2016
+++ loncom/interface/loncommon.pm	Sat Oct 29 05:29:28 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1257 2016/10/12 14:54:08 raeburn Exp $
+# $Id: loncommon.pm,v 1.1258 2016/10/29 05:29:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5949,7 +5949,8 @@
                                 $args->{'bread_crumbs'});
             } elsif ($forcereg) {
                 $bodytag .= &Apache::lonmenu::innerregister($forcereg,undef,
-                                                            $args->{'group'});
+                                                            $args->{'group'},
+                                                            $args->{'hide_buttons'});
             } else {
                 $bodytag .= 
                     &Apache::lonmenu::prepare_functions($env{'request.noversionuri'},
Index: rat/lonpage.pm
diff -u rat/lonpage.pm:1.118 rat/lonpage.pm:1.119
--- rat/lonpage.pm:1.118	Tue Aug  9 23:43:51 2016
+++ rat/lonpage.pm	Sat Oct 29 05:29:39 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Page Handler
 #
-# $Id: lonpage.pm,v 1.118 2016/08/09 23:43:51 raeburn Exp $
+# $Id: lonpage.pm,v 1.119 2016/10/29 05:29:39 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -184,6 +184,7 @@
   if (($env{'request.course.fn'}) && (!$env{'form.forceselect'})) {
       my $fn=$env{'request.course.fn'};
       if (-e "$fn.db") {
+          my %buttonshide;
           if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) {
 # ------------------------------------------------------------------- Hash tied
               my $firstres=$hash{'map_start_'.$requrl};
@@ -305,6 +306,11 @@
 			  if ($hash{'encrypted_'.$_}) {
 			      $src=&Apache::lonenc::encrypted($src);
 			  }
+                          my ($mapid,$resid)=split(/\./,$_);
+                          my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src);
+                          unless ($env{'request.role.adv'}) {
+                              $buttonshide{$symb} = &Apache::lonnet::EXT("resource.0.buttonshide",$symb);
+                          }
                           $cellemb{$_}=
 			      &Apache::loncommon::fileembstyle($extension);
                           if ($cellexternal{$_}) {
@@ -315,9 +321,6 @@
                               }
                           } elsif ($cellemb{$_} eq 'ssi') {
 # --------------------------------------------------------- This is an SSI cell
-			      my ($mapid,$resid)=split(/\./,$_);
-			      my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src);
-			      
 			      my $prefix=$_.'_';
                               my $idprefix= join('_',($mapid,$resid,''));
                               my %posthash=('request.prefix' => $prefix,
@@ -676,10 +679,27 @@
                                   &add_countdown_timer($currdisp,$donebuttontime,$donebuttonextras);
                               }
                           }
+                          my $pagebuttonshide;
+                          if (keys(%buttonshide)) {
+                              my %uniquebuttonhide;
+                              foreach my $item (values(%buttonshide)) {
+                                  if (exists($uniquebuttonhide{$item})) {
+                                      $uniquebuttonhide{$item} ++;
+                                  } else {
+                                      $uniquebuttonhide{$item} = 1;
+                                  }
+                              }
+                              if (keys(%uniquebuttonhide) == 1) {
+                                  if (lc((keys(%uniquebuttonhide))[0]) eq 'yes') {
+                                      $pagebuttonshide = 'yes';
+                                  }
+                              }
+                          }
 # ------------------------------------------------------------------ Start body
 			  $r->print(&Apache::loncommon::start_page(undef,$allscript,
 								   {'force_register' => 1,
-								    'bgcolor'        => '#ffffff',}));
+								    'bgcolor'        => '#ffffff',
+								    'hide_buttons'   => $pagebuttonshide}));
 # ------------------------------------------------------------------ Start form
 			  if ($nforms) {
 			      my $fmtag = '<form name="lonhomework" method="post"  enctype="multipart/form-data"';
@@ -725,7 +745,7 @@
                           my $avespan=$lcm/($#colcont+1);
                           for ($j=0;$j<=$#colcont;$j++) {
                               my $rid=$colcont[$j];
-			      my $metainfo =&get_buttons(\%hash,$rid).'<br />';
+			      my $metainfo =&get_buttons(\%hash,$rid,\%buttonshide).'<br />';
 			    unless (($target eq 'tex') || ($target eq 'tex_answer')) {
 				$r->print('<td colspan="'.$avespan.'"');
 			    }
@@ -853,7 +873,7 @@
 }
 
 sub get_buttons {
-    my ($hash,$rid) = @_;
+    my ($hash,$rid,$buttonshide) = @_;
 
     my $metainfo = '';
     my $esrc=&Apache::lonnet::declutter($hash->{'src_'.$rid});
@@ -862,7 +882,7 @@
 					  $resid,
 					  $hash->{'src_'.$rid});
     unless ($env{'request.role.adv'}) {
-        if (&Apache::lonnet::EXT('resource.0.buttonshide',$symb)) {
+        if ($buttonshide->{$symb} eq 'yes') {
             return;
         }
     }




More information about the LON-CAPA-cvs mailing list