--- loncom/interface/lonhelper.pm	2003/10/09 16:27:26	1.57
+++ loncom/interface/lonhelper.pm	2004/03/31 05:23:59	1.67
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.57 2003/10/09 16:27:26 albertel Exp $
+# $Id: lonhelper.pm,v 1.67 2004/03/31 05:23:59 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -230,7 +230,7 @@ my $paramHash;
 # In the debugger, this means that breakpoints are ignored until you step into
 # a function and get out of what must be a "faked up scope" in the Apache->
 # mod_perl connection. In this code, it was manifesting itself in the existence
-# of two seperate file-scoped $helper variables, one set to the value of the
+# of two separate file-scoped $helper variables, one set to the value of the
 # helper in the helper constructor, and one referenced by the handler on the
 # "$helper->process()" line. Using the debugger, one could actually
 # see the two different $helper variables, as hashes at completely
@@ -462,11 +462,11 @@ sub _saveVars {
     my $self = shift;
     my $result = "";
     $result .= '<input type="hidden" name="CURRENT_STATE" value="' .
-        HTML::Entities::encode($self->{STATE}) . "\" />\n";
+        HTML::Entities::encode($self->{STATE},'<>&"') . "\" />\n";
     $result .= '<input type="hidden" name="TOKEN" value="' .
         $self->{TOKEN} . "\" />\n";
     $result .= '<input type="hidden" name="RETURN_PAGE" value="' .
-        HTML::Entities::encode($self->{RETURN_PAGE}) . "\" />\n";
+        HTML::Entities::encode($self->{RETURN_PAGE},'<>&"') . "\" />\n";
 
     return $result;
 }
@@ -1264,7 +1264,7 @@ BUTTONS
         $result .= "<tr>\n<td width='20'>&nbsp;</td>\n";
         $result .= "<td valign='top'><input type='$type' name='$var.forminput'"
             . "' value='" . 
