[LON-CAPA-cvs] cvs: rat / lonratparms.pm lonratsrv.pm lonsequence.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 04 Apr 2006 15:32:18 -0000


This is a MIME encoded message

--albertel1144164738
Content-Type: text/plain

albertel		Tue Apr  4 11:32:18 2006 EDT

  Modified files:              
    /rat	lonratparms.pm lonratsrv.pm lonsequence.pm 
  Log:
  - start_page work
  - some $_ elimination
  - some xhtml cleanup
  
  
--albertel1144164738
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060404113218.txt"

Index: rat/lonratparms.pm
diff -u rat/lonratparms.pm:1.23 rat/lonratparms.pm:1.24
--- rat/lonratparms.pm:1.23	Thu Apr  7 02:56:27 2005
+++ rat/lonratparms.pm	Tue Apr  4 11:32:12 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Set parameters inside of the RAT
 #
-# $Id: lonratparms.pm,v 1.23 2005/04/07 06:56:27 albertel Exp $
+# $Id: lonratparms.pm,v 1.24 2006/04/04 15:32:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -76,17 +76,13 @@
   
 # --------------------------------------------------- Print input screen header
     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
-    my $bodytag=&Apache::loncommon::bodytag('Set Resource Parameters in Map');
+
     my %lt=&Apache::lonlocal::texthash('pa' => 'Parameter',
 			               'de' => 'Default',
 				       'va' => 'Value',
 				       'se' => 'Set');
- 
-    $r->print(<<ENDHEADER);
-<html>
-<head>
-<title>The LearningOnline Network with CAPA</title>
-<script language="JavaScript">
+    my $js = (<<ENDHEADER);
+<script type="text/javascript">
 
     function pclose() {
         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
@@ -105,20 +101,24 @@
 
 function setparms() {
 ENDHEADER
-    $r->print('var colon=""; opener.objparms['.$env{'form.resid'}.']="";');
-    map {
-       $r->print("\nif (document.parameters.def_".$_.
+    $js .= 'var colon=""; opener.objparms['.$env{'form.resid'}.']="";';
+    foreach my $key (keys(%content)) {
+	$js .= "\nif (document.parameters.def_".$key.
        '.checked) { opener.objparms['.$env{'form.resid'}.
-       ']+=colon+"'.$type{$_}.
-       '___'.$_.'___"+document.parameters.'.$_.'.value; colon=":"; }'); 
-    } keys %content;
-    $r->print(<<ENDDOCUMENT);
+       ']+=colon+"'.$type{$key}.
+       '___'.$key.'___"+document.parameters.'.$key.'.value; colon=":"; }'; 
+    }
+    $js .= '
     opener.save();
     window.close();
 }
 </script>
-</head>
-$bodytag
+';
+    my $start_page =
+	&Apache::loncommon::start_page('Set Resource Parameters in Map',$js);
+
+    $r->print(<<ENDDOCUMENT);
+$start_page
 <form action="javascript:setparms();" method="post" name="parameters">
 <input type="hidden" value='' name="pres_value">
 <input type="hidden" value='' name="pres_type">
@@ -126,24 +126,26 @@
 <table border=2>
 <tr><th>$lt{'pa'}</th><th>$lt{'de'}</th><th>$lt{'va'}</th><th>$lt{'se'}?</th></tr>
 ENDDOCUMENT
+
 ###    %display=&Apache::lonlocal::texthash(%display);
     my $enter=&mt('Enter');
-    foreach (sort(keys(%content))) {
-        my $cur=$content{$_};
-        # Should if(defined($value{$_})) be if(exists($value{$_})) ?
-        if (defined($value{$_})) { $cur=$value{$_}; };
+    foreach my $key (sort(keys(%content))) {
+        my $cur=$content{$key};
+        # Should if(defined($value{$key})) be if(exists($value{$key})) ?
+        if (defined($value{$key})) { $cur=$value{$key}; };
         $r->print(<<"END");
-<tr><td><b>$display{$_}</b><br><tt>$_</tt></td>
-<td>&nbsp;$content{$_}</td>
-<td><input type="text" size="10" name="$_" value="$cur">&nbsp;
-<a href='javascript:pjump("$type{$_}","$display{$_}",document.parameters.$_.value,"$_","parameters.pres","stpr");'>$enter</a></td>
-<td><input type="checkbox" name="def_$_" 
+<tr><td><b>$display{$key}</b><br><tt>$key</tt></td>
+<td>&nbsp;$content{$key}</td>
+<td><input type="text" size="10" name="$key" value="$cur">&nbsp;
+<a href='javascript:pjump("$type{$key}","$display{$key}",document.parameters.$key.value,"$key","parameters.pres","stpr");'>$enter</a></td>
+<td><input type="checkbox" name="def_$key" 
 END
-        if ($value{$_}) { $r->print(' checked'); }
+        if ($value{$key}) { $r->print(' checked'); }
         $r->print('></td></tr>');
     }
-    $r->print(
-        '</table><br><input type="submit" value="'.&mt('Set').'"></form></body></html>');
+    $r->print('</table><br />
+               <input type="submit" value="'.&mt('Set').'"></form>'.
+	      &Apache::loncommon::end_page());
     return OK;
 } 
 
Index: rat/lonratsrv.pm
diff -u rat/lonratsrv.pm:1.34 rat/lonratsrv.pm:1.35
--- rat/lonratsrv.pm:1.34	Mon Oct 31 13:52:10 2005
+++ rat/lonratsrv.pm	Tue Apr  4 11:32:12 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Server for RAT Maps
 #
-# $Id: lonratsrv.pm,v 1.34 2005/10/31 18:52:10 albertel Exp $
+# $Id: lonratsrv.pm,v 1.35 2006/04/04 15:32:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -346,24 +346,30 @@
   }
   ($outtext,$errtext,$infotext)=&loadmap($fn,$errtext,$infotext);
 
