[interchange-cvs] interchange - heins modified 4 files

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Wed Oct 30 12:40:01 2002


User:      heins
Date:      2002-10-30 17:39:06 GMT
Modified:  lib/Vend Dispatch.pm Form.pm Interpolate.pm
Modified:  lib/Vend/Table Editor.pm
Log:
* Change form hrefs for [table-editor] so that it does not generate
  "process" or "ui" by default. This will allow a URL restriction of
  $Config->{VendURL}/admin/ to be effective. TODO: Change the forms in
  pages/admin to not use [process].

  The methodology is to use mv_nextpage as the form action and set
  mv_action to the action, as well as mv_ui if the user is an admin.

* Add mv_ui CGI parameter to cause the 'ui' action to be performed
  prior to process. This allows ui handling while still using mv_action.
  To be debated -- setting mv_ui by default if $Vend::admin.

* Add handling of yesno_checkbox type so that you don't need to have
  two checkboxes with one/zero and "yes/no".

* Add "default_widget" option which allows setting the default widget
  for a field if none is specified.

* Fix {SEND} handling for nph output.

* Prevent insertion of $Variable->{MV_AUTOLOAD} on every interpolate_html.

* Allow extended handling of interpolation for append/prepend html
  if $opt->{restrict_allow} is set in the table editor.

Revision  Changes    Path
1.3       +3 -3      interchange/lib/Vend/Dispatch.pm


rev 1.3, prev_rev 1.2
Index: Dispatch.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Dispatch.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Dispatch.pm	27 Sep 2002 07:16:55 -0000	1.2
+++ Dispatch.pm	30 Oct 2002 17:39:06 -0000	1.3
@@ -1,6 +1,6 @@
 # Vend::Dispatch - Handle Interchange page requests
 #
-# $Id: Dispatch.pm,v 1.2 2002/09/27 07:16:55 mheins Exp $
+# $Id: Dispatch.pm,v 1.3 2002/10/30 17:39:06 mheins Exp $
 #
 # Copyright (C) 2002 ICDEVGROUP <interchange@icdevgroup.org>
 # Copyright (C) 2002 Mike Heins <mike@perusion.net>
@@ -26,7 +26,7 @@
 package Vend::Dispatch;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.2 $, 10);
+$VERSION = substr(q$Revision: 1.3 $, 10);
 
 use POSIX qw(strftime);
 use Vend::Util;
@@ -1367,7 +1367,7 @@
 		$CGI::values{mv_todo} = $CGI::values{mv_action}
 			if ! defined $CGI::values{mv_todo}
 			and ! defined $CGI::values{mv_doit};
-		$Vend::Action = 'process';
+		$Vend::Action = $CGI->{mv_ui} ? 'ui' : 'process';
 		$CGI::values{mv_nextpage} = $Vend::FinalPath
 			if ! defined $CGI::values{mv_nextpage};
 	}



2.20      +10 -4     interchange/lib/Vend/Form.pm


rev 2.20, prev_rev 2.19
Index: Form.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Form.pm,v
retrieving revision 2.19
retrieving revision 2.20
diff -u -r2.19 -r2.20
--- Form.pm	14 Oct 2002 20:05:33 -0000	2.19
+++ Form.pm	30 Oct 2002 17:39:06 -0000	2.20
@@ -1,6 +1,6 @@
 # Vend::Form - Generate Form widgets
 # 
