[interchange-cvs] interchange - heins modified 2 files

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Fri Mar 7 17:03:52 2003


User:      heins
Date:      2003-03-07 19:48:05 GMT
Modified:  lib/Vend Form.pm Interpolate.pm
Log:
* Add widget and filter to allow direct upload of a file to a database
  field. Useful for content/article bodies that you want to edit in a
  file but that are inconvenient to clip-past into a textarea.

  One new filter, "upload". Checks to see if the submitted variable
  is a file upload, if it is it reads the file and places it in the
  $CGI->{$varname}. Otherwise uses the value of the variable.

  One new widget, "filetext". This is an <input type=file> followed
  by a textarea. It shows the contents of the field in the textarea
  and you can edit it. If you want to replace it with a file upload,
  you just Browse to the file and upload it; it negates what is in
  the textarea. If no file is uploaded, the textarea pertains (I guess
  that statement is redundant).

  The type=filetext widget should always be used in combination with two
  filters, "nullselect upload".

Revision  Changes    Path
2.26      +11 -2     interchange/lib/Vend/Form.pm


rev 2.26, prev_rev 2.25
Index: Form.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Form.pm,v
retrieving revision 2.25
retrieving revision 2.26
diff -u -r2.25 -r2.26
--- Form.pm	8 Feb 2003 20:08:11 -0000	2.25
+++ Form.pm	7 Mar 2003 19:48:04 -0000	2.26
@@ -1,6 +1,6 @@
 # Vend::Form - Generate Form widgets
 # 
-# $Id: Form.pm,v 2.25 2003/02/08 20:08:11 mheins Exp $
+# $Id: Form.pm,v 2.26 2003/03/07 19:48:04 mheins Exp $
 #
 # Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -37,7 +37,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.25 $, 10);
+$VERSION = substr(q$Revision: 2.26 $, 10);
 
 @EXPORT = qw (
 	display
@@ -118,6 +118,15 @@
 		qq({EXTRA?} {EXTRA}{/EXTRA?})
 		.
 		qq(>{APPEND})
+		,
+	filetext =>
+		qq({PREPEND}<input type="file" name="{NAME}" value="{ENCODED}")
+		.
+		qq({COLS?} size="{COLS}"{/COLS?})
+		.
+		qq({EXTRA?} {EXTRA}{/EXTRA?})
+		.
+		qq(><br><textarea cols="{WIDTH}" rows="{HEIGHT}" NAME="{NAME}">{ENCODED}</textarea>{APPEND})
 		,
 	text =>
 		qq({PREPEND}<input type="text" name="{NAME}" value="{ENCODED}")



2.151     +11 -2     interchange/lib/Vend/Interpolate.pm


rev 2.151, prev_rev 2.150
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.150
retrieving revision 2.151
diff -u -r2.150 -r2.151
--- Interpolate.pm	1 Mar 2003 15:47:15 -0000	2.150
+++ Interpolate.pm	7 Mar 2003 19:48:05 -0000	2.151
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 # 
-# $Id: Interpolate.pm,v 2.150 2003/03/01 15:47:15 mheins Exp $
+# $Id: Interpolate.pm,v 2.151 2003/03/07 19:48:05 mheins Exp $
 #
 # Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -27,7 +27,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.150 $, 10);
+$VERSION = substr(q$Revision: 2.151 $, 10);
 
 @EXPORT = qw (
 
@@ -1022,6 +1022,15 @@
 					$val =~ s|\s*<P>\s*|\n|gi;
 					$val =~ s|\s*</P>\s*||gi;
 					return $val;
+				},
+	'upload' => sub {
+					my ($fn, $vn) = @_;
+					if( tag_value_extended($vn, { test => 'isfile', })) {
+						return tag_value_extended($vn, { file_contents => 1 });
+					}
+					else {
+						return $fn;
+					}
 				},
 	'namecase' => sub {
 					use locale;