-            HTML::Entities::encode($choice->[1]) 
+            HTML::Entities::encode($choice->[1],'<>&"') 
             . "'";
         if ($checkedChoices{$choice->[1]}) {
             $result .= " checked ";
@@ -1291,8 +1291,8 @@ sub postprocess {
     my $chosenValue = $ENV{'form.' . $self->{'variable'} . '.forminput'};
 
     if (!defined($chosenValue) && !$self->{'allowempty'}) {
-        $self->{ERROR_MSG} = "You must choose one or more choices to" .
-            " continue.";
+        $self->{ERROR_MSG} = 
+	    &mt("You must choose one or more choices to continue.");
         return 0;
     }
 
@@ -1419,7 +1419,7 @@ sub render {
     $result .= "<select name='${var}.forminput'>\n";
     foreach my $choice (@{$self->{CHOICES}}) {
         $result .= "<option value='" . 
-            HTML::Entities::encode($choice->[1]) 
+            HTML::Entities::encode($choice->[1],'<>&"') 
             . "'";
         if ($checkedChoices{$choice->[1]}) {
             $result .= " selected";
@@ -1595,25 +1595,28 @@ sub render {
 
     # Display Hours and Minutes if they are called for
     if ($self->{'hoursminutes'}) {
+	# This needs parameterization for times.
+	my $am = &mt('a.m.');
+	my $pm = &mt('p.m.');
         # Build hour
         $result .= "<select name='${var}hour'>\n";
         $result .= "<option " . ($date->hour == 0 ? 'selected ':'') .
-            " value='0'>midnight</option>\n";
+            " value='0'>" . &mt('midnight') . "</option>\n";
         for ($i = 1; $i < 12; $i++) {
             if ($date->hour == $i) {
-                $result .= "<option selected value='$i'>$i a.m.</option>\n";
+                $result .= "<option selected value='$i'>$i $am</option>\n";
             } else {
-                $result .= "<option value='$i'>$i a.m</option>\n";
+                $result .= "<option value='$i'>$i $am</option>\n";
             }
         }
         $result .= "<option " . ($date->hour == 12 ? 'selected ':'') .
-            " value='12'>noon</option>\n";
+            " value='12'>" . &mt('noon') . "</option>\n";
         for ($i = 13; $i < 24; $i++) {
             my $printedHour = $i - 12;
             if ($date->hour == $i) {
-                $result .= "<option selected value='$i'>$printedHour p.m.</option>\n";
+                $result .= "<option selected value='$i'>$printedHour $pm</option>\n";
             } else {
-                $result .= "<option value='$i'>$printedHour p.m.</option>\n";
+                $result .= "<option value='$i'>$printedHour $pm</option>\n";
             }
         }
 
@@ -1774,6 +1777,7 @@ sub start_resource {
     $paramHash->{'suppressEmptySequences'} = $token->[2]{'suppressEmptySequences'};
     $paramHash->{'toponly'} = $token->[2]{'toponly'};
     $paramHash->{'addstatus'} = $token->[2]{'addstatus'};
+    $paramHash->{'closeallpages'} = $token->[2]{'closeallpages'};
     return '';
 }
 
@@ -1942,7 +1946,7 @@ BUTTONS
 		$checked = 1;
 	    }
             $col .= "value='" . 
-                HTML::Entities::encode(&$valueFunc($resource)) 
+                HTML::Entities::encode(&$valueFunc($resource),'<>&"') 
                 . "' /></td>";
             return $col;
         }
@@ -1959,6 +1963,7 @@ BUTTONS
                                        'showParts' => 0,
                                        'filterFunc' => $filterFunc,
                                        'resource_no_folder_link' => 1,
+				       'closeAllPages' => $self->{'closeallpages'},
                                        'suppressEmptySequences' => $self->{'suppressEmptySequences'},
                                        'iterator_map' => $mapUrl }
                                        );
@@ -2024,7 +2029,7 @@ shown. Defaults to false.
 no strict;
 @ISA = ("Apache::lonhelper::element");
 use strict;
-
+use Apache::lonlocal;
 
 
 BEGIN {
@@ -2081,11 +2086,11 @@ sub render {
             }
         }
     }
-    function checksec() {
+    function checksec(value) {
 	for (i=0; i<document.forms.helpform.elements.length; i++) {
 	    comp = document.forms.helpform.elements.chksec.value;
             if (document.forms.helpform.elements[i].value.indexOf(':'+comp+':') != -1) {
-                document.forms.helpform.elements[i].checked=true;
+                document.forms.helpform.elements[i].checked=value;
             }
         }
     }
@@ -2098,13 +2103,17 @@ sub render {
     }
 </script>
 SCRIPT
+
+        my $selectAllStudents = &mt('Select All Students'); 
+	my $unselectAllStudents = &mt('Unselect All Students');
         $buttons = <<BUTTONS;
 <br />
 <input type="button" onclick="checkactive()" value="Select Only Current Students" />
-<input type="button" onclick="checkall(true, '$var')" value="Select All Students" />
-<input type="button" onclick="checkall(false, '$var')" value="Unselect All Students" />
-<input type="button" onclick="checksec()" value="Check for Section/Group">
+<input type="button" onclick="checkall(true, '$var')" value="$selectAllStudents" />
+<input type="button" onclick="checkall(false, '$var')" value="$unselectAllStudents" />
+<input type="button" onclick="checksec(true)" value="Select for Section/Group">
 <input type="text" size="5" name="chksec">&nbsp;
+<input type="button" onclick="checksec(false)" value="Unselect for Section/Group">
 <br />
 BUTTONS
     }
@@ -2163,14 +2172,14 @@ BUTTONS
 	}
     }
 
-    my $name = $self->{'coursepersonnel'} ? 'Name' : 'Student Name';
+    my $name = &mt($self->{'coursepersonnel'} ? 'Name' : 'Student Name');
     my $type = 'radio';
     if ($self->{'multichoice'}) { $type = 'checkbox'; }
     $result .= "<table cellspacing='2' cellpadding='2' border='0'>\n";
     $result .= "<tr><td></td><td align='center'><b>$name</b></td>".
