*** EditTablePlugin.pm.orig	Tue May  6 19:19:29 2003
--- EditTablePlugin.pm	Tue May  6 19:18:45 2003
***************
*** 47,53 ****
  use vars qw(
          $web $topic $user $installWeb $VERSION $debug
          $query $renderingWeb
!         $preSp $header $footer @format $changeRows $helpTopic $nrCols
          $encodeStart $encodeEnd $table
      );
  
--- 47,54 ----
  use vars qw(
          $web $topic $user $installWeb $VERSION $debug
          $query $renderingWeb
!         $preSp $header $footer @format @formatExpansed 
! 	$changeRows $helpTopic $nrCols
          $encodeStart $encodeEnd $table
      );
  
***************
*** 291,296 ****
--- 292,300 ----
      # FIXME: *very* crude encoding to escape Wiki rendering inside form fields
      $theText =~ s/\./%dot%/gos;
      $theText =~ s/(.)/\.$1/gos;
+ 
+     # convert <br /> markup to unicode linebreak character for text areas
+     $theText =~ s/.<.b.r. .\/.>/&#10;/gos;
      return $theText;
  }
  
***************
*** 301,310 ****
  
      $theText =~ s/\.(.)/$1/gos;
      $theText =~ s/%dot%/\./gos;
!     $theText =~ s/\&([^a-z])/&amp;$1/go; # escape non-entities
!     $theText =~ s/</\&lt;/go;            # change < to entity
!     $theText =~ s/>/\&gt;/go;            # change > to entity
!     $theText =~ s/\"/\&quot;/go;         # change " to entity
  
      return $theText;
  }
--- 305,314 ----
  
      $theText =~ s/\.(.)/$1/gos;
      $theText =~ s/%dot%/\./gos;
!     $theText =~ s/\&([^#a-z])/&amp;$1/go; # escape non-entities
!     $theText =~ s/</\&lt;/go;             # change < to entity
!     $theText =~ s/>/\&gt;/go;             # change > to entity
!     $theText =~ s/\"/\&quot;/go;          # change " to entity
  
      return $theText;
  }
***************
*** 360,365 ****
--- 364,374 ----
      $format[0] = "text,16" unless @format;
      $nrCols = @format;
  
+     # expansed form to be able to use %-vars in format
+     $tFormat =~ s/<nop>//gos;
+     $tFormat = &TWiki::Func::expandCommonVariables( $tFormat, $theTopic, $theWeb );
+     @formatExpansed = split( /\s*\|\s*/, $tFormat );
+     $formatExpansed[0] = "text,16" unless @formatExpansed;
      # FIXME: No handling yet of footer
  
      return "$preSp<nop>";
***************
*** 429,447 ****
      my $i = @format - 1;
      $i = $theCol if( $theCol < $i );
      my @bits = split( /,\s*/, $format[$i] );
      my $type = "text";
      $type = $bits[0] if @bits > 0;
      my $size = 0;
      $size = $bits[1] if @bits > 1;
      my $val  = "";
      my $sel  = "";
      if( $type eq "select" ) {
          $size = 1 if $size < 1;
!         $text = "<select name=\"$theName\" size=\"$size\">";
          $i = 2;
          while( $i < @bits ) {
              $val  = $bits[$i] || "";
!             if( $val eq $theValue ) {
                  $text .= " <option selected=\"selected\">$val</option>";
              } else {
                  $text .= " <option>$val</option>";
--- 438,460 ----
      my $i = @format - 1;
      $i = $theCol if( $theCol < $i );
      my @bits = split( /,\s*/, $format[$i] );
+     my @bitsExpansed = split( /,\s*/, $formatExpansed[$i] );
      my $type = "text";
      $type = $bits[0] if @bits > 0;
      my $size = 0;
      $size = $bits[1] if @bits > 1;
      my $val  = "";
+     my $valExpansed = "";
      my $sel  = "";
+     my $style = " style='background:#e8e8e8'" if ($theRowNr % 2);
      if( $type eq "select" ) {
          $size = 1 if $size < 1;
!         $text = "<select$style name=\"$theName\" size=\"$size\">";
          $i = 2;
          while( $i < @bits ) {
              $val  = $bits[$i] || "";
!             $valExpansed  = $bitsExpansed[$i] || "";
!             if( $valExpansed eq $theValue ) {
                  $text .= " <option selected=\"selected\">$val</option>";
              } else {
                  $text .= " <option>$val</option>";
***************
*** 475,484 ****
          $theValue = $encodeStart . encodeValue( $theValue ) . $encodeEnd if $theValue;
          $text .= "<input type=\"hidden\" name=\"$theName\" value=\"$theValue\" />";
  
!     } else {  # if( $type eq "text" )
          $size = 16 if $size < 1;
          $theValue = $encodeStart . encodeValue( $theValue ) . $encodeEnd if $theValue;
!         $text = "<input type=\"text\" name=\"$theName\" size=\"$size\" value=\"$theValue\" />";
      }
      return $text;
  }
--- 488,505 ----
          $theValue = $encodeStart . encodeValue( $theValue ) . $encodeEnd if $theValue;
          $text .= "<input type=\"hidden\" name=\"$theName\" value=\"$theValue\" />";
  
!     } elsif( $type eq "textarea" ) {
!         my ($rows, $cols) = split( /x/, $size );
!         $rows = 3 if $rows < 1;
!         $cols = 30 if $cols < 1;
! 
!         $theValue = $encodeStart . encodeValue( $theValue ) . $encodeEnd if $theValue;
!         $text .= "<textarea$style rows=\"$rows\" cols=\"$cols\" name=\"$theName\">$theValue</textarea>";
!         
!     } else { #  if( $type eq "text") 
          $size = 16 if $size < 1;
          $theValue = $encodeStart . encodeValue( $theValue ) . $encodeEnd if $theValue;
!         $text = "<input$style type=\"text\" name=\"$theName\" size=\"$size\" value=\"$theValue\" />";
      }
      return $text;
  }
***************
*** 504,510 ****
              $cellDefined = 0;
              $val = $query->param( "etcell${theRowNr}x$col" );
              if( defined $val ) {
!                 $val =~ s/[\n\r]/ /gos;  # Netscape on Unix can have new lines in an edit field
                  $cellDefined = 1;
                  $cell = $val;
              } elsif( $col <= @cells ) {
--- 525,532 ----
              $cellDefined = 0;
              $val = $query->param( "etcell${theRowNr}x$col" );
              if( defined $val ) {
! 		# change any new line character sequences to <br />
!                 $val =~ s/(\n\r?)|(\r\n?)+/<br \/>/gos;
                  $cellDefined = 1;
                  $cell = $val;
              } elsif( $col <= @cells ) {
