[interchange-cvs] interchange - heins modified lib/Vend/Table/Editor.pm

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Fri Sep 20 12:58:00 2002


User:      heins
Date:      2002-09-20 16:57:15 GMT
Modified:  lib/Vend/Table Editor.pm
Log:
* Fix problems with init and multiple table editors in a page.

* Break out options resolution to a subroutine.

Revision  Changes    Path
1.3       +313 -233  interchange/lib/Vend/Table/Editor.pm


rev 1.3, prev_rev 1.2
Index: Editor.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/lib/Vend/Table/Editor.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Editor.pm	19 Sep 2002 17:52:34 -0000	1.2
+++ Editor.pm	20 Sep 2002 16:57:15 -0000	1.3
@@ -1,6 +1,6 @@
 # Vend::Table::Editor - Swiss-army-knife table editor for Interchange
 #
-# $Id: Editor.pm,v 1.2 2002/09/19 17:52:34 mheins Exp $
+# $Id: Editor.pm,v 1.3 2002/09/20 16:57:15 mheins Exp $
 #
 # Copyright (C) 2002 ICDEVGROUP <interchange@icdevgroup.org>
 # Copyright (C) 2002 Mike Heins <mike@perusion.net>
@@ -26,11 +26,12 @@
 package Vend::Table::Editor;
=20
 use vars qw($VERSION);
-$VERSION =3D substr(q$Revision: 1.2 $, 10);
+$VERSION =3D substr(q$Revision: 1.3 $, 10);
=20
 use Vend::Util;
 use Vend::Interpolate;
 use Vend::Data;
+use strict;
=20
 =3Dhead1 NAME
=20
@@ -706,7 +707,7 @@
 <DIV id=3D"${id}panel$i"
 		class=3D"${id}panel"
 		style=3D"
-			background-color: $c;=20
+			background-color: $colors[$i];=20
 			z-index:$zi
 		">
 $opt->{panel_prepend}
@@ -718,7 +719,7 @@
 	id=3D"${id}tab$i"
 	class=3D"${id}tab"
 	style=3D"
-		background-color: $c;=20
+		background-color: $colors[$i];=20
 		cursor: pointer;
 		left: ${left}px;
 		top: ${top}px;
@@ -733,7 +734,7 @@
 					+ $opt->{tab_vert_offset} - 2;
 		$s2 .=3D <<EOF;
 <LAYER
-	bgcolor=3D"$c"
+	bgcolor=3D"$colors[$i]"
 	style=3D"$opt->{layer_tab_style}"
 	width=3D"$opt->{tab_width}"
 	height=3D"$lheight"
@@ -747,7 +748,7 @@
 $tit->[$i]
 </LAYER>
 <LAYER
-	bgcolor=3D"$c"
+	bgcolor=3D"$colors[$i]"
 	style=3D"$opt->{layer_panel_style}"
 	width=3D"$opt->{panel_width}"
 	height=3D"$opt->{panel_height}"
@@ -875,21 +876,71 @@
 	@titles =3D ();
 	%outhash =3D ();
 	%alias =3D ();
-	$tab_number =3D $tcount_all =3D 0;
+	$tcount_all =3D 0;
 }
