--- rat/lonratedt.pm	2003/07/25 04:14:32	1.46
+++ rat/lonratedt.pm	2003/12/12 15:16:35	1.49
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Edit Handler for RAT Maps
 #
-# $Id: lonratedt.pm,v 1.46 2003/07/25 04:14:32 bowersj2 Exp $
+# $Id: lonratedt.pm,v 1.49 2003/12/12 15:16:35 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -173,6 +173,7 @@ use Apache::lonnet;
 use Apache::lonratsrv;
 use Apache::lonsequence;
 use Apache::loncommon;
+use Apache::lonlocal;
 use File::Copy;
 
 use vars qw(@order @resources);
@@ -205,7 +206,7 @@ sub mapread {
             $links[$number]=$content;
         }
         if ($command eq 'objparms') {
-	    return('Map has resource parameters. Use advanced editor.',1);
+	    return(&mt('Map has resource parameters. Use advanced editor.'),1);
         }
     }
 # ------------------------------------------------------- Is this a linear map?
@@ -219,13 +220,13 @@ sub mapread {
 	    my ($start,$end,$cond)=split(/\:/,$_);
             if ((defined($starters[$start])) || (defined($endings[$end]))) { 
 		return
-                 ('Map has branchings. Use advanced editor.',1);
+                 (&mt('Map has branchings. Use advanced editor.'),1);
             }
 	    $starters[$start]=1;
 	    $endings[$end]=1;
 	    if ($cond) {
 		return
-                 ('Map has conditions. Use advanced editor.',1);
+                 (&mt('Map has conditions. Use advanced editor.'),1);
             }
 	}
 
@@ -234,7 +235,7 @@ sub mapread {
         if (defined($resources[$i])) {
 	    unless (($starters[$i]) || ($endings[$i])) {
                 return
-		 ('Map has unconnected resources. Use advanced editor.',1);
+		 (&mt('Map has unconnected resources. Use advanced editor.'),1);
             }
         }
     }
@@ -413,12 +414,12 @@ sub buttons {
     my $adv=shift;
     my $output='<form method=post>';     
     if ($adv==1) {
-	$output.='<input type=submit name=forceadv value="Edit">';
+	$output.='<input type=submit name=forceadv value="'.&mt('Edit').'">';
     } else {
         unless ($adv==2) {
-           $output.='<input type=submit name=forcesmp value="Simple Edit">';
+           $output.='<input type=submit name=forcesmp value="'.&mt('Simple Edit').'">';
         }
-	$output.='<input type=submit name=forceadv value="Advanced Edit">';
+	$output.='<input type=submit name=forceadv value="'.&mt('Advanced Edit').'">';
     }
     return $output.'</form><hr>';
 }
@@ -653,7 +654,7 @@ sub smpedt {
    }
    if (-e $tmpfn) {
       $targetmsg=
-        '<b><font color="red">You are working with an unsaved version of your map.</font></b><br>';
+        '<b><font color="red">'.&mt('You are working with an unsaved version of your map.').'</font></b><br>';
       my ($errtext,$fatal)=&mapread($tmpfn,'');
    }
 # ---------------------------------------------------------- Process form input