-        "<td align='center'><b>Section</b></td>" . 
+        "<td align='center'><b>" . &mt('Section') . "</b></td>" . 
 	"<td align='center'><b>Status</b></td>" . 
-	"<td align='center'><b>Role</b></td>" .
+	"<td align='center'><b>" . &mt("Role") . "</b></td></tr>" .
 	"<td align='center'><b>Username:Domain</b></td></tr>";
 
     my $checked = 0;
@@ -2183,17 +2192,17 @@ BUTTONS
             $checked = 1;
         }
         $result .=
-            " value='" . HTML::Entities::encode($choice->[0] . ':' . $choice->[2] . ':' . $choice->[1] . ':' . $choice->[3])
+            " value='" . HTML::Entities::encode($choice->[0] . ':' . $choice->[2] . ':' . $choice->[1] . ':' . $choice->[3],'<>&"')
             . "' /></td><td>"
-            . HTML::Entities::encode($choice->[1])
+            . HTML::Entities::encode($choice->[1],'<>&"')
             . "</td><td align='center'>" 
-            . HTML::Entities::encode($choice->[2])
+            . HTML::Entities::encode($choice->[2],'<>&"')
             . "</td>\n<td>" 
-	    . HTML::Entities::encode($choice->[3])
+	    . HTML::Entities::encode($choice->[3],'<>&"')
             . "</td>\n<td>" 
-	    . HTML::Entities::encode($choice->[4])
+	    . HTML::Entities::encode($choice->[4],'<>&"')
             . "</td>\n<td>" 
-	    . HTML::Entities::encode($choice->[0])
+	    . HTML::Entities::encode($choice->[0],'<>&"')
 	    . "</td></tr>\n";
     }
 
@@ -2208,8 +2217,8 @@ sub postprocess {
 
     my $result = $ENV{'form.' . $self->{'variable'} . '.forminput'};
     if (!$result) {
-        $self->{ERROR_MSG} = 'You must choose at least one student '.
-            'to continue.';
+        $self->{ERROR_MSG} = 
+	    &mt('You must choose at least one student to continue.');
         return 0;
     }
 
@@ -2275,6 +2284,7 @@ viewing the files.
 no strict;
 @ISA = ("Apache::lonhelper::element");
 use strict;
+use Apache::lonlocal;
 
 use Apache::lonpubdir; # for getTitleString
 
@@ -2393,16 +2403,20 @@ sub render {
     }
 </script>
 SCRIPT
+        my $selectAllFiles = &mt("Select All Files");
+	my $unselectAllFiles = &mt("Unselect All Files");
         $buttons = <<BUTTONS;
 <br /> &nbsp;
-<input type="button" onclick="checkall(true, '$var')" value="Select All Files" />
-<input type="button" onclick="checkall(false, '$var')" value="Unselect All Files" />
+<input type="button" onclick="checkall(true, '$var')" value="$selectAllFiles" />
+<input type="button" onclick="checkall(false, '$var')" value="$unselectAllFiles" />
 BUTTONS
 
+        my $selectAllPublished = &mt("Select All Published");
+	my $unselectAllPublished= &mt("UnselectAllPublished");
         if ($helper->{VARS}->{'construction'}) {
             $buttons .= <<BUTTONS;
-<input type="button" onclick="checkallclass(true, 'Published')" value="Select All Published" />
-<input type="button" onclick="checkallclass(false, 'Published')" value="Unselect All Published" />
+<input type="button" onclick="checkallclass(true, 'Published')" value="$selectAllPublished" />
+<input type="button" onclick="checkallclass(false, 'Published')" value="$unselectAllPublished" />
 <br /> &nbsp;
 BUTTONS
        }
@@ -2484,7 +2498,7 @@ BUTTONS
             }
             $result .= '<tr><td align="right"' . " bgcolor='$color'>" .
                 "<input $onclick type='$type' name='" . $var
