[LON-CAPA-cvs] cvs: loncom /homework edit.pm /xml lonplot.pm scripttag.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 22 Mar 2002 20:05:19 -0000


albertel		Fri Mar 22 15:05:19 2002 EDT

  Modified files:              
    /loncom/homework	edit.pm 
    /loncom/xml	lonplot.pm scripttag.pm 
  Log:
  - changed textfield to the more descriptive editline
  - updated all references to textfield to use edit line
  - update <import> <scriptlib> <parserlib> to use the new editline
  - editline, and editfield now protect entities, should preserve &nbsp; and " much better
  
  
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.31 loncom/homework/edit.pm:1.32
--- loncom/homework/edit.pm:1.31	Fri Mar 22 09:45:11 2002
+++ loncom/homework/edit.pm	Fri Mar 22 15:05:19 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.31 2002/03/22 14:45:11 matthew Exp $
+# $Id: edit.pm,v 1.32 2002/03/22 20:05:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,7 +31,8 @@
 package Apache::edit; 
 
 use strict;
-use Apache::lonnet;
+use Apache::lonnet();
+use HTML::Entities();
 
 # Global Vars
 # default list of colors to use in editing
@@ -301,8 +302,9 @@
   return ($rows,$cols);
 }
 
-sub textfield {
+sub editline {
     my ($tag,$data,$description,$size)=@_;
+    $data=&HTML::Entities::encode($data);
     if ($description) { $description="<br />".$description."<br />"; }
     my $result = <<"END";
 $description
@@ -320,7 +322,9 @@
   if ($cols < $minwidth ) { $cols = $minwidth; }
   if ($rows < $minheight) { $rows = $minheight; }
   if ($description) { $description="<br />".$description."<br />"; }
-  return "$description\n&nbsp;&nbsp;&nbsp;<textarea rows=\"$rows\" cols=\"$cols\" name=\"homework_edit_".$Apache::lonxml::curdepth."\">$data</textarea>\n";
+  return $description."\n".'&nbsp;&nbsp;&nbsp;<textarea rows="'.$rows.
+    '" cols="'.$cols.'" name="homework_edit_'.$Apache::lonxml::curdepth.'">'.
+      &HTML::Entities::encode($data).'</textarea>'."\n";
 }
 
 sub modifiedfield {
@@ -564,7 +568,7 @@
 the form element $elementname.
 
 = item *
-textfield(tag,data,description,size): Provide a <input type="text" ../> for
+editline(tag,data,description,size): Provide a <input type="text" ../> for
 single-line text entry.  This is to be used for text enclosed by tags, not
 arguements/parameters associated with a tag.
 
Index: loncom/xml/lonplot.pm
diff -u loncom/xml/lonplot.pm:1.62 loncom/xml/lonplot.pm:1.63
--- loncom/xml/lonplot.pm:1.62	Fri Mar 22 11:56:37 2002
+++ loncom/xml/lonplot.pm	Fri Mar 22 15:05:19 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Dynamic plot
 #
-# $Id: lonplot.pm,v 1.62 2002/03/22 16:56:37 matthew Exp $
+# $Id: lonplot.pm,v 1.63 2002/03/22 20:05:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -610,7 +610,7 @@
 	my $text=&Apache::lonxml::get_all_text("/title",$$parser[-1]);
 	$result.=&Apache::edit::end_row().
 	    &Apache::edit::start_spanning_row().
-	    &Apache::edit::textfield('',$text,'',60);
+	    &Apache::edit::editline('',$text,'',60);
     } elsif ($target eq 'modified') {
 	my $text=$$parser[-1]->get_text("/title");
 	$result.=&Apache::edit::rebuild_tag($token);
@@ -644,7 +644,7 @@
 	my $text=&Apache::lonxml::get_all_text("/xlabel",$$parser[-1]);
 	$result.=&Apache::edit::end_row().
 	    &Apache::edit::start_spanning_row().
-	    &Apache::edit::textfield('',$text,'',60);
+	    &Apache::edit::editline('',$text,'',60);
     } elsif ($target eq 'modified') {
 	my $text=$$parser[-1]->get_text("/xlabel");
 	$result.=&Apache::edit::rebuild_tag($token);	
@@ -679,7 +679,7 @@
 	my $text = &Apache::lonxml::get_all_text("/ylabel",$$parser[-1]);
 	$result .= &Apache::edit::end_row().
 	    &Apache::edit::start_spanning_row().
-	    &Apache::edit::textfield('',$text,'',60);
+	    &Apache::edit::editline('',$text,'',60);
     } elsif ($target eq 'modified') {
 	my $text=$$parser[-1]->get_text("/ylabel");
 	$result.=&Apache::edit::rebuild_tag($token);
@@ -718,7 +718,7 @@
 	my $text = &Apache::lonxml::get_all_text("/label",$$parser[-1]);
 	$result .= &Apache::edit::end_row().
 	    &Apache::edit::start_spanning_row().
-	    &Apache::edit::textfield('',$text,'',60);
+	    &Apache::edit::editline('',$text,'',60);
     } elsif ($target eq 'modified') {
 	&Apache::edit::get_new_args
 	    ($token,$parstack,$safeeval,keys(%label_defaults));
@@ -795,7 +795,7 @@
 	my $text = &Apache::lonxml::get_all_text("/function",$$parser[-1]);
 	$result .= &Apache::edit::end_row().
 	    &Apache::edit::start_spanning_row().
-	    &Apache::edit::textfield('',$text,'',60);
+	    &Apache::edit::editline('',$text,'',60);
     } elsif ($target eq 'modified') {
 	$result.=&Apache::edit::rebuild_tag($token);
 	my $text=$$parser[-1]->get_text("/function");
@@ -871,7 +871,7 @@
 	my $text = &Apache::lonxml::get_all_text("/data",$$parser[-1]);
 	$result .= &Apache::edit::end_row().
 	    &Apache::edit::start_spanning_row().
-	    &Apache::edit::textfield('',$text,'',60);
+	    &Apache::edit::editline('',$text,'',60);
     } elsif ($target eq 'modified') {
 	$result.=&Apache::edit::rebuild_tag($token);
 	my $text=$$parser[-1]->get_text("/data");
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.66 loncom/xml/scripttag.pm:1.67
--- loncom/xml/scripttag.pm:1.66	Wed Jan 30 11:04:04 2002
+++ loncom/xml/scripttag.pm	Fri Mar 22 15:05:19 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # <script> definiton
 #
-# $Id: scripttag.pm,v 1.66 2002/01/30 16:04:04 albertel Exp $
+# $Id: scripttag.pm,v 1.67 2002/03/22 20:05:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -161,7 +161,7 @@
   if ($target eq "edit" ) {
     $result=
       &Apache::edit::tag_start($target,$token,'New Script Functions').
-	&Apache::edit::editfield($token->[1],$bodytext,'',40,1).
+	&Apache::edit::editline($token->[1],$bodytext,'',40,1).
 	  $error.'</td></tr>'.
 	    &Apache::edit::end_table();
   }
@@ -206,7 +206,7 @@
   if ($target eq "edit" ) {
     $result=
       &Apache::edit::tag_start($target,$token,'New Tag Definitions').
-	&Apache::edit::editfield($token->[1],$bodytext,'',40,1).
+	&Apache::edit::editline($token->[1],$bodytext,'',40,1).
 	  $error.'</td></tr>'.
 	    &Apache::edit::end_table();
   }
@@ -277,7 +277,7 @@
     &Apache::lonxml::newparser($parser,\$file,$dir);
   } elsif ($target eq "edit" ) {
     $result.=&Apache::edit::tag_start($target,$token);
-    $result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1);
+    $result.=&Apache::edit::editline($token->[1],$bodytext,'',40,1);
     #FIXME this need to convert $bodytext to be a contruction space reference
     #my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
     #$result.="Click<a href=\"$location\">here</a> to edit<br />"