=20
-sub editor {
+my %o_default_length =3D (
+=09
+);
=20
-	my ($table, $key, $opt, $template) =3D @_;
-show_times("begin table editor call item_id=3D$key") if $Global::ShowTimes;
+my %o_default_var =3D (qw/
+	color_fail			UI_CONTRAST
+	color_success		UI_C_SUCCESS
+/);
+
+my %o_default_defined =3D (
+	mv_update_empty		=3D> 1,
+	restrict_allow		=3D> 'page area',
+);
=20
-	use vars qw/$Tag/;
+my %o_default =3D (
+	action				=3D> 'set',
+	wizard_next			=3D> 'return',
+	wizard_cancel		=3D> 'back',
+	across				=3D> 1,
+	color_success		=3D> '#00FF00',
+	color_fail			=3D> '#FF0000',
+	table_width			=3D> '60%',
+	left_width			=3D> '30%',
+);
+
+# Build maps for ui_te_* option pass
+my @cgi_opts =3D qw/
+        append check database default extra field filter height help
+        help_url lookup options outboard override passed pre_filter
+        prepend widget width
+/;
=20
+my @hmap;
+
+for(@cgi_opts) {
+	push @hmap, [ qr/ui_te_$_:/, $_ ];
+}
+
+sub resolve_options {
+	my ($opt, $CGI) =3D @_;
+
+	# This may be passed by the caller, but is normally from the form
+	# or URL
+	$CGI ||=3D \%CGI::values;
+
+	my $table	=3D $opt->{mv_data_table};
+	my $key		=3D $opt->{item_id};
+
+	$table =3D $CGI->{mv_data_table}
+		if ! $table and $opt->{cgi} and $CGI->{mv_data_table};
+
+	$opt->{table} =3D $opt->{mv_data_table} =3D $table;
+
+	# First we see if something has created a big options munge
+	# for us
 	if(ref($opt->{all_opts}) eq 'HASH') {
+#Debug("all_opts being brought in...");
 		my $o =3D $opt->{all_opts};
 		for (keys %$o ) {
 			$opt->{$_} =3D $o->{$_};
 		}
+#Debug("options now=3D" . ::uneval($opt));
 	}
 	elsif ($opt->{all_opts}) {
 		logError("%s: improper option %s, must be %s, was %s.",
@@ -899,18 +950,11 @@
 					ref $opt->{all_opts},
 					);
 	}
-#Debug("options now=3D" . ::uneval($opt));
=20
-	my @messages;
-	my @errors;
-
-	$table =3D $CGI->{mv_data_table}
-		if ! $table and $opt->{cgi} and $CGI->{mv_data_table};
-
-	### Need cleanup. Probably should bring in, along with
-	### display tag.
 	my $tmeta =3D meta_record($table, $opt->{ui_meta_view}) || {};
=20
+	# This section checks the passed options and converts them from
+	# strings to refs if necessary
 	FORMATS: {
 		no strict 'refs';
 		my $ref;
@@ -951,45 +995,72 @@
 		}
 	}
=20
-	my $rowcount =3D 0;
-	my $action =3D $opt->{action} || 'set';
-	my $wizard_next   =3D $opt->{wizard_next}   || 'return';
-	my $wizard_cancel =3D $opt->{wizard_cancel} || 'back';
-	my $rowdiv =3D $opt->{across} || 1;
-	my $span =3D $rowdiv * 2;
-	my $oddspan =3D $span - 1;
-	my $def =3D $opt->{default_ref} || $::Values;
+	my @mapdirect =3D qw/
+		mv_data_decode
+		mv_data_table
+		mv_blob_field
+		mv_blob_nick
+		mv_blob_pointer
+		mv_blob_label
+		mv_blob_title
+		left_width
+		table_width
+		tabbed
+		tab_bgcolor_template
+		tab_height
+		tab_width
+		tab_cellspacing
+		tab_cellpadding
+		panel_height
+		panel_width
+		panel_id
+		file_upload
+		tab_horiz_offset
+		tab_vert_offset
+		ui_break_before
+		ui_break_before_label
+		ui_data_fields
+		ui_data_fields_all
+		ui_data_key_name
+		ui_display_only
+		ui_hide_key
+		ui_meta_specific
+		ui_meta_view
+		ui_nextpage
+		ui_new_item
+		ui_delete_box
+		mv_update_empty
+	/;
=20
-	my $check       =3D $opt->{check};
-	my $default     =3D $opt->{default};
-	my $error       =3D $opt->{error};
-	my $extra       =3D $opt->{extra};
-	my $filter      =3D $opt->{filter};
-	my $height      =3D $opt->{height};
-	my $help        =3D $opt->{help};
-	my $help_url    =3D $opt->{help_url};
-	my $label       =3D $opt->{label};
-	my $override    =3D $opt->{override};
-	my $pre_filter  =3D $opt->{pre_filter};
-	my $passed      =3D $opt->{passed};
-	my $options     =3D $opt->{options};
-	my $outboard    =3D $opt->{outboard};
-	my $prepend     =3D $opt->{prepend};
-	my $append      =3D $opt->{append};
-	my $lookup      =3D $opt->{lookup};
-	my $lookup_query =3D $opt->{lookup_query};
-	my $database    =3D $opt->{database};
-	my $field       =3D $opt->{field};
-	my $widget      =3D $opt->{widget};
-	my $width       =3D $opt->{width};
-	my $pmeta       =3D $opt->{meta};
+	for(grep defined $tmeta->{$_}, @mapdirect) {
+		$opt->{$_} ||=3D $tmeta->{$_};
+	}
=20
+	if($opt->{cgi}) {
+		unshift @mapdirect, qw/
+				item_id
+				item_id_left
+				ui_clone_id
+				ui_clone_tables
+				ui_sequence_edit
+		/;
+		for(@mapdirect) {
+			next if ! defined $CGI->{$_};
+			$opt->{$_} =3D $CGI->{$_};
+		}
+		my @cgi =3D keys %{$CGI};
+		foreach my $row (@hmap) {
+			my @keys =3D grep $_ =3D~ $row->[0], @cgi;
+			for(@keys) {
+				/^ui_\w+:(\S+)/
+					and $row->[1]->{$1} =3D $CGI->{$_};
+			}
+		}
=20
-	#my $blabel      =3D $opt->{begin_label} || '<b>';
-	#my $elabel      =3D $opt->{end_label} || '</b>';
-	my $blabel      ;
-	my $elabel      ;
-	my $mlabel =3D '';
+		### Why these here?
+		#$table =3D $opt->{mv_data_table};
+		#$key =3D $opt->{item_id};
+	}
=20
 	if($opt->{wizard}) {
 		$opt->{noexport} =3D 1;
@@ -1006,6 +1077,165 @@
 		$opt->{$_} =3D errmsg($opt->{$_});
 	}
=20
+	if (! $opt->{inner_table_width}) {
+		if($opt->{table_width} =3D~ /%/) {
+			$opt->{inner_table_width} =3D '100%';
+		}
+		elsif ($opt->{table_width} =3D~ /^\d+$/) {
+			$opt->{inner_table_width} =3D $opt->{table_width} - 2;
+		}
+		else {
+			$opt->{inner_table_width} =3D $opt->{table_width};
+		}
+	}
+
+	if($opt->{wizard} || $opt->{notable} and ! $opt->{table}) {
+		$opt->{table} =3D 'mv_null';
+		$Vend::Database{mv_null} =3D=20
+			bless [
+					{},
+					undef,
+					[ 'code', 'value' ],
+					[ 'code' =3D> 0, 'value' =3D> 1 ],
+					0,
+					{ },
+					], 'Vend::Table::InMemory';
+	}
+
+	# resolve form defaults
+
+	while( my ($k, $v) =3D each %o_default_var) {
+		$opt->{$k} ||=3D $::Variable->{$v};
+	}
+
+	while( my ($k, $v) =3D each %o_default_length) {
+		$opt->{$k} =3D $v if ! length($opt->{$k});
+	}
+
+	while( my ($k, $v) =3D each %o_default_defined) {
+		$opt->{$k} =3D $v if ! defined($opt->{$k});
+	}
+
+	while( my ($k, $v) =3D each %o_default) {
+		$opt->{$k} ||=3D $v;
+	}
+
+	###############################################################
+	# Get the field display information including breaks and labels
+	###############################################################
+	if( ! $opt->{ui_data_fields} and ! $opt->{ui_data_fields_all}) {
+		$opt->{ui_data_fields} =3D $tmeta->{ui_data_fields} || $tmeta->{options};
+	}
+#::logDebug("fields were=3D$opt->{ui_data_fields}");
+	$opt->{ui_data_fields} =3D~ s/\r\n/\n/g;
+	$opt->{ui_data_fields} =3D~ s/\r/\n/g;
+	$opt->{ui_data_fields} =3D~ s/^[ \t]+//mg;
+	$opt->{ui_data_fields} =3D~ s/[ \t]+$//mg;
+
+	if($opt->{ui_data_fields} =3D~ /\n\n/) {
+		my @breaks;
+		my @break_labels;
+		my $fstring =3D "\n\n$opt->{ui_data_fields}";
+		while ($fstring =3D~ s/\n+(?:\n[ \t]*=3D(.*))?\n+[ \t]*(\w[:.\w]+)/\n$2/=
) {
+			push @breaks, $2;
+			push @break_labels, "$2=3D$1" if $1;
+		}
+		$opt->{ui_break_before} =3D join(" ", @breaks)
+			if ! $opt->{ui_break_before};
+		$opt->{ui_break_before_label} =3D join(",", @break_labels)
+			if ! $opt->{ui_break_before_label};
+		$opt->{ui_data_fields} =3D $fstring;
+	}
+
+	$opt->{ui_data_fields} ||=3D $opt->{mv_data_fields};
+	$opt->{ui_data_fields} =3D~ s/^[\s,\0]+//;
+	$opt->{ui_data_fields} =3D~ s/[\s,\0]+$//;
+#::logDebug("fields now=3D$opt->{ui_data_fields}");
+
+	$opt->{mv_nextpage} =3D $Global::Variable->{MV_PAGE}
+		if ! $opt->{mv_nextpage};
+
+	$opt->{form_extra} =3D~ s/^\s*/ /
+		if $opt->{form_extra};
+
+	$opt->{form_name} =3D qq{ NAME=3D"$opt->{form_name}"}
+		if $opt->{form_name};
+
+	$opt->{enctype} =3D $opt->{file_upload} ? ' ENCTYPE=3D"multipart/form-dat=
a"' : '';
+
+}
+# UserTag table-editor Order mv_data_table item_id
+# UserTag table-editor addAttr
+# UserTag table-editor AttrAlias clone ui_clone_id
+# UserTag table-editor AttrAlias table mv_data_table
+# UserTag table-editor AttrAlias fields ui_data_fields
+# UserTag table-editor AttrAlias mv_data_fields ui_data_fields
+# UserTag table-editor AttrAlias key   item_id
+# UserTag table-editor AttrAlias view  ui_meta_view
+# UserTag table-editor AttrAlias profile ui_profile
+# UserTag table-editor AttrAlias email_fields ui_display_only
+# UserTag table-editor hasEndTag
+# UserTag table-editor MapRoutine Vend::Table::Editor::editor
+sub editor {
+
+	my ($table, $key, $opt, $template) =3D @_;
+show_times("begin table editor call item_id=3D$key") if $Global::ShowTimes;
+
+	use vars qw/$Tag/;
+
+	editor_init($opt);
+
+	my @messages;
+	my @errors;
+
+#::logDebug("key at beginning: $key");
+	$opt->{mv_data_table} =3D $table if $table;
+	$opt->{item_id}		  =3D $key if $key;
+	$opt->{table}		  =3D $opt->{mv_data_table};
+#::logDebug("key before resolve_options: $key");
+
+	resolve_options($opt);
+	$table =3D $opt->{table};
+	$key =3D $opt->{item_id};
+#::logDebug("key after resolve_options: $key");
+
+	my $rowdiv =3D $opt->{across} || 1;
+	my $rowcount =3D 0;
+	my $span =3D $rowdiv * 2;
+	my $oddspan =3D $span - 1;
+	my $def =3D $opt->{default_ref} || $::Values;
+
+
+	my $append       =3D $opt->{append};
+	my $check        =3D $opt->{check};
+	my $database     =3D $opt->{database};
+	my $default      =3D $opt->{default};
+	my $error        =3D $opt->{error};
+	my $extra        =3D $opt->{extra};
+	my $field        =3D $opt->{field};
+	my $filter       =3D $opt->{filter};
+	my $height       =3D $opt->{height};
+	my $help         =3D $opt->{help};
+	my $help_url     =3D $opt->{help_url};
+	my $label        =3D $opt->{label};
+	my $lookup       =3D $opt->{lookup};
+	my $lookup_query =3D $opt->{lookup_query};
+	my $meta         =3D $opt->{meta};
+	my $options      =3D $opt->{options};
+	my $outboard     =3D $opt->{outboard};
+	my $override     =3D $opt->{override};
+	my $passed       =3D $opt->{passed};
+	my $pre_filter   =3D $opt->{pre_filter};
+	my $prepend      =3D $opt->{prepend};
+	my $widget       =3D $opt->{widget};
+	my $width        =3D $opt->{width};
+
+	#my $blabel      =3D $opt->{begin_label} || '<b>';
+	#my $elabel      =3D $opt->{end_label} || '</b>';
+	my $blabel      ;
+	my $elabel      ;
+	my $mlabel =3D '';
+
 	my $ntext;
 	my $btext;
 	my $ctext;
@@ -1015,14 +1245,14 @@
 	else {
 		if($opt->{action_click}) {
 			$ntext =3D <<EOF;
-mv_todo=3D$wizard_next
+mv_todo=3D$opt->{wizard_next}
 ui_wizard_action=3DNext
 mv_click=3D$opt->{action_click}
 EOF
 		}
 		else {
 			$ntext =3D <<EOF;
-mv_todo=3D$wizard_next
+mv_todo=3D$opt->{wizard_next}
 ui_wizard_action=3DNext
 mv_click=3Dui_override_next
 EOF
@@ -1035,14 +1265,14 @@
 mv_form_profile=3D
 ui_wizard_action=3DCancel
 mv_nextpage=3D$hidgo
-mv_todo=3D$wizard_cancel
+mv_todo=3D$opt->{wizard_cancel}
 EOF
 		if($opt->{mv_prevpage}) {
 			$btext =3D $::Scratch->{$opt->{back_text}} =3D <<EOF;
 mv_form_profile=3D
 ui_wizard_action=3DBack
 mv_nextpage=3D$opt->{mv_prevpage}
-mv_todo=3D$wizard_next
+mv_todo=3D$opt->{wizard_next}
 EOF
 		}
 		else {
@@ -1066,122 +1296,8 @@
 	$::Scratch->{$opt->{cancel_text}} =3D $ctext if $ctext;
 	$::Scratch->{$opt->{back_text}}   =3D $btext if $btext;
=20
-	if($opt->{wizard} || $opt->{notable} and ! $table) {
-		$table =3D 'mv_null';
-		$Vend::Database{mv_null} =3D=20
-			bless [
-					{},
-					undef,
-					[ 'code', 'value' ],
-					[ 'code' =3D> 0, 'value' =3D> 1 ],
-					0,
-					{ },
-					], 'Vend::Table::InMemory';
-	}
-
-	my @mapdirect =3D qw/
-		mv_data_decode
-		mv_data_table
-		mv_blob_field
-		mv_blob_nick
-		mv_blob_pointer
-		mv_blob_label
-		mv_blob_title
-		left_width
-		table_width
-		tabbed
-		tab_bgcolor_template
-		tab_height
-		tab_width
-		tab_cellspacing
-		tab_cellpadding
-		panel_height
-		panel_width
-		panel_id
-		tab_horiz_offset
-		tab_vert_offset
-		ui_break_before
-		ui_break_before_label
-		ui_data_fields
-		ui_data_fields_all
-		ui_data_key_name
-		ui_display_only
-		ui_hide_key
-		ui_meta_specific
-		ui_meta_view
-		ui_nextpage
-		ui_new_item
-		ui_delete_box
-		mv_update_empty
-	/;
-
-	for(grep defined $tmeta->{$_}, @mapdirect) {
-		$opt->{$_} ||=3D $tmeta->{$_};
-	}
+	undef $opt->{tabbed} if $::Scratch->{ui_old_browser};
=20
-	if($opt->{cgi}) {
-		unshift @mapdirect, qw/
-				item_id
-				item_id_left
-				ui_clone_id
-				ui_clone_tables
-				ui_sequence_edit
-		/;
-		for(@mapdirect) {
-			next if ! defined $CGI->{$_};
-			$opt->{$_} =3D $CGI->{$_};
-		}
-		my @hmap =3D (
-			[ qr/^ui_te_check:/, $check ],
-			[ qr/^ui_te_default:/, $default ],
-			[ qr/^ui_te_extra:/, $extra ],
-			[ qr/^ui_te_widget:/, $widget ],
-			[ qr/^ui_te_passed:/, $passed ],
-			[ qr/^ui_te_options:/, $options ],
-			[ qr/^ui_te_outboard:/, $outboard ],
-			[ qr/^ui_te_prepend:/, $prepend ],
-			[ qr/^ui_te_append:/, $append ],
-			[ qr/^ui_te_lookup:/, $lookup ],
-			[ qr/^ui_te_database:/, $database ],
-			[ qr/^ui_te_field:/, $field ],
-			[ qr/^ui_te_override:/, $override ],
-			[ qr/^ui_te_filter:/, $filter ],
-			[ qr/^ui_te_pre_filter:/, $pre_filter ],
-			[ qr/^ui_te_height:/, $height ],
-			[ qr/^ui_te_width:/, $width ],
-			[ qr/^ui_te_help:/, $help ],
-			[ qr/^ui_te_help_url:/, $help_url ],
-		);
-		my @cgi =3D keys %{$CGI};
-		foreach my $row (@hmap) {
-			my @keys =3D grep $_ =3D~ $row->[0], @cgi;
-			for(@keys) {
-				/^ui_\w+:(\S+)/
-					and $row->[1]->{$1} =3D $CGI->{$_};
-			}
-		}
-		$table =3D $opt->{mv_data_table};
-		$key =3D $opt->{item_id};
-	}
-
-	$opt->{table_width} =3D '60%' if ! $opt->{table_width};
-	$opt->{left_width}  =3D '30%' if ! $opt->{left_width};
-	if (! $opt->{inner_table_width}) {
-		if($opt->{table_width} =3D~ /%/) {
-			$opt->{inner_table_width} =3D '100%';
-		}
-		elsif ($opt->{table_width} =3D~ /^\d+$/) {
-			$opt->{inner_table_width} =3D $opt->{table_width} - 2;
-		}
-		else {
-			$opt->{inner_table_width} =3D $opt->{table_width};
-		}
-	}
-
-	$opt->{color_success} =3D $::Variable->{UI_C_SUCCESS} || '#00FF00'
-		if ! $opt->{color_success};
-	$opt->{color_fail} =3D $::Variable->{UI_CONTRAST} || '#FF0000'
-		if ! $opt->{color_fail};
 	### Build the error checking
 	my $error_show_var =3D 1;
 	my $have_errors;
@@ -1264,7 +1380,7 @@
 &fatal=3D1
 $success
 mv_form_profile=3Dmandatory
-&set=3Dmv_todo $action
+&set=3Dmv_todo $opt->{action}
 EOP
 [/perl]
 EOF
@@ -1299,10 +1415,23 @@
=20
 	my $db;
 	unless($opt->{notable}) {
-		$db =3D Vend::Data::database_exists_ref($table)
-		or return $die->('table-editor: bad table %s', $table);
+		# From Vend::Data
+		$db =3D database_exists_ref($table)
+			or return $die->("table-editor: bad table '%s'", $table);
 	}
=20
+	if(! $opt->{ui_data_fields}) {
+		if( $opt->{notable}) {
+			::logError("table_editor: no place to get fields!");
+			return '';
+		}
+		else {
+			$opt->{ui_data_fields} =3D join " ", $db->columns();
+		}
+	}
+
+	$opt->{ui_data_fields} =3D~ s/[,\0\s]+/ /g;
+
 	if($opt->{ui_wizard_fields}) {
 		$opt->{ui_data_fields} =3D $opt->{ui_display_only} =3D $opt->{ui_wizard_=
fields};
 	}
@@ -1315,49 +1444,6 @@
 		$keycol =3D $opt->{ui_data_key_name} || $db->config('KEY');
 	}
=20
-	$opt->{form_extra} =3D~ s/^\s*/ /
-		if $opt->{form_extra};
-
-	$opt->{form_name} =3D qq{ NAME=3D"$opt->{form_name}"}
-		if $opt->{form_name};
-
-	###############################################################
-	# Get the field display information including breaks and labels
-	###############################################################
-	if( ! $opt->{ui_data_fields} and ! $opt->{ui_data_fields_all}) {
-		$opt->{ui_data_fields} =3D $tmeta->{ui_data_fields} || $tmeta->{options};
-	}
-
-	$opt->{ui_data_fields} =3D~ s/\r\n/\n/g;
-	$opt->{ui_data_fields} =3D~ s/\r/\n/g;
-
-	if($opt->{ui_data_fields} =3D~ /\n\n/) {
-		my @breaks;
-		my @break_labels;
-		my $fstring =3D "\n\n$opt->{ui_data_fields}";
-		while ($fstring =3D~ s/\n+(?:\n[ \t]*=3D(.*))?\n+[ \t]*(\w[:.\w]+)/\n$2/=
) {
-			push @breaks, $2;
-			push @break_labels, "$2=3D$1" if $1;
-		}
-		$opt->{ui_break_before} =3D join(" ", @breaks)
-			if ! $opt->{ui_break_before};
-		$opt->{ui_break_before_label} =3D join(",", @break_labels)
-			if ! $opt->{ui_break_before_label};
-	}
-
-	$opt->{ui_data_fields} ||=3D $opt->{mv_data_fields};
-
-	if(! $opt->{ui_data_fields}) {
-		if( $opt->{notable}) {
-			::logError("table_editor: no place to get fields!");
-			return '';
-		}
-		else {
-			$opt->{ui_data_fields} =3D join " ", $db->columns();
-		}
-	}
-
-	$opt->{ui_data_fields} =3D~ s/[,\0\s]+/ /g;
 	###############################################################
=20
 	my $linecount;
@@ -1596,9 +1682,6 @@
 		$opt->{mv_data_function} =3D $exists ? 'update' : 'insert';
 	}
=20
-	$opt->{mv_nextpage} =3D $Global::Variable->{MV_PAGE} if ! $opt->{mv_nextp=
age};
-	$opt->{mv_update_empty} =3D 1 unless defined $opt->{mv_update_empty};
-
 	my $url_base =3D $opt->{secure} ? $Vend::Cfg->{SecureURL} : $Vend::Cfg->{=
VendURL};
=20
 	$opt->{href} =3D "$url_base/ui" if ! $opt->{href};
@@ -1614,7 +1697,6 @@
 		$sidstr =3D qq{<INPUT TYPE=3Dhidden NAME=3Dmv_session_id VALUE=3D"$Vend:=
:Session->{id}">
 };
 	}
-	$opt->{enctype} =3D $opt->{file_upload} ? ' ENCTYPE=3D"multipart/form-dat=
a"' : '';
=20
 	my $wo =3D $opt->{widgets_only};
=20
@@ -1629,7 +1711,7 @@
=20
 	chunk 'FORM_BEGIN', 'WO', 'TOP_PORTION', <<EOF; # unless $wo;
 $restrict_begin<FORM METHOD=3D$opt->{method} ACTION=3D"$opt->{href}"$opt->=
{form_name}$opt->{enctype}$opt->{form_extra}>
-$sidstr<INPUT TYPE=3Dhidden NAME=3Dmv_todo VALUE=3D"$action">
+$sidstr<INPUT TYPE=3Dhidden NAME=3Dmv_todo VALUE=3D"$opt->{action}">
 <INPUT TYPE=3Dhidden NAME=3Dmv_click VALUE=3D"process_filter">
 <INPUT TYPE=3Dhidden NAME=3Dmv_nextpage VALUE=3D"$opt->{mv_nextpage}">
 <INPUT TYPE=3Dhidden NAME=3Dmv_data_table VALUE=3D"$table">
@@ -2439,7 +2521,7 @@
 			$template =3D~ s/\$LABEL\$/$Tag->error($parm)/eg;
 		}
