Line # Revision Author
1 8 ahitrov@rambler.ru <%args>
2
3 $SETS => undef
4 $field => undef
5 $default=> undef
6 $object => undef
7 $prop => undef
8
9 </%args>
10 <%init>
11
12 return undef unless defined $SETS and defined $field;
13 #use vars qw($keeper);
14
15 # --------------------------------------------------------------------------------------
16 # Добавление одной картинки
17
18 my $BINARY = $default;
19
20 128 ahitrov if ($SETS->{$field} || $SETS->{"$field.ext_url"}) {
21
22 my $upload;
23 if ( $SETS->{$field} ) {
24 $upload = $r->upload($field);
25 } elsif ( $SETS->{"$field.ext_url"} && $SETS->{"$field.ext_url"} =~ /^(http|https|ftp):\/\/.*/ ) {
26 $upload = $SETS->{"$field.ext_url"};
27 8 ahitrov@rambler.ru }
28 128 ahitrov if ($upload) {
29 8 ahitrov@rambler.ru
30 347 ahitrov my $BIN = $object->_store_binary( $upload, attr => $prop->{attr}, prop => $prop );
31 8 ahitrov@rambler.ru
32 128 ahitrov if ( ref $BIN eq 'HASH' && exists $BIN->{filename} ) {
33 $object->_delete_binary( $default );
34 %$BINARY = %$BIN;
35 }
36 8 ahitrov@rambler.ru
37 128 ahitrov } else {
38 warn 'ERROR in incoming POST form: "'.$field.' is not file upload (value: "'.$SETS->{$field}.'")';
39 8 ahitrov@rambler.ru }
40
41 }
42
43 # Дополнительные поля - берем все, что найдем...
44
45 my $pattern = "^".$field.q|\.(.*)$|;
46
47 foreach my $localfield (keys(%{ $SETS })) {
48 if ($localfield =~ /$pattern/) {
49 128 ahitrov my $imagefield = $1;
50 $BINARY->{$imagefield} = $m->comp("/contenido/components/filter.msn", str => $SETS->{$localfield});
51 8 ahitrov@rambler.ru }
52 }
53
54 return $BINARY;
55
56 </%init>