Mercurial > pub > Impl
diff Lib/IMPL/DOM/Transform/QueryToDOM.pm @ 238:b8c724f6de36
DOM model refactoring
TT view refactoring, controls are no longer derived from DOM nodes
bugfixes
author | sergey |
---|---|
date | Tue, 16 Oct 2012 01:33:06 +0400 |
parents | 61db68166c37 |
children | a02b110da931 |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Transform/QueryToDOM.pm Mon Oct 15 17:39:12 2012 +0400 +++ b/Lib/IMPL/DOM/Transform/QueryToDOM.pm Tue Oct 16 01:33:06 2012 +0400 @@ -8,7 +8,7 @@ ], props => [ prefix => PROP_RO, - delimier => PROP_RO + delimiter => PROP_RO ] }; @@ -18,7 +18,8 @@ $this->templates->{'CGI'} = \&TransformCGI; $this->templates->{'CGIWrapper'} = \&TransformCGI; - $this->delimier('.'); + $this->delimiter('[.]'); + $this->prefix(''); } sub TransformCGI { @@ -32,21 +33,29 @@ foreach my $param (grep index($_,$prefix) >= 0 , $query->param()) { length (my $value = $query->param($param)) or next; - my @parts = split /\//,$param; + my @parts = split /$delim/,$param; my $node = $data; while ( my $part = shift @parts ) { - if (@parts) { - $node = ($node->{$part} ||= {}); - } else { - $node->{$part} = $value; + if (my ($name,$index) = ($part =~ m/^(\w+)(?:\[(\d+)\])?$/) ) { + if (@parts) { + if(defined $index) { + $node = ($node->{$name}[$index] ||= {}); + } else { + $node = ($node->{$name} ||= {}); + } + } else { + if(defined $index) { + $node->{$name}[$index] = $value; + } else { + $node->{$name} = $value; + } + } } } } - if (keys %$data > 1) { - $data = { document => $data }; - } - return $this->Transform($data); -} \ No newline at end of file +} + +1; \ No newline at end of file