=20
-		my $meta =3D '';
+		my $meta_string =3D '';
 		my $meta_url;
 		my $meta_url_specific;
 		if($show_meta) {
@@ -2483,7 +2565,7 @@
=20=09=09=09=09=09=09=09=09
 			$opt->{meta_append} =3D '</FONT>'
 				unless defined $opt->{meta_append};
-			$meta =3D <<EOF;
+			$meta_string =3D <<EOF;
 $opt->{meta_prepend}<a href=3D"$meta_url"$opt->{meta_extra}>$opt->{meta_an=
chor}</A>
 $meta_specific$opt->{meta_append}
 EOF
@@ -2505,7 +2587,7 @@
 										help_url =3D> $help_url->{$c},
 										label =3D> $label->{$c},
 										key =3D> $key,
-										meta =3D> $pmeta->{$c},
+										meta =3D> $meta->{$c},
 										meta_url =3D> $meta_url,
 										meta_url_specific =3D> $meta_url_specific,
 										name =3D> $namecol,
@@ -2532,16 +2614,14 @@
 			next;
 		}
=20
-		if($show_meta and $display =3D~ /\~META\~/) {
-			$display =3D~ s/\~META\~/$meta/g;
-		}
+		$display =3D~ s/\~META\~/$meta_string/g;
=20
 		$display =3D~ s/\~ERROR\~/$Tag->error({ name =3D> $c, keep =3D> 1 })/eg;
=20=20=20=20=20=20=20=20=20
 		my $update_ctl;
 		if (! $wo and $break{$namecol}) {
 			push @titles, $break_label{$namecol};
-			if(@columns =3D=3D 0 and @titles =3D=3D 1) {
+			if(@controls =3D=3D 0 and @titles =3D=3D 1) {
 				# do nothing
 			}
 			else {