1 # Copyright 2005-2007 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: imagehelper.widget,v 1.6 2007-03-30 23:40:58 pajamian Exp $
10 CodeDef imagehelper Widget 1
11 CodeDef imagehelper Description Image upload
12 CodeDef imagehelper Routine <<EOR
16 my $name = $opt->{name};
17 my $size = $opt->{cols} || $opt->{width};
18 my $val = $opt->{value};
19 my $path = $opt->{image_path} || $opt->{outboard};
20 my $name_from = $opt->{name_from_field} || '';
21 my $imagebase = $opt->{image_base} || $opt->{prepend};
23 Vend::Interpolate::vars_and_comments(\$path);
24 Vend::Interpolate::vars_and_comments(\$imagebase);
25 if ($imagebase ||= '') {
26 $imagebase =~ s/^\s+//;
27 $imagebase =~ s:[\s/]*$:/:;
31 if($path =~ s!/\*(?:\.([^/]+))?$!!) {
33 my @files = UI::Primitive::list_images($path, $spec);
34 unshift(@files, "=(none)");
35 my $passed = join ",", map { s/,/,/g; $_} @files;
39 attribute => 'mv_data_file_oldfile',
42 $of_widget = Vend::Interpolate::tag_accessories(
43 undef, undef, $opt, { 'mv_data_file_oldfile' => $val } );
46 $of_widget = qq{<INPUT TYPE=hidden NAME=mv_data_file_oldfile VALUE="$val">};
48 $size = qq{ SIZE="$size"} if $size > 0;
50 qq{<A HREF="$imagebase$path/$val">$val</A> <INPUT TYPE=hidden NAME=mv_data_file_field VALUE="$name"><INPUT TYPE=hidden NAME=mv_data_file_name_from VALUE="$name_from">
51 <INPUT TYPE=hidden NAME=mv_data_file_path VALUE="$path">$of_widget<INPUT TYPE=file NAME="$name" VALUE="$val">};
53 qq{<INPUT TYPE=hidden NAME=mv_data_file_field VALUE="$name"><INPUT TYPE=hidden NAME=mv_data_file_name_from VALUE="$name_from">
54 <INPUT TYPE=hidden NAME=mv_data_file_path VALUE="$path">$of_widget<INPUT TYPE=file NAME="$name"$size>};
59 CodeDef imagehelper ExtraMeta <<EOM
66 label => 'Image Path',
67 help => 'default is <b>images/items</b> in <i>standard catalog</i>',
71 label => 'Name from field',
72 help => 'Usually named from products SKU',
74 options => 'columns::',