| 1 | # Copyright (c) 1998-2005 by Jonathan Swartz. All rights reserved. | ||||||||||||||||||||||||||||
| 2 | # This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 3 | # under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # Miscellaneous Mason-related utilities expected to be used by | ||||||||||||||||||||||||||||
| 7 | # external applications. | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | package HTML::Mason::Utils; | ||||||||||||||||||||||||||||
| 11 | 32 | $HTML::Mason::Utils::VERSION = '1.60'; | |||||||||||||||||||||||||||
| 12 | 32 | ▶ | use HTML::Mason::Tools qw(compress_path); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 32 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 32 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 32 | require Exporter; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 32 | ▶ | use vars qw(@ISA @EXPORT_OK); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 32 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 21 | 32 | @EXPORT_OK = qw(data_cache_namespace cgi_request_args); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | sub data_cache_namespace | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
data_cache_namespace: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | 0 | my ($comp_id) = @_; | |||||||||||||||||||||||||||
| 26 | 0 | return compress_path($comp_id); | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | sub cgi_request_args | ||||||||||||||||||||||||||||
| 30 | 8 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
cgi_request_args: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 8 | my ($q, $method) = @_; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 8 | my %args; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Checking that there really is no query string when the method is | ||||||||||||||||||||||||||||
| 36 | # not POST is important because otherwise ->url_param returns a | ||||||||||||||||||||||||||||
| 37 | # parameter named 'keywords' with a value of () (empty array). | ||||||||||||||||||||||||||||
| 38 | # This is apparently a feature related to <ISINDEX> queries or | ||||||||||||||||||||||||||||
| 39 | # something (see the CGI.pm) docs. It makes my head hurt. - dave | ||||||||||||||||||||||||||||
| 40 | my @methods = | ||||||||||||||||||||||||||||
| 41 | 8 | ▶ | $method ne 'POST' || ! $ENV{QUERY_STRING} ? ( 'param' ) : ( 'param', 'url_param' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$method ne "POST" or not $ENV{"QUERY_STRING"}
MC/DC0%0/2
$method ne "POST" or not $ENV{"QUERY_STRING"}
$method ne "POST"
not $ENV{"QUERY_STRING"}
Truth table33%1/3
A or not(B)
A= $method ne "POST"B= not $ENV{"QUERY_STRING"}
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 8 | foreach my $key ( map { $q->$_() } @methods ) { | |||||||||||||||||||||||||||
| 44 | 5 | ▶ | next if exists $args{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 5 | local $CGI::LIST_CONTEXT_WARN = 0; | |||||||||||||||||||||||||||
| 46 | 5 | my @values = map { $q->$_($key) } @methods; | |||||||||||||||||||||||||||
| 47 | 5 | ▶ | $args{$key} = @values == 1 ? $values[0] : \@values; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 8 | ▶ | return wantarray ? %args : \%args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 32 | 1; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||||||||||