cvsuser     02/10/04 13:01:57

  Modified:    P5EEx/Blue/P5EEx/Blue/Request CGI.pm
  Log:
  clean up use of {:delete:} values and allow for symbolic (rather than literal) event 
arguments
  
  Revision  Changes    Path
  1.2       +35 -4     p5ee/P5EEx/Blue/P5EEx/Blue/Request/CGI.pm
  
  Index: CGI.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/P5EEx/Blue/P5EEx/Blue/Request/CGI.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -r1.1 -r1.2
  --- CGI.pm    12 Jul 2002 21:01:39 -0000      1.1
  +++ CGI.pm    4 Oct 2002 20:01:57 -0000       1.2
  @@ -1,6 +1,6 @@
   
   #############################################################################
  -## $Id: CGI.pm,v 1.1 2002/07/12 21:01:39 spadkins Exp $
  +## $Id: CGI.pm,v 1.2 2002/10/04 20:01:57 spadkins Exp $
   #############################################################################
   
   package P5EEx::Blue::Request::CGI;
  @@ -232,7 +232,7 @@
           #  3. "wname{m}[1]"  variable is a "multi-level hash key" under 
$context->{widget}{$wname}
           #  4. "wname"        variable is a "multi-level hash key"
           ##########################################################
  -        my (@eventvars, $var, @values, $value, $mlhashkey, $name);
  +        my (@eventvars, $var, @values, @tmp, $value, $mlhashkey, $name);
           @eventvars = ();
           foreach $var ($cgi->param()) {
               if ($var =~ /^p5ee\.event/) {
  @@ -244,6 +244,21 @@
               }
               else {
                   @values = $cgi->param($var);
  +                if ($#values > 0) {
  +                    @tmp = ();
  +                    foreach $value (@values) {
  +                        if ($value eq "{:delete:}") {
  +                            my $delvar = $var;
  +                            $delvar =~ s/\[\]$//;
  +                            $context->wdelete($name, $delvar);
  +                        }
  +                        else {
  +                            push(@tmp, $value);
  +                        }
  +                    }
  +                    @values = @tmp;
  +                }
  +                
                   if ($var =~ s/\[\]$//) {
                       $value = [ @values ];
                   }
  @@ -256,6 +271,7 @@
                   else {
                       $value = join(",",@values);
                   }
  +
                   if ($var =~ /^([^\[\]\{\}]+)([\[\]\{\}].*)/) {
                       $context->wset($1, $2, $value);
                   }
  @@ -280,7 +296,7 @@
               }
           }
   
  -        my ($key, $fullkey, $args, @args, $event, %x, %y, $x, $y);
  +        my ($key, $fullkey, $arg, $args, @args, $event, %x, %y, $x, $y);
           foreach $key (@eventvars) {
   
               # These events come from <input type=submit> type controls
  @@ -294,7 +310,22 @@
                   if ($key =~ /\((.*)\)/) {             # look for anything inside 
parentheses
                       $args = $1;
                   }
  +                if ($args eq "") {
  +                    # do nothing, @args = ()
  +                }
  +                elsif ($args =~ /\{/) {
  +                    foreach $arg (split(/ *, */,$args)) {
  +                        if ($arg =~ /^\{(.*)\}$/) {
  +                            push(@args, $context->wget($1));
  +                        }
  +                        else {
  +                            push(@args, $arg);
  +                        }
  +                    }
  +                }
  +                else {
                   @args = split(/ *, */,$args) if ($args ne "");
  +                }
   
                   # <input type=image name=joe> returns e.g. joe.x=20 joe.y=35
                   # these two variables get turned into one event with $x, $y added 
to the end of the @args
  
  
  


Reply via email to