[interchange-cvs] interchange - heins modified 5 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Thu Jun 3 02:31:34 EDT 2004
User: heins
Date: 2004-06-03 06:31:21 GMT
Modified: lib/Vend Data.pm
Modified: dist/lib/UI/pages/admin meta_editor.html
Modified: dist/standard/products mv_metadata.asc variable.txt
Added: code/Widget uploadblob.widget
Log:
* Add ability for Vend::Data::update_data to store filename
and file size info in one upload. Adds the variable
definitions:
mv_data_file_name_to_$name
mv_data_file_size_to_$name
For instance, if you do:
<INPUT TYPE=hidden NAME="mv_data_file_name_to_body" VALUE="filename">
<INPUT TYPE=hidden NAME="mv_data_file_size_to_body" VALUE="size">
<INPUT TYPE=hidden NAME="mv_data_file_field" VALUE="body">
<INPUT TYPE=file NAME="body">
the uploaded file would be stored to the "body" field, its
name to "filename", and its size to "size".
Size is a simple integer with all its implied limits. In
actual practice HTTP server timeouts and browser file upload
limits will ensure the value is large enough.
* Add new uploadblob widget with core and meta-editor support.
If you have a BLOB field and want to upload files to it, select
the "uploadblob=File upload to BLOB" widget. It will present
a file upload widget, and provide the proper fields to do the
upload.
If you select the extended.size_to = <fieldname> option in
the meta editor, the size of the uploaded file will be stored
to <fieldname>. Ditto for extended.name_to, which stores the
file name (minus prepending path) to <fieldname>.
For example, you might do:
[display
type=uploadblob
name=body
size_to=size
name_to=filename
]
This will produce:
<INPUT TYPE=hidden NAME="mv_data_file_name_to_body" VALUE="filename">
<INPUT TYPE=hidden NAME="mv_data_file_size_to_body" VALUE="size">
<INPUT TYPE=hidden NAME="mv_data_file_field" VALUE="body">
<INPUT TYPE=file NAME="body">
* Add ability to define your widget types for display in the meta editor
in the Variable UI_WIDGET_TYPES. Includes metadata formatting for
the Preferences editor.
Revision Changes Path
2.39 +19 -12 interchange/lib/Vend/Data.pm
rev 2.39, prev_rev 2.38
Index: Data.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Data.pm,v
retrieving revision 2.38
retrieving revision 2.39
diff -u -r2.38 -r2.39
--- Data.pm 11 Apr 2004 16:34:50 -0000 2.38
+++ Data.pm 3 Jun 2004 06:31:18 -0000 2.39
@@ -1,6 +1,6 @@
# Vend::Data - Interchange databases
#
-# $Id: Data.pm,v 2.38 2004/04/11 16:34:50 mheins Exp $
+# $Id: Data.pm,v 2.39 2004/06/03 06:31:18 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -1983,20 +1983,21 @@
}
for (my $i = 0; $i < @file_fields; $i++) {
- unless (length($data{$file_fields[$i]}->[0])) {
+ my $nm = $file_fields[$i];
+ unless (length($data{$nm}->[0])) {
# no need for a file update
- $data{$file_fields[$i]}->[0] = $file_oldfiles[$i];
+ $data{$nm}->[0] = $file_oldfiles[$i];
next;
}
# remove path components
- $data{$file_fields[$i]}->[0] =~ s:.*/::;
- $data{$file_fields[$i]}->[0] =~ s:.*\\::;
+ $data{$nm}->[0] =~ s:.*/::;
+ $data{$nm}->[0] =~ s:.*\\::;
if (length ($file_paths[$i])) {
# real file upload
- $outfile = join('/', $file_paths[$i], $data{$file_fields[$i]}->[0]);
-#::logDebug("file upload: field=$file_fields[$i] path=$file_paths[$i] outfile=$outfile");
+ $outfile = join('/', $file_paths[$i], $data{$nm}->[0]);
+#::logDebug("file upload: field=$nm path=$file_paths[$i] outfile=$outfile");
my $ok;
if (-f $outfile) {
eval {
@@ -2018,17 +2019,17 @@
}
my $err;
Vend::Interpolate::tag_value_extended(
- $file_fields[$i],
+ $nm,
{
test => 'isfile'
}
)
or do {
- logError("%s is not a file.", $data{$file_fields[$i]}->[0]);
+ logError("%s is not a file.", $data{$nm}->[0]);
next;
};
Vend::Interpolate::tag_value_extended(
- $file_fields[$i],
+ $nm,
{
outfile => $outfile,
umask => $::Scratch->{mv_create_umask} || '022',
@@ -2043,9 +2044,15 @@
}
else {
# preparing to dump file contents into database column
- $data{$file_fields[$i]}->[0]
- = Vend::Interpolate::tag_value_extended ($file_fields[$i],
+ if(my $nfield = $CGI::values{"mv_data_file_name_to_$nm"}) {
+ $data{$nfield}->[0] = $data{$nm}->[0];
+ }
+ $data{$nm}->[0]
+ = Vend::Interpolate::tag_value_extended ($nm,
{file_contents => 1});
+ if(my $sfield = $CGI::values{"mv_data_file_size_to_$nm"}) {
+ $data{$sfield}->[0] = length $data{$nm}->[0];
+ }
}
}
}
1.1 interchange/code/Widget/uploadblob.widget
rev 1.1, prev_rev 1.0
Index: uploadblob.widget
===================================================================
CodeDef uploadblob Widget 1
CodeDef uploadblob Routine <<EOR
sub {
# $column, $value, $record->{outboard}, $record->{width}
my ($opt) = @_;
my $name = $opt->{name};
my $size = $opt->{cols} || $opt->{width};
my $out = '';
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=file NAME="$name"$size>};
return $out;
}
EOR
2.12 +24 -1 interchange/dist/lib/UI/pages/admin/meta_editor.html
rev 2.12, prev_rev 2.11
Index: meta_editor.html
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/pages/admin/meta_editor.html,v
retrieving revision 2.11
retrieving revision 2.12
diff -u -r2.11 -r2.12
--- meta_editor.html 9 Apr 2004 03:30:29 -0000 2.11
+++ meta_editor.html 3 Jun 2004 06:31:19 -0000 2.12
@@ -74,6 +74,7 @@
if($sneak_type) {
$extra_meta = $Tag->meta_record("_widget::$sneak_type", undef, undef, 1);
}
+
%me_opt = (
ui_data_fields => qq{
=Typical
@@ -124,6 +125,11 @@
extended.data_cell_class
extended.data_cell_style
+ =File Upload
+
+ extended.name_to
+ extended.size_to
+
=Advanced
outboard
@@ -135,6 +141,9 @@
options => {
'extended.ui_sort_option' => qq{=--default--,f=Case insensitive, fr=Case insensitive/Reverse, n=Numeric, nr=Reverse Numeric},
+ 'extended.size_to' => qq{columns::$m_table},
+ 'extended.name_to' => qq{columns::$m_table},
+ 'field' => qq{columns::$m_table},
},
filter => {
@@ -164,9 +173,13 @@
'extended.data_row_class_even' => 'Data row CSS class, even numbers',
'extended.data_cell_class' => 'Data cell CSS class',
'extended.data_cell_style' => 'Data cell CSS style',
+ 'extended.lookup_query' => 'SQL for options',
+ 'extended.lookup_merge' => 'SQL for options merge',
'extended.maxlength' => 'Maxlength',
'extended.check' => 'Profile check',
'extended.blank_default' => 'Default value',
+ 'extended.size_to' => 'Field to store uploadblob size in',
+ 'extended.name_to' => 'Field to store uploadblob file name in',
},
help => {
'extended.fs_data_calc' => 'Current record passed as $item',
@@ -174,11 +187,15 @@
'extended.maxlength' => 'For text widget (HTML maxlength=NN)',
'extended.blank_default' => 'Applies only when empty',
'extended.check' => 'Standard IC mv_profile checks -- required, postcode, etc.',
+ 'extended.size_to' => 'if any -- must be in fields of table editor',
+ 'extended.name_to' => 'if any -- must be in fields of table editor',
},
widget => {
extended => "textarea_5_50",
'extended.ui_more_alpha' => 'yesno',
'extended.ui_sort_option' => 'select',
+ 'extended.size_to' => 'select',
+ 'extended.name_to' => 'select',
'extended.fs_no_group' => 'yesno',
'extended.fs_display_filter' => 'text_50',
'extended.fs_data_calc' => 'textarea_4_70',
@@ -187,6 +204,12 @@
},
);
+ if($Variable->{UI_WIDGET_TYPES}) {
+#Debug("Found UI_WIDGET_TYPES");
+ $me_opt{options}{type} = $Variable->{UI_WIDGET_TYPES};
+#Debug("me_opt{options}=" . uneval($me_opt{options}));
+ }
+
if($extra_meta) {
#Debug("Found extra_meta=" . uneval($extra_meta));
my $extra_fields = '';
@@ -255,4 +278,4 @@
][/table-editor]
@_UI_STD_FOOTER_@
-<!-- page: @@MV_PAGE@@ version: $Revision: 2.11 $ -->
+<!-- page: @@MV_PAGE@@ version: $Revision: 2.12 $ -->
1.3 +3 -2 interchange/dist/standard/products/mv_metadata.asc
rev 1.3, prev_rev 1.2
Index: mv_metadata.asc
===================================================================
RCS file: /var/cvs/interchange/dist/standard/products/mv_metadata.asc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mv_metadata.asc 9 May 2004 20:56:20 -0000 1.2
+++ mv_metadata.asc 3 Jun 2004 06:31:20 -0000 1.3
@@ -109,7 +109,7 @@
mv_metadata::options textarea 50 8 Options Options for SELECT/COMBO types (if lookup, prepended). Entered in the
interchange option format:<P>
<blockquote>
value=label*</blockquote>One per line. line2options options2line
mv_metadata::outboard text 30 Directory Select directory for image listing widget.
mv_metadata::prepend textarea 60 5 Prepend HTML <SMALL>HTML to be prepended to the widget.
Will substitute in the macros _UI_TABLE_, _UI_COLUMN_,
_UI_KEY, and _UI_VALUE_, and will resolve relative links
with absolute links.</SMALL>
-mv_metadata::type select text=Text entry*,
textarea=Textarea,
select=Select box,
yesno=Yes/No (Yes=1),
noyes=No/Yes (No=1),
yesno radio=Yes/No (radio),
noyes radio=No/Yes (radio),
multiple=Multiple Select,
combo=Combo Select,
reverse_combo=Reverse Combo,
move_combo=Combo move,
display=Text of option,
hidden_text=Hidden (show text),
radio=Radio box,
radio_nbsp=Radio (nbsp),
checkbox=Checkbox,
check_nbsp=Checkbox (nbsp),
imagedir=Image listing,
imagehelper=Image upload,
date=Date selector,
value=Value,
option_format=Option formatter,
show=Show all options,gpg_keys=GPG key selector Widget type Select the basic display type for the field.
+mv_metadata::type select text=Text entry*,
textarea=Textarea,
select=Select box,
yesno=Yes/No (Yes=1),
noyes=No/Yes (No=1),
yesno radio=Yes/No (radio),
noyes radio=No/Yes (radio),
multiple=Multiple Select,
combo=Combo Select,
reverse_combo=Reverse Combo,
move_combo=Combo move,
display=Text of option,
hidden_text=Hidden (show text),
radio=Radio box,
radio_nbsp=Radio (nbsp),
checkbox=Checkbox,
check_nbsp=Checkbox (nbsp),
imagedir=Image listing,
imagehelper=Image upload,
uploadblob=File upload to BLOB,
date=Date selector,
value=Value,
option_format=Option formatter,
show=Show all options,gpg_keys=GPG key selector Widget type Select the basic display type for the field.
mv_metadata::width text 4 Width SIZE for TEXT<BR>
COLS for TEXTAREA<BR>
Label limit for SELECT digits
optadd::mv_metadata::options textarea 20 8 Options Options in the format:<P>
<blockquote>
value=label*</blockquote>
option_format
options table code
sku
o_group
o_master
description(30)
price Product Options options
@@ -123,7 +123,7 @@
options::o_matrix select =Non-matrix,!=Matrix options Matrix options Matrix options allow you to maintain multiple option sets with
inventory on each combination.
options::o_modular select =Not modular,Modular options Modular options Modular options allow you to attach multiple SKUs to the same item,
possibly with attached options of their own. Very complex but you can do
most anything.
options::o_value option_format 20 5 Possible Values In Interchange option format:<PRE>
VALUE1=Label 1,
VALUE2=Label 2*
</PRE>(* = default selection) option_format
-options::o_widget select text=Text entry*,
textarea=Textarea,
select=Select box,
yesno=Yes/No (Yes=1),
noyes=No/Yes (No=1),
yesno radio=Yes/No (radio),
noyes radio=No/Yes (radio),
multiple=Multiple Select,
combo=Combo Select,
reverse_combo=Reverse Combo,
move_combo=Combo move,
display=Text of option,
hidden_text=Hidden (show text),
radio=Radio box,
radio_nbsp=Radio (nbsp),
checkbox=Checkbox,
check_nbsp=Checkbox (nbsp),
imagedir=Image listing,
imagehelper=Image upload,
date=Date selector,
value=Value,
option_format=Option formatter,
show=Show all options Widget type Select the basic display type for the field.
+options::o_widget select text=Text entry*,
textarea=Textarea,
select=Select box,
yesno=Yes/No (Yes=1),
noyes=No/Yes (No=1),
yesno radio=Yes/No (radio),
noyes radio=No/Yes (radio),
multiple=Multiple Select,
combo=Combo Select,
reverse_combo=Reverse Combo,
move_combo=Combo move,
display=Text of option,
hidden_text=Hidden (show text),
radio=Radio box,
radio_nbsp=Radio (nbsp),
checkbox=Checkbox,
check_nbsp=Checkbox (nbsp),
imagedir=Image listing,
imagehelper=Image upload,
uploadblob=File upload to BLOB,
date=Date selector,
value=Value,
option_format=Option formatter,
show=Show all options Widget type Select the basic display type for the field.
options::o_width text 4 Width
options::price text 12 Price Price data, either option=N.NN or
a number, depending on matrix settings.
options::sku text 20 Associated item
@@ -373,6 +373,7 @@
variable::Variable::UI_ITEM_EXPUNGE text 60 Item expunge tables The tables that should have the SKU removed when you DELETE ITEM from the items menu.
variable::Variable::UI_META_LINK select 0=No, 1=Yes Meta edit links Determines whether enabled by default. They can be turned on in Preferences.
variable::Variable::UI_SECURE yesno Determines whether to force UI into secure mode or not.
+variable::Variable::UI_WIDGET_TYPES textarea 40 40 Widget types for display in meta editor, needs to be in IC options format, i.e.
<blockquote>
VALUE=LABEL*
</blockquote>
one per line.
line2options options2line {}
variable::code text Variable name
variable::pref_group combo 20 Preferences area pref_group nullselect
variant::inventory::quantity text 8 On hand Inventory of this variant.
1.2 +1 -0 interchange/dist/standard/products/variable.txt
rev 1.2, prev_rev 1.1
Index: variable.txt
===================================================================
RCS file: /var/cvs/interchange/dist/standard/products/variable.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- variable.txt 25 Apr 2004 17:07:52 -0000 1.1
+++ variable.txt 3 Jun 2004 06:31:20 -0000 1.2
@@ -92,6 +92,7 @@
UI_SECURE Admin Control
UI_TEMPLATE_DIR templates Directories and Paths
UI_TRAFFIC_STATS Directories and Paths
+UI_WIDGET_TYPES Admin Control
UPS_COUNTRY_FIELD country Shipping
UPS_ORIGIN 45056 Shipping
UPS_POSTCODE_FIELD zip Shipping
More information about the interchange-cvs
mailing list