Revision 54
- Date:
- 2010/08/26 17:02:58
- Files:
Legend:
- Added
- Removed
- Modified
-
koi8/core/comps/contenido/components/set_properties.msn
1 1 <%ARGS> 2 2 3 $object => undef 4 $SETS => undef 3 $object => undef 4 $SETS => undef 5 5 6 6 </%ARGS> 7 7 <%INIT> 8 use Contenido::File; 8 use Contenido::File; 9 9 use vars qw($keeper $request ); 10 10 11 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 '��������'; 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 14 15 15 warn "Contenido Debug: ����� ��� �������������� ������ � ��������� ".$request->{local_codepage}."\n" if ($state->debug()); 16 16 17 18 17 my @properties = $object->structure(); 19 for (0..$#properties) 20 { 18 for (0..$#properties) { 21 19 my $prop = $properties[$_]; 22 20 my $name = $prop->{attr}; 23 21 my $type = $prop->{type}; … … 25 23 next if ($name eq 'sections'); 26 24 next if ($name eq 'id'); 27 25 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")) { 26 if ($m->comp_exists("/contenido/components/outputs/$type.msn")) { 32 27 $object->{$name} = $m->comp("/contenido/components/outputs/$type.msn", SETS => $SETS, name => $name, object => $object ); 33 } elsif ( $prop->{type} eq 'image' ) 34 { 28 29 } elsif ( $prop->{type} eq 'image' ) { 35 30 # -------------------------------------------------------------------------------------- 36 31 # ���������� �����, �������� ������� ��������... 37 32 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 } 33 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 } 48 42 $object->{$name} = ''; 49 43 } else { 50 44 my $IMAGE = undef; … … 60 54 $object->{$name} = Data::Dumper::Dumper($IMAGE); 61 55 } 62 56 } 63 } 64 elsif ($prop->{type} =~ /^images/) 65 { 57 58 } elsif ($prop->{type} =~ /^images/) { 66 59 # -------------------------------------------------------------------------------------- 67 60 # � ��� ��� ��� ������� - ����������� ����� �� ���� ��������... 68 61 … … 80 73 my $maxnumber_ = 0; 81 74 82 75 # ������ ���� ����������� ��� ��������� - � ����� ��� ��, ��� ��� �����... 83 foreach my $arg (keys(%{ $SETS })) 84 { 76 foreach my $arg (keys(%{ $SETS })) { 85 77 # ��������� ��� �� �����, ��������... 86 78 my ($partname,undef) = split(/\./,$arg); 87 79 $partname =~ /^(.+)_(\d+)$/; … … 92 84 93 85 my $partname = $localname.'_'.$number; 94 86 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 } 87 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 } 104 95 delete $IMAGES->{'image_'.$number}; 105 } 106 else 107 { 96 } else { 108 97 my $IMAGE = undef; 109 if (exists($IMAGES->{'image_'.$number})) 110 { 98 if (exists($IMAGES->{'image_'.$number})) { 111 99 $IMAGE = $IMAGES->{'image_'.$number}; 112 100 }; 113 101 $IMAGE = $m->comp('/contenido/components/set_image.msn', default=>$IMAGE, field=>$partname, SETS=>$SETS, object=>$object, prop => $prop); 114 if (exists($IMAGE->{filename})) 115 { 102 if (exists($IMAGE->{filename})) { 116 103 local $Data::Dumper::Indent = 0; 117 104 $IMAGE->{number} = $number; 118 105 $IMAGES->{'image_'.$number} = $IMAGE; … … 123 110 124 111 } 125 112 126 if ( scalar(keys(%{ $IMAGES })) > 0) 127 { 113 if ( scalar(keys(%{ $IMAGES })) > 0) { 128 114 local $Data::Dumper::Indent = 0; 129 115 $object->{$name} = Data::Dumper::Dumper($IMAGES); 130 116 } 131 117 132 } 133 elsif ( $prop->{type} eq 'multimedia' ) 134 { 118 } elsif ( $prop->{type} eq 'multimedia' ) { 135 119 # -------------------------------------------------------------------------------------- 136 120 # ���������� ������ ������ ����������� 137 121 … … 155 139 } 156 140 } 157 141 158 } 159 elsif ( $prop->{type} eq 'multimedia_new' ) 160 { 142 } elsif ( $prop->{type} eq 'multimedia_new' ) { 161 143 # -------------------------------------------------------------------------------------- 162 144 # ���������� ������ ������ ����������� 163 145 … … 181 163 } 182 164 } 183 165 184 } 185 elsif ( $prop->{type} eq 'audio' ) 186 { 166 } elsif ( $prop->{type} eq 'audio' ) { 187 167 # -------------------------------------------------------------------------------------- 188 168 # ���������� ������ ������ ����������� 189 169 190 if ($SETS->{'_delete_multi.'.$name} == 1) 191 { 192 my $VAR1 = undef; 193 eval "\$object->{$name}"; 170 if ($SETS->{'_delete_multi.'.$name} == 1) { 171 my $VAR1 = undef; 172 eval "\$object->{$name}"; 194 173 my $BINARY = $VAR1; 195 174 if (ref $BINARY) {$BINARY->remove} 196 175 $object->{$name} = ''; 197 176 } else { 198 177 my $MULTI = undef; 199 if (length($object->$name) > 8) 200 { 201 my $VAR1 = undef; 202 eval "\$object->{$name}"; 178 if (length($object->$name) > 8) { 179 my $VAR1 = undef; 180 eval "\$object->{$name}"; 203 181 $MULTI = $VAR1; 204 182 unless (ref $MULTI) {$MULTI = undef}; 205 183 } 206 184 $MULTI = $m->comp('/contenido/components/set_audio.msn', default=>$MULTI, field=>$name, SETS=>$SETS, object=>$object, prop => $prop); 207 if (exists($MULTI->{filename})) 208 { 185 if (exists($MULTI->{filename})) { 209 186 local $Data::Dumper::Indent = 0; 210 187 $object->{$name} = Data::Dumper::Dumper($MULTI); 211 188 } 212 189 } 213 190 214 } 215 else 216 { 191 } else { 217 192 $object->{$name} = $m->comp('/contenido/components/filter.msn', str => $SETS->{$name} ); 218 193 } 219 194