Revision 129 (by ahitrov, 2011/08/27 12:01:02) New multimedia control
<%args>

	$SETS	=> undef
	$field	=> undef
	$default=> undef
	$object	=> undef
	$prop	=> undef

</%args>
<%init>

return undef unless defined $SETS and defined $field;
#use vars qw($keeper);

# --------------------------------------------------------------------------------------
# ���������� ����� ��������

my $BINARY = $default;

if ($SETS->{$field} || $SETS->{"$field.ext_url"}) {

    my $upload;
    if ( $SETS->{$field} ) {
	$upload = $r->upload($field);
    } elsif ( $SETS->{"$field.ext_url"} && $SETS->{"$field.ext_url"} =~ /^(http|https|ftp):\/\/.*/ ) {
	$upload = $SETS->{"$field.ext_url"};
    }
    if ($upload) {

	my $BIN = $object->_store_binary( $upload, attr => $prop->{attr} );

	if ( ref $BIN eq 'HASH' && exists $BIN->{filename} ) {
		$object->_delete_binary( $default );
		%$BINARY = %$BIN;
	}

    } else {
	warn 'ERROR in incoming POST form: "'.$field.' is not file upload (value: "'.$SETS->{$field}.'")';
    }

}

# �������������� ���� - ����� ���, ��� ������...

my $pattern = "^".$field.q|\.(.*)$|;

foreach my $localfield (keys(%{ $SETS })) {
    if ($localfield =~ /$pattern/) {
	my $imagefield = $1;
	$BINARY->{$imagefield} = $m->comp("/contenido/components/filter.msn", str => $SETS->{$localfield});
    }
}

return $BINARY;

</%init>