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

raeburn raeburn@source.lon-capa.org
Mon, 29 Mar 2010 14:50:46 -0000


This is a MIME encoded message

--raeburn1269874246
Content-Type: text/plain

raeburn		Mon Mar 29 14:50:46 2010 EDT

  Modified files:              
    /loncom/interface	lonmenu.pm lonnavmaps.pm lonnavdisplay.pm 
  Log:
  - Propagate register=1 when "Table of Contents" item is included in a 
    course.
  
  lonnavmaps.pm
    - coding style: indentation.
    - eliminate some unused link items (launch external nav window).
   
  lonnavdisplay.pm 
    - coding style: replace \" with " within quoted text, by quoting text 
      with single quotes.
  
  lonnmenu.pm
    - omit initial "Course Contents" if "Table of Contents" item is included in course in top level directory in "Main Course Documents".
  
  
--raeburn1269874246
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20100329145046.txt"

Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.323 loncom/interface/lonmenu.pm:1.324
--- loncom/interface/lonmenu.pm:1.323	Mon Mar 29 00:53:52 2010
+++ loncom/interface/lonmenu.pm	Mon Mar 29 14:50:46 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.323 2010/03/29 00:53:52 raeburn Exp $
+# $Id: lonmenu.pm,v 1.324 2010/03/29 14:50:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -336,10 +336,13 @@
 #SD
 #course_type only Course and Community?
 #
-        my @crumbs = ({text  => Apache::loncommon::course_type() 
+        my @crumbs;
+        unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps')
+                && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
+            @crumbs = ({text  => Apache::loncommon::course_type() 
                                 . ' Contents', 
-                       href  => "Javascript:gopost('/adm/navmaps','')"});
-
+                        href  => "Javascript:gopost('/adm/navmaps','')"});
+        }
         if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { 
             push(@crumbs, {text  => '...',
                            no_mt => 1});
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.445 loncom/interface/lonnavmaps.pm:1.446
--- loncom/interface/lonnavmaps.pm:1.445	Tue Mar 16 19:55:49 2010
+++ loncom/interface/lonnavmaps.pm	Mon Mar 29 14:50:46 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.445 2010/03/16 19:55:49 droeschl Exp $
+# $Id: lonnavmaps.pm,v 1.446 2010/03/29 14:50:46 raeburn Exp $
 
 #
 # Copyright Michigan State University Board of Trustees
@@ -1400,19 +1400,22 @@
     if ($printCloseAll && !$args->{'resource_no_folder_link'}) {
 	my ($link,$text);
         if ($condition) {
-	    $link='"navmaps?condition=0&filter=&'.$queryString.
-		'&here='.&escape($here).'"';
+	    $link='navmaps?condition=0&filter=&'.$queryString.
+		'&here='.&escape($here);
 	    $text='Close all folders';
         } else {
-	    $link='"navmaps?condition=1&filter=&'.$queryString.
-		'&here='.&escape($here).'"';
+	    $link='navmaps?condition=1&filter=&'.$queryString.
+		'&here='.&escape($here);
 	    $text='Open all folders';
         }
+        if ($env{'form.register'}) {
+            $link .= '&register='.$env{'form.register'};
+        }
 	if ($args->{'caller'} eq 'navmapsdisplay') {
 	    &add_linkitem($args->{'linkitems'},'changefolder',
-			  'location.href='.$link,$text);
+			  "location.href='$link'",$text);
 	} else {
-	    $result.='<a href='.$link.'>'.&mt($text).'</a>';
+	    $result.= '<a href="'.$link.'">'.&mt($text).'</a>';
 	}
         $result .= "\n";
     }
@@ -1428,6 +1431,9 @@
 	<input type="hidden" name="navurl" value="$ENV{'QUERY_STRING'}" />
 	<input type="hidden" name="navtime" value="$time" />
 END
+        if ($env{'form.register'}) {
+            $result .= '<input type="hidden" name="register" value="'.$env{'form.register'}.'" />';
+        }
         if ($args->{'sort'} eq 'discussion') { 
 	    my $totdisc = 0;
 	    my $haveDisc = '';
@@ -1449,12 +1455,11 @@
 	$result.='</form>';
     }
 
-   
     if ($args->{'caller'} eq 'navmapsdisplay') {
         $result .= '<table><tr><td>'.
                    &Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT').'</td>';
 	    $result .= '<td>&nbsp;</td>'; 
-	$result.="<td class=\"LC_middle\">".mt('Tools:')."</td>";
+	$result.='<td class="LC_middle">'.&mt('Tools:').'</td>';
 	$result.=&show_linkitems_toolbar($args->{'linkitems'});
         if ($args->{'sort_html'}) {
             $result.='<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
@@ -1825,7 +1830,7 @@
 	}
     }
     $result .= '</select>&nbsp;<input type="button" name="chgnav"
