annotate Lib/IMPL/Web/TT/Control.pm @ 194:4d0e1962161c

Replaced tabs with spaces IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author cin
date Tue, 10 Apr 2012 20:08:29 +0400
parents d1676be8afcc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
1 package IMPL::Web::TT::Control;
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
2
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 140
diff changeset
3 use parent qw(IMPL::Web::TT::Collection);
78
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
4
171
59e5fcb59d86 Исправления, изменена концепция веб-форм
sourcer
parents: 166
diff changeset
5
78
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
6 use IMPL::Class::Property;
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 117
diff changeset
7 use IMPL::DOM::Property qw(_dom);
78
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
8
107
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
9 __PACKAGE__->PassThroughArgs;
78
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
10
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
11 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
12 public property controlClass => prop_all;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
13 public property template => prop_all;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
14 public property id => prop_all;
107
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
15 }
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
16
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
17 my $nextId = 1;
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
18
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
19 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
20 my ($this,%args) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
21
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
22 if ($this->document) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
23 # load a template
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
24 $this->template( $this->document->context->template($args{template})) if ($args{template} and not ref $args{template});
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
25 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
26 #$this->template($args{template}) if $args{template};
109
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
27
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
28 $this->id($this->nodeName . '-' . $nextId++);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
29 $this->controlClass('Control') unless $this->controlClass;
78
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
30 }
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
31
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
32 sub Render {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
33 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
34
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
35 if ($this->document) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
36 if ($this->template) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
37 return $this->document->context->include($this->template,{ this => $this }) ;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
38 } elsif ($this->document->presenter) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
39 return $this->document->presenter->print($this);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
40 } else {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
41 return $this->toString().": ".$this->controlClass() . ": ".$this->path;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
42 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
43 }
78
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
44 }
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 171
diff changeset
45 1;