1 |
3 |
ahitrov@rambler.ru |
<%ARGS> |
2 |
|
|
|
3 |
54 |
ahitrov@rambler.ru |
$object => undef |
4 |
|
|
$SETS => undef |
5 |
3 |
ahitrov@rambler.ru |
|
6 |
|
|
</%ARGS> |
7 |
|
|
<%INIT> |
8 |
|
|
|
9 |
114 |
ahitrov |
use Contenido::File; |
10 |
|
|
use vars qw($keeper $request ); |
11 |
3 |
ahitrov@rambler.ru |
|
12 |
114 |
ahitrov |
$request->{local_codepage} = 'KOI8'; |
13 |
|
|
$request->{local_codepage} = 'WIN' if Convert::Cyrillic::cstocs('WIN', 'KOI8', $SETS->{control_charset}) eq '��������'; |
14 |
|
|
$request->{local_codepage} = 'UTF8' if Convert::Cyrillic::cstocs('UTF8', 'KOI8', $SETS->{control_charset}) eq '��������'; |
15 |
3 |
ahitrov@rambler.ru |
|
16 |
114 |
ahitrov |
warn "Contenido Debug: ����� ��� �������������� ������ � ��������� ".$request->{local_codepage}."\n" if ($state->debug()); |
17 |
3 |
ahitrov@rambler.ru |
|
18 |
114 |
ahitrov |
my @properties = $object->structure(); |
19 |
|
|
for (0..$#properties) |
20 |
|
|
{ |
21 |
|
|
my $prop = $properties[$_]; |
22 |
|
|
my $name = $prop->{attr}; |
23 |
|
|
my $type = $prop->{type}; |
24 |
3 |
ahitrov@rambler.ru |
|
25 |
114 |
ahitrov |
next if ($name eq 'sections'); |
26 |
|
|
next if ($name eq 'id'); |
27 |
54 |
ahitrov@rambler.ru |
|
28 |
114 |
ahitrov |
if ($m->comp_exists("/contenido/components/outputs/$type.msn")) { |
29 |
|
|
$object->{$name} = $m->comp("/contenido/components/outputs/$type.msn", SETS => $SETS, name => $name, object => $object ); |
30 |
3 |
ahitrov@rambler.ru |
|
31 |
114 |
ahitrov |
} elsif ( $prop->{type} eq 'image' ) { |
32 |
|
|
# -------------------------------------------------------------------------------------- |
33 |
|
|
# ���������� �����, �������� ������� ��������... |
34 |
54 |
ahitrov@rambler.ru |
|
35 |
114 |
ahitrov |
if ($SETS->{'_delete_image.'.$name} == 1) |
36 |
|
|
{ |
37 |
|
|
my $IMAGE = $object->get_image( $name ); |
38 |
|
|
$object->_delete_image( $IMAGE ); |
39 |
|
|
$object->$name(''); |
40 |
|
|
} else { |
41 |
|
|
my $IMAGE = $object->get_image( $name ); |
42 |
|
|
$IMAGE = ref $IMAGE ? $IMAGE : {}; |
43 |
|
|
$IMAGE = $m->comp('/contenido/components/set_image.msn', default=>$IMAGE, field=>$name, SETS=>$SETS, object=>$object, prop => $prop); |
44 |
|
|
if ( exists $IMAGE->{filename} ) { |
45 |
|
|
local $Data::Dumper::Indent = 0; |
46 |
|
|
$object->$name( Data::Dumper::Dumper($IMAGE) ); |
47 |
|
|
} |
48 |
|
|
} |
49 |
3 |
ahitrov@rambler.ru |
|
50 |
114 |
ahitrov |
} elsif ($prop->{type} =~ /^images/) { |
51 |
|
|
# -------------------------------------------------------------------------------------- |
52 |
|
|
# � ��� ��� ��� ������� - ����������� ����� �� ���� ��������... |
53 |
3 |
ahitrov@rambler.ru |
|
54 |
114 |
ahitrov |
my $IMAGES = $object->get_image( $name ); |
55 |
|
|
if (ref($IMAGES) ne 'HASH') { |
56 |
|
|
$IMAGES = {}; |
57 |
|
|
$IMAGES->{maxnumber} = 0; |
58 |
|
|
}; |
59 |
3 |
ahitrov@rambler.ru |
|
60 |
114 |
ahitrov |
# ������ ���� ����������� ��� ��������� - � ����� ��� ��, ��� ��� �����... |
61 |
|
|
foreach my $arg (keys(%{ $SETS })) |
62 |
|
|
{ |
63 |
|
|
# ��������� ��� �� �����, ��������... |
64 |
|
|
my ($partname,undef) = split(/\./,$arg); |
65 |
|
|
$partname =~ /^(.+)_(\d+)$/; |
66 |
|
|
my ($localname,$number) = ($1, $2); |
67 |
|
|
if ( ($localname eq $prop->{attr}) && ($number > 0) && ( $arg eq $localname.'_'.$number )) { |
68 |
|
|
# ���! ����� �������! |
69 |
3 |
ahitrov@rambler.ru |
|
70 |
114 |
ahitrov |
my $partname = $localname.'_'.$number; |
71 |
3 |
ahitrov@rambler.ru |
|
72 |
114 |
ahitrov |
if ($SETS->{'_delete_image.'.$partname} == 1) { |
73 |
|
|
$object->_delete_image( $IMAGES->{'image_'.$number} ); |
74 |
|
|
delete $IMAGES->{'image_'.$number}; |
75 |
|
|
} else { |
76 |
|
|
my $IMAGE = undef; |
77 |
|
|
if (exists($IMAGES->{'image_'.$number})) { |
78 |
|
|
$IMAGE = $IMAGES->{'image_'.$number}; |
79 |
|
|
}; |
80 |
|
|
$IMAGE = $m->comp('/contenido/components/set_image.msn', default=>$IMAGE, field=>$partname, SETS=>$SETS, object=>$object, prop => $prop); |
81 |
|
|
if (exists($IMAGE->{filename})) { |
82 |
3 |
ahitrov@rambler.ru |
local $Data::Dumper::Indent = 0; |
83 |
114 |
ahitrov |
$IMAGE->{number} = $number; |
84 |
|
|
$IMAGES->{'image_'.$number} = $IMAGE; |
85 |
|
|
$IMAGES->{maxnumber} = $number if ($number > $IMAGES->{maxnumber}); |
86 |
3 |
ahitrov@rambler.ru |
} |
87 |
114 |
ahitrov |
} |
88 |
|
|
} |
89 |
|
|
} |
90 |
3 |
ahitrov@rambler.ru |
|
91 |
114 |
ahitrov |
if ( scalar(keys(%{ $IMAGES })) > 0) { |
92 |
|
|
my $maxnumber = 0; |
93 |
|
|
for ( 1..100 ) { |
94 |
|
|
$maxnumber = $_ if exists $IMAGES->{"image_$_"} && $_ > $maxnumber; |
95 |
|
|
} |
96 |
|
|
$IMAGES->{maxnumber} = $maxnumber; |
97 |
|
|
local $Data::Dumper::Indent = 0; |
98 |
|
|
$object->$name( Data::Dumper::Dumper($IMAGES) ); |
99 |
|
|
} |
100 |
3 |
ahitrov@rambler.ru |
|
101 |
114 |
ahitrov |
} elsif ( $prop->{type} eq 'multimedia' ) { |
102 |
|
|
# -------------------------------------------------------------------------------------- |
103 |
|
|
# ���������� ������ ������ ����������� |
104 |
3 |
ahitrov@rambler.ru |
|
105 |
114 |
ahitrov |
if ($SETS->{'_delete_multi.'.$name} == 1) |
106 |
|
|
{ |
107 |
|
|
my $BINARY = eval ('my '.$object->{ $name }); |
108 |
|
|
Contenido::File::remove($BINARY->{"filename"}); |
109 |
|
|
$object->{$name} = ''; |
110 |
|
|
} else { |
111 |
|
|
my $MULTI = undef; |
112 |
|
|
if (length($object->{ $name }) > 8) |
113 |
|
|
{ |
114 |
|
|
$MULTI = eval ('my '.$object->{ $name }); |
115 |
|
|
if (ref($MULTI) ne 'HASH') { $MULTI = {} }; |
116 |
|
|
} |
117 |
|
|
$MULTI = $m->comp('/contenido/components/set_multi.msn', default=>$MULTI, field=>$name, SETS=>$SETS, object=>$object); |
118 |
|
|
if (exists($MULTI->{filename})) |
119 |
|
|
{ |
120 |
|
|
local $Data::Dumper::Indent = 0; |
121 |
|
|
$object->{$name} = Data::Dumper::Dumper($MULTI); |
122 |
|
|
} |
123 |
|
|
} |
124 |
3 |
ahitrov@rambler.ru |
|
125 |
114 |
ahitrov |
} elsif ( $prop->{type} eq 'multimedia_new' ) { |
126 |
|
|
# -------------------------------------------------------------------------------------- |
127 |
|
|
# ���������� ������ ������ ����������� |
128 |
3 |
ahitrov@rambler.ru |
|
129 |
114 |
ahitrov |
if ($SETS->{'_delete_multi.'.$name} == 1) |
130 |
|
|
{ |
131 |
|
|
my $BINARY = eval ('my '.$object->{ $name }); |
132 |
|
|
Contenido::File::remove($BINARY->{"filename"}); |
133 |
|
|
$object->{$name} = ''; |
134 |
|
|
} else { |
135 |
|
|
my $MULTI = undef; |
136 |
|
|
if (length($object->{ $name }) > 8) |
137 |
|
|
{ |
138 |
|
|
$MULTI = eval ('my '.$object->{ $name }); |
139 |
|
|
if (ref($MULTI) ne 'HASH') { $MULTI = {} }; |
140 |
|
|
} |
141 |
|
|
$MULTI = $m->comp('/contenido/components/set_multimedia_new.msn', default=>$MULTI, field=>$name, SETS=>$SETS, object=>$object, prop => $prop); |
142 |
|
|
if (exists($MULTI->{filename})) |
143 |
|
|
{ |
144 |
|
|
local $Data::Dumper::Indent = 0; |
145 |
|
|
$object->{$name} = Data::Dumper::Dumper($MULTI); |
146 |
|
|
} |
147 |
|
|
} |
148 |
3 |
ahitrov@rambler.ru |
|
149 |
114 |
ahitrov |
} elsif ( $prop->{type} eq 'audio' ) { |
150 |
|
|
# -------------------------------------------------------------------------------------- |
151 |
|
|
# ���������� ������ ������ ����������� |
152 |
3 |
ahitrov@rambler.ru |
|
153 |
114 |
ahitrov |
if ($SETS->{'_delete_multi.'.$name} == 1) |
154 |
|
|
{ |
155 |
|
|
my $VAR1 = undef; |
156 |
|
|
eval "\$object->{$name}"; |
157 |
|
|
my $BINARY = $VAR1; |
158 |
|
|
if (ref $BINARY) {$BINARY->remove} |
159 |
|
|
$object->{$name} = ''; |
160 |
|
|
} else { |
161 |
|
|
my $MULTI = undef; |
162 |
|
|
if (length($object->$name) > 8) |
163 |
|
|
{ |
164 |
|
|
my $VAR1 = undef; |
165 |
|
|
eval "\$object->{$name}"; |
166 |
|
|
$MULTI = $VAR1; |
167 |
|
|
unless (ref $MULTI) {$MULTI = undef}; |
168 |
|
|
} |
169 |
|
|
$MULTI = $m->comp('/contenido/components/set_audio.msn', default=>$MULTI, field=>$name, SETS=>$SETS, object=>$object, prop => $prop); |
170 |
|
|
if (exists($MULTI->{filename})) |
171 |
|
|
{ |
172 |
|
|
local $Data::Dumper::Indent = 0; |
173 |
|
|
$object->{$name} = Data::Dumper::Dumper($MULTI); |
174 |
|
|
} |
175 |
|
|
} |
176 |
3 |
ahitrov@rambler.ru |
|
177 |
114 |
ahitrov |
} else { |
178 |
|
|
$object->{$name} = $m->comp('/contenido/components/filter.msn', str => $SETS->{$name} ); |
179 |
|
|
} |
180 |
3 |
ahitrov@rambler.ru |
|
181 |
114 |
ahitrov |
} |
182 |
3 |
ahitrov@rambler.ru |
|
183 |
114 |
ahitrov |
# �� ���� - �� �������� � �������, ��� ��� ������ �� ���� ����������! |
184 |
|
|
# O-��! �-��! �-��! |
185 |
|
|
return 1; |
186 |
|
|
|
187 |
3 |
ahitrov@rambler.ru |
</%INIT> |