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