-                   value="Go" onClick="javascript:changeNavDisplay()" />
+                   value="Go" onclick="javascript:changeNavDisplay()" />
                 </span></form></td>'."\n";
 	
     return $result;
@@ -1833,35 +1838,36 @@
 
 sub show_linkitems_toolbar {
     my ($linkitems,$condition)=@_;
-    my @linkorder = ("blank","launchnav","closenav","firsthomework",
-		     "everything","uncompleted","changefolder","clearbubbles");
-    
-    my $result .=' 
-              <td align="left">
-                       <span class="LC_nobreak">'."\n<ul id=\"LC_toolbar\">";
-	foreach my $link (@linkorder) {
-        my $link_id = "LC_content_toolbar_".$link;
-	if (defined($linkitems->{$link})) {
-	    if ($linkitems->{$link}{'text'} ne '') {
-		$linkitems->{$link}{'cmd'}=~s/"/'/g;
-		if($linkitems->{$link}{'cmd'}){
-                   if($link eq 'changefolder'){
-                      if($condition){$link_id='LC_content_toolbar_changefolder_toggled'}
-                      else{$link_id='LC_content_toolbar_changefolder'}
-                   }
-                          $result .=  ' <li><a href="#"'.
-			    	' onClick="'.$linkitems->{$link}{'cmd'}.'"'.
-                                ' id="'.$link_id.'"'.
-                                ' class="LC_toolbarItem"'.
-			   	' title="'.$linkitems->{$link}{'text'}.'"></a></li>'."\n";
-		}
-
-	    }
-	}
+    my @linkorder = ('firsthomework','everything','uncompleted',
+                     'changefolder','clearbubbles');
+    my $result .='<td align="left">'."\n". 
+                 '<span class="LC_nobreak">'."\n".
+                 '<ul id="LC_toolbar">';
+    foreach my $link (@linkorder) {
+        my $link_id = 'LC_content_toolbar_'.$link;
+        if (defined($linkitems->{$link})) {
+            if ($linkitems->{$link}{'text'} ne '') {
+                $linkitems->{$link}{'cmd'}=~s/"/'/g;
+                if ($linkitems->{$link}{'cmd'}) {
+                    if ($link eq 'changefolder') {
+                        if ($condition) {
+                            $link_id='LC_content_toolbar_changefolder_toggled';
+                        } else {
+                            $link_id='LC_content_toolbar_changefolder';
+                        }
+                    }
+                    $result .= '<li><a href="#" '.
+                               'onclick="'.$linkitems->{$link}{'cmd'}.'" '.
+                               'id="'.$link_id.'" '.
+                               'class="LC_toolbarItem" '.
+                               'title="'.$linkitems->{$link}{'text'}.'">'.
+                               '</a></li>'."\n";
+                }
+            }
+        }
     }
-    $result .= '</ul>';
-    $result .= ' </span></td>'."\n";
-	
+    $result .= '</ul>'.
+               '</span></td>'."\n";
     return $result;
 }
 
Index: loncom/interface/lonnavdisplay.pm
diff -u loncom/interface/lonnavdisplay.pm:1.16 loncom/interface/lonnavdisplay.pm:1.17
--- loncom/interface/lonnavdisplay.pm:1.16	Wed Mar 17 15:59:38 2010
+++ loncom/interface/lonnavdisplay.pm	Mon Mar 29 14:50:46 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavdisplay.pm,v 1.16 2010/03/17 15:59:38 droeschl Exp $
+# $Id: lonnavdisplay.pm,v 1.17 2010/03/29 14:50:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -67,8 +67,6 @@
     &Apache::loncommon::no_cache($r);
 
     my %toplinkitems=();
-    &Apache::lonnavmaps::add_linkitem(\%toplinkitems,'blank','',
-				      "Select Action");
 
     # Create the nav map
     my $navmap = Apache::lonnavmaps::navmap->new();
@@ -82,18 +80,26 @@
     $r->send_http_header;
 
 # ------------------------------------------------------------ Get query string
-    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['sort','showOnlyHomework','postsymb']);
+    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['sort','showOnlyHomework','postsymb','register']);
     
 # ----------------------------------------------------- Force menu registration
     # Header
     my $course_type = &Apache::loncommon::course_type();
     my $title = $course_type . ' Contents';