-            . ".forminput' value='" . HTML::Entities::encode($fileName) .
+            . ".forminput' value='" . HTML::Entities::encode($fileName,'<>&"').
                 "'";
             if (!$self->{'multichoice'} && $choices == 0) {
                 $result .= ' checked';
@@ -2893,7 +2907,7 @@ the old values taking effect.
 no strict;
 @ISA = ("Apache::lonhelper::element");
 use strict;
-
+use Apache::lonlocal;
 BEGIN {
     &Apache::lonhelper::register('Apache::lonhelper::final',
                                  ('final', 'exitpage'));
@@ -2978,7 +2992,8 @@ sub render {
 	}
 	
 	if (!@results) {
-	    $result .= '    <li>No changes were made to current settings.</li>';
+	    $result .= '    <li>' . 
+		&mt('No changes were made to current settings.') . '</li>';
 	}
 	
 	$result .= '</ul>';
@@ -2986,16 +3001,24 @@ sub render {
 
     if ($self->{'restartCourse'}) {
 	my $targetURL = '/adm/menu';
+	if ($ENV{'course.'.$ENV{'request.course.id'}.'.url'}=~/^uploaded/) {
+	    $targetURL = '/adm/coursedocs';
+	} else {
+	    $targetURL = '/adm/navmaps';
+	}
 	if ($ENV{'course.'.$ENV{'request.course.id'}.'.clonedfrom'}) {
 	    $targetURL = '/adm/parmset?overview=1';
 	}
+	my $previous = HTML::Entities::encode(&mt("<- Previous"), '<>&"');
+	my $next = HTML::Entities::encode(&mt("Next ->"), '<>&"');
         $result .= "<center>\n" .
             "<form action='/adm/roles' method='post' target='loncapaclient'>\n" .
-            "<input type='button' onclick='history.go(-1)' value='&lt;- Previous' />" .
+            "<input type='button' onclick='history.go(-1)' value='$previous' />" .
             "<input type='hidden' name='orgurl' value='$targetURL' />" .
             "<input type='hidden' name='selectrole' value='1' />\n" .
             "<input type='hidden' name='" . $ENV{'request.role'} . 
-            "' value='1' />\n<input type='submit' value='Finish Course Initialization' />\n" .
+            "' value='1' />\n<input type='submit' value='" .
+	    &mt('Finish Course Initialization') . "' />\n" .
             "</form></center>";
     }
 
@@ -3098,7 +3121,7 @@ sub render {
     }
 
     my $result = "<form name='helpform' method='get' action='/adm/parmset#$affectedResourceId&$parm_name&$level'>\n";
-    $result .= '<p>Confirm that this information is correct, then click &quot;Finish Wizard&quot; to complete setting the parameter.<ul>';
+    $result .= '<p>Confirm that this information is correct, then click &quot;Finish Helper&quot; to complete setting the parameter.<ul>';
     
     # Print the type of manipulation:
     $result .= '<li>Setting the <b>' . $dateTypeHash{$vars->{ACTION_TYPE}} . '</b>';
@@ -3143,7 +3166,7 @@ sub render {
         $result .= "<li>for section <b>$section</b></li>";
         $level -= 3;
         $result .= "<input type='hidden' name='csec' value='" .
-            HTML::Entities::encode($section) . "' />\n";
+            HTML::Entities::encode($section,'<>&"') . "' />\n";
     } else {
         # FIXME: This is probably wasteful! Store the name!
         my $classlist = Apache::loncoursedata::get_classlist();
@@ -3155,9 +3178,9 @@ sub render {
         $level -= 6;
         my ($uname, $udom) = split /:/, $vars->{USER_NAME};
         $result .= "<input type='hidden' name='uname' value='".
-            HTML::Entities::encode($uname) . "' />\n";
+            HTML::Entities::encode($uname,'<>&"') . "' />\n";
         $result .= "<input type='hidden' name='udom' value='".
-            HTML::Entities::encode($udom) . "' />\n";
+            HTML::Entities::encode($udom,'<>&"') . "' />\n";
     }
 
     # Print value