-# $Id: Form.pm,v 2.19 2002/10/14 20:05:33 mheins Exp $
+# $Id: Form.pm,v 2.20 2002/10/30 17:39:06 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.19 $, 10);
+$VERSION = substr(q$Revision: 2.20 $, 10);
 
 @EXPORT = qw (
 	display
@@ -684,11 +684,17 @@
 sub yesno {
 	my $opt = shift;
 	$opt->{value} = is_yes($opt->{value});
-	my @opts = (
+	my @opts;
+	my $routine = $opt->{subwidget} || \&dropdown;
+	if($opt->{variant} eq 'checkbox') {
+		@opts = [1, ' '];
+	}
+	else {
+		@opts = (
 					['', errmsg('No')],
 					['1', errmsg('Yes')],
 				);
-	my $routine = $opt->{subwidget} || \&dropdown;
+	}
 	return $routine->($opt, \@opts);
 }
 



2.123     +15 -5     interchange/lib/Vend/Interpolate.pm


rev 2.123, prev_rev 2.122
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.122
retrieving revision 2.123
diff -u -r2.122 -r2.123
--- Interpolate.pm	29 Oct 2002 17:04:32 -0000	2.122
+++ Interpolate.pm	30 Oct 2002 17:39:06 -0000	2.123
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 # 
-# $Id: Interpolate.pm,v 2.122 2002/10/29 17:04:32 jon Exp $
+# $Id: Interpolate.pm,v 2.123 2002/10/30 17:39:06 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.122 $, 10);
+$VERSION = substr(q$Revision: 2.123 $, 10);
 
 @EXPORT = qw (
 
@@ -628,10 +628,14 @@
 	my ($name, @post);
 	my ($bit, %post);
 
-	defined $::Variable->{MV_AUTOLOAD}
-		and $html =~ s/^/$::Variable->{MV_AUTOLOAD}/;
-
+	my $toplevel;
+	if(defined $Vend::PageInit and ! $Vend::PageInit) {
+		defined $::Variable->{MV_AUTOLOAD}
+			and $html =~ s/^/$::Variable->{MV_AUTOLOAD}/;
+		$toplevel = 1;
+	}
 #::logDebug("opt=" . uneval($opt));
+
 	vars_and_comments(\$html)
 		unless $opt and $opt->{onfly};
 
@@ -639,6 +643,12 @@
 	my $parse = new Vend::Parse;
 	$parse->parse($html);
 	while($parse->{_buf}) {
+		if($toplevel and $parse->{SEND}) {
+			delete $parse->{SEND};
+			substitute_image(\$parse->{OUT});
+			::response(\$parse->{OUT});
+			$parse->{OUT} = '';
+		}
 		$parse->parse('');
 	}
 	substitute_image(\$parse->{OUT});



1.17      +32 -9     interchange/lib/Vend/Table/Editor.pm


rev 1.17, prev_rev 1.16
Index: Editor.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Table/Editor.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Editor.pm	27 Oct 2002 05:09:39 -0000	1.16
+++ Editor.pm	30 Oct 2002 17:39:06 -0000	1.17
@@ -1,6 +1,6 @@
 # Vend::Table::Editor - Swiss-army-knife table editor for Interchange
 #
-# $Id: Editor.pm,v 1.16 2002/10/27 05:09:39 mheins Exp $
+# $Id: Editor.pm,v 1.17 2002/10/30 17:39:06 mheins Exp $
 #
 # Copyright (C) 2002 ICDEVGROUP <interchange@icdevgroup.org>
 # Copyright (C) 2002 Mike Heins <mike@perusion.net>
@@ -26,7 +26,7 @@
 package Vend::Table::Editor;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.16 $, 10);
+$VERSION = substr(q$Revision: 1.17 $, 10);
 
 use Vend::Util;
 use Vend::Interpolate;
@@ -331,6 +331,8 @@
 			}
 		}
 
+		$record->{type} ||= $opt->{default_widget};
+
 		$record->{name} ||= $column;
 #::logDebug("record now=" . ::uneval($record));
 
