[LON-CAPA-cvs] cvs: loncom /xml lonxml.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Fri, 17 Aug 2007 20:34:31 -0000


albertel		Fri Aug 17 16:34:31 2007 EDT

  Modified files:              
    /loncom/xml	lonxml.pm 
  Log:
  - reorder the textarea generation code
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.449 loncom/xml/lonxml.pm:1.450
--- loncom/xml/lonxml.pm:1.449	Fri Aug  3 19:29:54 2007
+++ loncom/xml/lonxml.pm	Fri Aug 17 16:34:31 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.449 2007/08/03 23:29:54 albertel Exp $
+# $Id: lonxml.pm,v 1.450 2007/08/17 20:34:31 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1350,11 +1350,12 @@
 
 
 sub inserteditinfo {
-      my ($result,$filecontents,$filetype)=@_;
+      my ($filecontents,$filetype)=@_;
       $filecontents = &HTML::Entities::encode($filecontents,'<>&"');
 #      my $editheader='<a href="#editsection">Edit below</a><hr />';
       my $xml_help = '';
       my $initialize='';
+      my $add_to_onload;
       if ($filetype eq 'html') {
 	  my $addbuttons=&Apache::lonhtmlcommon::htmlareaaddbuttons();
 	  $initialize=&Apache::lonhtmlcommon::spellheader();
@@ -1382,7 +1383,7 @@
 </script>
 FULLPAGE
 	  }
-          $result=~s/\<body([^\>]*)\>/\<body onload="initDocument()" $1\>/i;
+	  $add_to_onload = 'initDocument();';
 	  $xml_help=&Apache::loncommon::helpLatexCheatsheet();
       }
       my $cleanbut = '';
@@ -1416,9 +1417,7 @@
 $titledisplay
 </body>
 ENDFOOTER
-#      $result=~s/(\<body[^\>]*\>)/$1$editheader/is;
-      $result=~s/(\<\/body\>)/$editfooter/is;
-      return $result;
+      return ($editfooter,$add_to_onload);;
 }
 
 sub get_target {
@@ -1528,24 +1527,30 @@
 #
     unless ($env{'request.state'} eq 'published') {
 	if ($env{'form.editmode'} && (!($env{'form.viewmode'})) && (!($env{'form.discardview'})))
-	    {
+	{
+	    my ($edit_info, $add_to_onload)=
+		&inserteditinfo($filecontents,$filetype);
+
 	    my $displayfile=$request->uri;
 	    $displayfile=~s/^\/[^\/]*//;
-	    my %options = ();
+	    my %options = 
+		('add_entries' =>
+		    {'onload'   => $add_to_onload, });
 	    if ($env{'environment.remote'} ne 'off') {
 		$options{'bgcolor'}   = '#FFFFFF';
+		$options{'only_body'} = 1;
 	    }
 	    my $start_page = &Apache::loncommon::start_page(undef,undef,
 							    \%options);
 	    $result=$start_page.
 		&Apache::lonxml::message_location().'<h3>'.
 		$displayfile.
-		'</h3>'.&Apache::loncommon::end_page();
-	    $result=&inserteditinfo($result,$filecontents,$filetype);
+		'</h3>'.
+		$edit_info.
+		&Apache::loncommon::end_page();
 	}
     }
     if ($filetype eq 'html') { &writeallows($request->uri); }
-	
     
     &Apache::lonxml::add_messages(\$result);
     $request->print($result);