-    my $breadcrumb_text = mt($course_type . ' Contents');
-    $r->print(&Apache::loncommon::start_page($title, '',
-                         { 'bread_crumbs'    => [{text => $breadcrumb_text }],}));
-#SD
-    $r->print('<script type="text/javascript">window.focus();</script>');
-     
+    my ($start_page,$args);
+    if ($env{'form.register'}) {
+        $args = {'force_register' => $env{'form.register'}};
+        $start_page = &Apache::loncommon::start_page($title,undef,$args);
+    } else {
+        my $brcrum = [{href => '/adm/navmaps',
+                       text => &mt($course_type . ' Contents'),
+                       no_mt => 1},
+                     ];
+        $args = {'bread_crumbs' => $brcrum};
+        $start_page = &Apache::loncommon::start_page($title,undef,$args);
+    }
+    $r->print($start_page.
+              '<script type="text/javascript">window.focus();</script>');
     $r->rflush();
 
     # Check that it's defined
@@ -171,8 +177,12 @@
                      ."</span>");
         }
     } else {
+        my $link = 'navmaps?jumpToFirstHomework';
+        if ($env{'form.register'}) {
+            $link .= '&amp;register='.$env{'form.register'}; 
+        }
 	&Apache::lonnavmaps::add_linkitem(\%toplinkitems,'firsthomework',
-					  'location.href="navmaps?jumpToFirstHomework"',
+					  'location.href="'.$link.'"',
 					  "Show my first due problem");
     }
 
@@ -188,33 +198,41 @@
         $filterFunc = sub { my $res = shift; 
                             return $res->completable() || $res->is_map();
                         };
+        my $link = 'navmaps?sort='.$env{'form.sort'};
+        if ($env{'form.register'}) {
+            $link .= '&amp;register='.$env{'form.register'};
+        }
 	&Apache::lonnavmaps::add_linkitem(\%toplinkitems,'everything',
-					  'location.href="navmaps?sort='.$env{'form.sort'}.'"',
-					  "Show everything");
+					  'location.href="'.$link.'"',
+					  'Show everything');
         $r->print("<span class=\"LC_info\">".&mt("Uncompleted Problems")."</span>");
         $env{'form.filter'} = '';
         $env{'form.condition'} = 1;
 	$resource_no_folder_link = 1;
     } else {
+        my $link = 'navmaps?sort='.$env{'form.sort'}.'&amp;showOnlyHomework=1';
+        if ($env{'form.register'}) {
+            $link .= '&amp;register='.$env{'form.register'};
+        }
 	&Apache::lonnavmaps::add_linkitem(\%toplinkitems,'uncompleted',
-					  'location.href="navmaps?sort='.$env{'form.sort'}.
-					  '&showOnlyHomework=1"',
-					  "Show only uncompleted problems");
+					  'location.href="'.$link.'"',
+					  'Show only uncompleted problems');
     }
 
     my %selected=($env{'form.sort'} => ' selected="selected"');
-    my $sort_html=("<form name=\"sortForm\">
-                 <span class=\"LC_nobreak\">
-                    <input type=\"hidden\" name=\"showOnlyHomework\" value=\"".$env{'form.showOnlyHomework'}."\" />
-                    ".&mt('Sort by:')."
-                    <select name=\"sort\" onChange=\"document.sortForm.submit()\">
-                       <option value=\"default\"$selected{'default'}>".&mt('Default')."</option>
-                       <option value=\"title\"$selected{'title'}  >".&mt('Title')."</option>
-                       <option value=\"duedate\"$selected{'duedate'}>".&mt('Duedate')."</option>
-                       <option value=\"discussion\"$selected{'discussion'}>".&mt('Has New Discussion')."</option>
+    my $sort_html=('<form name="sortForm">
+                 <span class="LC_nobreak">
+                    <input type="hidden" name="showOnlyHomework" value="'.$env{'form.showOnlyHomework'}.'" />
+                    '.&mt('Sort by:').'
+                    <select name="sort" onChange="document.sortForm.submit()">
+                       <option value="default"'.$selected{'default'}.'>'.&mt('Default').'</option>
+                       <option value="title"'.$selected{'title'}.'>'.&mt('Title').'</option>
+                       <option value="duedate"'.$selected{'duedate'}.'>'.&mt('Duedate').'</option>
+                       <option value="discussion"'.$selected{'discussion'}.'>'.&mt('Has New Discussion').'</option>
                     </select>
+                    <input type="hidden" name="register" value="'.$env{'form.register'}.'" />
                  </span>
-               </form>");
+               </form>');
     # renderer call
     my $renderArgs = { 'cols' => [0,1,2,3],
 		       'sort' => $env{'form.sort'},

--raeburn1269874246--