@@ -390,7 +392,17 @@
 #::logDebug("formatting prepend/append");
 		for(qw/append prepend/) {
 			next unless $record->{$_};
-			$record->{$_} = expand_values($record->{$_});
+			if($opt->{restrict_allow}) {
+				$record->{$_} = $Tag->restrict({
+									log => 'none',
+									enable => $opt->{restrict_allow},
+									disable => $opt->{restrict_deny},
+									body => $record->{$_},
+								});
+			}
+			else {
+				$record->{$_} = expand_values($record->{$_});
+			}
 			$record->{$_} = Vend::Util::resolve_links($record->{$_});
 			$record->{$_} =~ s/_UI_VALUE_/$opt->{value}/g;
 			$record->{$_} =~ /_UI_URL_VALUE_/
@@ -1096,6 +1108,7 @@
 		data_cell_style
 		data_row_class
 		data_row_style
+		default_widget
 		file_upload
 		help_cell_class
 		help_cell_style
@@ -1698,7 +1711,7 @@
 
 	my $key_message;
 	if($opt->{ui_new_item} and ! $opt->{notable}) {
-		if( ! $db->config('_Auto_number') ) {
+		if( ! $db->config('_Auto_number') and ! $db->config('AUTO_SEQUENCE') ) {
 			$db->config('AUTO_NUMBER', '000001');
 			$key = $db->autonumber($key);
 		}
@@ -1917,7 +1930,13 @@
 
 	my $url_base = $opt->{secure} ? $Vend::Cfg->{SecureURL} : $Vend::Cfg->{VendURL};
 
-	$opt->{href} = "$url_base/ui" if ! $opt->{href};
+	if(! $opt->{href}) {
+		$opt->{href} = $opt->{mv_nextpage};
+		$opt->{hidden}{mv_ui} = 1
+			if $Vend::admin and ! defined $opt->{hidden}{mv_ui};
+		$opt->{hidden}{mv_action} = $opt->{action};
+	}
+
 	$opt->{href} = "$url_base/$opt->{href}"
 		if $opt->{href} !~ m{^(https?:|)/};
 
@@ -1935,6 +1954,7 @@
 
 	my $restrict_begin;
 	my $restrict_end;
+
 	if($opt->{reparse} and ! $opt->{promiscuous}) {
 		$restrict_begin = qq{[restrict allow="$opt->{restrict_allow}"]};
 		$restrict_end = '[/restrict]';
@@ -2711,7 +2731,6 @@
 				unless $do and ! $opt->{mailto};
 		}
 
-		my $type;
 		my $overridden;
 
 		$currval = $data->{$col} if defined $data->{$col};
@@ -2783,7 +2802,8 @@
 		$namecol = $col unless $namecol;
 
 #::logDebug("display_only=$do col=$c");
-		$type = $widget->{$c} = 'value' if $do and ! ($opt->{wizard} || $opt->{mailto});
+		$widget->{$c} = 'value'
+			if $do and ! ($opt->{wizard} || $opt->{mailto});
 
 		if (! length $currval and defined $default->{$c}) {
 			$currval = $default->{$c};
@@ -2878,7 +2898,7 @@
 			}
 		}
 
-#::logDebug("col=$c currval=$currval widget=$widget->{$c} label=$label->{$c} (type=$type)");
+#::logDebug("col=$c currval=$currval widget=$widget->{$c} label=$label->{$c}");
 		my $display = display($t, $c, $key, {
 							append				=> $append->{$c},
 							applylocale			=> 1,
@@ -2886,6 +2906,7 @@
 							column				=> $c,
 							db					=> $database->{$c},
 							default				=> $currval,
+							default_widget		=> $opt->{default_widget},
 							extra				=> $extra->{$c},
 							fallback			=> 1,
 							field				=> $field->{$c},
@@ -2910,9 +2931,10 @@
 							pre_filter			=> $pre_filter->{$c},
 							prepend				=> $prepend->{$c},
 							return_hash			=> 1,
+							restrict_allow      => $opt->{restrict_allow},
 							specific			=> $opt->{ui_meta_specific},
 							table				=> $t,
-							type				=> $widget->{$c} || $type,
+							type				=> $widget->{$c},
 							ui_no_meta_display	=> $opt->{ui_no_meta_display},
 							width				=> $width->{$c},
 						});
@@ -2991,6 +3013,7 @@
 	$::Scratch->{mv_data_enable} = '';
 	if($opt->{auto_secure}) {
 		$::Scratch->{mv_data_enable} .= "$table:" . join(",", @data_enable) . ':';
+		$::Scratch->{mv_data_enable} .=  $opt->{item_id};
 		$::Scratch->{mv_data_enable_key} = $opt->{item_id};
 	}
 	if(@ext_enable) {