Gantry.pm

filter: Statementstmt 13.7% 59 / 428 Branchbran 7.4% 14 / 188 Conditioncond 7.5% 6 / 80 MC/DCmcdc 6.8% 3 / 44 Subroutinesub 10.1% 8 / 79 Podpod 100% 70 / 70 totaltotal 18.0% 160 / 889 CC 137 SCAR 33.7
CC
137
Cov
11%
set_cookie
132.0
init
90.0
import
79.6
CRAP 29.2
« Gantry/Engine/MP20.pm ↑ Summary Gantry/State/Simple.pm »
1 package Gantry;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use Gantry::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Gantry::Init;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use CGI::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use POSIX qw( strftime );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ############################################################
11 # Variables #
12 ############################################################
13 5 our $VERSION = '3.64';
14 5 our $DEFAULT_PLUGIN_TEMPLATE = 'Gantry::Template::Default';
15 5 our $DEFAULT_STATE_MACHINE = 'Gantry::State::Default';
16 5 our $CONF;
17 5 our $engine_cycle = 0;
18 5 my %plugin_callbacks;
19  
20 ############################################################
21 # Functions #
22 ############################################################
23  
24 #-------------------------------------------------
25 # $self->handler( $r );
26 #-------------------------------------------------
27 0 ▶sub handler : method {
Subroutine handler: not called CC=2 SCAR=17.9
Pod documented
28 0 my $class = shift;
29 0 my $r_or_cgi = shift;
30 0 my $self = bless( {}, $class );
31  
32 0 my $status;
33  
34 # Create the stash object
35 0 $self->make_stash();
36 0 $self->_increment_engine_cycle();
37  
38 # die if we don't know the engine
39 0 ▶ if ( ! $self->can( 'engine' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->can("engine")) 0 0 0
40 0 die( 'No engine specified, engine required' );
41 }
42  
43 # initialize the engine
44 0 $self->engine_init( $r_or_cgi );
45  
46 # handle the request
47 0 $status = $self->state_run($r_or_cgi, \%plugin_callbacks);
48
49 0 return $status;
50
51 } # end handler
52  
53 #-------------------------------------------------
54 # $self->gantry_version( )
55 #-------------------------------------------------
56 0 ▶sub gantry_version {
Subroutine gantry_version: not called CC=1 SCAR=6.9
Pod documented
57 0 return $VERSION;
58 }
59  
60 #-------------------------------------------------
61 # $self->make_stash( )
62 #-------------------------------------------------
63 0 ▶sub make_stash {
Subroutine make_stash: not called CC=1 SCAR=6.9
Pod documented
64 0 my $self = shift;
65  
66 0 $self->{__STASH__} = stash->new();
67  
68 } # end make_stash
69  
70 #-------------------------------------------------
71 # $self->stash( )
72 #-------------------------------------------------
73 0 ▶sub stash {
Subroutine stash: not called CC=2 SCAR=17.9
Pod documented
74 0 my $self = shift;
75  
76 0 ▶ $self->{__STASH__} = stash->new() unless defined $self->{__STASH__};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"__STASH__"} 0 0 0
77  
78 0 return $self->{__STASH__};
79  
80 } # end stash
81  
82 #-------------------------------------------------
83 # $self->engine_cycle()
84 #-------------------------------------------------
85 0 ▶sub engine_cycle {
Subroutine engine_cycle: not called CC=1 SCAR=6.9
Pod documented
86 0 my ( $self ) = ( shift );
87  
88 0 return( $engine_cycle );
89
90 } # end engine_cycle
91  
92 #-------------------------------------------------
93 # $self->_increment_engine_cycle()
94 #-------------------------------------------------
95 0 ▶sub _increment_engine_cycle {
Subroutine _increment_engine_cycle: not called CC=1 SCAR=6.9
96 0 my ( $self ) = ( shift );
97  
98 0 ++$engine_cycle;
99
100 } # end _increment_engine_cycle
101  
102 #-------------------------------------------------
103 # $self->declined( value )
104 #-------------------------------------------------
105 0 ▶sub declined {
Subroutine declined: not called CC=2 SCAR=17.9
Pod documented
106 0 my ( $self, $p ) = ( shift, shift );
107  
108 0 ▶ $$self{__DECLINED__} = $p if defined $p;
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
109 0 return( $$self{__DECLINED__} );
110
111 } # end declined
112  
113 #-------------------------------------------------
114 # $self->gantry_response_page( value )
115 #-------------------------------------------------
116 0 ▶sub gantry_response_page {
Subroutine gantry_response_page: not called CC=2 SCAR=17.9
Pod documented
117 0 my ( $self, $p ) = ( shift, shift );
118  
119 0 ▶ $$self{__RESPONSE_PAGE__} = $p if defined $p;
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
120 0 return( $$self{__RESPONSE_PAGE__} );
121
122 } # end gantry_response_page
123  
124 #-------------------------------------------------
125 # $self->redirect( value )
126 #-------------------------------------------------
127 0 ▶sub redirect {
Subroutine redirect: not called CC=2 SCAR=17.9
Pod documented
128 0 my ( $self, $p ) = ( shift, shift );
129  
130 0 ▶ $$self{__REDIRECT__} = $p if defined $p;
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
131 0 return( $$self{__REDIRECT__} );
132
133 } # end redirect
134  
135 #-------------------------------------------------
136 # $self->status( value )
137 #-------------------------------------------------
138 0 ▶sub status {
Subroutine status: not called CC=2 SCAR=17.9
Pod documented
139 0 my ( $self, $p ) = ( shift, shift );
140  
141 0 ▶ $$self{__STATUS__} = $p if defined $p;
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
142 0 return( $$self{__STATUS__} );
143
144 } # end status
145  
146 #-----------------------------------------------------------------
147 # $self->smtp_host( value )
148 #-----------------------------------------------------------------
149 0 ▶sub smtp_host {
Subroutine smtp_host: not called CC=2 SCAR=17.9
Pod documented
150 0 my ( $self, $p ) = @_;
151  
152 0 ▶ $$self{__SMTP_HOST__} = $p if defined $p;
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
153 0 return( $$self{__SMTP_HOST__} );
154  
155 } # end smtp_host
156  
157 #-------------------------------------------------
158 # $self->get_cookies
159 #-------------------------------------------------
160 0 ▶sub get_cookies {
Subroutine get_cookies: not called CC=7 SCAR=40.3
Pod documented
161 0 my ( $self, $want_cookie ) = ( shift, shift );
162  
163 # return the cookies if previously parsed
164 0 ▶ if ( $self->{__PARSED_COOKIES__} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"__PARSED_COOKIES__"}) 0 0 0
165
166 0 ▶ return $self->{__PARSED_COOKIES__}->{$want_cookie}
Branch: 1 branch
BranchTrueFalseTotal
if defined $want_cookie 0 0 0
167 if defined $want_cookie;
168
169 0 return $self->{__PARSED_COOKIES__};
170 }
171
172 0 ▶ my $client =
Condition0%0/3
$self->header_in('Cookie') || $self->header_in('HTTP_COOKIE')
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->header_in('Cookie') || $self->header_in('HTTP_COOKIE')
$self->header_in('Cookie') $self->header_in('HTTP_COOKIE')
Truth table0%0/3
A || B
A= $self->header_in('Cookie')B= $self->header_in('HTTP_COOKIE')
ABresult
1X1
011
000
173 $self->header_in( 'Cookie' ) || $self->header_in( 'HTTP_COOKIE' );
174
175 0 ▶ return () if ( ! defined $client );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $client 0 0 0
176
177 0 my %cookies;
178  
179 0 for my $crumb ( split ( /; /, $client ) ) {
180 0 my ( $key, $value ) = split( /=/, $crumb );
181 0 $cookies{$key} = $value;
182 }
183
184 0 $self->{__PARSED_COOKIES__} = \%cookies;
185
186 0 ▶ if ( defined $want_cookie ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $want_cookie) { } 0 0 0
187 0 return( $cookies{$want_cookie} );
188 }
189 else {
190 0 return( \%cookies );
191 }
192
193 } # end get_cookies
194  
195 #-------------------------------------------------
196 # set_cookie( { @options } )
197 # name => cookie name
198 # value => cookie value
199 # expire => cookie expires
200 # path => cookie path
201 # domain => cookie domain
202 # secure => [0/1] cookie secure
203 #-------------------------------------------------
204 0 ▶sub set_cookie {
Subroutine set_cookie: not called CC=11 SCAR=48.8
Pod documented
205 0 my ( $self, @opts ) = @_;
206
207 0 ▶ my $options = (@opts == 1) && UNIVERSAL::isa($opts[0], 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
@opts == 1 && UNIVERSAL::isa($opts[0], 'HASH') ? : 0 0 0
Condition0%0/3
@opts == 1 and UNIVERSAL::isa($opts[0], "HASH")
!ll&&!rl&&r
000
MC/DC0%0/2
@opts == 1 and UNIVERSAL::isa($opts[0], "HASH")
@opts == 1 UNIVERSAL::isa($opts[0], "HASH")
Truth table0%0/3
A and B
A= @opts == 1B= UNIVERSAL::isa($opts[0], "HASH")
ABresult
0X0
100
111
208 ? shift(@opts) : { @opts };
209
210 0 ▶ croak( 'Cookie has no name' ) if ( ! defined $$options{name} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options->{"name"} 0 0 0
211 0 ▶ croak( 'Cookie has no value' ) if ( ! defined $$options{value} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options->{"value"} 0 0 0
212  
213 # Only required fields in the cookie.
214 0 my $cookie = sprintf( "%s=%s; ", $$options{name}, $$options{value} );
215  
216  
217  
218 $cookie .= sprintf( "path=%s; ", $$options{path} )
219 0 ▶ if ( defined $$options{path} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"path"} 0 0 0
220 $cookie .= sprintf( "domain=%s; ", $$options{domain} )
221 0 ▶ if ( defined $$options{domain} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"domain"} 0 0 0
222 $cookie .= 'secure'
223 0 ▶ if ( defined $$options{secure} && $$options{secure} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"secure"} and $options->{"secure"} 0 0 0
Condition0%0/3
defined $options->{"secure"} and $options->{"secure"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $options->{"secure"} and $options->{"secure"}
defined $options->{"secure"} $options->{"secure"}
Truth table0%0/3
A and B
A= defined $options->{"secure"}B= $options->{"secure"}
ABresult
0X0
100
111
224  
225 # these are all optional. and should be created as such.
226 0 ▶ if ( defined $$options{expire} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options->{"expire"}) 0 0 0
227 0 ▶ $$options{expire} = 0 if ( $$options{expire} !~ /^\d+$/ );
Branch: 1 branch
BranchTrueFalseTotal
unless $options->{"expire"} =~ /^\d+$/ 0 0 0
228 $cookie .= strftime( "expires=%a, %d-%b-%Y %H:%M:%S GMT; ",
229 0 gmtime( time + $$options{expire} ) );
230 }
231  
232 0 $cookie =~ s/\;\s*$/ /;
233  
234 0 $self->err_header_out( 'Set-Cookie', $cookie ); # mp13 mp20
235 0 $self->cookie_stash( $cookie ); # cgi
236  
237 0 return();
238
239 } # end set_cookies
240  
241 0 ▶sub cookie_stash {
Subroutine cookie_stash: not called CC=3 SCAR=24.8
Pod documented
242 0 my ( $self, $p ) = @_;
243  
244 $self->{__COOKIE_STASH__} = []
245 0 ▶ unless defined $self->{__COOKIE_STASH__};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"__COOKIE_STASH__"} 0 0 0
246
247 0 ▶ if ( defined $p ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $p) 0 0 0
248 0 push( @{ $self->{__COOKIE_STASH__} }, $p );
249 }
250 0 return( $self->{__COOKIE_STASH__} );
251
252 } # end method
253
254 0 ▶sub response_headers {
Subroutine response_headers: not called CC=3 SCAR=24.8
Pod documented
255 0 my ( $self, $key, $value ) = @_;
256  
257 $self->{__RESPONSE_HEADERS__} = {}
258 0 ▶ unless defined $self->{__RESPONSE_HEADERS__};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"__RESPONSE_HEADERS__"} 0 0 0
259
260 0 ▶ if ( defined $key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key) 0 0 0
261 0 $self->{__RESPONSE_HEADERS__}{ $key } = $value;
262 }
263 0 return( $self->{__RESPONSE_HEADERS__} );
264
265 } # end method
266  
267 #-------------------------------------------------
268 # $self->cleanroot( $uri, $root )
269 #-------------------------------------------------
270 0 ▶sub cleanroot {
Subroutine cleanroot: not called CC=1 SCAR=6.9
Pod documented
271 0 my ( $self, $uri, $root ) = @_;
272  
273 0 $uri =~ s!^$root!!g;
274 0 $uri =~ s/\/\//\//g;
275 0 $uri =~ s/^\///;
276  
277 0 return( split( '/', $uri ) );
278
279 } # end cleanroot
280  
281 #-------------------------------------------------
282 # $self->import( $self, @options )
283 #-------------------------------------------------
284 8 ▶sub import {
Subroutine import: called CC=21 SCAR=43.8
285 8 my ( $class, @options ) = @_;
286  
287 8 my( $engine, $tplugin, $plugin, $splugin, $conf_instance, $conf_file );
288  
289 8 my $plugin_namespace = 'Gantry';
290 8 my $plugin_dir = 'Gantry::Plugins';
291
292 8 foreach (@options) {
293
294 # Import the proper engine
295 5 ▶ if ( /^-Engine=(\S+)/ ) {
Branch: 5 branches
BranchTrueFalseTotal
if (/^-Engine=(\S+)/) { } 1 4 5
elsif (/^-TemplateEngine=(\S+)/) { } 4 0 4
elsif (/^-StateMachine=(\S+)/) { } 0 0 0
elsif (/^-PluginNamespace=(\S+)/) { } 0 0 0
elsif (/^-PluginDir=(\S+)/) { } 0 0 0
296 1 ▶ unless ( $class->can( 'engine' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->can("engine")) 1 0 1
297 1 $engine = "Gantry::Engine::$1";
298 1 my $engine_file = File::Spec->catfile(
299 'Gantry', 'Engine', "${1}.pm"
300 );
301  
302 1 eval {
303 1 require $engine_file;
304 1 $engine->import();
305 };
306  
307 0 ▶ if ( $@ ) { die qq/Could not load engine "$engine", "$@"/ }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
308 }
309 }
310
311 # Load Template Engine
312 elsif ( /^-TemplateEngine=(\S+)/ ) {
313 4 $tplugin = "Gantry::Template::$1";
314 4 my $tfile = File::Spec->catfile(
315 'Gantry', 'Template', "${1}.pm"
316 );
317  
318 4 eval qq[
319 package $plugin_namespace;
320 require "$tfile";
321 $tplugin->import();
322 ];
323  
324 0 ▶ if ($@) { die qq/Could not load plugin "$tplugin", "$@"/ }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 4 4
325 }
326  
327 # Load the desired State Machine
328 elsif ( /^-StateMachine=(\S+)/ ) {
329 0 $splugin = "Gantry::State::$1";
330 0 my $sfile = File::Spec->catfile(
331 'Gantry', 'State', "${1}.pm"
332 );
333  
334 0 eval qq[
335 package $plugin_namespace;
336 require "$sfile";
337 $splugin->import();
338 ];
339  
340 0 ▶ if ($@) { die qq/Could not load state machine "$splugin", "$@"/ }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
341 }
342  
343 elsif ( /^-PluginNamespace=(\S+)/ ) {
344 0 $plugin_namespace = $1;
345 }
346
347 elsif ( /^-PluginDir=(\S+)/ ) {
348 0 $plugin_dir = $1;
349 }
350
351 else {
352 0 my @plugin_path;
353 my $plugin_file;
354 0 my $import_list = '';
355
356 # Check for plugin import list.
357 # Save list and strip it from the plugin.
358 0 ▶ if ( /\=(.*)$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\=(.*)$/o) 0 0 0
359 0 $import_list = $1;
360 0 $_ =~ s/=.*$//o;
361 }
362
363 0 $plugin = sprintf('%s::%s', $plugin_dir, $_);
364 0 @plugin_path = split /::/, $plugin . '.pm';
365  
366 0 $plugin_file = File::Spec->catfile(
367 @plugin_path
368 );
369  
370 0 eval qq[
371 package $plugin_namespace;
372 require "$plugin_file";
373 $plugin->import( qw( $import_list ) );
374 ];
375  
376 0 ▶ if ($@) { die qq/Could not load plugin "$plugin", "$@"/ }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
377
378 0 eval {
379 0 ▶ if ( $plugin_namespace eq 'Gantry' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($plugin_namespace eq "Gantry") 0 0 0
380 0 $plugin_namespace = $class->namespace;
381 }
382  
383 0 my @new_callbacks = $plugin->get_callbacks(
384 $plugin_namespace
385 );
386  
387 0 foreach my $callback ( @new_callbacks ) {
388 push @{
389 $plugin_callbacks{ $plugin_namespace }
390 { $callback->{ phase } }
391 0 }, $callback->{ callback };
392 }
393 };
394
395 # failure means not having to register callbacks
396 }
397 }
398
399 # Load Default template plugin if one hasn't been defined
400 8 ▶ if ( ! $tplugin && ! $class->can( 'do_action' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tplugin or $class->can("do_action")) 1 7 8
Condition100%3/3
$tplugin or $class->can("do_action")
l!l&&r!l&&!r
431
MC/DC100%2/2
$tplugin or $class->can("do_action")
$tplugin $class->can("do_action")
Truth table100%3/3
A or B
A= $tpluginB= $class->can("do_action")
ABresult
1X1
011
000
401 1 my( $tengine ) = ( $DEFAULT_PLUGIN_TEMPLATE =~ m!::(\w+)$! );
402 1 my $def_tengine_file = File::Spec->catfile(
403 'Gantry', 'Template', "${tengine}.pm"
404 );
405  
406 1 eval {
407 1 require $def_tengine_file;
408 1 import $DEFAULT_PLUGIN_TEMPLATE;
409 };
410 0 ▶ if ($@) { die qq/Could not load Default template engine, "$@"/ }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
411
412 }
413  
414 # Load the default state machine if one hasn't been defined
415 8 ▶ if ( ! $splugin && ! $class->can( 'state_run' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $splugin || $class->can("state_run")) 5 3 8
Condition66%2/3
$splugin || $class->can('state_run')
l!l&&r!l&&!r
035
MC/DC50%1/2
$splugin || $class->can('state_run')
$splugin $class->can('state_run')
Truth table66%2/3
A || B
A= $spluginB= $class->can('state_run')
ABresult
1X1
011
000
416  
417 5 my( $sengine ) = ( $DEFAULT_STATE_MACHINE =~ m!::(\w+)$! );
418 5 my $def_sengine_file = File::Spec->catfile(
419 'Gantry', 'State', "${sengine}.pm"
420 );
421  
422 5 eval {
423 5 require $def_sengine_file;
424 5 import $DEFAULT_STATE_MACHINE;
425 };
426 0 ▶ if ($@) { die qq/Could not load Default state machine, "$@"/ }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 5 5
427
428 }
429  
430 }
431  
432 #-------------------------------------------------
433 # $class->namespace or $site->namespace
434 #-------------------------------------------------
435 0 ▶sub namespace {
Subroutine namespace: not called CC=1 SCAR=6.9
Pod documented
436 0 return 'Gantry';
437 }
438  
439 #-------------------------------------------------
440 # $site->init( $r )
441 # note: this function should be redefined in the application.
442 # This will act as the default but it's recommended
443 # that only global init rules are defined here
444 #
445 # application note: for "proper" or suggested practice,
446 # the application level init function should immeadiatly
447 # call:
448 #
449 # $site->SUPER::init( $r );
450 #
451 # After the call to SUPER, the application level init
452 # should include its init intructions.
453 #-------------------------------------------------
454 0 ▶sub init {
Subroutine init: not called CC=9 SCAR=45.0
Pod documented
455 0 my ( $self, $r_or_cgi ) = @_;
456  
457 0 $self->uri( $self->fish_uri() );
458 0 $self->location( $self->fish_location() );
459 0 $self->path_info( $self->fish_path_info() );
460 0 $self->method( $self->fish_method() );
461 0 ▶ $self->protocol( $ENV{HTTPS} ? 'https://' : 'http://' );
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'HTTPS'} ? : 0 0 0
462 0 $self->status( "" );
463  
464 0 ▶ if (defined $plugin_callbacks{ $self->namespace }{ init }) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $plugin_callbacks{$self->namespace}{"init"}) 0 0 0
465 # Do the plugin callbacks for the 'init' phase
466 0 foreach my $callback (sort
467 0 @{ $plugin_callbacks{ $self->namespace }{ init } }
468 ) {
469 0 $callback->( $self );
470 }
471 }
472  
473 # set post_max - used for apache request object
474 0 ▶ $self->post_max( $self->fish_config( 'post_max' ) || '20000000' );
Condition0%0/2
$self->fish_config('post_max') || '20000000'
l!l
00
MC/DC0%0/1
$self->fish_config('post_max') || '20000000'
$self->fish_config('post_max')
Truth table0%0/2
A
A= $self->fish_config('post_max')
Aresult
11
00
475  
476 # set user varible
477 0 $self->user( $self->fish_user() );
478
479 # set default content-type
480 0 ▶ $self->content_type( $self->fish_config( 'content_type' ) || 'text/html' );
Condition0%0/2
$self->fish_config('content_type') || 'text/html'
l!l
00
MC/DC0%0/1
$self->fish_config('content_type') || 'text/html'
$self->fish_config('content_type')
Truth table0%0/2
A
A= $self->fish_config('content_type')
Aresult
11
00
481  
482 # set template variables
483 0 $self->template( $self->fish_config( 'template' ) );
484 0 $self->template_default( $self->fish_config( 'template_default' ) );
485 0 $self->template_wrapper( $self->fish_config( 'template_wrapper' ) );
486 0 $self->template_disable( $self->fish_config( 'template_disable' ) );
487
488 # set application directory variables
489 0 ▶ my $app_root = $self->fish_config( 'root' ) || '';
Condition0%0/2
$self->fish_config('root') || ''
l!l
00
MC/DC0%0/1
$self->fish_config('root') || ''
$self->fish_config('root')
Truth table0%0/2
A
A= $self->fish_config('root')
Aresult
11
00
490
491 0 $self->root( $app_root );
492 0 $self->doc_root( $self->fish_config( 'doc_root' ) );
493 0 $self->css_root( $self->fish_config( 'css_root' ) );
494 0 $self->img_root( $self->fish_config( 'img_root' ) );
495 0 $self->js_root( $self->fish_config( 'js_root' ) );
496 0 $self->tmp_root( $self->fish_config( 'tmp_root' ) );
497
498 # set application uri variables
499 0 $self->doc_rootp( $self->fish_config( 'doc_rootp' ) );
500 0 $self->web_rootp( $self->fish_config( 'web_rootp' ) );
501 0 $self->app_rootp( $self->fish_config( 'app_rootp' ) );
502 0 $self->img_rootp( $self->fish_config( 'img_rootp' ) );
503 0 $self->css_rootp( $self->fish_config( 'css_rootp' ) );
504 0 $self->js_rootp( $self->fish_config( 'js_rootp' ) );
505 0 $self->tmp_rootp( $self->fish_config( 'tmp_rootp' ) );
506 0 $self->editor_rootp( $self->fish_config( 'editor_rootp' ) );
507
508 # set no cache
509 0 $self->no_cache( $self->fish_config( 'no_cache' ) );
510
511 # set page title
512 0 ▶ $self->page_title( $self->fish_config( 'page_title' ) || $self->uri );
Condition0%0/3
$self->fish_config('page_title') || $self->uri
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->fish_config('page_title') || $self->uri
$self->fish_config('page_title') $self->uri
Truth table0%0/3
A || B
A= $self->fish_config('page_title')B= $self->uri
ABresult
1X1
011
000
513
514 # set default date format
515 0 ▶ $self->date_fmt( $self->fish_config( 'date_fmt' ) || '%b %d, %Y' );
Condition0%0/2
$self->fish_config('date_fmt') || '%b %d, %Y'
l!l
00
MC/DC0%0/1
$self->fish_config('date_fmt') || '%b %d, %Y'
$self->fish_config('date_fmt')
Truth table0%0/2
A
A= $self->fish_config('date_fmt')
Aresult
11
00
516
517
518 # set request body paramater variables
519 0 $self->set_req_params();
520  
521 # database and auth database variables are handled in each engine's
522 # Gantry::Utils::DBConnHelper::* sublcass.
523
524 } # END $site->init
525  
526 #-------------------------------------------------
527 # $self->r( value )
528 #-------------------------------------------------
529 0 ▶sub r {
Subroutine r: not called CC=2 SCAR=17.9
Pod documented
530 0 my ( $self, $p ) = @_;
531  
532 0 ▶ $self->{__R__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
533 0 return( $self->{__R__} );
534
535 } # end r
536  
537 #-------------------------------------------------
538 # $self->cgi( value )
539 #-------------------------------------------------
540 0 ▶sub cgi {
Subroutine cgi: not called CC=2 SCAR=17.9
Pod documented
541 0 my( $self, $p ) = @_;
542  
543 0 ▶ $self->{__CGI__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
544 0 return( $self->{__CGI__} );
545 } # end cgi
546  
547 #-------------------------------------------------
548 # $self->method( value )
549 #-------------------------------------------------
550 0 ▶sub method {
Subroutine method: not called CC=2 SCAR=17.9
Pod documented
551 0 my ( $self, $p ) = @_;
552  
553 0 ▶ $self->{__METHOD__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
554 0 return( $self->{__METHOD__} );
555
556 } # end method
557  
558 #-------------------------------------------------
559 # $self->no_cache( value )
560 #-------------------------------------------------
561 0 ▶sub no_cache {
Subroutine no_cache: not called CC=2 SCAR=17.9
Pod documented
562 0 my ( $self, $p ) = @_;
563  
564 0 ▶ $self->{__NO_CACHE__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
565 0 return( $self->{__NO_CACHE__} );
566
567 } # end no_cache
568  
569 #-------------------------------------------------
570 # $self->uri( value )
571 #-------------------------------------------------
572 0 ▶sub uri {
Subroutine uri: not called CC=3 SCAR=24.8
Pod documented
573 0 my ( $self, $p ) = @_;
574  
575 0 ▶ $self->{__URI__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
576 0 ▶ return( $self->{__URI__} || '' );
Condition0%0/2
$self->{'__URI__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__URI__'} || ''
$self->{'__URI__'}
Truth table0%0/2
A
A= $self->{'__URI__'}
Aresult
11
00
577
578 } # end uri
579  
580 #-------------------------------------------------
581 # $self->location( value )
582 #-------------------------------------------------
583 9 ▶sub location {
Subroutine location: called CC=3 SCAR=11.1
Pod documented
584 9 my ( $self, $p ) = @_;
585  
586 9 ▶ $self->{__LOCATION__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 4 5 9
587 9 ▶ return( $self->{__LOCATION__} || '' );
Condition50%1/2
$self->{'__LOCATION__'} || ''
l!l
90
MC/DC0%0/1
$self->{'__LOCATION__'} || ''
$self->{'__LOCATION__'}
Truth table50%1/2
A
A= $self->{'__LOCATION__'}
Aresult
11
00
588
589 } # end location
590  
591 #-------------------------------------------------
592 # $self->action( value )
593 #-------------------------------------------------
594 0 ▶sub action {
Subroutine action: not called CC=3 SCAR=24.8
Pod documented
595 0 my ( $self, $p ) = @_;
596  
597 0 ▶ $self->{__ACTION__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
598 0 ▶ return( $self->{__ACTION__} || '' );
Condition0%0/2
$self->{'__ACTION__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__ACTION__'} || ''
$self->{'__ACTION__'}
Truth table0%0/2
A
A= $self->{'__ACTION__'}
Aresult
11
00
599
600 } # end action
601  
602 #-------------------------------------------------
603 # $self->current_url( )
604 #-------------------------------------------------
605 0 ▶sub current_url {
Subroutine current_url: not called CC=1 SCAR=6.9
Pod documented
606 0 my ( $self ) = @_;
607  
608 0 return $self->protocol . $self->base_server . $self->uri;
609 } # end location
610  
611 #-------------------------------------------------
612 # $self->path_info( value )
613 #-------------------------------------------------
614 0 ▶sub path_info {
Subroutine path_info: not called CC=3 SCAR=24.8
Pod documented
615 0 my ( $self, $p ) = @_;
616  
617 0 ▶ $self->{__PATH_INFO__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
618 0 ▶ return( $self->{__PATH_INFO__} || '' );
Condition0%0/2
$self->{'__PATH_INFO__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__PATH_INFO__'} || ''
$self->{'__PATH_INFO__'}
Truth table0%0/2
A
A= $self->{'__PATH_INFO__'}
Aresult
11
00
619
620 } # end path_info
621  
622 #-------------------------------------------------
623 # $self->content_length( value )
624 #-------------------------------------------------
625 0 ▶sub content_length {
Subroutine content_length: not called CC=2 SCAR=17.9
Pod documented
626 0 my ( $self, $p ) = @_;
627  
628 0 ▶ $self->{__CONTENT_LENGTH__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
629 0 return( $self->{__CONTENT_LENGTH__} );
630
631 } # end content_length
632  
633 #-------------------------------------------------
634 # $self->content_type( value )
635 #-------------------------------------------------
636 0 ▶sub content_type {
Subroutine content_type: not called CC=2 SCAR=17.9
Pod documented
637 0 my ( $self, $p ) = @_;
638  
639 0 ▶ $self->{__CONTENT_TYPE__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
640 0 return( $self->{__CONTENT_TYPE__} );
641
642 } # end content_type
643  
644 #-------------------------------------------------
645 # $self->template( value )
646 #-------------------------------------------------
647 0 ▶sub template {
Subroutine template: not called CC=2 SCAR=17.9
Pod documented
648 0 my ( $self, $p ) = @_;
649  
650 0 ▶ $self->{__TEMPLATE__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
651 0 return( $self->{__TEMPLATE__} );
652
653 } # end template
654  
655 #-------------------------------------------------
656 # $self->template_default( value )
657 #-------------------------------------------------
658 0 ▶sub template_default {
Subroutine template_default: not called CC=2 SCAR=17.9
Pod documented
659 0 my ( $self, $p ) = @_;
660  
661 0 ▶ $self->{__TEMPLATE_DEFAULT__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
662 0 return( $self->{__TEMPLATE_DEFAULT__} );
663
664 } # end template_default
665  
666 #-------------------------------------------------
667 # $self->template_wrapper( value )
668 #-------------------------------------------------
669 0 ▶sub template_wrapper {
Subroutine template_wrapper: not called CC=2 SCAR=17.9
Pod documented
670 0 my ( $self, $p ) = @_;
671  
672 0 ▶ $self->{__TEMPLATE_WRAPPER__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
673 0 return( $self->{__TEMPLATE_WRAPPER__} );
674
675 } # end template_wrapper
676  
677 #-------------------------------------------------
678 # $self->template_disable( value )
679 #-------------------------------------------------
680 0 ▶sub template_disable {
Subroutine template_disable: not called CC=2 SCAR=17.9
Pod documented
681 0 my ( $self, $p ) = @_;
682  
683 0 ▶ $self->{__TEMPLATE_DISABLE__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
684 0 return( $self->{__TEMPLATE_DISABLE__} );
685
686 } # end template_disable
687  
688 #-------------------------------------------------
689 # $self->root( value )
690 #-------------------------------------------------
691 0 ▶sub root {
Subroutine root: not called CC=3 SCAR=24.8
Pod documented
692 0 my ( $self, $p ) = @_;
693  
694 0 ▶ $self->{__ROOT__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
695 0 ▶ return( $self->{__ROOT__} || '' );
Condition0%0/2
$self->{'__ROOT__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__ROOT__'} || ''
$self->{'__ROOT__'}
Truth table0%0/2
A
A= $self->{'__ROOT__'}
Aresult
11
00
696
697 } # end root
698  
699 #-------------------------------------------------
700 # $self->css_root( value )
701 #-------------------------------------------------
702 0 ▶sub css_root {
Subroutine css_root: not called CC=3 SCAR=24.8
Pod documented
703 0 my ( $self, $p ) = @_;
704  
705 0 ▶ $self->{__CSS_ROOT__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
706 0 ▶ return( $self->{__CSS_ROOT__} || '' );
Condition0%0/2
$self->{'__CSS_ROOT__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__CSS_ROOT__'} || ''
$self->{'__CSS_ROOT__'}
Truth table0%0/2
A
A= $self->{'__CSS_ROOT__'}
Aresult
11
00
707
708 } # end css_root
709  
710 #-------------------------------------------------
711 # $self->tmp_root( value )
712 #-------------------------------------------------
713 0 ▶sub tmp_root {
Subroutine tmp_root: not called CC=3 SCAR=24.8
Pod documented
714 0 my ( $self, $p ) = @_;
715  
716 0 ▶ $self->{__TMP_ROOT__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
717 0 ▶ return( $self->{__TMP_ROOT__} || '' );
Condition0%0/2
$self->{'__TMP_ROOT__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__TMP_ROOT__'} || ''
$self->{'__TMP_ROOT__'}
Truth table0%0/2
A
A= $self->{'__TMP_ROOT__'}
Aresult
11
00
718  
719 } # end tmp_root
720  
721 #-------------------------------------------------
722 # $self->tmp_rootp( value )
723 #-------------------------------------------------
724 0 ▶sub tmp_rootp {
Subroutine tmp_rootp: not called CC=3 SCAR=24.8
Pod documented
725 0 my ( $self, $p ) = @_;
726  
727 0 ▶ $self->{__TMP_ROOTP__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
728 0 ▶ return( $self->{__TMP_ROOTP__} || '' );
Condition0%0/2
$self->{'__TMP_ROOTP__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__TMP_ROOTP__'} || ''
$self->{'__TMP_ROOTP__'}
Truth table0%0/2
A
A= $self->{'__TMP_ROOTP__'}
Aresult
11
00
729  
730 } # end tmp_rootp
731  
732 #-------------------------------------------------
733 # $self->editor_rootp( value )
734 #-------------------------------------------------
735 0 ▶sub editor_rootp {
Subroutine editor_rootp: not called CC=3 SCAR=24.8
Pod documented
736 0 my ( $self, $p ) = @_;
737  
738 0 ▶ $self->{__EDITOR_ROOTP__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
739 0 ▶ return( $self->{__EDITOR_ROOTP__} || '' );
Condition0%0/2
$self->{'__EDITOR_ROOTP__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__EDITOR_ROOTP__'} || ''
$self->{'__EDITOR_ROOTP__'}
Truth table0%0/2
A
A= $self->{'__EDITOR_ROOTP__'}
Aresult
11
00
740  
741 } # end editor_rootp
742  
743 #-------------------------------------------------
744 # $self->img_root( value )
745 #-------------------------------------------------
746 0 ▶sub img_root {
Subroutine img_root: not called CC=3 SCAR=24.8
Pod documented
747 0 my ( $self, $p ) = @_;
748  
749 0 ▶ $self->{__IMG_ROOT__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
750 0 ▶ return( $self->{__IMG_ROOT__} || '' );
Condition0%0/2
$self->{'__IMG_ROOT__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__IMG_ROOT__'} || ''
$self->{'__IMG_ROOT__'}
Truth table0%0/2
A
A= $self->{'__IMG_ROOT__'}
Aresult
11
00
751
752 } # end img_root
753  
754 #-------------------------------------------------
755 # $self->js_root( value )
756 #-------------------------------------------------
757 0 ▶sub js_root {
Subroutine js_root: not called CC=3 SCAR=24.8
Pod documented
758 0 my ( $self, $p ) = @_;
759  
760 0 ▶ $self->{__JS_ROOT__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
761 0 ▶ return( $self->{__JS_ROOT__} || '' );
Condition0%0/2
$self->{'__JS_ROOT__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__JS_ROOT__'} || ''
$self->{'__JS_ROOT__'}
Truth table0%0/2
A
A= $self->{'__JS_ROOT__'}
Aresult
11
00
762
763 } # end js_root
764  
765 #-------------------------------------------------
766 # $self->app_rootp( value )
767 #-------------------------------------------------
768 0 ▶sub app_rootp {
Subroutine app_rootp: not called CC=3 SCAR=24.8
Pod documented
769 0 my ( $self, $p ) = @_;
770  
771 0 ▶ if ( defined $p ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $p) 0 0 0
772 # trim trailing slashes
773 0 $p =~ s{/+$}{}g;
774  
775 0 $self->{__APP_ROOTP__} = $p;
776 }
777 0 ▶ return( $self->{__APP_ROOTP__} || '' );
Condition0%0/2
$self->{'__APP_ROOTP__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__APP_ROOTP__'} || ''
$self->{'__APP_ROOTP__'}
Truth table0%0/2
A
A= $self->{'__APP_ROOTP__'}
Aresult
11
00
778
779 } # end app_rootp
780  
781 #-------------------------------------------------
782 # $self->web_rootp( value )
783 #-------------------------------------------------
784 0 ▶sub web_rootp {
Subroutine web_rootp: not called CC=3 SCAR=24.8
Pod documented
785 0 my ( $self, $p ) = @_;
786  
787 0 ▶ $self->{__WEB_ROOTP__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
788 0 ▶ return( $self->{__WEB_ROOTP__} || '' );
Condition0%0/2
$self->{'__WEB_ROOTP__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__WEB_ROOTP__'} || ''
$self->{'__WEB_ROOTP__'}
Truth table0%0/2
A
A= $self->{'__WEB_ROOTP__'}
Aresult
11
00
789
790 } # end web_rootp
791  
792 #-------------------------------------------------
793 # $self->doc_rootp( value )
794 #-------------------------------------------------
795 0 ▶sub doc_rootp {
Subroutine doc_rootp: not called CC=3 SCAR=24.8
Pod documented
796 0 my ( $self, $p ) = @_;
797  
798 0 ▶ $self->{__DOC_ROOTP__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
799 0 ▶ return( $self->{__DOC_ROOTP__} || '' );
Condition0%0/2
$self->{'__DOC_ROOTP__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__DOC_ROOTP__'} || ''
$self->{'__DOC_ROOTP__'}
Truth table0%0/2
A
A= $self->{'__DOC_ROOTP__'}
Aresult
11
00
800
801 } # end doc_rootp
802  
803 #-------------------------------------------------
804 # $self->js_rootp( value )
805 #-------------------------------------------------
806 0 ▶sub js_rootp {
Subroutine js_rootp: not called CC=3 SCAR=24.8
Pod documented
807 0 my ( $self, $p ) = @_;
808  
809 0 ▶ $self->{__JS_ROOTP__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
810 0 ▶ return( $self->{__JS_ROOTP__} || '' );
Condition0%0/2
$self->{'__JS_ROOTP__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__JS_ROOTP__'} || ''
$self->{'__JS_ROOTP__'}
Truth table0%0/2
A
A= $self->{'__JS_ROOTP__'}
Aresult
11
00
811
812 } # end js_rootp
813  
814 #-------------------------------------------------
815 # $self->doc_root( value )
816 #-------------------------------------------------
817 0 ▶sub doc_root {
Subroutine doc_root: not called CC=3 SCAR=24.8
Pod documented
818 0 my ( $self, $p ) = @_;
819  
820 0 ▶ $self->{__DOC_ROOT__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
821 0 ▶ return( $self->{__DOC_ROOT__} || '' );
Condition0%0/2
$self->{'__DOC_ROOT__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__DOC_ROOT__'} || ''
$self->{'__DOC_ROOT__'}
Truth table0%0/2
A
A= $self->{'__DOC_ROOT__'}
Aresult
11
00
822
823 } # end doc_root
824  
825 #-------------------------------------------------
826 # $self->img_rootp( value )
827 #-------------------------------------------------
828 0 ▶sub img_rootp {
Subroutine img_rootp: not called CC=3 SCAR=24.8
Pod documented
829 0 my ( $self, $p ) = @_;
830  
831 0 ▶ if ( defined $p ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $p) 0 0 0
832 # trim trailing slashes
833 0 $p =~ s{/+$}{}g;
834  
835 0 $self->{__IMG_ROOTP__} = $p;
836 }
837 0 ▶ return( $self->{__IMG_ROOTP__} || '' );
Condition0%0/2
$self->{'__IMG_ROOTP__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__IMG_ROOTP__'} || ''
$self->{'__IMG_ROOTP__'}
Truth table0%0/2
A
A= $self->{'__IMG_ROOTP__'}
Aresult
11
00
838
839 } # end img_rootp
840  
841 #-------------------------------------------------
842 # $self->css_rootp( value )
843 #-------------------------------------------------
844 0 ▶sub css_rootp {
Subroutine css_rootp: not called CC=3 SCAR=24.8
Pod documented
845 0 my ( $self, $p ) = @_;
846  
847 0 ▶ if ( defined $p ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $p) 0 0 0
848 # trim trailing slashes
849 0 $p =~ s{/+$}{}g;
850  
851 0 $self->{__CSS_ROOTP__} = $p;
852 }
853 0 ▶ return( $self->{__CSS_ROOTP__} || '' );
Condition0%0/2
$self->{'__CSS_ROOTP__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__CSS_ROOTP__'} || ''
$self->{'__CSS_ROOTP__'}
Truth table0%0/2
A
A= $self->{'__CSS_ROOTP__'}
Aresult
11
00
854
855 } # end css_rootp
856  
857 #-------------------------------------------------
858 # $self->page_title( value )
859 #-------------------------------------------------
860 0 ▶sub page_title {
Subroutine page_title: not called CC=3 SCAR=24.8
Pod documented
861 0 my ( $self, $p ) = @_;
862  
863 0 ▶ $self->{__PAGE_TITLE__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
864 0 ▶ return( $self->{__PAGE_TITLE__} || '' );
Condition0%0/2
$self->{'__PAGE_TITLE__'} || ''
l!l
00
MC/DC0%0/1
$self->{'__PAGE_TITLE__'} || ''
$self->{'__PAGE_TITLE__'}
Truth table0%0/2
A
A= $self->{'__PAGE_TITLE__'}
Aresult
11
00
865
866 } # end uri
867  
868 #-------------------------------------------------
869 # $self->date_fmt( value )
870 #-------------------------------------------------
871 0 ▶sub date_fmt {
Subroutine date_fmt: not called CC=2 SCAR=17.9
Pod documented
872 0 my ( $self, $p ) = @_;
873  
874 0 ▶ $self->{__DATE_FMT__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
875 0 return( $self->{__DATE_FMT__} );
876
877 } # end date_fmt
878  
879 #-------------------------------------------------
880 # $self->user( value )
881 #-------------------------------------------------
882 0 ▶sub user {
Subroutine user: not called CC=2 SCAR=17.9
Pod documented
883 0 my ( $self, $p ) = @_;
884  
885 0 ▶ $self->{__USER__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
886 0 return( $self->{__USER__} );
887
888 } # end user
889  
890 #-------------------------------------------------
891 # $self->test( value )
892 #-------------------------------------------------
893 0 ▶sub test {
Subroutine test: not called CC=2 SCAR=17.9
Pod documented
894 0 my ( $self, $p ) = @_;
895  
896 0 ▶ $self->{__TEST__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
897 0 return( $self->{__TEST__} );
898
899 } # end test
900  
901 #-------------------------------------------------
902 # $self->get_auth_model_name( )
903 #-------------------------------------------------
904 0 ▶sub get_auth_model_name {
Subroutine get_auth_model_name: not called CC=2 SCAR=17.9
Pod documented
905 0 my ( $self ) = shift;
906  
907 return $self->{__MODELS__}{__AUTH_USERS__}
908 0 ▶ || 'Gantry::Control::Model::auth_users';
Condition0%0/2
$self->{'__MODELS__'}{'__AUTH_USERS__'} || 'Gantry::Control::Model::auth_users'
l!l
00
MC/DC0%0/1
$self->{'__MODELS__'}{'__AUTH_USERS__'} || 'Gantry::Control::Model::auth_users'
$self->{'__MODELS__'}{'__AUTH_USERS__'}
Truth table0%0/2
A
A= $self->{'__MODELS__'}{'__AUTH_USERS__'}
Aresult
11
00
909 }
910  
911 #-------------------------------------------------
912 # $self->set_auth_model_name( )
913 #-------------------------------------------------
914 0 ▶sub set_auth_model_name {
Subroutine set_auth_model_name: not called CC=2 SCAR=17.9
Pod documented
915 0 my ( $self, $model ) = @_;
916  
917 0 ▶ $model = $self->get_auth_model_name() unless $model;
Branch: 1 branch
BranchTrueFalseTotal
unless $model 0 0 0
918  
919 0 $self->{__MODELS__}{__AUTH_USERS__} = $model;
920  
921 0 my @pieces = split /::/, $model;
922 0 my $base = pop @pieces;
923  
924 0 my $file_name = File::Spec->catfile( @pieces, "$base.pm" );
925  
926 0 require $file_name;
927 }
928  
929 #-------------------------------------------------
930 # $self->user_row( { model => '', user_name => '' } )
931 #-------------------------------------------------
932 0 ▶sub user_row {
Subroutine user_row: not called CC=6 SCAR=37.4
Pod documented
933 0 my ( $self, @opts ) = @_;
934  
935 0 ▶ my $options = (@opts == 1) && UNIVERSAL::isa($opts[0], 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
@opts == 1 && UNIVERSAL::isa($opts[0], 'HASH') ? : 0 0 0
Condition0%0/3
@opts == 1 and UNIVERSAL::isa($opts[0], "HASH")
!ll&&!rl&&r
000
MC/DC0%0/2
@opts == 1 and UNIVERSAL::isa($opts[0], "HASH")
@opts == 1 UNIVERSAL::isa($opts[0], "HASH")
Truth table0%0/3
A and B
A= @opts == 1B= UNIVERSAL::isa($opts[0], "HASH")
ABresult
0X0
100
111
936 ? shift(@opts) : { @opts };
937  
938 0 $self->set_auth_model_name( $options->{model} );
939  
940 0 ▶ if ( defined $self->{__MODELS__}{__AUTH_USERS__} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'__MODELS__'}{'__AUTH_USERS__'}) { } 0 0 0
941
942 # use request user_name if passed to function
943 my $user_name = defined $options->{user_name} ?
944 0 ▶ $options->{user_name} : $self->user;
Branch: 1 branch
BranchTrueFalseTotal
defined $options->{'user_name'} ? : 0 0 0
945  
946 my @rows = $self->{__MODELS__}{__AUTH_USERS__}->search(
947 0 { user_name => $user_name }, $self, undef
948 );
949  
950 0 ▶ return( $rows[0] ) if @rows;
Branch: 1 branch
BranchTrueFalseTotal
if @rows 0 0 0
951 }
952 else {
953 0 die( "failed to lookup user: unknown auth_users model" );
954 }
955  
956 0 return; # don't know
957
958 } # end user_row
959  
960 #-------------------------------------------------
961 # $self->user_id( { model => '', user_name => '' } )
962 #-------------------------------------------------
963 0 ▶sub user_id {
Subroutine user_id: not called CC=2 SCAR=17.9
Pod documented
964 0 my ( $self, @opts ) = @_;
965  
966 0 my $row = $self->user_row( @opts );
967  
968 0 ▶ ( defined $row ) ? return $row->user_id : return;
Branch: 1 branch
BranchTrueFalseTotal
defined $row ? : 0 0 0
969 }
970  
971 #-------------------------------------------------
972 # $self->post_max( value )
973 #-------------------------------------------------
974 0 ▶sub post_max {
Subroutine post_max: not called CC=2 SCAR=17.9
Pod documented
975 0 my ( $self, $p ) = @_;
976  
977 0 ▶ $self->{__POST_MAX__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
978 0 return( $self->{__POST_MAX__} );
979
980 } # end POST_MAX
981  
982 #-------------------------------------------------
983 # $self->ap_req( value )
984 #-------------------------------------------------
985 0 ▶sub ap_req {
Subroutine ap_req: not called CC=3 SCAR=24.8
Pod documented
986 0 my ( $self, $p ) = @_;
987  
988 $self->{__AP_REQ__} = $p
989 0 ▶ if ( ( ! defined $self->{__AP_REQ__} ) and defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $self->{"__AP_REQ__"} and defined $p 0 0 0
Condition0%0/3
not defined $self->{"__AP_REQ__"} and defined $p
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $self->{"__AP_REQ__"} and defined $p
not defined $self->{"__AP_REQ__"} defined $p
Truth table0%0/3
not(A) and B
A= not defined $self->{"__AP_REQ__"}B= defined $p
ABresult
0X0
100
111
990
991 0 return( $self->{__AP_REQ__} );
992 } # end ap_req
993  
994 #-------------------------------------------------
995 # $self->params( value )
996 #-------------------------------------------------
997 0 ▶sub params {
Subroutine params: not called CC=2 SCAR=17.9
Pod documented
998 0 my ( $self, $p ) = @_;
999  
1000 0 ▶ $self->{__PARAMS__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
1001 0 return( $self->{__PARAMS__} );
1002  
1003 } # end params
1004  
1005 #-------------------------------------------------
1006 # $self->uf_params( value )
1007 #-------------------------------------------------
1008 0 ▶sub uf_params {
Subroutine uf_params: not called CC=2 SCAR=17.9
Pod documented
1009 0 my ( $self, $p ) = @_;
1010  
1011 0 ▶ $self->{__UF_PARAMS__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
1012 0 return( $self->{__UF_PARAMS__} );
1013  
1014 } # end uf_params
1015  
1016 #-------------------------------------------------
1017 # $self->get_param_hash()
1018 #-------------------------------------------------
1019 0 ▶sub get_param_hash {
Subroutine get_param_hash: not called CC=3 SCAR=24.8
Pod documented
1020 0 my $self = shift;
1021
1022 0 my %param = ();
1023
1024 0 eval {
1025 0 %param = %{ $self->params };
1026 };
1027 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1028 0 die "$@";
1029 }
1030
1031 0 ▶ return wantarray ? %param : \%param;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1032  
1033 } # end get_param_hash
1034  
1035 #-------------------------------------------------
1036 # $self->get_uf_param_hash()
1037 #-------------------------------------------------
1038 0 ▶sub get_uf_param_hash {
Subroutine get_uf_param_hash: not called CC=3 SCAR=24.8
Pod documented
1039 0 my $self = shift;
1040  
1041 0 my %param = ();
1042  
1043 0 eval {
1044 0 %param = %{ $self->uf_params };
1045 };
1046 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1047 0 die "$@";
1048 }
1049  
1050 0 ▶ return wantarray ? %param : \%param;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1051  
1052 } # end get_uf_param_hash
1053  
1054 #-------------------------------------------------
1055 # $self->protocol( value )
1056 #-------------------------------------------------
1057 0 ▶sub protocol {
Subroutine protocol: not called CC=2 SCAR=17.9
Pod documented
1058 0 my ( $self, $p ) = @_;
1059  
1060 0 ▶ $self->{__PROTOCOL__} = $p if ( defined $p );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p 0 0 0
1061 0 return( $self->{__PROTOCOL__} );
1062
1063 } # end protocol
1064  
1065 #-------------------------------------------------
1066 # $self->is_post()
1067 #-------------------------------------------------
1068 0 ▶sub is_post {
Subroutine is_post: not called CC=2 SCAR=17.9
Pod documented
1069 0 my ( $self ) = @_;
1070
1071 0 ▶ return( $self->method eq 'POST' ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$self->method eq 'POST' ? : 0 0 0
1072
1073 } # end is_post
1074  
1075 #-------------------------------------------------
1076 # $self->gantry_secret()
1077 #-------------------------------------------------
1078 0 ▶sub gantry_secret {
Subroutine gantry_secret: not called CC=2 SCAR=17.9
Pod documented
1079 0 my ( $self ) = @_;
1080
1081 0 ▶ return $self->fish_config( 'gantry_secret' ) || 'w3s3cR7';
Condition0%0/2
$self->fish_config('gantry_secret') || 'w3s3cR7'
l!l
00
MC/DC0%0/1
$self->fish_config('gantry_secret') || 'w3s3cR7'
$self->fish_config('gantry_secret')
Truth table0%0/2
A
A= $self->fish_config('gantry_secret')
Aresult
11
00
1082 } # end gantry_secret
1083  
1084 #-------------------------------------------------
1085 # $self->controller_config()
1086 #-------------------------------------------------
1087 0 ▶sub controller_config {
Subroutine controller_config: not called CC=1 SCAR=6.9
Pod documented
1088 0 return {};
1089 } # end controller_config
1090  
1091 ##-------------------------------------------------
1092 ## $self->get_conf( )
1093 ##-------------------------------------------------
1094 #sub get_conf {
1095 # my $class = shift;
1096 # my $instance = shift;
1097 # my $file = shift;
1098 #
1099 # return Gantry::Conf->retrieve(
1100 # $instance,
1101 # $file
1102 # );
1103 #}
1104  
1105 #-------------------------------------------------
1106 # $self->cleanup( $r )
1107 # note: this function should be redefined in the application.
1108 # This will act as the default but it's recommended
1109 # that only global cleanup rules are defined here
1110 #
1111 # application note: for "proper" or suggested practice,
1112 # the application level cleanup function should immeadiatly
1113 # call:
1114 #
1115 # $self->SUPER::cleanup( $r );
1116 #
1117 # After the call to SUPER, the application level cleanup
1118 # should include its cleanup intructions.
1119 #-------------------------------------------------
1120 0 ▶sub cleanup {
Subroutine cleanup: not called CC=4 SCAR=30.0
Pod documented
1121 0 my ( $self ) = @_;
1122  
1123 # Make sure get_schema() is available first.
1124 0 ▶ if ( $self->can( 'get_schema' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can("get_schema")) 0 0 0
1125 # Get main database schema.
1126 0 my $schema = $self->get_schema();
1127  
1128 # Disconnect from database, if the schema exists.
1129 0 ▶ if ($schema) {
Branch: 1 branch
BranchTrueFalseTotal
if ($schema) 0 0 0
1130 0 $schema->storage()->disconnect();
1131 }
1132 }
1133  
1134 # Create helper to get and set auth schema dbh.
1135 0 my $helper = Gantry::Utils::DBConnHelper->get_subclass();
1136 0 my $auth_schema = $helper->get_auth_dbh();
1137  
1138 # Disconnect from database, if the schema exists.
1139 0 ▶ if ($auth_schema) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auth_schema) 0 0 0
1140 0 $auth_schema->disconnect();
1141  
1142 # Undefine the dbh so that it will re-connect automatically
1143 # on the next request.
1144 0 $helper->set_auth_dbh( undef );
1145 }
1146  
1147 # db_disconnect( $$self{dbh} );
1148  
1149 } # end cleanup
1150  
1151 #-------------------------------------------------
1152 # $self->custom_error( @errors )
1153 #-------------------------------------------------
1154 0 ▶sub custom_error {
Subroutine custom_error: not called CC=2 SCAR=17.9
Pod documented
1155 0 my( $self, @err ) = @_;
1156
1157 0 eval "use Data::Dumper";
1158  
1159 0 my $die_msg = join( "\n", @err );
1160
1161 0 my $param_dump = Dumper( $self->params );
1162 0 $param_dump =~ s/(?:^|\n)(\s+)/&trim( $1 )/ge;
1163 0 $param_dump =~ s/</&lt;/g;
1164  
1165 0 my $request_dump = Dumper( $self );
1166 0 my $response_dump = '';
1167 0 $request_dump =~ s/(?:^|\n)(\s+)/&trim( $1 )/ge;
1168 0 $request_dump =~ s/</&lt;/g;
1169  
1170 0 ▶ my $status = $self->status || 'Bad Request';
Condition0%0/2
$self->status || 'Bad Request'
l!l
00
MC/DC0%0/1
$self->status || 'Bad Request'
$self->status
Truth table0%0/2
A
A= $self->status
Aresult
11
00
1171
1172 0 my $page = $self->_error_page();
1173
1174 0 $page =~ s/##DIE_MESSAGE##/$die_msg/sg;
1175 0 $page =~ s/##PARAM_DUMP##/$param_dump/sg;
1176 0 $page =~ s/##REQUEST_DUMP##/$request_dump/sg;
1177 0 $page =~ s/##RESPONSE_DUMP##/$response_dump/sg;
1178 0 $page =~ s/##STATUS##/$status/sg;
1179 0 $page =~ s/##PAGE_TITLE##/$self->page_title/sge;
1180
1181 0 return( $page );
1182
1183  
1184 } # end custom_error
1185  
1186 0 ▶sub trim {
Subroutine trim: not called CC=1 SCAR=6.9
Pod documented
1187 0 my $spaces = $1;
1188  
1189 0 my $new_sp = " " x int( length($spaces) / 4 );
1190 0 return( "\n$new_sp" );
1191 }
1192  
1193 #-------------------------------------------------
1194 # $self->serialize_params( [ keys to exclude ], <separator> )
1195 #-------------------------------------------------
1196 0 ▶sub serialize_params {
Subroutine serialize_params: not called CC=7 SCAR=40.3
Pod documented
1197 0 my( $self, $exclude_ref, $separator ) = @_;
1198
1199 0 ▶ $exclude_ref ||= [];
Condition0%0/2
$exclude_ref ||= []
l!l
00
MC/DC0%0/1
$exclude_ref ||= []
$exclude_ref
Truth table0%0/2
A
A= $exclude_ref
Aresult
11
00
1200 0 ▶ $separator ||= '&';
Condition0%0/2
$separator ||= "&"
l!l
00
MC/DC0%0/1
$separator ||= "&"
$separator
Truth table0%0/2
A
A= $separator
Aresult
11
00
1201 0 my $exclude_hash = {};
1202
1203 0 foreach ( @{ $exclude_ref } ) {
1204 0 ++$exclude_hash->{$_};
1205 }
1206
1207 0 my @page_params;
1208 0 foreach my $p ( keys %{ $self->params } ) {
1209 0 ▶ next if $p =~ /^\./;
Branch: 1 branch
BranchTrueFalseTotal
if $p =~ /^\./ 0 0 0
1210 0 ▶ next if exists $exclude_hash->{$p};
Branch: 1 branch
BranchTrueFalseTotal
if exists $exclude_hash->{$p} 0 0 0
1211  
1212 0 push( @page_params, sprintf( "%s=%s", $p, $self->params->{$p} ) );
1213 }
1214  
1215 0 return join( $separator, @page_params );
1216
1217 }
1218  
1219 #-------------------------------------------------
1220 # $self->escape_html($value)
1221 #-------------------------------------------------
1222 0 ▶sub escape_html {
Subroutine escape_html: not called CC=1 SCAR=6.9
Pod documented
1223 0 my ($self, $value) = @_;
1224
1225 0 $value =~ s/</&lt;/go;
1226 0 $value =~ s/>/&gt;/go;
1227 0 $value =~ s/"/&#34;/go;
1228 0 $value =~ s/'/&#39;/go;
1229
1230 0 return $value;
1231 }
1232  
1233 #-------------------------------------------------
1234 # $self->unescape_html($value)
1235 #-------------------------------------------------
1236 0 ▶sub unescape_html {
Subroutine unescape_html: not called CC=1 SCAR=6.9
Pod documented
1237 0 my ($self, $value) = @_;
1238
1239 0 $value =~ s/&lt;/</go;
1240 0 $value =~ s/&gt;/>/go;
1241 0 $value =~ s/&#34;/"/go;
1242 0 $value =~ s/&#39;/'/go;
1243
1244 0 return $value;
1245 }
1246  
1247 #-------------------------------------------------
1248 # $self->_error_page()
1249 #-------------------------------------------------
1250 0 ▶sub _error_page {
Subroutine _error_page: not called CC=1 SCAR=6.9
1251 0 my( $self ) = ( shift );
1252
1253 0 return( qq!
1254 <html>
1255 <head>
1256 <title>##PAGE_TITLE## ##STATUS##</title>
1257 <style type="text/css">
1258 body {
1259 font-family: "Bitstream Vera Sans", "Trebuchet MS", Verdana,
1260 Tahoma, Arial, helvetica, sans-serif;
1261 color: #ddd;
1262 background-color: #eee;
1263 margin: 0px;
1264 padding: 0px;
1265 }
1266 div.box {
1267 background-color: #ccc;
1268 border: 1px solid #aaa;
1269 padding: 4px;
1270 margin: 10px;
1271 -moz-border-radius: 10px;
1272 }
1273 div.error {
1274 font: 20px Tahoma;
1275 background-color: #88003A;
1276 border: 1px solid #755;
1277 padding: 8px;
1278 margin: 4px;
1279 margin-bottom: 10px;
1280 -moz-border-radius: 10px;
1281 }
1282 div.infos {
1283 font: 9px Tahoma;
1284 background-color: #779;
1285 border: 1px solid #575;
1286 padding: 8px;
1287 margin: 4px;
1288 margin-bottom: 10px;
1289 -moz-border-radius: 10px;
1290 }
1291 .head {
1292 font: 12px Tahoma;
1293 }
1294 div.name {
1295 font: 12px Tahoma;
1296 background-color: #66B;
1297 border: 1px solid #557;
1298 padding: 8px;
1299 margin: 4px;
1300 -moz-border-radius: 10px;
1301 }
1302 </style>
1303 </head>
1304 <body>
1305 <div class="box">
1306 <div class="error">##DIE_MESSAGE##</div>
1307 <div class="infos"><br/>
1308
1309 <div class="head"><u>site.params</u></div>
1310 <br />
1311 <pre>
1312 ##PARAM_DUMP##
1313 </pre>
1314
1315 <div class="head"><u>site</u></div><br/>
1316 <pre>
1317 ##REQUEST_DUMP##
1318 </pre>
1319 <div class="head"><u>Response</u></div><br/>
1320 <pre>
1321 ##RESPONSE_DUMP##
1322 </pre>
1323
1324 </div>
1325
1326 <div class="name">Running on Gantry $Gantry::VERSION</div>
1327 </div>
1328 </body>
1329 </html>! );
1330
1331 } # end _error_page
1332  
1333 5 1;
1334  
1335 __END__
« Gantry/Engine/MP20.pm ↑ Summary Gantry/State/Simple.pm »