Index: FormPivotPlugin.pm
===================================================================
RCS file: /twiki/src/cvsroot/twiki/CvsPlugins/FormPivotPlugin/lib/TWiki/Plugins/FormPivotPlugin.pm,v
retrieving revision 1.2
diff -c -r1.2 FormPivotPlugin.pm
*** FormPivotPlugin.pm	9 Aug 2002 01:34:02 -0000	1.2
--- FormPivotPlugin.pm	9 Aug 2002 20:38:52 -0000
***************
*** 109,115 ****
     
     # Find all topics with this form.
     
!    my $searchVal = "%META:FORM\{.*name=\\\"$form\\\".*\}%";
         
     my $search = &TWiki::Search::searchWeb( "1", $web, $searchVal, "",
            "", "on", "", "",
--- 109,115 ----
     
     # Find all topics with this form.
     
!    my $searchVal = "%META:FORM\\{.*name=\\\"$form\\\".*\\}%";
         
     my $search = &TWiki::Search::searchWeb( "1", $web, $searchVal, "",
            "", "on", "", "",
***************
*** 122,128 ****
     my @found = ();
     my @foundTopic = ();
     
!    for( my $i; $i<=$#fields; $i++ ) {
         my %hash = ();
         my %hashTopic = ();
         $found[$i] = \%hash;
--- 122,128 ----
     my @found = ();
     my @foundTopic = ();
     
!    for( my $i=0; $i<=$#fields; $i++ ) {
         my %hash = ();
         my %hashTopic = ();
         $found[$i] = \%hash;
***************
*** 132,141 ****
     
     foreach my $formTopic ( split( /\s/, $search ) ) {
         my( $meta, $text ) = TWiki::Store::readTopic( $web, $formTopic );
!        for( my $i; $i<=$#fields; $i++ ) {
             my $name = $fields[$i];
             $name =~ s/\s*//go;
             my %field0 = $meta->findOne( "FIELD", $name );
             my @values = split( /,/, $field0{"value"} );
             foreach my $value ( @values ) {
                 $value =~ s/^\s*//go; # Trim left
--- 132,142 ----
     
     foreach my $formTopic ( split( /\s/, $search ) ) {
         my( $meta, $text ) = TWiki::Store::readTopic( $web, $formTopic );
!        for( my $i=0; $i<=$#fields; $i++ ) {
             my $name = $fields[$i];
             $name =~ s/\s*//go;
             my %field0 = $meta->findOne( "FIELD", $name );
+ 	   $field0{"value"} = '' if ! defined($field0{"value"});
             my @values = split( /,/, $field0{"value"} );
             foreach my $value ( @values ) {
                 $value =~ s/^\s*//go; # Trim left
***************
*** 155,161 ****
     }
     
     if( $type ne "grid" ) {
!        for( my $i; $i<=$#fields; $i++ ) {
             my $field = $fields[$i];
             $pivot .= "---++ $field\n";
  
--- 156,162 ----
     }
     
     if( $type ne "grid" ) {
!        for( my $i=0; $i<=$#fields; $i++ ) {
             my $field = $fields[$i];
             $pivot .= "---++ $field\n";
  
***************
*** 166,172 ****
                 # FIXME should use field name not title without spaces
                 $field =~ s/\s*//go;
                 # Problems passing = and " to URL
!                my $searchVal = "%META:FIELD\{.*name..$field..*value..$key.*\}%";
                 $title = "<a href=\"" . &TWiki::getScriptUrl( $web, "", "search" ) . "?regex=on&search=$searchVal&nosearch=on\">$title</a>";
                 $table .= "| $title | " . $found[$i]->{$key} . " |\n";
             }
--- 167,175 ----
                 # FIXME should use field name not title without spaces
                 $field =~ s/\s*//go;
                 # Problems passing = and " to URL
! 	       # Key may not be first in multi select value. Extend RE
! 	       # to match in with any non " preceeding characters.
!                my $searchVal = qq(%META:FIELD\\{.*name..$field..*value..[^%22]*$key.*\\}%);
                 $title = "<a href=\"" . &TWiki::getScriptUrl( $web, "", "search" ) . "?regex=on&search=$searchVal&nosearch=on\">$title</a>";
                 $table .= "| $title | " . $found[$i]->{$key} . " |\n";
             }
***************
*** 193,200 ****
                foreach my $rowTopic ( keys %$hashRowTopics ) {
                   $count++ if( $hashColTopics->{$rowTopic} );
                }
!               my $searchVal = "%META:FIELD\{.*name%3D.$fieldRow..*value..$valueRow.*\}%%3B" .
!                               "%META:FIELD\{.*name%3D.$fieldCol..*value..$valueCol.*\}%";
                #my $searchVal = "FIELD,$fieldRow,value,$valueRow,FIELD,$fieldCol,value,$valueCol";
                my $link = "<a href=\"" . &TWiki::getScriptUrl( $web, "", "search" ) . "?regex=on&search=$searchVal&nosearch=on\">$count</a>";
                $pivot .= " $link |";
--- 196,203 ----
                foreach my $rowTopic ( keys %$hashRowTopics ) {
                   $count++ if( $hashColTopics->{$rowTopic} );
                }
!               my $searchVal = "%META:FIELD\\{.*name%3D.$fieldRow..*value..$valueRow.*\\}%%3B" .
!                               "%META:FIELD\\{.*name%3D.$fieldCol..*value..$valueCol.*\\}%";
                #my $searchVal = "FIELD,$fieldRow,value,$valueRow,FIELD,$fieldCol,value,$valueCol";
                my $link = "<a href=\"" . &TWiki::getScriptUrl( $web, "", "search" ) . "?regex=on&search=$searchVal&nosearch=on\">$count</a>";
                $pivot .= " $link |";