+  my $start_page =
+      &Apache::loncommon::start_page('Alert',undef,
+				     {'only_body' => 1,
+				      'bgcolor'   => '#FFFFFF',});
+  my $end_page =
+      &Apache::loncommon::end_page();
+
   $r->print(<<ENDDOCUMENT);
-<html>
-<body bgcolor="#FFFFFF">
-<form name=storage method=post action="$url">
-<input type=hidden name=output value="$outtext">
+$start_page
+<form name="storage" method="post" action="$url">
+<input type="hidden" name="output" value="$outtext" />
 </form>
-<script>
+<script type ="text/javascript">
     parent.flag=1;
 </script>
 ENDDOCUMENT
     if (($errtext ne '') || ($infotext ne '')) {
 	$r->print(<<ENDSCRIPT);
-<script>
+<script type="text/javascript">
     alert("$infotext $errtext");
 </script>
 ENDSCRIPT
     }
-    $r->print("</body>\n</html>\n");
+    $r->print($end_page);
 
   return OK;
 }
Index: rat/lonsequence.pm
diff -u rat/lonsequence.pm:1.25 rat/lonsequence.pm:1.26
--- rat/lonsequence.pm:1.25	Thu Jan  5 15:57:55 2006
+++ rat/lonsequence.pm	Tue Apr  4 11:32:12 2006
@@ -2,7 +2,7 @@
 #
 # Sequence Handler
 #
-# $Id: lonsequence.pm,v 1.25 2006/01/05 20:57:55 albertel Exp $
+# $Id: lonsequence.pm,v 1.26 2006/04/04 15:32:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -70,9 +70,11 @@
 
 sub viewmap {
     my ($r,$url)=@_;
-    $r->print('<html>');
-    if ($env{'form.forceselect'}) { $r->print(<<ENDSCRIPT);
-<script>
+
+    my $js;
+    if ($env{'form.forceselect'}) {
+	$js = (<<ENDSCRIPT);
+<script type="text/javascript">
 
 function select_group() {
     window.location="/adm/groupsort?catalogmode=groupsec&mode=rat&acts="+document.forms.fileattr.acts.value;
@@ -94,7 +96,9 @@
 </script>
 ENDSCRIPT
     }
-    $r->print(&Apache::loncommon::bodytag('Map Contents').'<h1>'.$url.'</h1>');
+
+    $r->print(&Apache::loncommon::start_page('Map Contents',$js).
+	      '<h1>'.$url.'</h1>');
 # ------------------ This is trying to select. Provide buttons and tie %selhash
     if ($env{'form.forceselect'}) { $r->print(<<ENDSELECT);
 <form name=fileattr><input type=hidden name=acts value=''>
@@ -198,7 +202,7 @@
             }
         }
     }
-    $r->print('</body></html>');
+    $r->print(&Apache::loncommon::end_page());
     if ($successtied) {
 	untie %selhash;
     }
@@ -315,30 +319,30 @@
            my %lt =&Apache::lonlocal::texthash(
                    'back' => 'beginning',
                    'forward' => 'end',
-                   'emfo' => 'Empty Folder/Sequence',
                    'nere' => 'Next resource could not be displayed',
                    'goba' => 'Go Back',
                    'nacc' => 'Navigate Course Content',
                           );
-           my $warnmsg = 'As all folders and sequences ';
+           my $warnmsg = &mt('As all folders and sequences ');
            if ($arrow_dir eq 'forward') {
                $warnmsg .= &mt('following the current resource were empty').',';
            } elsif ($arrow_dir eq 'back') {
                $warnmsg .= &mt('preceding the current resource were empty').',';
            }
            $warnmsg .= &mt('you have now reached the').' '.$lt{$arrow_dir}.' '.&mt('of the course.');
-           my $bodytag=&Apache::loncommon::bodytag('Empty Folder/Sequence');
+           my $start_page=
+	       &Apache::loncommon::start_page('Empty Folder/Sequence');
+           my $end_page=
+	       &Apache::loncommon::end_page();
            $r->print(<<ENDNONE);
-<head><title>$lt{'emfo'}</title></head>
-$bodytag
+$start_page
 <h3>$lt{'nere'}</h3>
 <p>$warnmsg</p>
 <ul>
   <li><a href="javascript:history.go(-1)">$lt{'goba'}</a></li>
   <li><a href="/adm/navmaps">$lt{'nacc'}</a></li>
 </ul>
-</body>
- </html>
+$end_page
 ENDNONE
        } else {
            &viewmap($r,$requrl);

--albertel1144164738--