[interchange-cvs] interchange - heins modified 2 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Fri Apr 2 12:19:22 EST 2004
User: heins
Date: 2004-04-02 17:19:21 GMT
Modified: lib/Vend Page.pm Config.pm
Log:
* SpecialSub -- directive to specify subroutines (catalog or global)
upon certain conditions, i.e. "missing".
When the routine is called, it should perform whatever action is
required. If it wants the catalog to continue with the default
action, i.e. the "missing" special page, it should return false.
If it returns true, and there is no second parameter of a page name
returned, it will be assumed all required action has
been taken and the default action will not be performed.
If it returns true, and a second parameter is returned, it
is the name of a page to display in lieu of the original one.
This allows
SpecialSub missing check_category
Sub check_category <<EOS
sub {
my ($name) = @_;
return unless $name =~ m{^[A-Z]};
$name =~ s,_, ,g;
my ($prod_group, $category) = split m{/}, $name;
$CGI->{co} = 1;
$CGI->{fi} = 'products';
$CGI->{st} = 'db';
$CGI->{sf} = join "\0", 'prod_group', 'category';
$CGI->{op} = join "\0", 'eq', 'eq';
$CGI->{se} = join "\0", $prod_group, $category;
$CGI->{sp} = 'results';
$CGI->{mv_todo} = 'search';
$Tag->update('process');
return (1, 'results');
}
EOS
You can also use a GlobalSub to perform actions not allowed in a catalog
subroutine.
* The Vend::Page module is modified to call a "missing" SpecialSub if
it exists. No other actions are currently handled.
Revision Changes Path
2.18 +13 -2 interchange/lib/Vend/Page.pm
rev 2.18, prev_rev 2.17
Index: Page.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Page.pm,v
retrieving revision 2.17
retrieving revision 2.18
diff -u -r2.17 -r2.18
--- Page.pm 28 Mar 2004 20:29:39 -0000 2.17
+++ Page.pm 2 Apr 2004 17:19:20 -0000 2.18
@@ -1,6 +1,6 @@
# Vend::Page - Handle Interchange page routing
#
-# $Id: Page.pm,v 2.17 2004/03/28 20:29:39 mheins Exp $
+# $Id: Page.pm,v 2.18 2004/04/02 17:19:20 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -46,7 +46,7 @@
use vars qw/$VERSION/;
-$VERSION = substr(q$Revision: 2.17 $, 10);
+$VERSION = substr(q$Revision: 2.18 $, 10);
my $wantref = 1;
@@ -139,6 +139,17 @@
return 1;
}
else {
+ my $handled;
+ my $newpage;
+ if(my $subname = $Vend::Cfg->{SpecialSub}{missing}) {
+ my $sub = $Vend::Cfg->{Sub}{$subname} || $Global::GlobalSub->{$subname};
+ ($handled, $newpage) = $sub->($name)
+ if $sub;
+ }
+ if($handled) {
+ return display_page($newpage) if $newpage;
+ return 0;
+ }
HTML::Entities::encode($name, $ESCAPE_CHARS::std);
display_special_page(find_special_page('missing'), $name);
return 0;
2.136 +3 -2 interchange/lib/Vend/Config.pm
rev 2.136, prev_rev 2.135
Index: Config.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.135
retrieving revision 2.136
diff -u -r2.135 -r2.136
--- Config.pm 7 Mar 2004 06:59:50 -0000 2.135
+++ Config.pm 2 Apr 2004 17:19:21 -0000 2.136
@@ -1,6 +1,6 @@
# Vend::Config - Configure Interchange
#
-# $Id: Config.pm,v 2.135 2004/03/07 06:59:50 mheins Exp $
+# $Id: Config.pm,v 2.136 2004/04/02 17:19:21 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -48,7 +48,7 @@
use Vend::File;
use Vend::Data;
-$VERSION = substr(q$Revision: 2.135 $, 10);
+$VERSION = substr(q$Revision: 2.136 $, 10);
my %CDname;
my %CPname;
@@ -461,6 +461,7 @@
['ImageDirInternal', undef, ''],
['ImageDir', undef, ''],
['DeliverImage', 'yesno', 'no'],
+ ['SpecialSub', 'hash', ''],
['UseCode', undef, 'yes'],
['SetGroup', 'valid_group', ''],
['UseModifier', 'array', ''],
More information about the interchange-cvs
mailing list