@@ -892,7 +893,7 @@ sub smpedt {
    $idx=0;
    $targetdetail='';
    my $targetwindow=       
-       '<option value="0"> ------- Target Edit Map ------- </option>'.
+       '<option value="0"> ------- '.&mt('Target Edit Map').' ------- </option>'.
      join("\n",map { 
        my ($name,$url)=split(/\:/,$resources[$_]);
        unless ($name) {  $name=(split(/\//,$url))[-1]; }
@@ -907,6 +908,26 @@ sub smpedt {
 # ----------------------------------------------------- Start simple RAT screen
    my $editscript=&editscript('simple');
    my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);
+   my %lt=&Apache::lonlocal::texthash(
+				      'sa' => 'Save',
+				      'nt' => 'New Title',
+				      'se' => 'Search',
+				      'im' => 'Import',
+				      'vi' => 'View',
+				      'lm' => 'Load Map',
+				      'ds' => 'Discard Selected',
+				      'ca' => 'Clear All',
+				      'ta' => 'Temporary Assembly Workspace',
+				      'rv' => 'Revert to Last Saved',
+                                      'sa' => 'Save',
+                                      'mu' => 'Move Up',
+                                      'md' => 'Move Down',
+                                      're' => 'Rename',
+                                      'as' => 'after selected',
+                                      'cs' => 'Cut selected',
+                                      'ps' => 'Copy selected',
+                                      'pas' => 'Paste after selected',
+				      );
    $r->print(<<ENDSMPHEAD);
 <html>
 <head>
@@ -943,7 +964,7 @@ sub smpedt {
        oldname=unescape(nameparts.join('"'));
        nameparts=oldname.split('&#39;');
        oldname=unescape(nameparts.join("'"));
-       newtitle=prompt('New Title',oldname);
+       newtitle=prompt('$lt{'nt'}',oldname);
        if (newtitle) {
            document.forms.simpleedit.renameres.value=1;
            document.forms.simpleedit.renameidx.value=selidx;
@@ -963,37 +984,37 @@ $buttons
 <input type=hidden name=renametitle value=''>
 <input type=hidden name=renameidx value=0>
 <table>
-    <tr><th width="40%">Temporary Assembly Workspace</th>
+    <tr><th width="40%">$lt{'ta'}</th>
 <th>&nbsp;</th>
 <th width="40%">File: $url</th></tr>
 <tr><td bgcolor="#FFFFCC">
-<input type=button onClick="javascript:groupsearch()" value="Search">
-<input type=button onClick="javascript:groupimport();" value="Import">
-after selected
+<input type=button onClick="javascript:groupsearch()" value="$lt{'se'}">
+<input type=button onClick="javascript:groupimport();" value="$lt{'im'}">
+$lt{'as'}
 <hr>
 <input type=text size=20 name=importmap>
 <input type=button 
 onClick="javascript:openbrowser('simpleedit','importmap','sequence,page','')"
-value="Select Map"><input type=submit name=loadmap value="Load Map"><hr>
-<input type=submit name="discard" value="Discard Selected">
-<input type=submit name="clear" value="Clear All">
-<input type=button onClick="javascript:viewimport()" value="View">
+value="Select Map"><input type=submit name=loadmap value="$lt{'lm'}"><hr>
+<input type=submit name="discard" value="$lt{'ds'}">
+<input type=submit name="clear" value="$lt{'ca'}">
+<input type=button onClick="javascript:viewimport()" value="$lt{'vi'}">
 
     </td><td>&nbsp;</td><td bgcolor="#FFFFCC">
 
 <input type=button onClick=
-"javascript:impfortarget.value=1;groupsearch()" value="Search">
+"javascript:impfortarget.value=1;groupsearch()" value="$lt{'se'}">
 <input type=button onClick=
-"javascript:impfortarget.value=1;groupimport();" value="Import">
-after selected
+"javascript:impfortarget.value=1;groupimport();" value="$lt{'im'}">
+$lt{'as'}
 <hr>
-<input type=submit name="moveup" value="Move Up">
-<input type=submit name="movedown" value="Move Down">
-<input type=button onClick="javascript:renametarget()" value="Rename">
+<input type=submit name="moveup" value="$lt{'mu'}">
+<input type=submit name="movedown" value="$lt{'md'}">
+<input type=button onClick="javascript:renametarget()" value="$lt{'re'}">
 <hr>$targetmsg
-<input type=submit name="revert" value="Revert to Last Saved">
-<input type=submit name="save" value="Save">
-<input type=button onClick="javascript:viewtarget()" value="View">
+<input type=submit name="revert" value="$lt{'rv'}">
+<input type=submit name="save" value="$lt{'sa'}">
+<input type=button onClick="javascript:viewtarget()" value="$lt{'vi'}">
 </td></tr>
 
 <tr><td bgcolor="#FFFFCC"><select name="importsel" size=10 multiple>
@@ -1001,13 +1022,13 @@ $importwindow
 </select>
 </td>
 <td bgcolor="#FFFFAA" align="center">
-Cut selected<br>
+$lt{'cs'}<br>
 <input type=submit name=cut value='<<<'><p>
 <hr>
-Copy selected<br>
+$lt{'ps'}<br>
 <input type=submit name=copy value='<--'><p>
 <hr>
-Paste after selected<br>
+$lt{'pas'}<br>
 <input type=submit name=paste value='-->'>
 </td>
 <td bgcolor="#FFFFCC"><select name="target" size=10 multiple>
@@ -1049,7 +1070,7 @@ sub viewmap {
     my $idx=0;
     $r->print('<h1>'.$url.'</h1>');
     if ($adv) {
-	$r->print('<p><b><font color="red">Map contents are not shown in order.</font></b></p><br />');
+	$r->print('<p><b><font color="red">'.&mt('Map contents are not shown in order.').'</font></b></p><br />');
     }
     foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) {
 	if (defined($_)) {
@@ -1074,11 +1095,17 @@ sub viewmap {
 
 sub handler {
   my $r=shift;
-  $r->content_type('text/html');
+  &Apache::loncommon::content_type($r,'text/html');
   $r->send_http_header;
 
   return OK if $r->header_only;
-
+  my $target = $ENV{'form.grade_target'};
+  if ($target eq 'meta') {
+      &Apache::loncommon::content_type($r,'text/html');
+      $r->send_http_header;
+      return OK;
+  }
+  
   my $url=$r->uri;
   my $fn=&Apache::lonnet::filelocation('',$url);