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 |
|
|
|
11 |
|
|
<%init> |
12 |
|
|
use IO::File; |
13 |
|
|
use Data::Dumper; |
14 |
|
|
|
15 |
|
|
return undef unless defined $SETS and defined $field; |
16 |
|
|
|
17 |
|
|
# -------------------------------------------------------------------------------------- |
18 |
|
|
# ���������� ����� �������� |
19 |
|
|
|
20 |
|
|
my $IMAGE = $default; |
21 |
|
|
|
22 |
121 |
ahitrov |
if ($SETS->{$field} || $SETS->{"$field.ext_url"}) { |
23 |
3 |
ahitrov@rambler.ru |
|
24 |
121 |
ahitrov |
my $upload; |
25 |
|
|
if ( $SETS->{$field} ) { |
26 |
|
|
$upload = $r->upload($field); |
27 |
|
|
} elsif ( $SETS->{"$field.ext_url"} && $SETS->{"$field.ext_url"} =~ /^(http|https|ftp):\/\/.*/ ) { |
28 |
|
|
$upload = $SETS->{"$field.ext_url"}; |
29 |
|
|
} |
30 |
3 |
ahitrov@rambler.ru |
if ($upload) { |
31 |
48 |
ahitrov@rambler.ru |
|
32 |
114 |
ahitrov |
my $IMG = $object->_store_image( $upload, attr => $prop->{attr} ); |
33 |
48 |
ahitrov@rambler.ru |
|
34 |
114 |
ahitrov |
if ( ref $IMG eq 'HASH' && exists $IMG->{filename} ) { |
35 |
|
|
$object->_delete_image( $default ); |
36 |
|
|
%$IMAGE = %$IMG; |
37 |
|
|
} |
38 |
48 |
ahitrov@rambler.ru |
|
39 |
3 |
ahitrov@rambler.ru |
} else { |
40 |
114 |
ahitrov |
warn 'ERROR in incoming POST form: "'.$field.' is not file upload (value: "'.$SETS->{$field}.'")'; |
41 |
3 |
ahitrov@rambler.ru |
} |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
# �������������� ���� - ����� ���, ��� ������... |
45 |
|
|
|
46 |
|
|
my $pattern = "^".$field.q|\.(.*)$|; |
47 |
|
|
|
48 |
|
|
foreach my $localfield (keys(%{ $SETS })) { |
49 |
|
|
if ($localfield =~ /$pattern/) { |
50 |
114 |
ahitrov |
my $imagefield = $1; |
51 |
|
|
$IMAGE->{$imagefield} = $m->comp("/contenido/components/filter.msn", str => $SETS->{$localfield}); |
52 |
3 |
ahitrov@rambler.ru |
} |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
return $IMAGE; |
56 |
114 |
ahitrov |
|
57 |
3 |
ahitrov@rambler.ru |
</%init> |