Line # Revision Author
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 526 ahitrov } elsif ($prop->{type} eq 'multimedia_multi') {
150 # --------------------------------------------------------------------------------------
151 # � ��� ��� ��� ������� - ����������� ����� �� ���� ������...
152
153 my $FILES = $object->get_image( $name );
154 if ( ref($FILES) ne 'HASH' ) {
155 $FILES = {};
156 $FILES->{maxnumber} = 0;
157 };
158
159 # ������ ���� ����������� ��� ��������� - � ����� ��� ��, ��� ��� �����...
160 foreach my $arg (keys(%{ $SETS }))
161 {
162 # ��������� ��� �� �����, ��������...
163 my ($partname,undef) = split(/\./,$arg);
164 $partname =~ /^(.+)_(\d+)$/;
165 my ($localname,$number) = ($1, $2);
166 if ( ($localname eq $prop->{attr}) && ($number > 0) && ( $arg eq $localname.'_'.$number )) {
167 # ���! ����� �������!
168
169 my $partname = $localname.'_'.$number;
170
171 if ($SETS->{'_delete_multi.'.$partname} == 1) {
172 $object->_delete_binary( $FILES->{'file_'.$number} );
173 delete $FILES->{'file_'.$number};
174 } else {
175 my $MULTI = undef;
176 if (exists($FILES->{'file_'.$number})) {
177 $MULTI = $FILES->{'file_'.$number};
178 };
179 $MULTI = $m->comp('/contenido/components/set_multimedia_new.msn', default=>$MULTI, field=>$partname, SETS=>$SETS, object=>$object, prop => $prop);
180 if (exists($MULTI->{filename})) {
181 $MULTI->{number} = $number;
182 $FILES->{'file_'.$number} = $MULTI;
183 $FILES->{maxnumber} = $number if ($number > $FILES->{maxnumber});
184 }
185 }
186 }
187 }
188
189 if ( scalar(keys(%{ $FILES })) > 0) {
190 my $maxnumber = 0;
191 for ( 1..100 ) {
192 $maxnumber = $_ if exists $FILES->{"file_$_"} && $_ > $maxnumber;
193 }
194 $FILES->{maxnumber} = $maxnumber;
195 $object->$name( $object->_serialize($FILES) );
196 }
197
198 114 ahitrov } elsif ( $prop->{type} eq 'audio' ) {
199 # --------------------------------------------------------------------------------------
200 # ���������� ������ ������ �����������
201 3 ahitrov@rambler.ru
202 114 ahitrov if ($SETS->{'_delete_multi.'.$name} == 1)
203 {
204 my $VAR1 = undef;
205 eval "\$object->{$name}";
206 my $BINARY = $VAR1;
207 if (ref $BINARY) {$BINARY->remove}
208 $object->{$name} = '';
209 } else {
210 my $MULTI = undef;
211 if (length($object->$name) > 8)
212 {
213 my $VAR1 = undef;
214 eval "\$object->{$name}";
215 $MULTI = $VAR1;
216 unless (ref $MULTI) {$MULTI = undef};
217 }
218 $MULTI = $m->comp('/contenido/components/set_audio.msn', default=>$MULTI, field=>$name, SETS=>$SETS, object=>$object, prop => $prop);
219 if (exists($MULTI->{filename}))
220 {
221 local $Data::Dumper::Indent = 0;
222 $object->{$name} = Data::Dumper::Dumper($MULTI);
223 }
224 }
225 3 ahitrov@rambler.ru
226 114 ahitrov } else {
227 $object->{$name} = $m->comp('/contenido/components/filter.msn', str => $SETS->{$name} );
228 }
229 3 ahitrov@rambler.ru
230 114 ahitrov }
231 3 ahitrov@rambler.ru
232 114 ahitrov # �� ���� - �� �������� � �������, ��� ��� ������ �� ���� ����������!
233 # O-��! �-��! �-��!
234 return 1;
235
236 3 ahitrov@rambler.ru </%INIT>