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 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 my $maxnumber_ = 0;
74
75 # ������ ���� ����������� ��� ��������� - � ����� ��� ��, ��� ��� �����...
76 54 ahitrov@rambler.ru foreach my $arg (keys(%{ $SETS })) {
77 3 ahitrov@rambler.ru # ��������� ��� �� �����, ��������...
78 my ($partname,undef) = split(/\./,$arg);
79 $partname =~ /^(.+)_(\d+)$/;
80 my ($localname,$number) = ($1, $2);
81 if ( ($localname eq $prop->{attr}) && ($number > 0) && ( $arg eq $localname.'_'.$number ))
82 {
83 # ���! ����� �������!
84
85 my $partname = $localname.'_'.$number;
86
87 54 ahitrov@rambler.ru if ($SETS->{'_delete_image.'.$partname} == 1) {
88 Contenido::File::remove($IMAGES->{'image_'.$number}{"filename"});
89 Contenido::File::remove($IMAGES->{'image_'.$number}{"mini"}{"filename"});
90 foreach my $key (keys %{$IMAGES->{'image_'.$number}{'mini'}}) {
91 if (ref $IMAGES->{'image_'.$number}{'mini'}{$key} && ref $IMAGES->{'image_'.$number}{'mini'}{$key} eq 'HASH' && $IMAGES->{'image_'.$number}{'mini'}{$key}->{'filename'}) {
92 Contenido::File::remove($IMAGES->{'image_'.$number}{'mini'}{$key}->{'filename'}) if $IMAGES->{'image_'.$number}{'mini'}{$key}->{'filename'} ne $IMAGES->{'image_'.$number}{'mini'}{'filename'};
93 }
94 }
95 3 ahitrov@rambler.ru delete $IMAGES->{'image_'.$number};
96 54 ahitrov@rambler.ru } else {
97 3 ahitrov@rambler.ru my $IMAGE = undef;
98 54 ahitrov@rambler.ru if (exists($IMAGES->{'image_'.$number})) {
99 3 ahitrov@rambler.ru $IMAGE = $IMAGES->{'image_'.$number};
100 };
101 $IMAGE = $m->comp('/contenido/components/set_image.msn', default=>$IMAGE, field=>$partname, SETS=>$SETS, object=>$object, prop => $prop);
102 54 ahitrov@rambler.ru if (exists($IMAGE->{filename})) {
103 3 ahitrov@rambler.ru local $Data::Dumper::Indent = 0;
104 $IMAGE->{number} = $number;
105 $IMAGES->{'image_'.$number} = $IMAGE;
106 $IMAGES->{maxnumber} = $number if ($number > $IMAGES->{maxnumber});
107 }
108 }
109 }
110
111 }
112
113 54 ahitrov@rambler.ru if ( scalar(keys(%{ $IMAGES })) > 0) {
114 3 ahitrov@rambler.ru local $Data::Dumper::Indent = 0;
115 $object->{$name} = Data::Dumper::Dumper($IMAGES);
116 }
117
118 54 ahitrov@rambler.ru } elsif ( $prop->{type} eq 'multimedia' ) {
119 3 ahitrov@rambler.ru # --------------------------------------------------------------------------------------
120 # ���������� ������ ������ �����������
121
122 if ($SETS->{'_delete_multi.'.$name} == 1)
123 {
124 my $BINARY = eval ('my '.$object->{ $name });
125 Contenido::File::remove($BINARY->{"filename"});
126 $object->{$name} = '';
127 } else {
128 my $MULTI = undef;
129 if (length($object->{ $name }) > 8)
130 {
131 $MULTI = eval ('my '.$object->{ $name });
132 if (ref($MULTI) ne 'HASH') { $MULTI = {} };
133 }
134 $MULTI = $m->comp('/contenido/components/set_multi.msn', default=>$MULTI, field=>$name, SETS=>$SETS, object=>$object);
135 if (exists($MULTI->{filename}))
136 {
137 local $Data::Dumper::Indent = 0;
138 $object->{$name} = Data::Dumper::Dumper($MULTI);
139 }
140 }
141
142 54 ahitrov@rambler.ru } elsif ( $prop->{type} eq 'multimedia_new' ) {
143 3 ahitrov@rambler.ru # --------------------------------------------------------------------------------------
144 # ���������� ������ ������ �����������
145
146 if ($SETS->{'_delete_multi.'.$name} == 1)
147 {
148 my $BINARY = eval ('my '.$object->{ $name });
149 Contenido::File::remove($BINARY->{"filename"});
150 $object->{$name} = '';
151 } else {
152 my $MULTI = undef;
153 if (length($object->{ $name }) > 8)
154 {
155 $MULTI = eval ('my '.$object->{ $name });
156 if (ref($MULTI) ne 'HASH') { $MULTI = {} };
157 }
158 $MULTI = $m->comp('/contenido/components/set_multimedia_new.msn', default=>$MULTI, field=>$name, SETS=>$SETS, object=>$object, prop => $prop);
159 if (exists($MULTI->{filename}))
160 {
161 local $Data::Dumper::Indent = 0;
162 $object->{$name} = Data::Dumper::Dumper($MULTI);
163 }
164 }
165
166 54 ahitrov@rambler.ru } elsif ( $prop->{type} eq 'audio' ) {
167 3 ahitrov@rambler.ru # --------------------------------------------------------------------------------------
168 # ���������� ������ ������ �����������
169
170 54 ahitrov@rambler.ru if ($SETS->{'_delete_multi.'.$name} == 1) {
171 my $VAR1 = undef;
172 eval "\$object->{$name}";
173 3 ahitrov@rambler.ru my $BINARY = $VAR1;
174 if (ref $BINARY) {$BINARY->remove}
175 $object->{$name} = '';
176 } else {
177 my $MULTI = undef;
178 54 ahitrov@rambler.ru if (length($object->$name) > 8) {
179 my $VAR1 = undef;
180 eval "\$object->{$name}";
181 3 ahitrov@rambler.ru $MULTI = $VAR1;
182 unless (ref $MULTI) {$MULTI = undef};
183 }
184 $MULTI = $m->comp('/contenido/components/set_audio.msn', default=>$MULTI, field=>$name, SETS=>$SETS, object=>$object, prop => $prop);
185 54 ahitrov@rambler.ru if (exists($MULTI->{filename})) {
186 3 ahitrov@rambler.ru local $Data::Dumper::Indent = 0;
187 $object->{$name} = Data::Dumper::Dumper($MULTI);
188 }
189 }
190
191 54 ahitrov@rambler.ru } else {
192 3 ahitrov@rambler.ru $object->{$name} = $m->comp('/contenido/components/filter.msn', str => $SETS->{$name} );
193 }
194
195 }
196
197 # �� ���� - �� �������� � �������, ��� ��� ������ �� ���� ����������!
198 # O-��! �-��! �-��!
199 return 1;
200
201 </%INIT>