[interchange-cvs] interchange - heins modified 7 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Sun Feb 22 14:28:38 EST 2004
User: heins
Date: 2004-02-22 19:28:38 GMT
Modified: . .cvsignore MANIFEST
Modified: dist/lib/UI/pages/admin meta_editor.html
Modified: lib/Vend Dispatch.pm Form.pm Order.pm
Modified: lib/Vend/Table Editor.pm
Log:
* Allow individual profile checks defined in metadata.
It is defined in the "Help and Check" section of meta_editor.
IMPORTANT: To enable these checks, the ui_profile part of the overall
table definition has to be non-blank. You can just put a comment like
# Enable individual form profile checks
To enforce a profile on a field, set it's check value to a valid
IC profile check. For example, to make sure the length of a field
is between 4 and 10 characters, do:
length 4-10
Or to ensure it looks like a US or Canada postal code
postcode
This results in the following being set in the extended field
of mv_metadata:
{ check => 'postcode' }
If the check has an "=" sign anywhere, the field name is not
prepended. So to do multiple checks, you need to do
SECURITY:
Since the filter or lookup check type can do data lookups and potentially
call routines, we need to have some security. The table-editor tag
sets the scratch value "mv_individual_profile" when a ui_profile
is defined.
WITHOUT TABLE EDITOR:
To use this without the table editor, just set an mv_profile as
normal. Then for each individual check, define in the form:
<input type=text name=foo value="">
<input type=hidden name=mv_individual_profile value="foo=length 1">
That would check the form variable "foo" for a length of 1.
This is automatically done by the [display ...] tag, so you can
do:
[display type=text name=foo check="length 1"]
to do the same thing.
You will need to set the scratch value mv_individual_profile yourself
to enable these.
POSITIONING WITHIN PROFILE:
The facility works by modifying the first mv_form_profile run and
inserts its values either just before the first &fatal=yes or
*after* the first &update=yes, whichever comes first. If neither
are in the profile, they are put first in the profile.
MULTIPLE CHECKS:
If you have multiple mv_form_profile settings, the individual checks
are only run as a part of the first one and are not repeated.
* Add blank_default metadata setting, which is the value a field should
be initialized to (on display) if the current value has a length of 0.
* Remove extended.js_check from meta editor, as that was never implemented.
* Add some labels and help to meta editor.
Revision Changes Path
2.2 +1 -0 interchange/.cvsignore
rev 2.2, prev_rev 2.1
Index: .cvsignore
===================================================================
RCS file: /var/cvs/interchange/.cvsignore,v
retrieving revision 2.1
retrieving revision 2.2
diff -u -r2.1 -r2.2
--- .cvsignore 10 Aug 2001 07:03:53 -0000 2.1
+++ .cvsignore 22 Feb 2004 19:28:37 -0000 2.2
@@ -4,6 +4,7 @@
blib
build
Makefile
+META.yml
pm_to_blib
build-stamp
*.pdf
2.127 +1 -0 interchange/MANIFEST
rev 2.127, prev_rev 2.126
Index: MANIFEST
===================================================================
RCS file: /var/cvs/interchange/MANIFEST,v
retrieving revision 2.126
retrieving revision 2.127
diff -u -r2.126 -r2.127
--- MANIFEST 10 Dec 2003 22:19:10 -0000 2.126
+++ MANIFEST 22 Feb 2004 19:28:37 -0000 2.127
@@ -1368,3 +1368,4 @@
share/interchange-5/u/tab_light_right.gif
share/interchange-5/u/tab_right.gif
test.pl
+META.yml Module meta-data (added by MakeMaker)
2.10 +17 -3 interchange/dist/lib/UI/pages/admin/meta_editor.html
rev 2.10, prev_rev 2.9
Index: meta_editor.html
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/pages/admin/meta_editor.html,v
retrieving revision 2.9
retrieving revision 2.10
diff -u -r2.9 -r2.10
--- meta_editor.html 24 Jul 2003 17:28:59 -0000 2.9
+++ meta_editor.html 22 Feb 2004 19:28:37 -0000 2.10
@@ -106,14 +106,14 @@
width
height
options
- default
+ extended.blank_default
=Help and Check
help
help_url
+ extended.check
extended.maxlength
- extended.js_check
=Database lookup
@@ -158,6 +158,12 @@
'extended.ui_sort_option' => qq{=--default--,f=Case insensitive, fr=Case insensitive/Reverse, n=Numeric, nr=Reverse Numeric},
}`
+ filter=`{
+ 'extended.maxlength' => 'digits',
+ 'extended.width' => 'digits',
+ 'extended.height' => 'digits',
+ }`
+
label=`{
'extended.ui_more_alpha' => 'Alphabetic more links',
'extended.ui_sort_option' => 'Sort option',
@@ -179,10 +185,16 @@
'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.maxlength' => 'Maxlength',
+ 'extended.check' => 'Profile check',
+ 'extended.blank_default' => 'Default value',
}`
help=`{
'extended.fs_data_calc' => 'Current record passed as $item',
'extended.fs_data_tables' => 'To have open for Safe module',
+ '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.',
}`
widget=`{
extended => "textarea_5_50",
@@ -191,6 +203,8 @@
'extended.fs_no_group' => 'yesno',
'extended.fs_display_filter' => 'text_50',
'extended.fs_data_calc' => 'textarea_4_70',
+ 'extended.maxlength' => 'text_4',
+ 'extended.check' => 'textarea_2_50',
}`
ui_style=1
@@ -199,4 +213,4 @@
][/table-editor]
@_UI_STD_FOOTER_@
-<!-- page: @@MV_PAGE@@ version: $Revision: 2.9 $ -->
+<!-- page: @@MV_PAGE@@ version: $Revision: 2.10 $ -->
1.31 +7 -3 interchange/lib/Vend/Dispatch.pm
rev 1.31, prev_rev 1.30
Index: Dispatch.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Dispatch.pm,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- Dispatch.pm 2 Feb 2004 20:53:28 -0000 1.30
+++ Dispatch.pm 22 Feb 2004 19:28:37 -0000 1.31
@@ -1,6 +1,6 @@
# Vend::Dispatch - Handle Interchange page requests
#
-# $Id: Dispatch.pm,v 1.30 2004/02/02 20:53:28 mheins Exp $
+# $Id: Dispatch.pm,v 1.31 2004/02/22 19:28:37 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 2002 Mike Heins <mike at perusion.net>
@@ -26,7 +26,7 @@
package Vend::Dispatch;
use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.30 $, 10);
+$VERSION = substr(q$Revision: 1.31 $, 10);
use POSIX qw(strftime);
use Vend::Util;
@@ -596,7 +596,11 @@
}
if($CGI::values{mv_form_profile}) {
- my ($status) = check_order($CGI::values{mv_form_profile}, \%CGI::values);
+ my ($status) = check_order(
+ $CGI::values{mv_form_profile},
+ \%CGI::values,
+ $CGI::values{mv_individual_profile},
+ );
return 1 if defined $status and ! $status;
}
2.43 +13 -2 interchange/lib/Vend/Form.pm
rev 2.43, prev_rev 2.42
Index: Form.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Form.pm,v
retrieving revision 2.42
retrieving revision 2.43
diff -u -r2.42 -r2.43
--- Form.pm 11 Feb 2004 21:32:13 -0000 2.42
+++ Form.pm 22 Feb 2004 19:28:37 -0000 2.43
@@ -1,6 +1,6 @@
# Vend::Form - Generate Form widgets
#
-# $Id: Form.pm,v 2.42 2004/02/11 21:32:13 mheins Exp $
+# $Id: Form.pm,v 2.43 2004/02/22 19:28:37 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -38,7 +38,7 @@
require Exporter;
@ISA = qw(Exporter);
-$VERSION = substr(q$Revision: 2.42 $, 10);
+$VERSION = substr(q$Revision: 2.43 $, 10);
@EXPORT = qw (
display
@@ -1206,6 +1206,11 @@
}
$opt->{value} = $opt->{default} if ! defined $opt->{value};
+
+ if(length($opt->{blank_default}) and ! length($opt->{value}) ) {
+ $opt->{value} = $opt->{blank_default};
+ }
+
$opt->{encoded} = encode($opt->{value}, $ESCAPE_CHARS::std);
$opt->{value} =~ s/[/\[/g if $opt->{enable_itl};
@@ -1264,6 +1269,12 @@
|| $daction{default};
}
+ if(my $c = $opt->{check}) {
+ $c = "$opt->{name}=$c" unless $c =~ /=/;
+ HTML::Entities::encode($c);
+ no warnings;
+ $opt->{append} .= qq{<input type=hidden name="mv_individual_profile" value="$c">};
+ }
return $sub->($opt, $data);
}
2.63 +41 -5 interchange/lib/Vend/Order.pm
rev 2.63, prev_rev 2.62
Index: Order.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Order.pm,v
retrieving revision 2.62
retrieving revision 2.63
diff -u -r2.62 -r2.63
--- Order.pm 27 Dec 2003 14:01:17 -0000 2.62
+++ Order.pm 22 Feb 2004 19:28:37 -0000 2.63
@@ -1,6 +1,6 @@
# Vend::Order - Interchange order routing routines
#
-# $Id: Order.pm,v 2.62 2003/12/27 14:01:17 mheins Exp $
+# $Id: Order.pm,v 2.63 2004/02/22 19:28:37 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -29,7 +29,7 @@
package Vend::Order;
require Exporter;
-$VERSION = substr(q$Revision: 2.62 $, 10);
+$VERSION = substr(q$Revision: 2.63 $, 10);
@ISA = qw(Exporter);
@@ -970,15 +970,25 @@
}
sub check_order {
- my ($profiles, $vref) = @_;
+ my ($profiles, $vref, $individual) = @_;
reset_order_vars();
my $status;
$Vend::Session->{errors} = {}
unless ref $Vend::Session->{errors} eq 'HASH';
+ ## Must have some security on mv_individual_profile because data
+ ## lookups can be done via filter and/or unique
+ if($individual and ! delete($::Scratch->{mv_individual_profile})) {
+ ::logError("Individual profile supplied without scratch authorization");
+ undef $individual;
+ }
+
for my $profile (split /\0+/, $profiles) {
- $status = check_order_each($profile, $vref);
+ $status = check_order_each($profile, $vref, $individual);
+
+ # only do the individual checks once
+ undef $individual;
my $np = $CGI::values{mv_nextpage};
if ($status) {
@@ -1048,7 +1058,7 @@
}
sub check_order_each {
- my ($profile, $vref) = @_;
+ my ($profile, $vref, $individual) = @_;
my $params;
$Profile = $profile;
if(defined $Vend::Cfg->{OrderProfileName}->{$profile}) {
@@ -1076,6 +1086,32 @@
my($var,$val,$message);
my $status = 1;
my(@param) = split /[\r\n]+/, $params;
+
+ ## Find marker for individual insertion
+ if($individual) {
+ my $mark;
+ my $i = -1;
+ for(@param) {
+ $i++;
+ next unless /^\s*\&fatal\s*=\s*(.*)/i and is_yes($1);
+ $mark = $i;
+ last;
+ }
+ if(! defined $mark) {
+ $i = -1;
+ for(@param) {
+ $i++;
+ next unless /^\s*\&update\s*=\s*(.*)/i and is_yes($1);
+ $mark = $i + 1;
+ last;
+ }
+ }
+ $mark = 0 unless defined $mark;
+ my @newparams = split /\0/, $individual;
+ splice(@param, $mark, 0, @newparams);
+ }
+
+#::logDebug("Total profile:\n" . join ("\n", @param));
my $m;
my $join;
my $here;
1.52 +25 -2 interchange/lib/Vend/Table/Editor.pm
rev 1.52, prev_rev 1.51
Index: Editor.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Table/Editor.pm,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- Editor.pm 13 Feb 2004 15:01:00 -0000 1.51
+++ Editor.pm 22 Feb 2004 19:28:38 -0000 1.52
@@ -1,6 +1,6 @@
# Vend::Table::Editor - Swiss-army-knife table editor for Interchange
#
-# $Id: Editor.pm,v 1.51 2004/02/13 15:01:00 mheins Exp $
+# $Id: Editor.pm,v 1.52 2004/02/22 19:28:38 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 2002 Mike Heins <mike at perusion.net>
@@ -26,7 +26,7 @@
package Vend::Table::Editor;
use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.51 $, 10);
+$VERSION = substr(q$Revision: 1.52 $, 10);
use Vend::Util;
use Vend::Interpolate;
@@ -1925,6 +1925,11 @@
$prof .= "$_=mandatory\n";
}
}
+
+ ## Enable individual widget checks
+ $::Scratch->{mv_individual_profile} = 1;
+
+ ## Call the profile in the form
$opt->{hidden}{mv_form_profile} = 'ui_profile';
my $fail = $opt->{mv_failpage} || $Global::Variable->{MV_PAGE};
@@ -3115,6 +3120,16 @@
my @extra_hidden;
my $icount = 0;
+
+ my $reload;
+ ## Find out what our errors are
+ if($CGI->{mv_form_profile} eq 'ui_profile' and $Vend::Session->{errors}) {
+ for(keys %{$Vend::Session->{errors}}) {
+ $error->{$_} = 1;
+ }
+ $reload = 1 unless $opt->{no_reload};
+ }
+
foreach my $col (@cols) {
my $t;
my $c;
@@ -3203,6 +3218,10 @@
$overridden = 1;
}
+ if($reload and defined $CGI::values{$col}) {
+ $currval = $CGI::values{$col};
+ }
+
my $namecol;
if($serialize) {
#::logDebug("serialize=$serialize");
@@ -3230,6 +3249,10 @@
#::logDebug("fetched hk=$hk value=$currval");
$overridden = 1;
$namecol = $c = $serialize;
+
+ if($reload and defined $CGI::values{$namecol}) {
+ $currval = $CGI::values{$namecol};
+ }
}
$namecol = $col unless $namecol;
More information about the interchange-cvs
mailing list