| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#============================================================= -*-Perl-*- |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Template::Plugin::CGI |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# DESCRIPTION |
|
6
|
|
|
|
|
|
|
# Simple Template Toolkit plugin interfacing to the CGI.pm module. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# AUTHOR |
|
9
|
|
|
|
|
|
|
# Andy Wardley |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# COPYRIGHT |
|
12
|
|
|
|
|
|
|
# Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# This module is free software; you can redistribute it and/or |
|
15
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
#============================================================================ |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Template::Plugin::CGI; |
|
20
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TODDR'; |
|
21
|
|
|
|
|
|
|
# ABSTRACT: Simple Template Toolkit plugin interfacing to the CGI.pm module |
|
22
|
|
|
|
|
|
|
$Template::Plugin::CGI::VERSION = '3.100'; |
|
23
|
1
|
|
|
1
|
|
88980
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
24
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
24
|
|
|
25
|
1
|
|
|
1
|
|
5
|
use base 'Template::Plugin'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
82
|
|
|
26
|
1
|
|
|
1
|
|
15
|
use CGI; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
7
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
|
29
|
2
|
|
|
2
|
1
|
29477
|
my $class = shift; |
|
30
|
2
|
|
|
|
|
4
|
my $context = shift; |
|
31
|
2
|
|
|
|
|
14
|
CGI->new(@_); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# monkeypatch CGI::params() method to Do The Right Thing in TT land |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub CGI::params { |
|
37
|
3
|
|
|
3
|
0
|
519
|
my $self = shift; |
|
38
|
3
|
|
|
|
|
7
|
local $" = ', '; |
|
39
|
|
|
|
|
|
|
|
|
40
|
3
|
|
66
|
|
|
22
|
return $self->{ _TT_PARAMS } ||= do { |
|
41
|
|
|
|
|
|
|
# must call Vars() in a list context to receive |
|
42
|
|
|
|
|
|
|
# plain list of key/vals rather than a tied hash |
|
43
|
1
|
|
|
|
|
4
|
my $params = { $self->Vars() }; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# convert any null separated values into lists |
|
46
|
|
|
|
|
|
|
@$params{ keys %$params } = map { |
|
47
|
1
|
100
|
|
|
|
128
|
/\0/ ? [ split /\0/ ] : $_ |
|
|
2
|
|
|
|
|
13
|
|
|
48
|
|
|
|
|
|
|
} values %$params; |
|
49
|
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
10
|
$params; |
|
51
|
|
|
|
|
|
|
}; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=pod |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=encoding UTF-8 |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Template::Plugin::CGI - Simple Template Toolkit plugin interfacing to the CGI.pm module |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 VERSION |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
version 3.100 |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
[% USE CGI %] |
|
71
|
|
|
|
|
|
|
[% CGI.param('parameter') %] |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
[% USE things = CGI %] |
|
74
|
|
|
|
|
|
|
[% things.param('name') %] |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# see CGI docs for other methods provided by the CGI object |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This is a very simple Template Toolkit Plugin interface to the C module. |
|
81
|
|
|
|
|
|
|
A C object will be instantiated via the following directive: |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
[% USE CGI %] |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
C methods may then be called as follows: |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
[% CGI.header %] |
|
88
|
|
|
|
|
|
|
[% CGI.param('parameter') %] |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
An alias can be used to provide an alternate name by which the object should |
|
91
|
|
|
|
|
|
|
be identified. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
[% USE mycgi = CGI %] |
|
94
|
|
|
|
|
|
|
[% mycgi.start_form %] |
|
95
|
|
|
|
|
|
|
[% mycgi.popup_menu({ Name => 'Color' |
|
96
|
|
|
|
|
|
|
Values => [ 'Green' 'Black' 'Brown' ] }) %] |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Parenthesised parameters to the C |
|
99
|
|
|
|
|
|
|
constructor: |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
[% USE cgiprm = CGI('uid=abw&name=Andy+Wardley') %] |
|
102
|
|
|
|
|
|
|
[% cgiprm.param('uid') %] |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 NAME |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Template::Plugin::CGI - Interface to the CGI module |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 METHODS |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
In addition to all the methods supported by the C module, this |
|
111
|
|
|
|
|
|
|
plugin defines the following. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 params() |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This method returns a reference to a hash of all the C parameters. |
|
116
|
|
|
|
|
|
|
Any parameters that have multiple values will be returned as lists. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
[% USE CGI('user=abw&item=foo&item=bar') %] |
|
119
|
|
|
|
|
|
|
[% CGI.params.user %] # abw |
|
120
|
|
|
|
|
|
|
[% CGI.params.item.join(', ') %] # foo, bar |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Andy Wardley Eabw@wardley.orgE L |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
|
131
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L, L |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 AUTHOR |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Andy Wardley |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This software is Copyright (c) 2022 by Andy Wardley. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This is free software, licensed under: |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The MIT (X11) License |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
__END__ |