Fix handling of extra_query_params in Business::OnlinePayment wrapper.
[interchange.git] / code / SystemTag / control.coretag
1 # Copyright 2002-2007 Interchange Development Group and others
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.  See the LICENSE file for details.
7
8 # $Id: control.coretag,v 1.4 2007-03-30 23:40:49 pajamian Exp $
9
10 UserTag control             Order        name default
11 UserTag control             addAttr
12 UserTag control             PosNumber    2
13 UserTag control             Version      $Revision: 1.4 $
14 UserTag control             Routine      <<EOR
15 sub {
16         my ($name, $default, $opt) = @_;
17
18         use vars qw/$Tmp/;
19
20         if(! $name) {
21                 # Here we either reset the index or increment it
22                 # Done this way for speed, no blocks to enter other than top one
23                 if($opt->{space}) {
24                         $::Control = $Tmp->{$opt->{space}} ||= [];
25                         return set_tmp('control_index', 0);
26                 }
27                 else {
28                         ($::Scratch->{control_index} = 0, return) if $opt->{reset};
29                         return set_tmp('control_index', ++$::Scratch->{control_index});
30                 }
31         }
32
33         $name = lc $name;
34         $name =~ s/-/_/g;
35         $opt ||= {};
36         if (! defined $default and $opt->{set}) {
37                 $::Control->[$::Scratch->{control_index}]{$name} = $::Scratch->{$name};
38                 return;
39         }
40
41         return defined $::Control->[$::Scratch->{control_index}]{$name} 
42                         ?  ( $::Control->[$::Scratch->{control_index}]{$name} || $default )
43                         :  ( length($::Scratch->{$name}) ? ($::Scratch->{$name}) : $default )
44 }
45 EOR