Line # Revision Author
1 3 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 129 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 3 ahitrov@rambler.ru }
28 129 ahitrov if ($upload) {
29 3 ahitrov@rambler.ru
30 129 ahitrov my $BIN = $object->_store_binary( $upload, attr => $prop->{attr} );
31 3 ahitrov@rambler.ru
32 129 ahitrov if ( ref $BIN eq 'HASH' && exists $BIN->{filename} ) {
33 $object->_delete_binary( $default );
34 %$BINARY = %$BIN;
35 }
36 3 ahitrov@rambler.ru
37 129 ahitrov } else {
38 warn 'ERROR in incoming POST form: "'.$field.' is not file upload (value: "'.$SETS->{$field}.'")';
39 3 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 129 ahitrov my $imagefield = $1;
50 $BINARY->{$imagefield} = $m->comp("/contenido/components/filter.msn", str => $SETS->{$localfield});
51 3 ahitrov@rambler.ru }
52 }
53
54 return $BINARY;
55
56 </%init>