Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

73 lines (67 sloc) 2.335 kb
# Copyright 2005 Interchange Development Group (http://www.icdevgroup.org/)
# Licensed under the GNU GPL v2. See file LICENSE for details.
# $Id: imagehelper.widget,v 1.5 2005-09-11 23:46:39 docelic Exp $
CodeDef imagehelper Widget 1
CodeDef imagehelper Description Image upload
CodeDef imagehelper Routine <<EOR
sub {
my ($opt) = @_;
my $name = $opt->{name};
my $size = $opt->{cols} || $opt->{width};
my $val = $opt->{value};
my $path = $opt->{image_path} || $opt->{outboard};
my $name_from = $opt->{name_from_field} || '';
my $imagebase = $opt->{image_base} || $opt->{prepend};
Vend::Interpolate::vars_and_comments(\$path);
Vend::Interpolate::vars_and_comments(\$imagebase);
if ($imagebase ||= '') {
$imagebase =~ s/^\s+//;
$imagebase =~ s:[\s/]*$:/:;
}
my $of_widget;
if($path =~ s!/\*(?:\.([^/]+))?$!!) {
my $spec = $1;
my @files = UI::Primitive::list_images($path, $spec);
unshift(@files, "=(none)");
my $passed = join ",", map { s/,/&#44;/g; $_} @files;
my $opt = {
type => 'select',
default => $val,
attribute => 'mv_data_file_oldfile',
passed => $passed,
};
$of_widget = Vend::Interpolate::tag_accessories(
undef, undef, $opt, { 'mv_data_file_oldfile' => $val } );
}
else {
$of_widget = qq{<INPUT TYPE=hidden NAME=mv_data_file_oldfile VALUE="$val">};
}
$size = qq{ SIZE="$size"} if $size > 0;
if ($val) {
qq{<A HREF="$imagebase$path/$val">$val</A>&nbsp;<INPUT TYPE=hidden NAME=mv_data_file_field VALUE="$name"><INPUT TYPE=hidden NAME=mv_data_file_name_from VALUE="$name_from">
<INPUT TYPE=hidden NAME=mv_data_file_path VALUE="$path">$of_widget<INPUT TYPE=file NAME="$name" VALUE="$val">};
} else {
qq{<INPUT TYPE=hidden NAME=mv_data_file_field VALUE="$name"><INPUT TYPE=hidden NAME=mv_data_file_name_from VALUE="$name_from">
<INPUT TYPE=hidden NAME=mv_data_file_path VALUE="$path">$of_widget<INPUT TYPE=file NAME="$name"$size>};
}
}
EOR
CodeDef imagehelper ExtraMeta <<EOM
{
_order => [ qw/
image_path
name_from_field
/],
image_path => {
label => 'Image Path',
help => 'default is <b>images/items</b> in <i>standard catalog</i>',
widget => 'text_30',
},
name_from_field => {
label => 'Name from field',
help => 'Usually named from products SKU',
widget => 'select',
options => 'columns::',
},
}
EOM
Jump to Line
Something went wrong with that request. Please try again.