annotate Lib/IMPL/DOM/Transform/PostToDOM.pm @ 139:5a9f64890c31

Fixed module loading by the UriController
author wizard
date Thu, 01 Jul 2010 17:32:29 +0400
parents 06a34c197b05
children b56ebc31bf18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
112
0ed8e2541b1c Form processing mechanism
wizard
parents: 106
diff changeset
1 package IMPL::DOM::Transform::PostToDOM;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
4
112
0ed8e2541b1c Form processing mechanism
wizard
parents: 106
diff changeset
5 use IMPL::DOM::Navigator::Builder;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
6 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
7
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
8 use base qw(IMPL::Transform);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
9
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
10 BEGIN {
106
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
11 public property documentClass => prop_get | owner_set;
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
12 public property documentSchema => prop_get | owner_set;
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
13 public property prefix => prop_get | owner_set;
106
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
14 private property _navi => prop_all;
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
15 public property Errors => prop_all | prop_list;
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
16 private property _schema => prop_all;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
17 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
18
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
19 our %CTOR = (
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
20 'IMPL::Transform' => sub {
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
21 -plain => \&TransformPlain,
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
22 HASH => \&TransformContainer,
130
06a34c197b05 Added support for utf-8 and old versions of CGI module
wizard
parents: 126
diff changeset
23 CGI => \&TransformCGI,
06a34c197b05 Added support for utf-8 and old versions of CGI module
wizard
parents: 126
diff changeset
24 CGIWrapper => \&TransformCGI
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
25 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
26 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
27
106
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
28 sub CTOR {
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
29 my ($this,$docClass,$docSchema,$prefix) = @_;
112
0ed8e2541b1c Form processing mechanism
wizard
parents: 106
diff changeset
30 $docClass ||= 'IMPL::DOM::Document';
0ed8e2541b1c Form processing mechanism
wizard
parents: 106
diff changeset
31
0ed8e2541b1c Form processing mechanism
wizard
parents: 106
diff changeset
32 $this->_navi(
0ed8e2541b1c Form processing mechanism
wizard
parents: 106
diff changeset
33 IMPL::DOM::Navigator::Builder->new(
0ed8e2541b1c Form processing mechanism
wizard
parents: 106
diff changeset
34 $docClass,
0ed8e2541b1c Form processing mechanism
wizard
parents: 106
diff changeset
35 $docSchema
0ed8e2541b1c Form processing mechanism
wizard
parents: 106
diff changeset
36 )
0ed8e2541b1c Form processing mechanism
wizard
parents: 106
diff changeset
37 );
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
38 $this->_schema($docSchema);
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
39 $this->prefix($prefix) if $prefix;
106
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
40 }
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
41
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
42 sub TransformContainer {
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
43 my ($this,$data) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
44
112
0ed8e2541b1c Form processing mechanism
wizard
parents: 106
diff changeset
45 my $navi = $this->_navi;
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
46
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
47 while (my ($key,$value) = each %$data) {
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
48
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
49 $navi->NavigateCreate($key);
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
50
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
51 $this->Transform($value);
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
52
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
53 $navi->Back();
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
54 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
55
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
56 return $navi->Current;
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
57 }
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
58
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
59 sub TransformPlain {
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
60 my ($this,$data) = @_;
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
61
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
62 $this->_navi->Current->nodeValue( $this->_navi->inflateValue($data) );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
63 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
64
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
65 sub TransformCGI {
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
66 my ($this,$query) = @_;
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 113
diff changeset
67
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
68 my $data={};
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
69
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
70 my $prefix = $this->prefix;
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
71 $prefix = qr/$prefix/;
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
72
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
73 foreach my $param (grep $_=~/$prefix/, $query->param()) {
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
74 my $value = $query->param($param);
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
75
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
76 my @parts = split /\//,$param;
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
77
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
78 my $node = $data;
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
79 while ( my $part = shift @parts ) {
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
80 if (@parts) {
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
81 $node = ($node->{$part} ||= {});
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
82 } else {
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
83 $node->{$part} = $value;
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
84 }
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
85 }
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
86 }
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
87
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
88 my $doc = $this->Transform($data);
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
89 $this->Errors->Append( $this->_navi->BuildErrors);
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
90 $this->Errors->Append( $this->_schema->Validate($doc));
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 112
diff changeset
91 return $doc;
106
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
92 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
93
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
94 1;