line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#$Id: Element.pm 216 2007-11-13 08:48:37Z zag $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTML::WebDAO::Element; |
4
|
6
|
|
|
6
|
|
1359
|
use Data::Dumper; |
|
6
|
|
|
|
|
18576
|
|
|
6
|
|
|
|
|
306
|
|
5
|
6
|
|
|
6
|
|
1101
|
use HTML::WebDAO::Base; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
316
|
|
6
|
6
|
|
|
6
|
|
32
|
use base qw/ HTML::WebDAO::Base/; |
|
6
|
|
|
|
|
39
|
|
|
6
|
|
|
|
|
843
|
|
7
|
6
|
|
|
6
|
|
32
|
use strict 'vars'; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
3531
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->attributes |
9
|
|
|
|
|
|
|
qw/ _format_subs __attribute_names __my_name __parent __path2me __engine __extra_path /; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _init { |
12
|
|
|
|
|
|
|
my $self = shift; |
13
|
|
|
|
|
|
|
$self->_sysinit( \@_ ); #For system internal inherites |
14
|
|
|
|
|
|
|
$self->init(@_); # if (@_); |
15
|
|
|
|
|
|
|
return 1; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub RegEvent { |
19
|
|
|
|
|
|
|
my $self = shift; |
20
|
|
|
|
|
|
|
my $ref_eng = $self->getEngine; |
21
|
|
|
|
|
|
|
$ref_eng->RegEvent( $self, @_ ); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# |
25
|
|
|
|
|
|
|
sub _sysinit { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#get init hash reference |
29
|
|
|
|
|
|
|
my $ref_init_hash = shift( @{ $_[0] } ); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#_engine - reference to engine |
32
|
|
|
|
|
|
|
$self->__engine( $ref_init_hash->{ref_engine} ); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#_my_name - name of this object |
35
|
|
|
|
|
|
|
$self->__my_name( $ref_init_hash->{name_obj} ); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#init hash of attribute_names |
38
|
|
|
|
|
|
|
my $ref_names_hash = {}; |
39
|
|
|
|
|
|
|
map { $ref_names_hash->{$_} = 1 } $self->get_attribute_names(); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# _attribute_names $self $ref_names_hash; |
42
|
|
|
|
|
|
|
$self->__attribute_names($ref_names_hash); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#init array of _format sub's references |
45
|
|
|
|
|
|
|
# $self->_format_subs( |
46
|
|
|
|
|
|
|
# [ |
47
|
|
|
|
|
|
|
# sub { $self->pre_format(@_) }, |
48
|
|
|
|
|
|
|
# sub { $self->format(@_) }, |
49
|
|
|
|
|
|
|
# sub { $self->post_format(@_) }, |
50
|
|
|
|
|
|
|
# ] |
51
|
|
|
|
|
|
|
# ); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub init { |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#Public Init metod for modules; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _get_vars { |
61
|
|
|
|
|
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
my $res; |
63
|
|
|
|
|
|
|
for my $key ( keys %{ $self->__attribute_names } ) { |
64
|
|
|
|
|
|
|
my $val = $self->get_attribute($key); |
65
|
|
|
|
|
|
|
no strict 'vars'; |
66
|
|
|
|
|
|
|
$res->{$key} = $val if ( defined($val) ); |
67
|
|
|
|
|
|
|
use strict 'vars'; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
return $res; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head3 _get_childs() |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Return ref to childs array |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _get_childs { |
79
|
|
|
|
|
|
|
return []; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub call_path { |
83
|
|
|
|
|
|
|
my $self = shift; |
84
|
|
|
|
|
|
|
my $path = shift; |
85
|
|
|
|
|
|
|
$path = [ grep { $_ } split( /\//, $path ) ]; |
86
|
|
|
|
|
|
|
return $self->getEngine->_call_method( $path, @_ ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _call_method { |
90
|
|
|
|
|
|
|
my $self = shift; |
91
|
|
|
|
|
|
|
my ( $method, @path ) = @{ shift @_ }; |
92
|
|
|
|
|
|
|
if ( scalar @path ) { |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#_log4 $self "Extra path @path $self"; |
95
|
|
|
|
|
|
|
return; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
unless ( $self->can($method) ) { |
98
|
|
|
|
|
|
|
_log4 $self $self->_obj_name . ": don't have method $method"; |
99
|
|
|
|
|
|
|
return; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
else { |
102
|
|
|
|
|
|
|
$self->$method(@_); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub __get_self_refs { |
107
|
|
|
|
|
|
|
return $_[0]; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _set_parent { |
111
|
|
|
|
|
|
|
my ( $self, $parent ) = @_; |
112
|
|
|
|
|
|
|
$self->__parent($parent); |
113
|
|
|
|
|
|
|
$self->_set_path2me(); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub _set_path2me { |
117
|
|
|
|
|
|
|
my $self = shift; |
118
|
|
|
|
|
|
|
my $parent = $self->__parent; |
119
|
|
|
|
|
|
|
if ( $self != $parent ) { |
120
|
|
|
|
|
|
|
( my $parents_path = $parent->__path2me ) ||= ""; |
121
|
|
|
|
|
|
|
my $extr = $parent->__extra_path; |
122
|
|
|
|
|
|
|
$extr = [] unless defined $extr; |
123
|
|
|
|
|
|
|
$extr = [$extr] unless ( ref($extr) eq 'ARRAY' ); |
124
|
|
|
|
|
|
|
my $my_path = join "/", $parents_path, @$extr, $self->__my_name; |
125
|
|
|
|
|
|
|
$self->__path2me($my_path); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
else { |
128
|
|
|
|
|
|
|
$self->__path2me(''); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub _obj_name { |
133
|
|
|
|
|
|
|
return $_[0]->__my_name; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub getEngine { |
137
|
|
|
|
|
|
|
my $self = shift; |
138
|
|
|
|
|
|
|
return $self->__engine; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub SendEvent { |
142
|
|
|
|
|
|
|
my $self = shift; |
143
|
|
|
|
|
|
|
my $parent = __parent $self; |
144
|
|
|
|
|
|
|
$self->_log1( "Not def parent $self name:" |
145
|
|
|
|
|
|
|
. ( $self->__my_name ) |
146
|
|
|
|
|
|
|
. Dumper( \@_ ) |
147
|
|
|
|
|
|
|
. Dumper( [ map { [ caller($_) ] } ( 1 .. 10 ) ] ) ) |
148
|
|
|
|
|
|
|
unless $parent; |
149
|
|
|
|
|
|
|
$parent->SendEvent(@_); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub pre_format { |
153
|
|
|
|
|
|
|
my $self = shift; |
154
|
|
|
|
|
|
|
return []; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub _format { |
158
|
|
|
|
|
|
|
my $self = shift; |
159
|
|
|
|
|
|
|
my @res; |
160
|
|
|
|
|
|
|
push( @res, @{ $self->pre_format(@_) } ); #for compat |
161
|
|
|
|
|
|
|
if ( my $result = $self->fetch(@_) ) { |
162
|
|
|
|
|
|
|
push @res, ( ref($result) eq 'ARRAY' ? @{$result} : $result ); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
push( @res, @{ $self->post_format(@_) } ); #for compat |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
\@res; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub format { |
170
|
|
|
|
|
|
|
my $self = shift; |
171
|
|
|
|
|
|
|
return shift; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub post_format { |
175
|
|
|
|
|
|
|
my $self = shift; |
176
|
|
|
|
|
|
|
return []; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub fetch { my $self = shift; return [] } |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub _destroy { |
182
|
|
|
|
|
|
|
my $self = shift; |
183
|
|
|
|
|
|
|
$self->__parent(undef); |
184
|
|
|
|
|
|
|
$self->__engine(undef); |
185
|
|
|
|
|
|
|
$self->_format_subs(undef); |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub _set_vars { |
189
|
|
|
|
|
|
|
my ( $self, $ref, $names ) = @_; |
190
|
|
|
|
|
|
|
$names = $self->__attribute_names; |
191
|
|
|
|
|
|
|
for my $key ( keys %{$ref} ) { |
192
|
|
|
|
|
|
|
if ( exists( $names->{$key} ) ) { |
193
|
|
|
|
|
|
|
$self ->${key}( $ref->{$key} ); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
else { |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# Uknown attribute ??? |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 __get_objects_by_path [path], $session |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Check if exist method in $path and return $self or undef |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub __get_objects_by_path { |
210
|
|
|
|
|
|
|
my $self = shift; |
211
|
|
|
|
|
|
|
return; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
1; |