# Copyright 2005-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: uploadblob.widget,v 1.5 2007-03-30 23:40:58 pajamian Exp $

CodeDef uploadblob  Widget  1
CodeDef uploadblob  Description File upload to BLOB
CodeDef uploadblob  Routine <<EOR
sub {
	# $column, $value, $record->{outboard}, $record->{width}
    my ($opt) = @_;
	my $name = $opt->{name};
	my $size = $opt->{cols} || $opt->{width};

	my $pre = $opt->{prepend} || '';
	my $app = $opt->{append} || '';
	my $out = $pre;

	if(my $n = $opt->{name_to}) {
		$out .= qq{<INPUT TYPE=hidden NAME="mv_data_file_name_to_$name" VALUE="$n">};
	}
	if(my $s = $opt->{size_to}) {
		$out .= qq{<INPUT TYPE=hidden NAME="mv_data_file_size_to_$name" VALUE="$s">};
	}
	
	$size = qq{ SIZE="$size"} if $size > 0;
    $out .= qq{<INPUT TYPE=hidden NAME="mv_data_file_field" VALUE="$name">
<INPUT TYPE=hidden NAME="mv_data_file_path" VALUE="">
<INPUT TYPE=hidden NAME="mv_data_file_oldfile" VALUE="">
<INPUT TYPE=file NAME="$name"$size>$app};
	return $out;
}
EOR

CodeDef uploadblob ExtraMeta <<EOM
{
	_order => [ qw/ name_to size_to /],
	name_to => {
		options => 'columns::',
		label => 'Field to store uploadblob file name in',
		help => 'if any -- must be in fields of table editor',
		widget => 'select',
	},
	size_to => {
		options => 'columns::',
		label => 'Field to store uploadblob size in',
		help => 'if any -- must be in fields of table editor',
		widget => 'select',
	},
}
EOM
