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