annotate Lib/IMPL/Web/TT/Collection.pm @ 130:06a34c197b05

Added support for utf-8 and old versions of CGI module
author wizard
date Wed, 16 Jun 2010 01:50:56 +0400
parents ddf0f037d460
children 4369d5458bb6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
107
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
1 package IMPL::Web::TT::Collection;
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
2 use strict;
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
3
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
4 use base qw(IMPL::DOM::Node);
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
5
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
6 __PACKAGE__->PassThroughArgs;
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
7
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
8 our $AUTOLOAD;
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
9 sub AUTOLOAD {
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
10 my $this = shift;
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
11 my ($method) = ($AUTOLOAD =~ /(\w+)$/);
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
12
109
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
13 return if $method eq 'DESTROY';
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
14
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
15 if ($method =~ /^add(\w+)/) {
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
16 my ($name,$args) = @_;
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
17 return $this->appendChild($this->document->CreateControl($name,$1,$args));
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
18 }
107
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
19
109
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
20 if ( @_ >= 1 ) {
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
21 # set
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
22 # we can't assing a node, so this is a dynamic property
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
23 return $this->nodeProperty($method,@_);
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
24 } else {
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
25 # get
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
26 # try a dynamic property first
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
27 if ( my $val = $this->nodeProperty($method) ) {
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
28 return $val;
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
29 } else {
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
30 # and return a first child node as last opportunity
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
31 my @result = $this->selectNodes($method);
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
32
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
33 return $result[0] if @result;
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
34 return;
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
35 }
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
36 }
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 107
diff changeset
37 die new IMPL::Exception("We shoud never get here, this is a bug!!!");
107
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
38 }
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
39
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
40 sub as_list {
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
41 $_[0]->childNodes;
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
42 }
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
43
0e72ad99eef7 Updated Web::TT
wizard
parents:
diff changeset
44 1;