CGI/Portable.pm

filter: Statementstmt 14.2% 128 / 900 Branchbran 0.3% 1 / 316 Conditioncond 6.2% 1 / 16 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 6.7% 10 / 149 Podpod 100% 142 / 142 totaltotal 18.4% 282 / 1532 CC 167 SCAR 49.2
CC
167
Cov
11%
take_context_output
1190.0
page_as_string
72.0
resolve_prefs_node_to_hash
30.0
CRAP 137.4
« DemoUsage.pm ↑ Summary DemoTextFile.pm »
1 =head1 NAME
2  
3 CGI::Portable - Framework for server-generic web apps
4  
5 =cut
6  
7 ######################################################################
8  
9 package CGI::Portable;
10 1 require 5.004;
11  
12 # Copyright (c) 1999-2004, Darren R. Duncan. All rights reserved. This module
13 # is free software; you can redistribute it and/or modify it under the same terms
14 # as Perl itself. However, I do request that this copyright information and
15 # credits remain attached to the file. If you modify this module and
16 # redistribute a changed version then please attach a note listing the
17 # modifications. This module is available "as-is" and the author can not be held
18 # accountable for any problems resulting from its use.
19  
20 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 $VERSION = '0.51';
24  
25 ######################################################################
26  
27 =head1 DEPENDENCIES
28  
29 =head2 Perl Version
30  
31 5.004
32  
33 =head2 Standard Modules
34  
35 I<none>
36  
37 =head2 Nonstandard Modules
38  
39 File::VirtualPath 1.011
40 CGI::MultiValuedHash 1.09
41 HTML::EasyTags 1.071 -- only required in page_as_string()
42  
43 =cut
44  
45 ######################################################################
46  
47 1 ▶use File::VirtualPath 1.011;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 1 ▶use CGI::MultiValuedHash 1.09;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 ######################################################################
51  
52 =head1 SYNOPSIS
53  
54 =head2 Content of thin shell "startup_cgi.pl" for CGI or Apache::Registry env:
55  
56 #!/usr/bin/perl
57 use strict;
58 use warnings;
59  
60 require CGI::Portable;
61 my $globals = CGI::Portable->new();
62  
63 use Cwd;
64 $globals->file_path_root( cwd() ); # let us default to current working directory
65 $globals->file_path_delimiter( $^O=~/Mac/i ? ":" : $^O=~/Win/i ? "\\" : "/" );
66  
67 $globals->set_prefs( 'config.pl' );
68 $globals->current_user_path_level( 1 );
69  
70 require CGI::Portable::AdapterCGI;
71 my $io = CGI::Portable::AdapterCGI->new();
72  
73 $io->fetch_user_input( $globals );
74 $globals->call_component( 'DemoAardvark' );
75 $io->send_user_output( $globals );
76  
77 1;
78  
79 =head2 Content of thin shell "startup_socket.pl" for IO::Socket::INET:
80  
81 #!/usr/bin/perl
82 use strict;
83 use warnings;
84  
85 print "[Server $0 starting up]\n";
86  
87 require CGI::Portable;
88 my $globals = CGI::Portable->new();
89  
90 use Cwd;
91 $globals->file_path_root( cwd() ); # let us default to current working directory
92 $globals->file_path_delimiter( $^O=~/Mac/i ? ":" : $^O=~/Win/i ? "\\" : "/" );
93  
94 $globals->set_prefs( 'config.pl' );
95 $globals->current_user_path_level( 1 );
96  
97 require CGI::Portable::AdapterSocket;
98 my $io = CGI::Portable::AdapterSocket->new();
99  
100 use IO::Socket;
101 my $server = IO::Socket::INET->new(
102 Listen => SOMAXCONN,
103 LocalAddr => '127.0.0.1',
104 LocalPort => 1984,
105 Proto => 'tcp'
106 );
107 die "[Error: can't setup server $0]" unless $server;
108  
109 print "[Server $0 accepting clients]\n";
110  
111 while( my $client = $server->accept() ) {
112 printf "%s: [Connect from %s]\n", scalar localtime, $client->peerhost;
113  
114 my $content = $globals->make_new_context();
115  
116 $io->fetch_user_input( $content, $client );
117 $content->call_component( 'DemoAardvark' );
118 $io->send_user_output( $content, $client );
119  
120 close $client;
121  
122 printf "%s http://%s:%s%s %s\n", $content->request_method,
123 $content->server_domain, $content->server_port,
124 $content->user_path_string, $content->http_status_code;
125 }
126  
127 1;
128  
129 =head2 Content of settings file "config.pl"
130  
131 my $rh_prefs = {
132 title => 'Welcome to DemoAardvark',
133 credits => '<p>This program copyright 2001 Darren Duncan.</p>',
134 screens => {
135 one => {
136 'link' => 'Fill Out A Form',
137 mod_name => 'DemoTiger',
138 mod_prefs => {
139 field_defs => [
140 {
141 visible_title => "What's your name?",
142 type => 'textfield',
143 name => 'name',
144 }, {
145 visible_title => "What's the combination?",
146 type => 'checkbox_group',
147 name => 'words',
148 'values' => ['eenie', 'meenie', 'minie', 'moe'],
149 default => ['eenie', 'minie'],
150 rows => 2,
151 }, {
152 visible_title => "What's your favorite colour?",
153 type => 'popup_menu',
154 name => 'color',
155 'values' => ['red', 'green', 'blue', 'chartreuse'],
156 }, {
157 type => 'submit',
158 },
159 ],
160 },
161 },
162 two => {
163 'link' => 'Fly Away',
164 mod_name => 'DemoOwl',
165 mod_prefs => {
166 fly_to => 'http://www.perl.com',
167 },
168 },
169 three => {
170 'link' => 'Don\'t Go Here',
171 mod_name => 'DemoCamel',
172 mod_subdir => 'files',
173 mod_prefs => {
174 priv => 'private.txt',
175 prot => 'protected.txt',
176 publ => 'public.txt',
177 },
178 },
179 four => {
180 'link' => 'Look At Some Files',
181 mod_name => 'DemoPanda',
182 mod_prefs => {
183 food => 'plants',
184 color => 'black and white',
185 size => 'medium',
186 files => [qw( priv prot publ )],
187 file_reader => '/three',
188 },
189 },
190 },
191 };
192  
193 =head2 Content of fat main program component "DemoAardvark.pm"
194  
195 I<This module acts sort of like CGI::Portable::AppMultiScreen.>
196  
197 package DemoAardvark;
198 use strict;
199 use warnings;
200 use CGI::Portable;
201  
202 sub main {
203 my ($class, $globals) = @_;
204 my $users_choice = $globals->current_user_path_element();
205 my $rh_screens = $globals->pref( 'screens' );
206
207 if( my $rh_screen = $rh_screens->{$users_choice} ) {
208 my $inner = $globals->make_new_context();
209 $inner->inc_user_path_level();
210 $inner->navigate_url_path( $users_choice );
211 $inner->navigate_file_path( $rh_screen->{mod_subdir} );
212 $inner->set_prefs( $rh_screen->{mod_prefs} );
213 $inner->call_component( $rh_screen->{mod_name} );
214 $globals->take_context_output( $inner );
215
216 } else {
217 $globals->set_page_body( "<p>Please choose a screen to view.</p>" );
218 foreach my $key (keys %{$rh_screens}) {
219 my $label = $rh_screens->{$key}->{link};
220 my $url = $globals->url_as_string( $key );
221 $globals->append_page_body( "<br /><a href=\"$url\">$label</a>" );
222 }
223 }
224
225 $globals->page_title( $globals->pref( 'title' ) );
226 $globals->prepend_page_body( "<h1>".$globals->page_title()."</h1>\n" );
227 $globals->append_page_body( $globals->pref( 'credits' ) );
228 }
229  
230 1;
231  
232 =head2 Content of component module "DemoTiger.pm"
233  
234 I<This module acts sort of like DemoMailForm without the emailing.>
235  
236 package DemoTiger;
237 use strict;
238 use warnings;
239 use CGI::Portable;
240 use HTML::FormTemplate;
241  
242 sub main {
243 my ($class, $globals) = @_;
244 my $ra_field_defs = $globals->resolve_prefs_node_to_array(
245 $globals->pref( 'field_defs' ) );
246 if( $globals->get_error() ) {
247 $globals->set_page_body(
248 "Sorry I can not do that form thing now because we are missing ",
249 "critical settings that say what the questions are.",
250 "Reason: ", $globals->get_error(),
251 );
252 $globals->add_no_error();
253 return( 0 );
254 }
255 my $form = HTML::FormTemplate->new();
256 $form->form_submit_url( $globals->recall_url() );
257 $form->field_definitions( $ra_field_defs );
258 $form->user_input( $globals->user_post() );
259 $globals->set_page_body(
260 '<h1>Here Are Some Questions</h1>',
261 $form->make_html_input_form( 1 ),
262 '<hr />',
263 '<h1>Answers From Last Time If Any</h1>',
264 $form->new_form() ? '' : $form->make_html_input_echo( 1 ),
265 );
266 }
267  
268 1;
269  
270 =head2 Content of component module "DemoOwl.pm"
271  
272 I<This module acts sort of like DemoRedirect.>
273  
274 package DemoOwl;
275 use strict;
276 use warnings;
277 use CGI::Portable;
278  
279 sub main {
280 my ($class, $globals) = @_;
281 my $url = $globals->pref( 'fly_to' );
282 $globals->http_status_code( '301 Moved' );
283 $globals->http_redirect_url( $url );
284 }
285  
286 1;
287  
288 =head2 Content of component module "DemoCamel.pm"
289  
290 I<This module acts sort of like DemoTextFile.>
291  
292 package DemoCamel;
293 use strict;
294 use warnings;
295 use CGI::Portable;
296  
297 sub main {
298 my ($class, $globals) = @_;
299 my $users_choice = $globals->current_user_path_element();
300 my $filename = $globals->pref( $users_choice );
301 my $filepath = $globals->physical_filename( $filename );
302 SWITCH: {
303 $globals->add_no_error();
304 open( FH, $filepath ) or do {
305 $globals->add_virtual_filename_error( 'open', $filename );
306 last SWITCH;
307 };
308 local $/ = undef;
309 defined( my $file_content = <FH> ) or do {
310 $globals->add_virtual_filename_error( "read from", $filename );
311 last SWITCH;
312 };
313 close( FH ) or do {
314 $globals->add_virtual_filename_error( "close", $filename );
315 last SWITCH;
316 };
317 $globals->set_page_body( $file_content );
318 }
319 if( $globals->get_error() ) {
320 $globals->append_page_body(
321 "Can't show requested screen: ".$globals->get_error() );
322 $globals->add_no_error();
323 }
324 }
325  
326 1;
327  
328 =head2 Content of component module "DemoPanda.pm"
329  
330 I<This module acts sort of like nothing I've ever seen.>
331  
332 package DemoPanda;
333 use strict;
334 use warnings;
335 use CGI::Portable;
336  
337 sub main {
338 my ($class, $globals) = @_;
339 $globals->set_page_body( <<__endquote );
340 <p>Food: @{[$globals->pref( 'food' )]}
341 <br />Color: @{[$globals->pref( 'color' )]}
342 <br />Size: @{[$globals->pref( 'size' )]}</p>
343 <p>Now let's look at some files; take your pick:
344 __endquote
345 $globals->navigate_url_path( $globals->pref( 'file_reader' ) );
346 foreach my $frag (@{$globals->pref( 'files' )}) {
347 my $url = $globals->url_as_string( $frag );
348 $globals->append_page_body( "<br /><a href=\"$url\">$frag</a>" );
349 }
350 $globals->append_page_body( "</p>" );
351 }
352  
353 1;
354  
355 =head1 DESCRIPTION
356  
357 The CGI::Portable class is a framework intended to support complex web
358 applications that are easily portable across servers because common
359 environment-specific details are abstracted away, including the file system type,
360 the web server type, and your project's location in the file system or uri
361 hierarchy.
362  
363 Also abstracted away are details related to how users of your applications
364 arrange instance config/preferences data across single or multiple files, so they
365 get more flexability in how to use your application without you writing the code
366 to support it. So your apps are easier to make data-controlled.
367  
368 Application cores would use CGI::Portable as an interface to the server they are
369 running under, where they receive user input through it and they return a
370 response (HTML page or other data type) to the user through it. Since
371 CGI::Portable should be able to express all of their user input or output needs,
372 your application cores should run well under CGI or mod_perl or IIS or a
373 Perl-based server or a command line without having code that supports each type's
374 individual needs.
375  
376 That said, CGI::Portable doesn't contain any user input/output code of its own,
377 but allows you to use whatever platform-specific code or modules you wish between
378 it and the actual server. By using my module as an abstraction layer, your own
379 program core doesn't need to know which platform-specific code it is talking to.
380  
381 As a logical extension to the interfacing functionality, CGI::Portable makes it
382 easier for you to divide your application into autonomous components, each of
383 which acts like it is its own application core with user input and instance
384 config data provided to it and a recepticle for its user output provided. This
385 module would be an interface between the components.
386  
387 This class has 5 main types of functionality, or sets of properties that exist
388 in parallel but are fully/mostly independant from each other. As such, it
389 could conceptually be split into 5 physical modules, some of which could be
390 used on their own, but they are actually contained in this one module for
391 simplicity of use (just one object for user code to keep track of). The 5
392 functionality sets could be called: Errors, Files, Request, Response, Misc.
393  
394 =head2 Errors - Manages error list for operations
395  
396 This class implements methods that manage an "error list" property,
397 which is designed to accumulate any error strings that should be printed to the
398 program's error log or shown to the user before the program exits. What
399 constitutes an error condition is up to you, but the suggested use is for things
400 that are not the web user's fault, such as problems compiling or calling program
401 modules, or problems using file system files for settings or data. The errors
402 list is not intended to log invalid user input, which would be common activity.
403 Since some errors are non-fatal and other parts of your program would still
404 work, it is possible for several errors to happen in parallel; hence a list.
405 At program start-up this list starts out empty.
406  
407 An extension to this feature is the concept of "no error" messages (undefined
408 strings) which if used indicate that the last operation *did* work. This gives
409 you the flexability to always record the result of an operation for acting on
410 later. If you use get_error() in a boolean context then it would be true if the
411 last noted operation had an error and false if it didn't. You can also issue an
412 add_no_error() to mask errors that have been dealt with so they don't continue
413 to look unresolved.
414  
415 =head2 Files - Manages virtual file system and app instance config files
416  
417 This class implements two distinct but closely related "input" properties, the
418 "file path", and the "preferences", which manage a virtual file system and
419 application instance config data respectively. Please see VIRTUAL FILE SYSTEM
420 OVERVIEW and INSTANCE PREFERENCES OVERVIEW below for a conceptual explanation of
421 what these are for and how to use them.
422  
423 =head2 Request - Stores user input, makes self-referencing urls
424  
425 This class implements several distinct but closely related "input" properties,
426 the "user input", and the "url constructor", which store several kinds of input
427 from the web user and store pieces of new self-referencing urls respectively.
428 Please see TCP/IP CONNECTION OVERVIEW, HTTP REQUEST OVERVIEW, USER INPUT
429 OVERVIEW, MAKING NEW URLS OVERVIEW, and RECALL URLS OVERVIEW below for a
430 conceptual explanation of what these are for and how to use them.
431  
432 =head2 Response - Stores user output; HTTP headers/body, HTML page pieces
433  
434 This class is designed to accumulate and assemble the components of an HTTP
435 response, complete with status code, content type, other headers, and a body. The
436 intent is for your core program to use these to store its user output, and then
437 your thin program config shell would actually send the page to the user. These
438 properties are initialized with values suitable for returning an HTML page.
439  
440 Half of the 'Response' functionality is specialized for HTML responses, which
441 are assumed to be the dominant activity. This class is designed to accumulate
442 and assemble the components of a new HTML page, complete with body, title, meta
443 tags, and cascading style sheets. HTML assembly is done with the
444 page_as_string() method.
445  
446 The "http body" property is intended for use when you want to return raw content
447 of any type, whether it is text or image or other binary. It is a complement for
448 the html assembling methods and should be left undefined if they are used.
449  
450 =head2 Misc
451  
452 The miscellaneous functionality includes the call_component() method and the
453 methods listed in these documentation sections: METHODS FOR DEBUGGING, METHODS
454 FOR SEARCH AND REPLACE, METHODS FOR GLOBAL PREFERENCES, METHODS FOR
455 MISCELLANEOUS OBJECT SERVICES.
456  
457 =head1 VIRTUAL FILE SYSTEM OVERVIEW
458  
459 This class implements methods that manage a "file path" property, which is
460 designed to facilitate easy portability of your application across multiple file
461 systems or across different locations in the same file system. It maintains a
462 "virtual file system" that you can use, within which your program core owns the
463 root directory.
464  
465 Your program core would take this virtual space and organize it how it sees fit
466 for configuration and data files, including any use of subdirectories that is
467 desired. This class will take care of mapping the virtual space onto the real
468 one, in which your virtual root is actually a subdirectory and your path
469 separators may or may not be UNIXy ones.
470  
471 If this class is faithfully used to translate your file system operations, then
472 you will stay safely within your project root directory at all times. Your core
473 app will never have to know if the project is moved around since details of the
474 actual file paths, including level delimiters, has been abstracted away. It will
475 still be able to find its files. Only your program's thin instance startup shell
476 needs to know the truth.
477  
478 The file path property is a File::VirtualPath object so please see the POD for
479 that class to learn about its features.
480  
481 =head1 INSTANCE PREFERENCES OVERVIEW
482  
483 This class implements methods that manage a "preferences" property, which
484 is designed to facilitate easy access to your application instance settings.
485 The "preferences" is a hierarchical data structure which has a hash as its root
486 and can be arbitrarily complex from that point on. A hash is used so that any
487 settings can be accessed by name; the hierarchical nature comes from any
488 setting values that are references to non-scalar values, or resolve to such.
489  
490 CGI::Portable makes it easy for your preferences structure to scale across
491 any number of storage files, helping with memory and speed efficiency. At
492 certain points in your program flow, branches of the preferences will be followed
493 until a node is reached that your program wants to be a hash. At that point,
494 this node can be given back to this class and resolved into a hash one way or
495 another. If it already is a hash ref then it is given back as is; otherwise it
496 is taken as a filename for a Perl file which when evaluated with "do" returns
497 a hash ref. This filename would be a relative path in the virtual file system
498 and this class would resolve it properly.
499  
500 Since the fact of hash-ref-vs-filename is abstracted from your program, this
501 makes it easy for your data itself to determine how the structure is segmented.
502 The decision-making begins with the root preferences node that your thin config
503 shell gives to CGI::Portable at program start-up. What is resolved from
504 that determines how any child nodes are gotten, and they determine their
505 children. Since this class handles such details, it is much easier to make your
506 program data-controlled rather than code-controlled. For instance, your startup
507 shell may contain the entire preferences structure itself, meaning that you only
508 need a single file to define a project instance. Or, your startup shell may
509 just have a filename for where the preferences really are, making it minimalist.
510 Depending how your preferences are segmented, only the needed parts actually get
511 loaded, so we save resources.
512  
513 =head1 TCP/IP CONNECTION OVERVIEW
514  
515 This class implements methods for storing pertinent details relating to the
516 current TCP/IP connection for which the program using this class is the server
517 or host, and a user's web browser or a robot is the client. Using the analogy
518 that a TCP connection is like a pipe, that is connected at one end to a process
519 on a server, and at the other end to the process on the client, these pertinent
520 details are the fully-qualified location or address of each end of the pipe.
521 At each end, we have an IP Address, which says how to find the particular
522 machine, and we have a Port Number, which says what process on that machine is
523 handling the connection. An ip address is like "127.0.0.1" and a port is like
524 "80". Each ip address can optionally have a "domain" (or several) aliased to
525 it, which is a more human-friendly. This class stores 6 details on the TCP
526 connection, 3 each for server and client, which are the ip, domain, and port.
527 In a CGI environment, where your script isn't the actual server but talks to
528 the server, the connection details match %ENV keys like SERVER_NAME or
529 REMOTE_PORT. These details are technically not in the HTTP request headers.
530  
531 =head1 HTTP REQUEST OVERVIEW
532  
533 This class implements methods for storing all of the details from the http
534 request. Using the above analogy of a pipe, the http request is all of the
535 data that is sent from the client to the server that tells the server what
536 the client wants it to return. The http response is everything that the
537 server sends to the client afterwards. The two main parts of an http request
538 (and response) are headers and body, which are separated by a blank line.
539 While the content of the request body is arbitrary, the headers are specially
540 formatted text lines with one line per header. The very first header is
541 special, and looks like "GET / HTTP/1.0" or "GET /dir/script.pl?q=v HTTP/1.0".
542 The 3 pieces of information there are the "method", "uri", and "protocol".
543 All of the other header lines are key/value pairs in the format "Key: value".
544 In a CGI environment, all of the request headers that aren't ignored match
545 %ENV keys; most normal headers match one key, and the first header can be
546 parsed to match 5 or more keys; the request body isn't put in %ENV but piped
547 to STDIN instead. For your convenience, this class also stores parsed copies
548 of complicated parts of the http request, available under USER INPUT.
549  
550 =head1 USER INPUT OVERVIEW
551  
552 This class implements methods that manage several "user input" properties,
553 which include: "user path", "user query", "user post", and "user cookies".
554 These properties store parsed copies of the various information that the web
555 user provided when invoking this program instance. Note that you should not
556 modify the user input in your program, since the recall methods depend on them.
557  
558 This class does not gather any user input itself, but expects your thin program
559 instance shell to do that and hand the data to this class prior to starting the
560 program core. The rationale is both for keeping this class simpler and for
561 keeping it compatible with all types of web servers instead of just the ones it
562 knows about. So it works equally well with CGI under any server or mod_perl or
563 when your Perl is its own web server or when you are debugging on the command
564 line. This class does know how to *parse* some url-encoded strings, however.
565  
566 The kind of input you need to gather depends on what your program uses, but it
567 doesn't hurt to get more. If you are in a CGI environment then you often get
568 user input from the following places: 1. $ENV{QUERY_STRING} for the query string
569 -- pass to user_query(); 2. <STDIN> for the post data -- pass to user_post(); 3.
570 $ENV{HTTP_COOKIE} for the raw cookies -- pass to user_cookies(); 4. either
571 $ENV{PATH_INFO} or a query parameter for the virtual web resource path -- pass to
572 user_path(). If you are in mod_perl then you call Apache methods to get the user
573 input. If you are your own server then the incoming HTTP headers contain
574 everything except the post data, which is in the HTTP body. If you are on the
575 command line then you can look in @ARGV or <STDIN> as is your preference.
576  
577 The virtual web resource path is a concept with CGI::Portable designed to
578 make it easy for different user interface pages of your program to be identified
579 and call each other in the web environment. The idea is that all the interface
580 components that the user sees have a unique uri and can be organized
581 hierarchically like a tree; by invoking your program with a different "path",
582 the user indicates what part of the program they want to use. It is analogous
583 to choosing different html pages on a normal web site because each page has a
584 separate uri on the server, and each page calls others by using different uris.
585 What makes the virtual paths different is that each uri does not correspond to
586 a different file; the user just pretends they do. Ultimately you have control
587 over what your program does with any particular virtual "user path".
588  
589 The user path property is a File::VirtualPath object, and the other user input
590 properties are each CGI::MultiValuedHash objects, so please see the respective
591 POD for those classes to learn about their features. Note that the user path
592 always works in the virtual space and has no physical equivalent like file path.
593  
594 =head1 MAKING NEW URLS OVERVIEW
595  
596 This class implements methods that manage several "url constructor" properties,
597 which are designed to store components of the various information needed to make
598 new urls that call this script back in order to change from one interface screen
599 to another. When the program is reinvoked with one of these urls, this
600 information becomes part of the user input, particularly the "user path" and
601 "user query". You normally use the url_as_string() method to do the actual
602 assembly of these components, but the various "recall" methods also pay attention
603 to them.
604  
605 =head1 RECALL URLS OVERVIEW
606  
607 This class implements methods that are designed to make HTML for the user to
608 reinvoke this program with their input intact. They pay attention to both the
609 current user input and the current url constructor properties. Specifically,
610 these methods act like url_as_string() in the way they use most url constructor
611 properties, but they use the user path and user query instead of the url path and
612 url query.
613  
614 =head1 SIMILAR MODULES
615  
616 Based on the above, you could conceivably say CGI::Portable has similarities to
617 these modules: CGI::Screen, CGI::MxScreen, CGI::Application, CGI::BuildPage,
618 CGI::Response, HTML::Mason, CGI, and others.
619  
620 To start with, all of the above modules do one or more of: storing and providing
621 access to user input, helping to organize access to multiple user screens or
622 application modes, collecting and storing output for the user, and so on.
623  
624 Some ways that the modules are different from mine are: level of complexity,
625 because my module is simpler than HTML::Mason and CGI::MxScreen and CGI,
626 but it is more complex and/or comprehensive than the others; functionality,
627 because it takes portability between servers to a new level by being agnostic on
628 both ends, where the other solutions are all/mostly tied to specific server types
629 since they do the I/O by themselves; my module also does filesystem translation
630 and some settings management, and I don't think any of the others do; I have
631 built-in functionality for organizing user screens hierarchically, called
632 user_path/url_path (in/out equivalents); I keep query params and post params
633 separate whereas most of the others use CGI.pm which combines them together; more
634 differences.
635  
636 =head1 YES, THIS MODULE DOES IMAGES
637  
638 Just in case you were thinking that this module does plain html only and is no
639 good for image-making applications, let me remind you that, yes, CGI::Portable
640 can map urls to, store, and output any type of file, including pictures and other
641 binary types.
642  
643 To illustrate this, I have provided the "image" demo consisting of an html page
644 containing a PNG graphic, both of which are generated by the same script. (You
645 will need to have GD installed to see the picture, though.)
646  
647 Besides that, this module has explicit support for the likes of cascading style
648 sheets (css) and complete multi-frame documents in one script as well, which are
649 normally just used in graphical environments.
650  
651 So while a few critics have pointed out the fact that my own websites, which use
652 this module, don't have graphics, then that is purely my own preference as a way
653 to make them load faster and use less bandwidth, not due to any lack of the
654 ability to use pictures.
655  
656 =head1 A DIFFERENT MASTER OVERVIEW
657  
658 This class is designed primarily as a data structure that intermediates between
659 your large central program logic and the small shell part of your code that knows
660 anything specific about your environment. The way that this works is that the
661 shell code instantiates an CGI::Portable object and stores any valid user
662 input in it, gathered from the appropriate places in the current environment.
663 Then the central program is started and given the CGI::Portable object, from
664 which it takes stored user input and performs whatever tasks it needs to. The
665 central program stores its user output in the same CGI::Portable object and
666 then quits. Finally, the shell code takes the stored user output from the
667 CGI::Portable object and does whatever is necessary to send it to the user.
668 Similarly, your thin shell code knows where to get the instance-specific file
669 system and stored program settings data, which it gives to the CGI::Portable
670 object along with the user input.
671  
672 Here is a diagram:
673  
674 YOUR THIN CGI::Portable YOUR FAT "CORE"
675 USER <----> "MAIN" CONFIG, <----> INTERFACE LAYER <----> PROGRAM LOGIC
676 I/O SHELL FRAMEWORK FUNCTIONALITY
677 (may be portable) (portable) (portable)
678  
679 This class does not gather any user input or send any user input by itself, but
680 expects your thin program instance shell to do that. The rationale is both for
681 keeping this class simpler and for keeping it compatible with all types of web
682 servers instead of just the ones it knows about. So it works equally well with
683 CGI under any server or mod_perl or when your Perl is its own web server or when
684 you are debugging on the command line.
685  
686 Because your program core uses this class to communicate with its "superior", it
687 can be written the same way regardless of what platform it is running on. The
688 interface that it needs to written to is consistent across platforms. An
689 analogy to this is that the core always plays in the same sandbox and that
690 environment is all it knows; you can move the sandbox anywhere you want and its
691 occupant doesn't have to be any the wiser to how the outside world had changed.
692  
693 From there, it is a small step to breaking your program core into reusable
694 components and using CGI::Portable as an interface between them. Each
695 component exists in its own sandbox and acts like it is its own core program,
696 with its own task to produce an html page or other http response, and with its
697 own set of user input and program settings to tell it how to do its job.
698 Depending on your needs, each "component" instance could very well be its own
699 complete application, or it would in fact be a subcontractee of another one.
700 In the latter case, the "subcontractor" component may have other components do
701 a part of its own task, and then assemble a derivative work as its own output.
702  
703 When one component wants another to do work for it, the first one instantiates
704 a new CGI::Portable object which it can pass on any user input or settings
705 data that it wishes, and then provides this to the second component; the second
706 one never has to know where its CGI::Portable object it has came from, but
707 that everything it needs to know for its work is right there. This class
708 provides convenience methods like make_new_context() to simplify this task by
709 making a partial clone that replicates input but not output data.
710  
711 Due to the way CGI::Portable stores program settings and other input/output
712 data, it lends itself well to supporting data-driven applications. That is,
713 your application components can be greatly customizable as to their function by
714 simply providing instances of them with different setup data. If any component
715 is so designed, its own config instructions can detail which other components it
716 subcontracts, as well as what operating contexts it sets up for them. This
717 results in a large variety of functionality from just a small set of components.
718  
719 Another function that CGI::Portable provides for component management is that
720 there is limited protection for components that are not properly designed to be
721 kept from harming other ones. You see, any components designed a certain way can
722 be invoked by CGI::Portable itself at the request of another component.
723 This internal call is wrapped in an eval block such that if a component fails to
724 compile or has a run-time exception, this class will log an error to the effect
725 and the component that called it continues to run. Also, called components get
726 a different CGI::Portable object than the parent, so that if they mess around
727 with the stored input/output then the parent component's own data isn't lost.
728 It is the parent's own choice as to which output of its child that it decides to
729 copy back into its own output, with or without further processing.
730  
731 Note that the term "components" above suggests that each one is structured as
732 a Perl 5 module and is called like one; the module should have a method called
733 main() that takes an CGI::Portable object as its argument and has the
734 dispatch code for that component. Of course, it is up to you.
735  
736 =cut
737  
738 ######################################################################
739  
740 # Names of 'Errors' properties for objects of this class are declared here:
741 1 my $KEY_ERRORS = 'errors'; # array - a list of short error messages
742  
743 # Names of 'Files' properties for objects of this class are declared here:
744 1 my $KEY_FILE_PATH = 'file_path'; # FVP - tracks filesystem loc of our files
745 1 my $KEY_PREFS = 'prefs'; # hash - tracks our current file-based preferences
746  
747 # These 'Request' properties describe the TCP/IP connection details for server+client
748 1 my $KEY_TCP_SEIP = 'tcp_seip'; # string - tcp ip address of server
749 1 my $KEY_TCP_SEDO = 'tcp_sedo'; # string - tcp domain of server
750 1 my $KEY_TCP_SEPO = 'tcp_sepo'; # number - tcp server port
751 1 my $KEY_TCP_CLIP = 'tcp_clip'; # string - tcp remote IP address of web user
752 1 my $KEY_TCP_CLDO = 'tcp_cldo'; # string - tcp remote host domain of web user
753 1 my $KEY_TCP_CLPO = 'tcp_clpo'; # number - tcp client port
754  
755 # These 'Request' properties are raw values from the HTTP request headers and body
756 1 my $KEY_REQ_METH = 'req_meth'; # string - request method (GET/POST/HEAD)
757 1 my $KEY_REQ_URIX = 'req_urix'; # string - request uri (path + query string)
758 1 my $KEY_REQ_PROT = 'req_prot'; # string - request protocol (eg: HTTP/1.0)
759 1 my $KEY_REQ_HEAD = 'req_head'; # hash - stores all raw req headers not above
760 1 my $KEY_REQ_BODY = 'req_body'; # string - stores the raw request body
761  
762 # These 'Request' properties represent user input and are parsed from raw HTTP request
763 1 my $KEY_UI_PATH = 'ui_path'; # FVP - parsed path info from uri (usually)
764 1 my $KEY_UI_QUER = 'ui_quer'; # CMVH - parsed user input query from uri
765 1 my $KEY_UI_POST = 'ui_post'; # CMVH - parsed user input post (http body)
766 1 my $KEY_UI_COOK = 'ui_cook'; # CMVH - parsed user input cookies
767  
768 # These 'Request' properties are used when making new self-referencing urls in output
769 1 my $KEY_URL_BASE = 'url_base'; # string - stores joined host, script_name, etc
770 1 my $KEY_URL_PATH = 'url_path'; # FVP - virtual path used in s-r urls
771 1 my $KEY_URL_QUER = 'url_quer'; # CMVH - holds query params to put in all urls
772  
773 # These 'Response' properties would go in output HTTP headers and body
774 1 my $KEY_HTTP_STAT = 'http_stat'; # string - HTTP status code; first to output
775 1 my $KEY_HTTP_WITA = 'http_wita'; # string - stores Window-Target of output
776 1 my $KEY_HTTP_COTY = 'http_coty'; # string - stores Content-Type of outp
777 1 my $KEY_HTTP_REDI = 'http_redi'; # string - stores URL to redirect to
778 1 my $KEY_HTTP_COOK = 'http_cook'; # array - stores outgoing encoded cookies
779 1 my $KEY_HTTP_HEAD = 'http_head'; # hash - stores misc HTTP headers keys/values
780 1 my $KEY_HTTP_BODY = 'http_body'; # string - stores raw HTTP body if wanted
781 1 my $KEY_HTTP_BINA = 'http_bina'; # boolean - true if HTTP body is binary
782  
783 # These 'Response' properties will be combined into the output page if it is text/html
784 1 my $KEY_PAGE_PROL = 'page_prol'; # string - prologue tag or "doctype" at top
785 1 my $KEY_PAGE_TITL = 'page_titl'; # string - new HTML title
786 1 my $KEY_PAGE_AUTH = 'page_auth'; # string - new HTML author
787 1 my $KEY_PAGE_META = 'page_meta'; # hash - new HTML meta keys/values
788 1 my $KEY_PAGE_CSSR = 'page_cssr'; # array - new HTML css file urls
789 1 my $KEY_PAGE_CSSC = 'page_cssc'; # array - new HTML css embedded code
790 1 my $KEY_PAGE_HEAD = 'page_head'; # array - raw misc content for HTML head
791 1 my $KEY_PAGE_FATR = 'page_fatr'; # hash - attribs for optional HTML frameset tag
792 1 my $KEY_PAGE_FRAM = 'page_fram'; # array of hashes - list of frame attributes
793 1 my $KEY_PAGE_BATR = 'page_batr'; # hash - attribs for HTML body tag
794 1 my $KEY_PAGE_BODY = 'page_body'; # array - raw content for HTML body
795  
796 # Names of 'Misc' properties for objects of this class are declared here:
797 1 my $KEY_IS_DEBUG = 'is_debug'; # boolean - a flag to say we are debugging
798  
799 # These 'Misc' properties are special prefs to be set once and global avail (copied)
800 1 my $KEY_PREF_APIT = 'pref_apit'; # string - application instance title
801 1 my $KEY_PREF_MNAM = 'pref_mnam'; # string - maintainer name
802 1 my $KEY_PREF_MEAD = 'pref_mead'; # string - maintainer email address
803 1 my $KEY_PREF_MESP = 'pref_mesp'; # string - maintainer email screen url path
804 1 my $KEY_PREF_SMTP = 'pref_smtp'; # string - smtp host domain/ip to use
805 1 my $KEY_PREF_TIME = 'pref_time'; # number - timeout in seconds for smtp connect
806  
807 # This 'Misc' property is generally static across all derived objects for misc sharing
808 1 my $KEY_MISC_OBJECTS = 'misc_objects'; # hash - holds misc objects we may need
809  
810 ######################################################################
811  
812 =head1 SYNTAX
813  
814 This class does not export any functions or methods, so you need to call them
815 using object notation. This means using B<Class-E<gt>function()> for functions
816 and B<$object-E<gt>method()> for methods. If you are inheriting this class for
817 your own modules, then that often means something like B<$self-E<gt>method()>.
818  
819 =head1 CONSTRUCTOR FUNCTIONS AND METHODS
820  
821 These functions and methods are involved in making new CGI::Portable objects.
822  
823 =head2 new([ FILE_ROOT[, FILE_DELIM[, PREFS]] ])
824  
825 This function creates a new CGI::Portable (or subclass) object and
826 returns it. All of the method arguments are passed to initialize() as is; please
827 see the POD for that method for an explanation of them.
828  
829 =head2 initialize([ FILE_ROOT[, FILE_DELIM[, PREFS]] ])
830  
831 This method is used by B<new()> to set the initial properties of objects that it
832 creates. The optional 3 arguments are used in turn to set the properties
833 accessed by these methods: file_path_root(), file_path_delimiter(), set_prefs().
834  
835 =head2 clone([ CLONE ])
836  
837 This method initializes a new object to have all of the same properties of the
838 current object and returns it. This new object can be provided in the optional
839 argument CLONE (if CLONE is an object of the same class as the current object);
840 otherwise, a brand new object of the current class is used. Only object
841 properties recognized by CGI::Portable are set in the clone; other
842 properties are not changed.
843  
844 =cut
845  
846 ######################################################################
847  
848 2 ▶sub new {
Subroutine new: called CC=2 SCAR=7.4
Pod documented
849 2 my $class = shift( @_ );
850 2 ▶ my $self = bless( {}, ref($class) || $class );
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
851 2 $self->initialize( @_ );
852 2 return( $self );
853 }
854  
855 2 ▶sub initialize {
Subroutine initialize: called CC=1 SCAR=0.0
Pod documented
856 2 my ($self, $file_root, $file_delim, $prefs) = @_;
857  
858 2 $self->{$KEY_ERRORS} = [];
859  
860 2 $self->{$KEY_FILE_PATH} = File::VirtualPath->new();
861 2 $self->{$KEY_PREFS} = {};
862  
863 2 $self->{$KEY_TCP_SEIP} = '127.0.0.1';
864 2 $self->{$KEY_TCP_SEDO} = 'localhost';
865 2 $self->{$KEY_TCP_SEPO} = 80;
866 2 $self->{$KEY_TCP_CLIP} = '127.0.0.1';
867 2 $self->{$KEY_TCP_CLDO} = 'localhost';
868 2 $self->{$KEY_TCP_CLPO} = undef;
869  
870 2 $self->{$KEY_REQ_METH} = 'GET';
871 2 $self->{$KEY_REQ_URIX} = '/';
872 2 $self->{$KEY_REQ_PROT} = 'HTTP/1.0';
873 2 $self->{$KEY_REQ_HEAD} = {};
874 2 $self->{$KEY_REQ_BODY} = undef;
875  
876 2 $self->{$KEY_UI_PATH} = File::VirtualPath->new();
877 2 $self->{$KEY_UI_QUER} = CGI::MultiValuedHash->new();
878 2 $self->{$KEY_UI_POST} = CGI::MultiValuedHash->new();
879 2 $self->{$KEY_UI_COOK} = CGI::MultiValuedHash->new();
880  
881 2 $self->{$KEY_URL_BASE} = 'http://localhost/';
882 2 $self->{$KEY_URL_PATH} = File::VirtualPath->new();
883 2 $self->{$KEY_URL_QUER} = CGI::MultiValuedHash->new();
884  
885 2 $self->{$KEY_HTTP_STAT} = '200 OK';
886 2 $self->{$KEY_HTTP_WITA} = undef;
887 2 $self->{$KEY_HTTP_COTY} = 'text/html';
888 2 $self->{$KEY_HTTP_REDI} = undef;
889 2 $self->{$KEY_HTTP_COOK} = [];
890 2 $self->{$KEY_HTTP_HEAD} = {};
891 2 $self->{$KEY_HTTP_BODY} = undef;
892 2 $self->{$KEY_HTTP_BINA} = undef;
893  
894 2 $self->{$KEY_PAGE_PROL} = undef;
895 2 $self->{$KEY_PAGE_TITL} = undef;
896 2 $self->{$KEY_PAGE_AUTH} = undef;
897 2 $self->{$KEY_PAGE_META} = {};
898 2 $self->{$KEY_PAGE_CSSR} = [];
899 2 $self->{$KEY_PAGE_CSSC} = [];
900 2 $self->{$KEY_PAGE_HEAD} = [];
901 2 $self->{$KEY_PAGE_FATR} = {};
902 2 $self->{$KEY_PAGE_FRAM} = [];
903 2 $self->{$KEY_PAGE_BATR} = {};
904 2 $self->{$KEY_PAGE_BODY} = [];
905  
906 2 $self->{$KEY_IS_DEBUG} = undef;
907  
908 2 $self->{$KEY_PREF_APIT} = 'Untitled Application';
909 2 $self->{$KEY_PREF_MNAM} = 'Webmaster';
910 2 $self->{$KEY_PREF_MEAD} = 'webmaster@localhost';
911 2 $self->{$KEY_PREF_MESP} = undef;
912 2 $self->{$KEY_PREF_SMTP} = 'localhost';
913 2 $self->{$KEY_PREF_TIME} = '30';
914  
915 2 $self->{$KEY_MISC_OBJECTS} = {};
916  
917 2 $self->file_path_root( $file_root );
918 2 $self->file_path_delimiter( $file_delim );
919 2 $self->set_prefs( $prefs );
920 }
921  
922 0 ▶sub clone {
Subroutine clone: not called CC=2 SCAR=17.9
Pod documented
923 0 my ($self, $clone) = @_;
924 0 ▶ ref($clone) eq ref($self) or $clone = bless( {}, ref($self) );
Branch: 1 branch
BranchTrueFalseTotal
ref $clone eq ref $self or $clone = bless({}, ref $self) 0 0 0
925  
926 0 $clone->{$KEY_ERRORS} = [@{$self->{$KEY_ERRORS}}];
927  
928 0 $clone->{$KEY_FILE_PATH} = $self->{$KEY_FILE_PATH}->clone();
929 0 $clone->{$KEY_PREFS} = {%{$self->{$KEY_PREFS}}};
930  
931 0 $clone->{$KEY_TCP_SEIP} = $self->{$KEY_TCP_SEIP};
932 0 $clone->{$KEY_TCP_SEDO} = $self->{$KEY_TCP_SEDO};
933 0 $clone->{$KEY_TCP_SEPO} = $self->{$KEY_TCP_SEPO};
934 0 $clone->{$KEY_TCP_CLIP} = $self->{$KEY_TCP_CLIP};
935 0 $clone->{$KEY_TCP_CLDO} = $self->{$KEY_TCP_CLDO};
936 0 $clone->{$KEY_TCP_CLPO} = $self->{$KEY_TCP_CLPO};
937  
938 0 $clone->{$KEY_REQ_METH} = $self->{$KEY_REQ_METH};
939 0 $clone->{$KEY_REQ_URIX} = $self->{$KEY_REQ_URIX};
940 0 $clone->{$KEY_REQ_PROT} = $self->{$KEY_REQ_PROT};
941 0 $clone->{$KEY_REQ_HEAD} = {%{$self->{$KEY_REQ_HEAD}}};
942 0 $clone->{$KEY_REQ_BODY} = $self->{$KEY_REQ_BODY};
943  
944 0 $clone->{$KEY_UI_PATH} = $self->{$KEY_UI_PATH}->clone();
945 0 $clone->{$KEY_UI_QUER} = $self->{$KEY_UI_QUER}->clone();
946 0 $clone->{$KEY_UI_POST} = $self->{$KEY_UI_POST}->clone();
947 0 $clone->{$KEY_UI_COOK} = $self->{$KEY_UI_COOK}->clone();
948  
949 0 $clone->{$KEY_URL_BASE} = $self->{$KEY_URL_BASE};
950 0 $clone->{$KEY_URL_PATH} = $self->{$KEY_URL_PATH}->clone();
951 0 $clone->{$KEY_URL_QUER} = $self->{$KEY_URL_QUER}->clone();
952  
953 0 $clone->{$KEY_HTTP_STAT} = $self->{$KEY_HTTP_STAT};
954 0 $clone->{$KEY_HTTP_WITA} = $self->{$KEY_HTTP_WITA};
955 0 $clone->{$KEY_HTTP_COTY} = $self->{$KEY_HTTP_COTY};
956 0 $clone->{$KEY_HTTP_REDI} = $self->{$KEY_HTTP_REDI};
957 0 $clone->{$KEY_HTTP_COOK} = [@{$self->{$KEY_HTTP_COOK}}];
958 0 $clone->{$KEY_HTTP_HEAD} = {%{$self->{$KEY_HTTP_HEAD}}};
959 0 $clone->{$KEY_HTTP_BODY} = $self->{$KEY_HTTP_BODY};
960 0 $clone->{$KEY_HTTP_BINA} = $self->{$KEY_HTTP_BINA};
961  
962 0 $clone->{$KEY_PAGE_PROL} = $self->{$KEY_PAGE_PROL};
963 0 $clone->{$KEY_PAGE_TITL} = $self->{$KEY_PAGE_TITL};
964 0 $clone->{$KEY_PAGE_AUTH} = $self->{$KEY_PAGE_AUTH};
965 0 $clone->{$KEY_PAGE_META} = {%{$self->{$KEY_PAGE_META}}};
966 0 $clone->{$KEY_PAGE_CSSR} = [@{$self->{$KEY_PAGE_CSSR}}];
967 0 $clone->{$KEY_PAGE_CSSC} = [@{$self->{$KEY_PAGE_CSSC}}];
968 0 $clone->{$KEY_PAGE_HEAD} = [@{$self->{$KEY_PAGE_HEAD}}];
969 0 $clone->{$KEY_PAGE_FATR} = {%{$self->{$KEY_PAGE_FATR}}};
970 0 $clone->{$KEY_PAGE_FRAM} = [map { {%{$_}} } @{$self->{$KEY_PAGE_FRAM}}];
971 0 $clone->{$KEY_PAGE_BATR} = {%{$self->{$KEY_PAGE_BATR}}};
972 0 $clone->{$KEY_PAGE_BODY} = [@{$self->{$KEY_PAGE_BODY}}];
973  
974 0 $clone->{$KEY_IS_DEBUG} = $self->{$KEY_IS_DEBUG};
975  
976 0 $clone->{$KEY_PREF_APIT} = $self->{$KEY_PREF_APIT};
977 0 $clone->{$KEY_PREF_MNAM} = $self->{$KEY_PREF_MNAM};
978 0 $clone->{$KEY_PREF_MEAD} = $self->{$KEY_PREF_MEAD};
979 0 $clone->{$KEY_PREF_MESP} = $self->{$KEY_PREF_MESP};
980 0 $clone->{$KEY_PREF_SMTP} = $self->{$KEY_PREF_SMTP};
981 0 $clone->{$KEY_PREF_TIME} = $self->{$KEY_PREF_TIME};
982  
983 0 $clone->{$KEY_MISC_OBJECTS} = $self->{$KEY_MISC_OBJECTS}; # copy hash ref
984  
985 0 return( $clone );
986 }
987  
988 ######################################################################
989  
990 =head1 METHODS FOR CONTEXT SWITCHING
991  
992 These methods are designed to facilitate easy modularity of your application
993 into multiple components by providing context switching functions for the parent
994 component in a relationship. While you could still use this class effectively
995 without using them, they are available for your convenience.
996  
997 =head2 make_new_context([ CONTEXT ])
998  
999 This method initializes a new object of the current class and returns it. This
1000 new object has some of the current object's properties, namely the "input"
1001 properties, but lacks others, namely the "output" properties; the latter are
1002 initialized to default values instead. As with clone(), the new object can be
1003 provided in the optional argument CONTEXT (if CONTEXT is an object of the same
1004 class); otherwise a brand new object is used. Only properties recognized by
1005 CGI::Portable are set in this object; others are not touched.
1006  
1007 =cut
1008  
1009 ######################################################################
1010  
1011 0 ▶sub make_new_context {
Subroutine make_new_context: not called CC=2 SCAR=17.9
Pod documented
1012 0 my ($self, $context) = @_;
1013 0 ▶ ref($context) eq ref($self) or $context = bless( {}, ref($self) );
Branch: 1 branch
BranchTrueFalseTotal
ref $context eq ref $self or $context = bless({}, ref $self) 0 0 0
1014  
1015 0 $context->{$KEY_ERRORS} = [];
1016  
1017 0 $context->{$KEY_FILE_PATH} = $self->{$KEY_FILE_PATH}->clone();
1018 0 $context->{$KEY_PREFS} = {%{$self->{$KEY_PREFS}}};
1019  
1020 0 $context->{$KEY_TCP_SEIP} = $self->{$KEY_TCP_SEIP};
1021 0 $context->{$KEY_TCP_SEDO} = $self->{$KEY_TCP_SEDO};
1022 0 $context->{$KEY_TCP_SEPO} = $self->{$KEY_TCP_SEPO};
1023 0 $context->{$KEY_TCP_CLIP} = $self->{$KEY_TCP_CLIP};
1024 0 $context->{$KEY_TCP_CLDO} = $self->{$KEY_TCP_CLDO};
1025 0 $context->{$KEY_TCP_CLPO} = $self->{$KEY_TCP_CLPO};
1026  
1027 0 $context->{$KEY_REQ_METH} = $self->{$KEY_REQ_METH};
1028 0 $context->{$KEY_REQ_URIX} = $self->{$KEY_REQ_URIX};
1029 0 $context->{$KEY_REQ_PROT} = $self->{$KEY_REQ_PROT};
1030 0 $context->{$KEY_REQ_HEAD} = {%{$self->{$KEY_REQ_HEAD}}};
1031 0 $context->{$KEY_REQ_BODY} = $self->{$KEY_REQ_BODY};
1032  
1033 0 $context->{$KEY_UI_PATH} = $self->{$KEY_UI_PATH}->clone();
1034 0 $context->{$KEY_UI_QUER} = $self->{$KEY_UI_QUER}->clone();
1035 0 $context->{$KEY_UI_POST} = $self->{$KEY_UI_POST}->clone();
1036 0 $context->{$KEY_UI_COOK} = $self->{$KEY_UI_COOK}->clone();
1037  
1038 0 $context->{$KEY_URL_BASE} = $self->{$KEY_URL_BASE};
1039 0 $context->{$KEY_URL_PATH} = $self->{$KEY_URL_PATH}->clone();
1040 0 $context->{$KEY_URL_QUER} = $self->{$KEY_URL_QUER}->clone();
1041  
1042 0 $context->{$KEY_HTTP_STAT} = '200 OK';
1043 0 $context->{$KEY_HTTP_WITA} = undef;
1044 0 $context->{$KEY_HTTP_COTY} = 'text/html';
1045 0 $context->{$KEY_HTTP_REDI} = undef;
1046 0 $context->{$KEY_HTTP_COOK} = [];
1047 0 $context->{$KEY_HTTP_HEAD} = {};
1048 0 $context->{$KEY_HTTP_BODY} = undef;
1049 0 $context->{$KEY_HTTP_BINA} = undef;
1050  
1051 0 $context->{$KEY_PAGE_PROL} = undef;
1052 0 $context->{$KEY_PAGE_TITL} = undef;
1053 0 $context->{$KEY_PAGE_AUTH} = undef;
1054 0 $context->{$KEY_PAGE_META} = {};
1055 0 $context->{$KEY_PAGE_CSSR} = [];
1056 0 $context->{$KEY_PAGE_CSSC} = [];
1057 0 $context->{$KEY_PAGE_HEAD} = [];
1058 0 $context->{$KEY_PAGE_FATR} = {};
1059 0 $context->{$KEY_PAGE_FRAM} = [];
1060 0 $context->{$KEY_PAGE_BATR} = {};
1061 0 $context->{$KEY_PAGE_BODY} = [];
1062  
1063 0 $context->{$KEY_IS_DEBUG} = $self->{$KEY_IS_DEBUG};
1064  
1065 0 $context->{$KEY_PREF_APIT} = $self->{$KEY_PREF_APIT};
1066 0 $context->{$KEY_PREF_MNAM} = $self->{$KEY_PREF_MNAM};
1067 0 $context->{$KEY_PREF_MEAD} = $self->{$KEY_PREF_MEAD};
1068 0 $context->{$KEY_PREF_MESP} = $self->{$KEY_PREF_MESP};
1069 0 $context->{$KEY_PREF_SMTP} = $self->{$KEY_PREF_SMTP};
1070 0 $context->{$KEY_PREF_TIME} = $self->{$KEY_PREF_TIME};
1071  
1072 0 $context->{$KEY_MISC_OBJECTS} = $self->{$KEY_MISC_OBJECTS}; # copy hash ref
1073  
1074 0 return( $context );
1075 }
1076  
1077 ######################################################################
1078  
1079 =head2 take_context_output( CONTEXT[, LEAVE_SCALARS[, REPLACE_LISTS]] )
1080  
1081 This method takes another CGI::Portable (or subclass) object as its
1082 CONTEXT argument and copies some of its properties to this object, potentially
1083 overwriting any versions already in this object. If CONTEXT is not a valid
1084 CGI::Portable (or subclass) object then this method returns without
1085 changing anything. The properties that get copied are the "output" properties
1086 that presumably need to work their way back to the user. In other words, this
1087 method copies everything that make_new_context() did not. This method will
1088 never copy any properties which are undefined scalars or empty lists, so a
1089 CONTEXT with no "output" properties set will not cause any changes. If any
1090 scalar output properties of CONTEXT are defined, they will overwrite any
1091 defined corresponding properties of this object by default; however, if the
1092 optional boolean argument LEAVE_SCALARS is true, then the scalar values are
1093 only copied if the ones in this object are not defined. If any list output
1094 properties of CONTEXT have elements, then they will be appended to
1095 any corresponding ones of this object by default, thereby preserving both
1096 (except with hash properties, where like hash keys will overwrite);
1097 however, if the optional boolean argument REPLACE_LISTS is true, then any
1098 existing list values are overwritten by any copied CONTEXT equivalents.
1099  
1100 =cut
1101  
1102 ######################################################################
1103  
1104 0 ▶sub take_context_output {
Subroutine take_context_output: not called CC=34 SCAR=70.8
Pod documented
1105 0 my ($self, $context, $leave_scalars, $replace_lists) = @_;
1106 0 ▶ UNIVERSAL::isa( $context, 'CGI::Portable' ) or return( 0 );
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($context, "CGI::Portable") or return 0 0 0 0
1107  
1108 0 ▶ if( $replace_lists ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($replace_lists) { } 0 0 0
1109 0 @{$context->{$KEY_ERRORS}} and
1110 0 ▶ $self->{$KEY_ERRORS} = [@{$context->{$KEY_ERRORS}}];
Branch: 1 branch
BranchTrueFalseTotal
@{$context->{$KEY_ERRORS};} and $self->{$KEY_ERRORS} = [@{$context->{$KEY_ERRORS};}] 0 0 0
1111 } else {
1112 0 push( @{$self->{$KEY_ERRORS}}, @{$context->{$KEY_ERRORS}} );
1113 }
1114  
1115 # The 'Files' properties are all input, so this method does nothing with them.
1116  
1117 # The 'Request' properties are all input, so this method does nothing with them.
1118  
1119 0 ▶ if( $leave_scalars ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leave_scalars) { } 0 0 0
1120 defined( $self->{$KEY_HTTP_STAT} ) or
1121 0 ▶ $self->{$KEY_HTTP_STAT} = $context->{$KEY_HTTP_STAT};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$KEY_HTTP_STAT} or $self->{$KEY_HTTP_STAT} = $context->{$KEY_HTTP_STAT} 0 0 0
1122 defined( $self->{$KEY_HTTP_WITA} ) or
1123 0 ▶ $self->{$KEY_HTTP_WITA} = $context->{$KEY_HTTP_WITA};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$KEY_HTTP_WITA} or $self->{$KEY_HTTP_WITA} = $context->{$KEY_HTTP_WITA} 0 0 0
1124 defined( $self->{$KEY_HTTP_COTY} ) or
1125 0 ▶ $self->{$KEY_HTTP_COTY} = $context->{$KEY_HTTP_COTY};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$KEY_HTTP_COTY} or $self->{$KEY_HTTP_COTY} = $context->{$KEY_HTTP_COTY} 0 0 0
1126 defined( $self->{$KEY_HTTP_REDI} ) or
1127 0 ▶ $self->{$KEY_HTTP_REDI} = $context->{$KEY_HTTP_REDI};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$KEY_HTTP_REDI} or $self->{$KEY_HTTP_REDI} = $context->{$KEY_HTTP_REDI} 0 0 0
1128 defined( $self->{$KEY_HTTP_BODY} ) or
1129 0 ▶ $self->{$KEY_HTTP_BODY} = $context->{$KEY_HTTP_BODY};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$KEY_HTTP_BODY} or $self->{$KEY_HTTP_BODY} = $context->{$KEY_HTTP_BODY} 0 0 0
1130 defined( $self->{$KEY_HTTP_BINA} ) or
1131 0 ▶ $self->{$KEY_HTTP_BINA} = $context->{$KEY_HTTP_BINA};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$KEY_HTTP_BINA} or $self->{$KEY_HTTP_BINA} = $context->{$KEY_HTTP_BINA} 0 0 0
1132 defined( $self->{$KEY_PAGE_PROL} ) or
1133 0 ▶ $self->{$KEY_PAGE_PROL} = $context->{$KEY_PAGE_PROL};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$KEY_PAGE_PROL} or $self->{$KEY_PAGE_PROL} = $context->{$KEY_PAGE_PROL} 0 0 0
1134 defined( $self->{$KEY_PAGE_TITL} ) or
1135 0 ▶ $self->{$KEY_PAGE_TITL} = $context->{$KEY_PAGE_TITL};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$KEY_PAGE_TITL} or $self->{$KEY_PAGE_TITL} = $context->{$KEY_PAGE_TITL} 0 0 0
1136 defined( $self->{$KEY_PAGE_AUTH} ) or
1137 0 ▶ $self->{$KEY_PAGE_AUTH} = $context->{$KEY_PAGE_AUTH};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$KEY_PAGE_AUTH} or $self->{$KEY_PAGE_AUTH} = $context->{$KEY_PAGE_AUTH} 0 0 0
1138  
1139 } else {
1140 defined( $context->{$KEY_HTTP_STAT} ) and
1141 0 ▶ $self->{$KEY_HTTP_STAT} = $context->{$KEY_HTTP_STAT};
Branch: 1 branch
BranchTrueFalseTotal
defined $context->{$KEY_HTTP_STAT} and $self->{$KEY_HTTP_STAT} = $context->{$KEY_HTTP_STAT} 0 0 0
1142 defined( $context->{$KEY_HTTP_WITA} ) and
1143 0 ▶ $self->{$KEY_HTTP_WITA} = $context->{$KEY_HTTP_WITA};
Branch: 1 branch
BranchTrueFalseTotal
defined $context->{$KEY_HTTP_WITA} and $self->{$KEY_HTTP_WITA} = $context->{$KEY_HTTP_WITA} 0 0 0
1144 defined( $context->{$KEY_HTTP_COTY} ) and
1145 0 ▶ $self->{$KEY_HTTP_COTY} = $context->{$KEY_HTTP_COTY};
Branch: 1 branch
BranchTrueFalseTotal
defined $context->{$KEY_HTTP_COTY} and $self->{$KEY_HTTP_COTY} = $context->{$KEY_HTTP_COTY} 0 0 0
1146 defined( $context->{$KEY_HTTP_REDI} ) and
1147 0 ▶ $self->{$KEY_HTTP_REDI} = $context->{$KEY_HTTP_REDI};
Branch: 1 branch
BranchTrueFalseTotal
defined $context->{$KEY_HTTP_REDI} and $self->{$KEY_HTTP_REDI} = $context->{$KEY_HTTP_REDI} 0 0 0
1148 defined( $context->{$KEY_HTTP_BODY} ) and
1149 0 ▶ $self->{$KEY_HTTP_BODY} = $context->{$KEY_HTTP_BODY};
Branch: 1 branch
BranchTrueFalseTotal
defined $context->{$KEY_HTTP_BODY} and $self->{$KEY_HTTP_BODY} = $context->{$KEY_HTTP_BODY} 0 0 0
1150 defined( $context->{$KEY_HTTP_BINA} ) and
1151 0 ▶ $self->{$KEY_HTTP_BINA} = $context->{$KEY_HTTP_BINA};
Branch: 1 branch
BranchTrueFalseTotal
defined $context->{$KEY_HTTP_BINA} and $self->{$KEY_HTTP_BINA} = $context->{$KEY_HTTP_BINA} 0 0 0
1152 defined( $context->{$KEY_PAGE_PROL} ) and
1153 0 ▶ $self->{$KEY_PAGE_PROL} = $context->{$KEY_PAGE_PROL};
Branch: 1 branch
BranchTrueFalseTotal
defined $context->{$KEY_PAGE_PROL} and $self->{$KEY_PAGE_PROL} = $context->{$KEY_PAGE_PROL} 0 0 0
1154 defined( $context->{$KEY_PAGE_TITL} ) and
1155 0 ▶ $self->{$KEY_PAGE_TITL} = $context->{$KEY_PAGE_TITL};
Branch: 1 branch
BranchTrueFalseTotal
defined $context->{$KEY_PAGE_TITL} and $self->{$KEY_PAGE_TITL} = $context->{$KEY_PAGE_TITL} 0 0 0
1156 defined( $context->{$KEY_PAGE_AUTH} ) and
1157 0 ▶ $self->{$KEY_PAGE_AUTH} = $context->{$KEY_PAGE_AUTH};
Branch: 1 branch
BranchTrueFalseTotal
defined $context->{$KEY_PAGE_AUTH} and $self->{$KEY_PAGE_AUTH} = $context->{$KEY_PAGE_AUTH} 0 0 0
1158 }
1159  
1160 0 ▶ if( $replace_lists ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($replace_lists) { } 0 0 0
1161 0 @{$context->{$KEY_HTTP_COOK}} and
1162 0 ▶ $self->{$KEY_HTTP_COOK} = [@{$context->{$KEY_HTTP_COOK}}];
Branch: 1 branch
BranchTrueFalseTotal
@{$context->{$KEY_HTTP_COOK};} and $self->{$KEY_HTTP_COOK} = [@{$context->{$KEY_HTTP_COOK};}] 0 0 0
1163 0 @{$context->{$KEY_PAGE_CSSR}} and
1164 0 ▶ $self->{$KEY_PAGE_CSSR} = [@{$context->{$KEY_PAGE_CSSR}}];
Branch: 1 branch
BranchTrueFalseTotal
@{$context->{$KEY_PAGE_CSSR};} and $self->{$KEY_PAGE_CSSR} = [@{$context->{$KEY_PAGE_CSSR};}] 0 0 0
1165 0 @{$context->{$KEY_PAGE_CSSC}} and
1166 0 ▶ $self->{$KEY_PAGE_CSSC} = [@{$context->{$KEY_PAGE_CSSC}}];
Branch: 1 branch
BranchTrueFalseTotal
@{$context->{$KEY_PAGE_CSSC};} and $self->{$KEY_PAGE_CSSC} = [@{$context->{$KEY_PAGE_CSSC};}] 0 0 0
1167 0 @{$context->{$KEY_PAGE_HEAD}} and
1168 0 ▶ $self->{$KEY_PAGE_HEAD} = [@{$context->{$KEY_PAGE_HEAD}}];
Branch: 1 branch
BranchTrueFalseTotal
@{$context->{$KEY_PAGE_HEAD};} and $self->{$KEY_PAGE_HEAD} = [@{$context->{$KEY_PAGE_HEAD};}] 0 0 0
1169 0 @{$context->{$KEY_PAGE_FRAM}} and $self->{$KEY_PAGE_FRAM} =
1170 0 ▶ [map { {%{$_}} } @{$context->{$KEY_PAGE_FRAM}}];
Branch: 1 branch
BranchTrueFalseTotal
@{$context->{$KEY_PAGE_FRAM};} and $self->{$KEY_PAGE_FRAM} = [map({+{%{$_;}};} @{$$context{$KEY_PAGE_FRAM};})] 0 0 0
1171 0 @{$context->{$KEY_PAGE_BODY}} and
1172 0 ▶ $self->{$KEY_PAGE_BODY} = [@{$context->{$KEY_PAGE_BODY}}];
Branch: 1 branch
BranchTrueFalseTotal
@{$context->{$KEY_PAGE_BODY};} and $self->{$KEY_PAGE_BODY} = [@{$context->{$KEY_PAGE_BODY};}] 0 0 0
1173  
1174 0 %{$context->{$KEY_HTTP_HEAD}} and
1175 0 ▶ $self->{$KEY_HTTP_HEAD} = {%{$context->{$KEY_HTTP_HEAD}}};
Branch: 1 branch
BranchTrueFalseTotal
%{$context->{$KEY_HTTP_HEAD};} and $self->{$KEY_HTTP_HEAD} = {%{$context->{$KEY_HTTP_HEAD};}} 0 0 0
1176 0 %{$context->{$KEY_PAGE_META}} and
1177 0 ▶ $self->{$KEY_PAGE_META} = {%{$context->{$KEY_PAGE_META}}};
Branch: 1 branch
BranchTrueFalseTotal
%{$context->{$KEY_PAGE_META};} and $self->{$KEY_PAGE_META} = {%{$context->{$KEY_PAGE_META};}} 0 0 0
1178 0 %{$context->{$KEY_PAGE_FATR}} and
1179 0 ▶ $self->{$KEY_PAGE_FATR} = {%{$context->{$KEY_PAGE_FATR}}};
Branch: 1 branch
BranchTrueFalseTotal
%{$context->{$KEY_PAGE_FATR};} and $self->{$KEY_PAGE_FATR} = {%{$context->{$KEY_PAGE_FATR};}} 0 0 0
1180 0 %{$context->{$KEY_PAGE_BATR}} and
1181 0 ▶ $self->{$KEY_PAGE_BATR} = {%{$context->{$KEY_PAGE_BATR}}};
Branch: 1 branch
BranchTrueFalseTotal
%{$context->{$KEY_PAGE_BATR};} and $self->{$KEY_PAGE_BATR} = {%{$context->{$KEY_PAGE_BATR};}} 0 0 0
1182  
1183 } else {
1184 0 push( @{$self->{$KEY_HTTP_COOK}}, @{$context->{$KEY_HTTP_COOK}} );
1185 0 push( @{$self->{$KEY_PAGE_CSSR}}, @{$context->{$KEY_PAGE_CSSR}} );
1186 0 push( @{$self->{$KEY_PAGE_CSSC}}, @{$context->{$KEY_PAGE_CSSC}} );
1187 0 push( @{$self->{$KEY_PAGE_HEAD}}, @{$context->{$KEY_PAGE_HEAD}} );
1188 0 push( @{$self->{$KEY_PAGE_FRAM}},
1189 0 map { {%{$_}} } @{$context->{$KEY_PAGE_FRAM}} );
1190 0 push( @{$self->{$KEY_PAGE_BODY}}, @{$context->{$KEY_PAGE_BODY}} );
1191  
1192 0 @{$self->{$KEY_HTTP_HEAD}}{keys %{$context->{$KEY_HTTP_HEAD}}} =
1193 0 values %{$context->{$KEY_HTTP_HEAD}};
1194 0 @{$self->{$KEY_PAGE_META}}{keys %{$context->{$KEY_PAGE_META}}} =
1195 0 values %{$context->{$KEY_PAGE_META}};
1196 0 @{$self->{$KEY_PAGE_FATR}}{keys %{$context->{$KEY_PAGE_FATR}}} =
1197 0 values %{$context->{$KEY_PAGE_FATR}};
1198 0 @{$self->{$KEY_PAGE_BATR}}{keys %{$context->{$KEY_PAGE_BATR}}} =
1199 0 values %{$context->{$KEY_PAGE_BATR}};
1200 }
1201 }
1202  
1203 ######################################################################
1204  
1205 =head2 call_component( COMP_NAME )
1206  
1207 This method can be used by one component to invoke another. For this to work,
1208 the called component needs to be a Perl 5 module with a method called main(). The
1209 argument COMP_NAME is a string containing the name of the module to be invoked.
1210 This method will first "require [COMP_NAME]" and then invoke its dispatch method
1211 with a "[COMP_NAME]->main()". These statements are wrapped in an "eval" block
1212 and if there was a compile or runtime failure then this method will log an error
1213 message like "can't use module '[COMP_NAME]': $@" and also set the output page
1214 to be an error screen using that. So regardless of whether the component worked
1215 or not, you can simply print the output page the same way. The call_component()
1216 method will pass a reference to the CGI::Portable object it is invoked from as an
1217 argument to the main() method of the called module. If you want the called
1218 component to get a different CGI::Portable object then you will need to
1219 create it in your caller using make_new_context() or new() or clone().
1220 Anticipating that your component would fail because of it, this method will
1221 abort with an error screen prior to any "require" if there are errors already
1222 logged and unresolved. Any errors existing now were probably set by
1223 set_prefs(), meaning that the component would be missing its config data were it
1224 started up. This method will return 0 upon making an error screen; otherwise,
1225 it will return 1 if everything worked. Since this method calls add_no_error()
1226 upon making the error screen, you should pay attention to its return value if
1227 you want to make a custom screen instead (so you know when to).
1228  
1229 =cut
1230  
1231 ######################################################################
1232  
1233 0 ▶sub call_component {
Subroutine call_component: not called CC=4 SCAR=30.0
Pod documented
1234 0 my ($self, $comp_name) = @_;
1235 0 ▶ if( $self->get_error() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_error) 0 0 0
1236 0 $self->_make_call_component_error_page( $comp_name );
1237 0 return( 0 );
1238 }
1239 0 eval {
1240 # "require $comp_name;" yields can't find module in @INC error in 5.004
1241 0 ▶ eval "require $comp_name;"; $@ and die;
Branch: 1 branch
BranchTrueFalseTotal
$@ and die 0 0 0
1242 0 $comp_name->main( $self );
1243 };
1244 0 ▶ if( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1245 0 $self->add_error( "can't use module '$comp_name': $@" );
1246 0 $self->_make_call_component_error_page( $comp_name );
1247 0 return( 0 );
1248 }
1249 0 return( 1 );
1250 }
1251  
1252 # _make_call_component_error_page( COMP_NAME )
1253 # This private method is used by call_component() to make error screens in
1254 # situations where there is a failure calling an application component.
1255 # The main situation in question involves the component module failing to
1256 # compile or it having a run-time death. It can also be used when there is
1257 # nothing wrong with the component itself, but there was a failure in getting
1258 # preferences for it ahead of time. This method assumes that the details of
1259 # the particular error will be returned by get_error() when it is called.
1260 # The scalar argument COMP_NAME is the name of the module that call_component
1261 # was trying to or would have been using. The intent of this method is to
1262 # save the parent component or thin program config shell from having to compose
1263 # an error screen for the user by itself, which is often repedative. The parent
1264 # module can simply take back the context result page as it always does, which
1265 # either contains successful output of the component or result of this method.
1266  
1267 0 ▶sub _make_call_component_error_page {
Subroutine _make_call_component_error_page: not called CC=1 SCAR=6.9
1268 0 my ($self, $comp_name) = @_;
1269 0 $self->page_title( 'Error Getting Screen' );
1270  
1271 0 $self->set_page_body( <<__endquote );
1272 0 <h1>@{[$self->page_title()]}</h1>
1273  
1274 <p>I'm sorry, but an error occurred while getting the requested screen.
1275 We were unable to use the application component that was in charge of
1276 producing the screen content, named '$comp_name'.</p>
1277  
1278 <p>This should be temporary, the result of a transient server problem or an
1279 0 update being performed at the moment. Click @{[$self->recall_html('here')]}
1280 to automatically try again. If the problem persists, please try again later,
1281 0 or send an @{[$self->maintainer_email_html('e-mail')]} message about the
1282 problem, so it can be fixed.</p>
1283  
1284 0 <p>Detail: @{[$self->get_error()]}</p>
1285 __endquote
1286  
1287 0 $self->add_no_error();
1288 }
1289  
1290 ######################################################################
1291  
1292 =head1 METHODS FOR ERROR MESSAGES
1293  
1294 These methods are accessors for the "error list" property of this object,
1295 which is designed to accumulate any error strings that should be printed to the
1296 program's error log or shown to the user before the program exits. See the
1297 DESCRIPTION for more details.
1298  
1299 =head2 get_errors()
1300  
1301 This method returns a list of the stored error messages with any undefined
1302 strings (no error) filtered out.
1303  
1304 =head2 get_error([ INDEX ])
1305  
1306 This method returns a single error message. If the numerical argument INDEX is
1307 defined then the message is taken from that element in the error list.
1308 INDEX defaults to -1 if not defined, so the most recent message is returned.
1309  
1310 =head2 add_error( MESSAGE )
1311  
1312 This method appends the scalar argument MESSAGE to the error list.
1313  
1314 =head2 add_no_error()
1315  
1316 This message appends an undefined value to the error list, a "no error" message.
1317  
1318 =cut
1319  
1320 ######################################################################
1321  
1322 0 ▶sub get_errors {
Subroutine get_errors: not called CC=1 SCAR=6.9
Pod documented
1323 0 return( grep { defined($_) } @{$_[0]->{$KEY_ERRORS}} );
1324 }
1325  
1326 0 ▶sub get_error {
Subroutine get_error: not called CC=2 SCAR=17.9
Pod documented
1327 0 my ($self, $index) = @_;
1328 0 ▶ defined( $index ) or $index = -1;
Branch: 1 branch
BranchTrueFalseTotal
defined $index or $index = -1 0 0 0
1329 0 return( $self->{$KEY_ERRORS}->[$index] );
1330 }
1331  
1332 0 ▶sub add_error {
Subroutine add_error: not called CC=1 SCAR=6.9
Pod documented
1333 0 my ($self, $message) = @_;
1334 0 push( @{$self->{$KEY_ERRORS}}, $message );
1335 }
1336  
1337 0 ▶sub add_no_error {
Subroutine add_no_error: not called CC=1 SCAR=6.9
Pod documented
1338 0 push( @{$_[0]->{$KEY_ERRORS}}, undef );
1339 }
1340  
1341 ######################################################################
1342  
1343 =head1 METHODS FOR THE VIRTUAL FILE SYSTEM
1344  
1345 These methods are accessors for the "file path" property of this object, which is
1346 designed to facilitate easy portability of your application across multiple file
1347 systems or across different locations in the same file system. See the
1348 DESCRIPTION for more details.
1349  
1350 =head2 get_file_path_ref()
1351  
1352 This method returns a reference to the file path object which you can then
1353 manipulate directly with File::VirtualPath methods.
1354  
1355 =head2 file_path_root([ VALUE ])
1356  
1357 This method is an accessor for the "physical root" string property of the file
1358 path, which it returns. If VALUE is defined then this property is set to it.
1359 This property says where your project directory is actually located in the
1360 current physical file system, and is used in translations from the virtual to
1361 the physical space. The only part of your program that should set this method
1362 is your thin startup shell; the rest should be oblivious to it.
1363  
1364 =head2 file_path_delimiter([ VALUE ])
1365  
1366 This method is an accessor for the "physical delimiter" string property of the
1367 file path, which it returns. If VALUE is defined then this property is set to
1368 it. This property says what character is used to delimit directory path levels
1369 in your current physical file system, and is used in translations from the
1370 virtual to the physical space. The only part of your program that should set
1371 this method is your thin startup shell; the rest should be oblivious to it.
1372  
1373 =head2 file_path([ VALUE ])
1374  
1375 This method is an accessor to the "virtual path" array property of the file path,
1376 which it returns. If VALUE is defined then this property is set to it; it can
1377 be an array of path levels or a string representation in the virtual space.
1378 This method returns an array ref having the current virtual file path.
1379  
1380 =head2 file_path_string([ TRAILER ])
1381  
1382 This method returns a string representation of the file path in the virtual
1383 space. If the optional argument TRAILER is true, then a virtual file path
1384 delimiter, "/" by default, is appended to the end of the returned value.
1385  
1386 =head2 navigate_file_path( CHANGE_VECTOR )
1387  
1388 This method updates the "virtual path" property of the file path by taking the
1389 current one and applying CHANGE_VECTOR to it using the FVP's chdir() method.
1390 This method returns an array ref having the changed virtual file path.
1391  
1392 =head2 virtual_filename( CHANGE_VECTOR[, WANT_TRAILER] )
1393  
1394 This method uses CHANGE_VECTOR to derive a new path in the virtual file-system
1395 relative to the current one and returns it as a string. If WANT_TRAILER is true
1396 then the string has a path delimiter appended; otherwise, there is none.
1397  
1398 =head2 physical_filename( CHANGE_VECTOR[, WANT_TRAILER] )
1399  
1400 This method uses CHANGE_VECTOR to derive a new path in the real file-system
1401 relative to the current one and returns it as a string. If WANT_TRAILER is true
1402 then the string has a path delimiter appended; otherwise, there is none.
1403  
1404 =head2 add_virtual_filename_error( UNIQUE_PART, FILENAME[, REASON] )
1405  
1406 This message constructs a new error message using its arguments and appends it to
1407 the error list. You can call this after doing a file operation that failed where
1408 UNIQUE_PART is a sentence fragment like "open" or "read from" and FILENAME is the
1409 relative portion of the file name. The new message looks like
1410 "can't [UNIQUE_PART] file '[FILEPATH]': $!" where FILEPATH is defined as the
1411 return value of "virtual_filename( FILENAME )". If the optional argument REASON
1412 is defined then its value is used in place of $!, so you can use this method for
1413 errors relating to a file where $! wouldn't have an appropriate value.
1414  
1415 =head2 add_physical_filename_error( UNIQUE_PART, FILENAME[, REASON] )
1416  
1417 This message constructs a new error message using its arguments and appends it to
1418 the error list. You can call this after doing a file operation that failed where
1419 UNIQUE_PART is a sentence fragment like "open" or "read from" and FILENAME is the
1420 relative portion of the file name. The new message looks like
1421 "can't [UNIQUE_PART] file '[FILEPATH]': $!" where FILEPATH is defined as the
1422 return value of "physical_filename( FILENAME )". If the optional argument REASON
1423 is defined then its value is used in place of $!, so you can use this method for
1424 errors relating to a file where $! wouldn't have an appropriate value.
1425  
1426 =cut
1427  
1428 ######################################################################
1429  
1430 0 ▶sub get_file_path_ref {
Subroutine get_file_path_ref: not called CC=1 SCAR=6.9
Pod documented
1431 0 return( $_[0]->{$KEY_FILE_PATH} ); # returns ref for further use
1432 }
1433  
1434 2 ▶sub file_path_root {
Subroutine file_path_root: called CC=1 SCAR=0.0
Pod documented
1435 2 my ($self, $new_value) = @_;
1436 2 return( $self->{$KEY_FILE_PATH}->physical_root( $new_value ) );
1437 }
1438  
1439 2 ▶sub file_path_delimiter {
Subroutine file_path_delimiter: called CC=1 SCAR=0.0
Pod documented
1440 2 my ($self, $new_value) = @_;
1441 2 return( $self->{$KEY_FILE_PATH}->physical_delimiter( $new_value ) );
1442 }
1443  
1444 0 ▶sub file_path {
Subroutine file_path: not called CC=1 SCAR=6.9
Pod documented
1445 0 my ($self, $new_value) = @_;
1446 0 return( $self->{$KEY_FILE_PATH}->path( $new_value ) );
1447 }
1448  
1449 0 ▶sub file_path_string {
Subroutine file_path_string: not called CC=1 SCAR=6.9
Pod documented
1450 0 my ($self, $trailer) = @_;
1451 0 return( $self->{$KEY_FILE_PATH}->path_string( $trailer ) );
1452 }
1453  
1454 0 ▶sub navigate_file_path {
Subroutine navigate_file_path: not called CC=1 SCAR=6.9
Pod documented
1455 0 my ($self, $chg_vec) = @_;
1456 0 return( $self->{$KEY_FILE_PATH}->chdir( $chg_vec ) );
1457 }
1458  
1459 0 ▶sub virtual_filename {
Subroutine virtual_filename: not called CC=1 SCAR=6.9
Pod documented
1460 0 my ($self, $chg_vec, $trailer) = @_;
1461 0 return( $self->{$KEY_FILE_PATH}->child_path_string( $chg_vec, $trailer ) );
1462 }
1463  
1464 0 ▶sub physical_filename {
Subroutine physical_filename: not called CC=1 SCAR=6.9
Pod documented
1465 0 my ($self, $chg_vec, $trailer) = @_;
1466 0 return( $self->{$KEY_FILE_PATH}->physical_child_path_string(
1467 $chg_vec, $trailer ) );
1468 }
1469  
1470 0 ▶sub add_virtual_filename_error {
Subroutine add_virtual_filename_error: not called CC=2 SCAR=17.9
Pod documented
1471 0 my ($self, $unique_part, $filename, $reason) = @_;
1472 0 my $filepath = $self->virtual_filename( $filename );
1473 0 ▶ defined( $reason ) or $reason = $!;
Branch: 1 branch
BranchTrueFalseTotal
defined $reason or $reason = $! 0 0 0
1474 0 $self->add_error( "can't $unique_part file '$filepath': $reason" );
1475 }
1476  
1477 0 ▶sub add_physical_filename_error {
Subroutine add_physical_filename_error: not called CC=2 SCAR=17.9
Pod documented
1478 0 my ($self, $unique_part, $filename, $reason) = @_;
1479 0 my $filepath = $self->physical_filename( $filename );
1480 0 ▶ defined( $reason ) or $reason = $!;
Branch: 1 branch
BranchTrueFalseTotal
defined $reason or $reason = $! 0 0 0
1481 0 $self->add_error( "can't $unique_part file '$filepath': $reason" );
1482 }
1483  
1484 ######################################################################
1485  
1486 =head1 METHODS FOR INSTANCE PREFERENCES
1487  
1488 These methods are accessors for the "preferences" property of this object, which
1489 is designed to facilitate easy access to your application instance settings.
1490 See the DESCRIPTION for more details.
1491  
1492 =head2 resolve_prefs_node_to_hash( RAW_NODE )
1493  
1494 This method takes a raw preferences node, RAW_NODE, and resolves it into a hash
1495 ref, which it returns. If RAW_NODE is a hash ref then this method performs a
1496 single-level copy of it and returns a new hash ref. Otherwise, this method
1497 takes the argument as a filename and tries to execute it. If the file fails to
1498 execute for some reason or it doesn't return a hash ref, then this method adds
1499 a file error message and returns an empty hash ref. The file is executed with
1500 "do [FILEPATH]" where FILEPATH is defined as the return value of
1501 "physical_filename( FILENAME )". The error message uses a virtual path.
1502  
1503 =head2 resolve_prefs_node_to_array( RAW_NODE )
1504  
1505 This method takes a raw preferences node, RAW_NODE, and resolves it into an array
1506 ref, which it returns. If RAW_NODE is a hash ref then this method performs a
1507 single-level copy of it and returns a new array ref. Otherwise, this method
1508 takes the argument as a filename and tries to execute it. If the file fails to
1509 execute for some reason or it doesn't return an array ref, then this method adds
1510 a file error message and returns an empty array ref. The file is executed with
1511 "do [FILEPATH]" where FILEPATH is defined as the return value of
1512 "physical_filename( FILENAME )". The error message uses a virtual path.
1513  
1514 =head2 get_prefs_ref()
1515  
1516 This method returns a reference to the internally stored "preferences" hash.
1517  
1518 =head2 set_prefs( VALUE )
1519  
1520 This method sets this object's preferences property with the return value of
1521 "resolve_prefs_node_to_hash( VALUE )", even if VALUE is not defined.
1522  
1523 =head2 pref( KEY[, VALUE] )
1524  
1525 This method is an accessor to individual settings in this object's preferences
1526 property, and returns the setting value whose name is defined in the scalar
1527 argument KEY. If the optional scalar argument VALUE is defined then it becomes
1528 the value for this setting. All values are set or fetched with a scalar copy.
1529  
1530 =cut
1531  
1532 ######################################################################
1533  
1534 0 ▶sub resolve_prefs_node_to_hash {
Subroutine resolve_prefs_node_to_hash: not called CC=5 SCAR=34.0
Pod documented
1535 0 my ($self, $raw_node) = @_;
1536 0 ▶ if( ref( $raw_node ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $raw_node eq 'HASH') { } 0 0 0
1537 0 return( {%{$raw_node}} );
1538 } else {
1539 0 $self->add_no_error();
1540 0 my $filepath = $self->physical_filename( $raw_node );
1541 0 my $result = do $filepath;
1542 0 ▶ if( ref( $result ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result eq 'HASH') { } 0 0 0
1543 0 return( $result );
1544 } else {
1545 0 ▶ $self->add_virtual_filename_error(
Branch: 2 branches
BranchTrueFalseTotal
defined $result ? : 0 0 0
$@ ? : 0 0 0
1546 'obtain required preferences hash from', $raw_node,
1547 defined( $result ) ? "result not a hash ref, but '$result'" :
1548 $@ ? "compilation or runtime error of '$@'" : undef );
1549 0 return( {} );
1550 }
1551 }
1552 }
1553  
1554 0 ▶sub resolve_prefs_node_to_array {
Subroutine resolve_prefs_node_to_array: not called CC=5 SCAR=34.0
Pod documented
1555 0 my ($self, $raw_node) = @_;
1556 0 ▶ if( ref( $raw_node ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $raw_node eq 'ARRAY') { } 0 0 0
1557 0 return( [@{$raw_node}] );
1558 } else {
1559 0 $self->add_no_error();
1560 0 my $filepath = $self->physical_filename( $raw_node );
1561 0 my $result = do $filepath;
1562 0 ▶ if( ref( $result ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result eq 'ARRAY') { } 0 0 0
1563 0 return( $result );
1564 } else {
1565 0 ▶ $self->add_virtual_filename_error(
Branch: 2 branches
BranchTrueFalseTotal
defined $result ? : 0 0 0
$@ ? : 0 0 0
1566 'obtain required preferences array from', $raw_node,
1567 defined( $result ) ? "result not an array ref, but '$result'" :
1568 $@ ? "compilation or runtime error of '$@'" : undef );
1569 0 return( [] );
1570 }
1571 }
1572 }
1573  
1574 0 ▶sub get_prefs_ref {
Subroutine get_prefs_ref: not called CC=1 SCAR=6.9
Pod documented
1575 0 return( $_[0]->{$KEY_PREFS} ); # returns ref for further use
1576 }
1577  
1578 2 ▶sub set_prefs {
Subroutine set_prefs: called CC=2 SCAR=8.1
Pod documented
1579 2 my ($self, $new_value) = @_;
1580 2 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 2 2
1581 0 $self->{$KEY_PREFS} = $self->resolve_prefs_node_to_hash( $new_value );
1582 }
1583 }
1584  
1585 0 ▶sub pref {
Subroutine pref: not called CC=2 SCAR=17.9
Pod documented
1586 0 my ($self, $key, $new_value) = @_;
1587 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1588 0 $self->{$KEY_PREFS}->{$key} = $new_value;
1589 }
1590 0 return( $self->{$KEY_PREFS}->{$key} );
1591 }
1592  
1593 ######################################################################
1594  
1595 =head1 METHODS FOR TCP/IP CONNECTION
1596  
1597 These methods are accessors for the "TCP Connection" properties of this object.
1598 Under a CGI environment these would correspond to some of the %ENV keys.
1599  
1600 =head2 server_ip([ VALUE ])
1601  
1602 This method is an accessor for the "server ip" scalar property of this object,
1603 which it returns. If VALUE is defined, this property is set to it.
1604 During a valid TCP/IP connection, this property refers to the IP address of the
1605 host machine, which this program is running on.
1606  
1607 =head2 server_domain([ VALUE ])
1608  
1609 This method is an accessor for the "server domain" scalar property of this object,
1610 which it returns. If VALUE is defined, this property is set to it.
1611 This property refers to the tcp host domain, if any, that was resolved to the
1612 server IP. It would be provided in the TCP request header named "Host".
1613 Often, multiple domains will resolve to the same IP address, in which case this
1614 "Host" header is needed to tell what website the client really wanted.
1615  
1616 =head2 server_port([ VALUE ])
1617  
1618 This method is an accessor for the "server port" scalar property of this object,
1619 which it returns. If VALUE is defined, this property is set to it.
1620 During a valid TCP/IP connection, this property refers to the tcp port on the
1621 host machine that this program or its parent service is listening on.
1622 Port 80 is the standard one used for HTTP services.
1623  
1624 =head2 client_ip([ VALUE ])
1625  
1626 This method is an accessor for the "client ip" scalar property of this object,
1627 which it returns. If VALUE is defined, this property is set to it.
1628 During a valid TCP/IP connection, this property refers to the IP address of the
1629 client machine, which is normally what the web-browsing user is sitting at,
1630 though it could be a proxy or a robot instead.
1631  
1632 =head2 client_domain([ VALUE ])
1633  
1634 This method is an accessor for the "client domain" scalar property of this object,
1635 which it returns. If VALUE is defined, this property is set to it.
1636 This property often is not set, but if it is then it refers to internet domain
1637 for the ISP that the web-browsing user is employing, or it is the domain for the
1638 machine that the web robot is on.
1639  
1640 =head2 client_port([ VALUE ])
1641  
1642 This method is an accessor for the "client port" scalar property of this object,
1643 which it returns. If VALUE is defined, this property is set to it.
1644 During a valid TCP/IP connection, this property refers to the tcp port on the
1645 client machine that the web browser or robot is using for this connection, and it
1646 is also how the web server can differentiate between multiple clients talking with
1647 it on the same server port. Web browsers often use multiple client ports at once
1648 in order to request multiple files (eg, images) at once.
1649  
1650 =cut
1651  
1652 ######################################################################
1653  
1654 0 ▶sub server_ip {
Subroutine server_ip: not called CC=2 SCAR=17.9
Pod documented
1655 0 my ($self, $new_value) = @_;
1656 0 ▶ if( defined( $new_value ) ) { $self->{$KEY_TCP_SEIP} = $new_value; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1657 0 return( $self->{$KEY_TCP_SEIP} );
1658 }
1659  
1660 0 ▶sub server_domain {
Subroutine server_domain: not called CC=2 SCAR=17.9
Pod documented
1661 0 my ($self, $new_value) = @_;
1662 0 ▶ if( defined( $new_value ) ) { $self->{$KEY_TCP_SEDO} = $new_value; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1663 0 return( $self->{$KEY_TCP_SEDO} );
1664 }
1665  
1666 0 ▶sub server_port {
Subroutine server_port: not called CC=2 SCAR=17.9
Pod documented
1667 0 my ($self, $new_value) = @_;
1668 0 ▶ if( defined( $new_value ) ) { $self->{$KEY_TCP_SEPO} = $new_value; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1669 0 return( $self->{$KEY_TCP_SEPO} );
1670 }
1671  
1672 0 ▶sub client_ip {
Subroutine client_ip: not called CC=2 SCAR=17.9
Pod documented
1673 0 my ($self, $new_value) = @_;
1674 0 ▶ if( defined( $new_value ) ) { $self->{$KEY_TCP_CLIP} = $new_value; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1675 0 return( $self->{$KEY_TCP_CLIP} );
1676 }
1677  
1678 0 ▶sub client_domain {
Subroutine client_domain: not called CC=2 SCAR=17.9
Pod documented
1679 0 my ($self, $new_value) = @_;
1680 0 ▶ if( defined( $new_value ) ) { $self->{$KEY_TCP_CLDO} = $new_value; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1681 0 return( $self->{$KEY_TCP_CLDO} );
1682 }
1683  
1684 0 ▶sub client_port {
Subroutine client_port: not called CC=2 SCAR=17.9
Pod documented
1685 0 my ($self, $new_value) = @_;
1686 0 ▶ if( defined( $new_value ) ) { $self->{$KEY_TCP_CLPO} = $new_value; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1687 0 return( $self->{$KEY_TCP_CLPO} );
1688 }
1689  
1690 ######################################################################
1691  
1692 =head1 METHODS FOR HTTP REQUEST
1693  
1694 These methods are accessors for all "http request" properties of this object.
1695 Under a CGI environment these would correspond to various %ENV keys.
1696 Some request details are special, and parsed versions are also under USER INPUT.
1697  
1698 =head2 request_method([ VALUE ])
1699  
1700 This method is an accessor for the "request method" scalar property of this object,
1701 which it returns. If VALUE is defined, this property is set to it.
1702 This property is a string such as ['GET','POST','HEAD','PUT'] and refers to the
1703 type of http operation that the client wants to do. It would be provided as the
1704 first word of the first line of the HTTP request headers. If the request method
1705 is POST then the server should expect an HTTP body; if the method is GET or HEAD
1706 then the server should expect no HTTP body. If the method is GET or POST then
1707 the client expects an HTTP response with both headers and body; if the method is
1708 HEAD then the client expects only the response headers.
1709  
1710 =head2 request_uri([ VALUE ])
1711  
1712 This method is an accessor for the "request uri" scalar property of this object,
1713 which it returns. If VALUE is defined, this property is set to it.
1714 This property is a string such as ["/", "/one/two.html", "/cgi/getit.pl/five",
1715 "/cgi/getit.pl?six=seven"] and refers to the name of the resource on the server
1716 that the client wants returned. It would be provided as the second word of the
1717 first line of the HTTP request headers. Under an ordinary web file server such
1718 as Apache, the "request path" would be split into 3 main pieces with names like:
1719 "script name" ("/" or "/cgi/getit.pl"), "path info" ("/five"), "query string"
1720 ("six=seven").
1721  
1722 =head2 request_protocol([ VALUE ])
1723  
1724 This method is an accessor for the "request protocol" scalar property of this object,
1725 which it returns. If VALUE is defined, this property is set to it.
1726 This property is a string like ["HTTP/1.0", "HTTP/1.1"] and refers to the set of
1727 protocols that the client would like to use during this session. It would be
1728 provided as the third word of the first line of the HTTP request headers.
1729  
1730 =cut
1731  
1732 ######################################################################
1733  
1734 0 ▶sub request_method {
Subroutine request_method: not called CC=2 SCAR=17.9
Pod documented
1735 0 my ($self, $new_value) = @_;
1736 0 ▶ if( defined( $new_value ) ) { $self->{$KEY_REQ_METH} = $new_value; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1737 0 return( $self->{$KEY_REQ_METH} );
1738 }
1739  
1740 0 ▶sub request_uri {
Subroutine request_uri: not called CC=2 SCAR=17.9
Pod documented
1741 0 my ($self, $new_value) = @_;
1742 0 ▶ if( defined( $new_value ) ) { $self->{$KEY_REQ_URIX} = $new_value; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1743 0 return( $self->{$KEY_REQ_URIX} );
1744 }
1745  
1746 0 ▶sub request_protocol {
Subroutine request_protocol: not called CC=2 SCAR=17.9
Pod documented
1747 0 my ($self, $new_value) = @_;
1748 0 ▶ if( defined( $new_value ) ) { $self->{$KEY_REQ_PROT} = $new_value; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1749 0 return( $self->{$KEY_REQ_PROT} );
1750 }
1751  
1752 ######################################################################
1753  
1754 =head2 get_request_headers_ref()
1755  
1756 This method is an accessor for the "http request headers" hash property of this
1757 object, a reference to which it returns. HTTP headers constitute the first of
1758 two main parts of an HTTP request, and say things like the expected server host
1759 domain (where multiple domains share an ip), the query string, returned cookies,
1760 what human language or text encoding the browser expects, and more. Copies of
1761 some of these are parsed and also available under METHODS FOR USER INPUT.
1762 Each key/value pair in the hash would come from a header line like "Key: value".
1763 Header names are case-sensitive and have capitalized format, with dashes to
1764 separate multple words in the name; an example is "Header-Name: value".
1765 This is different from the CGI environment, which translates the headers to
1766 all-uppercase with underscores replaing the dashes.
1767  
1768 =head2 get_request_headers([ KEY ])
1769  
1770 This method allows you to get the "http request headers" hash property of this
1771 object. If KEY is defined then it is taken as a key in the hash and the
1772 associated value is returned. If KEY is not defined then the entire hash is
1773 returned as a list; in scalar context this list is in a new hash ref.
1774  
1775 =head2 set_request_headers( KEY[, VALUE] )
1776  
1777 This method allows you to set the "http request headers" hash property of this
1778 object. If KEY is a valid HASH ref then all the existing headers information is
1779 replaced with the new hash keys and values. If KEY is defined but it is not a
1780 Hash ref, then KEY and VALUE are inserted together into the existing hash.
1781  
1782 =head2 add_request_headers( KEY[, VALUE] )
1783  
1784 This method allows you to add key/value pairs to the "http request headers"
1785 hash property of this object. If KEY is a valid HASH ref then the keys and
1786 values it contains are inserted into the existing hash property; any like-named
1787 keys will overwrite existing ones, but different-named ones will coexist.
1788 If KEY is defined but it is not a Hash ref, then KEY and VALUE are inserted
1789 together into the existing hash.
1790  
1791 =cut
1792  
1793 ######################################################################
1794  
1795 0 ▶sub get_request_headers_ref {
Subroutine get_request_headers_ref: not called CC=1 SCAR=6.9
Pod documented
1796 0 return( $_[0]->{$KEY_REQ_HEAD} ); # returns ref for further use
1797 }
1798  
1799 0 ▶sub get_request_headers {
Subroutine get_request_headers: not called CC=3 SCAR=24.8
Pod documented
1800 0 my ($self, $key) = @_;
1801 0 ▶ if( defined( $key ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key) 0 0 0
1802 0 return( $self->{$KEY_REQ_HEAD}->{$key} );
1803 }
1804 0 my %hash_copy = %{$self->{$KEY_REQ_HEAD}};
1805 0 ▶ return( wantarray ? %hash_copy : \%hash_copy );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1806 }
1807  
1808 0 ▶sub set_request_headers {
Subroutine set_request_headers: not called CC=3 SCAR=24.8
Pod documented
1809 0 my ($self, $first, $second) = @_;
1810 0 ▶ if( defined( $first ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first) 0 0 0
1811 0 ▶ if( ref( $first ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first eq 'HASH') { } 0 0 0
1812 0 $self->{$KEY_REQ_HEAD} = {%{$first}};
1813 } else {
1814 0 $self->{$KEY_REQ_HEAD}->{$first} = $second;
1815 }
1816 }
1817 }
1818  
1819 0 ▶sub add_request_headers {
Subroutine add_request_headers: not called CC=3 SCAR=24.8
Pod documented
1820 0 my ($self, $first, $second) = @_;
1821 0 ▶ if( defined( $first ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first) 0 0 0
1822 0 ▶ if( ref( $first ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first eq 'HASH') { } 0 0 0
1823 0 @{$self->{$KEY_REQ_HEAD}}{keys %{$first}} = values %{$first};
1824 } else {
1825 0 $self->{$KEY_REQ_HEAD}->{$first} = $second;
1826 }
1827 }
1828 }
1829  
1830 ######################################################################
1831  
1832 =head2 request_body([ VALUE ])
1833  
1834 This method is an accessor for the "http request body" scalar property of this
1835 object, which it returns. This contitutes the second of two main parts of
1836 an HTTP request, and contains the actual document/file or url-encoded form
1837 field data that the client/user has sent to the server over the http protocol.
1838 By definition, this property is only defined with a POST request, and does not
1839 have a value with a GET or HEAD request. This property defaults to undefined.
1840  
1841 =cut
1842  
1843 ######################################################################
1844  
1845 0 ▶sub request_body {
Subroutine request_body: not called CC=2 SCAR=17.9
Pod documented
1846 0 my ($self, $new_value) = @_;
1847 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1848 0 $self->{$KEY_REQ_BODY} = $new_value;
1849 }
1850 0 return( $self->{$KEY_REQ_BODY} );
1851 }
1852  
1853 ######################################################################
1854  
1855 =head2 referer([ VALUE ])
1856  
1857 This method is an accessor to the "Referer" key in the "request headers" hash.
1858 The associated value is returned, and a defined VALUE will set it.
1859 This header refers to the complete url of the web page that the user was
1860 viewing before coming to the current url; most likely, said "referer"
1861 page contains a hyperlink leading to the current request url.
1862  
1863 =head2 user_agent([ VALUE ])
1864  
1865 This method is an accessor to the "User-Agent" key in the "request headers" hash.
1866 The associated value is returned, and a defined VALUE will set it.
1867 This header refers to the name that the client user's "agent" or "web
1868 browser" or robot identifies itself to the server as; this identifier tends to
1869 include the agent's brand, version, and o/s platform. An example is
1870 "Mozilla/4.08 (Macintosh; U; PPC, Nav)".
1871  
1872 =cut
1873  
1874 ######################################################################
1875  
1876 0 ▶sub referer {
Subroutine referer: not called CC=2 SCAR=17.9
Pod documented
1877 0 my ($self, $new_value) = @_;
1878 0 my $rh_headers = $self->{$KEY_REQ_HEAD};
1879 0 ▶ if( defined( $new_value ) ) { $rh_headers->{"Referer"} = $new_value; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1880 0 return( $rh_headers->{"Referer"} );
1881 }
1882  
1883 0 ▶sub user_agent {
Subroutine user_agent: not called CC=2 SCAR=17.9
Pod documented
1884 0 my ($self, $new_value) = @_;
1885 0 my $rh_headers = $self->{$KEY_REQ_HEAD};
1886 0 ▶ if( defined( $new_value ) ) { $rh_headers->{"User-Agent"} = $new_value; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
1887 0 return( $rh_headers->{"User-Agent"} );
1888 }
1889  
1890 ######################################################################
1891  
1892 =head1 METHODS FOR USER INPUT
1893  
1894 These methods are accessors for the "user input" properties of this object,
1895 which include: "user path", "user query", "user post", and "user cookies".
1896 See the DESCRIPTION for more details.
1897  
1898 =head2 get_user_path_ref()
1899  
1900 This method returns a reference to the user path object which you can then
1901 manipulate directly with File::VirtualPath methods.
1902  
1903 =head2 user_path([ VALUE ])
1904  
1905 This method is an accessor to the user path, which it returns as an array ref.
1906 If VALUE is defined then this property is set to it; it can be an array of path
1907 levels or a string representation.
1908  
1909 =head2 user_path_string([ TRAILER ])
1910  
1911 This method returns a string representation of the user path. If the optional
1912 argument TRAILER is true, then a "/" is appended.
1913  
1914 =head2 user_path_element( INDEX[, NEW_VALUE] )
1915  
1916 This method is an accessor for individual segments of the "user path" property of
1917 this object, and it returns the one at INDEX. If NEW_VALUE is defined then
1918 the segment at INDEX is set to it. This method is useful if you want to examine
1919 user path segments one at a time. INDEX defaults to 0, meaning you are
1920 looking at the first segment, which happens to always be empty. That said, this
1921 method will let you change this condition if you want to.
1922  
1923 =head2 current_user_path_level([ NEW_VALUE ])
1924  
1925 This method is an accessor for the number "current path level" property of the user
1926 input, which it returns. If NEW_VALUE is defined, this property is set to it.
1927 If you want to examine the user path segments sequentially then this property
1928 tracks the index of the segment you are currently viewing. This property
1929 defaults to 0, the first segment, which always happens to be an empty string.
1930  
1931 =head2 inc_user_path_level()
1932  
1933 This method will increment the "current path level" property by 1 so
1934 you can view the next path segment. The new current value is returned.
1935  
1936 =head2 dec_user_path_level()
1937  
1938 This method will decrement the "current path level" property by 1 so
1939 you can view the previous path segment. The new current value is returned.
1940  
1941 =head2 current_user_path_element([ NEW_VALUE ])
1942  
1943 This method is an accessor for individual segments of the "user path" property of
1944 this object, the current one of which it returns. If NEW_VALUE is defined then
1945 the current segment is set to it. This method is useful if you want to examine
1946 user path segments one at a time in sequence. The segment you are looking at
1947 now is determined by the current_user_path_level() method; by default you are
1948 looking at the first segment, which is always an empty string. That said, this
1949 method will let you change this condition if you want to.
1950  
1951 =cut
1952  
1953 ######################################################################
1954  
1955 0 ▶sub get_user_path_ref {
Subroutine get_user_path_ref: not called CC=1 SCAR=6.9
Pod documented
1956 0 return( $_[0]->{$KEY_UI_PATH} ); # returns ref for further use
1957 }
1958  
1959 0 ▶sub user_path {
Subroutine user_path: not called CC=1 SCAR=6.9
Pod documented
1960 0 my ($self, $new_value) = @_;
1961 0 return( $self->{$KEY_UI_PATH}->path( $new_value ) );
1962 }
1963  
1964 0 ▶sub user_path_string {
Subroutine user_path_string: not called CC=1 SCAR=6.9
Pod documented
1965 0 my ($self, $trailer) = @_;
1966 0 return( $self->{$KEY_UI_PATH}->path_string( $trailer ) );
1967 }
1968  
1969 0 ▶sub user_path_element {
Subroutine user_path_element: not called CC=1 SCAR=6.9
Pod documented
1970 0 my ($self, $index, $new_value) = @_;
1971 0 return( $self->{$KEY_UI_PATH}->path_element( $index, $new_value ) );
1972 }
1973  
1974 0 ▶sub current_user_path_level {
Subroutine current_user_path_level: not called CC=1 SCAR=6.9
Pod documented
1975 0 my ($self, $new_value) = @_;
1976 0 return( $self->{$KEY_UI_PATH}->current_path_level( $new_value ) );
1977 }
1978  
1979 0 ▶sub inc_user_path_level {
Subroutine inc_user_path_level: not called CC=1 SCAR=6.9
Pod documented
1980 0 return( $_[0]->{$KEY_UI_PATH}->inc_path_level() );
1981 }
1982  
1983 0 ▶sub dec_user_path_level {
Subroutine dec_user_path_level: not called CC=1 SCAR=6.9
Pod documented
1984 0 return( $_[0]->{$KEY_UI_PATH}->dec_path_level() );
1985 }
1986  
1987 0 ▶sub current_user_path_element {
Subroutine current_user_path_element: not called CC=1 SCAR=6.9
Pod documented
1988 0 my ($self, $new_value) = @_;
1989 0 return( $self->{$KEY_UI_PATH}->current_path_element( $new_value ) );
1990 }
1991  
1992 ######################################################################
1993  
1994 =head2 get_user_query_ref()
1995  
1996 This method returns a reference to the user query object which you can then
1997 manipulate directly with CGI::MultiValuedHash methods.
1998  
1999 =head2 user_query([ VALUE ])
2000  
2001 This method is an accessor to the user query, which it returns as a
2002 cloned CGI::MultiValuedHash object. If VALUE is defined then it is used to
2003 initialize a new user query.
2004  
2005 =head2 user_query_string()
2006  
2007 This method url-encodes the user query and returns it as a string.
2008  
2009 =head2 user_query_param( KEY[, VALUES] )
2010  
2011 This method is an accessor for individual user query parameters. If there are
2012 any VALUES then this method stores them in the query under the name KEY and
2013 returns a count of values now associated with KEY. VALUES can be either an array
2014 ref or a literal list and will be handled correctly. If there are no VALUES then
2015 the current value(s) associated with KEY are returned instead. If this method is
2016 called in list context then all of the values are returned as a literal list; in
2017 scalar context, this method returns only the first value. The 3 cases that this
2018 method handles are implemented with the query object's [store( KEY, *), fetch(
2019 KEY ), fetch_value( KEY )] methods, respectively. (This method is designed to
2020 work like CGI.pm's param() method, if you like that sort of thing.)
2021  
2022 =cut
2023  
2024 ######################################################################
2025  
2026 0 ▶sub get_user_query_ref {
Subroutine get_user_query_ref: not called CC=1 SCAR=6.9
Pod documented
2027 0 return( $_[0]->{$KEY_UI_QUER} ); # returns ref for further use
2028 }
2029  
2030 0 ▶sub user_query {
Subroutine user_query: not called CC=2 SCAR=17.9
Pod documented
2031 0 my ($self, $new_value) = @_;
2032 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2033 0 $self->{$KEY_UI_QUER} = CGI::MultiValuedHash->new( 0, $new_value );
2034 }
2035 0 return( $self->{$KEY_UI_QUER}->clone() );
2036 }
2037  
2038 0 ▶sub user_query_string {
Subroutine user_query_string: not called CC=1 SCAR=6.9
Pod documented
2039 0 return( $_[0]->{$KEY_UI_QUER}->to_url_encoded_string() );
2040 }
2041  
2042 0 ▶sub user_query_param {
Subroutine user_query_param: not called CC=4 SCAR=30.0
Pod documented
2043 0 my $self = shift( @_ );
2044 0 my $key = shift( @_ );
2045 0 ▶ if( @_ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 0 0
elsif (wantarray) { } 0 0 0
2046 0 return( $self->{$KEY_UI_QUER}->store( $key, @_ ) );
2047 } elsif( wantarray ) {
2048 0 ▶ return( @{$self->{$KEY_UI_QUER}->fetch( $key ) || []} );
Condition0%0/2
$self->{$KEY_UI_QUER}->fetch($key) || []
l!l
00
MC/DC0%0/1
$self->{$KEY_UI_QUER}->fetch($key) || []
$self->{$KEY_UI_QUER}->fetch($key)
Truth table0%0/2
A
A= $self->{$KEY_UI_QUER}->fetch($key)
Aresult
11
00
2049 } else {
2050 0 return( $self->{$KEY_UI_QUER}->fetch_value( $key ) );
2051 }
2052 }
2053  
2054 ######################################################################
2055  
2056 =head2 get_user_post_ref()
2057  
2058 This method returns a reference to the user post object which you can then
2059 manipulate directly with CGI::MultiValuedHash methods.
2060  
2061 =head2 user_post([ VALUE ])
2062  
2063 This method is an accessor to the user post, which it returns as a
2064 cloned CGI::MultiValuedHash object. If VALUE is defined then it is used to
2065 initialize a new user post.
2066  
2067 =head2 user_post_string()
2068  
2069 This method url-encodes the user post and returns it as a string.
2070  
2071 =head2 user_post_param( KEY[, VALUES] )
2072  
2073 This method is an accessor for individual user post parameters. If there are
2074 any VALUES then this method stores them in the post under the name KEY and
2075 returns a count of values now associated with KEY. VALUES can be either an array
2076 ref or a literal list and will be handled correctly. If there are no VALUES then
2077 the current value(s) associated with KEY are returned instead. If this method is
2078 called in list context then all of the values are returned as a literal list; in
2079 scalar context, this method returns only the first value. The 3 cases that this
2080 method handles are implemented with the post object's [store( KEY, *), fetch(
2081 KEY ), fetch_value( KEY )] methods, respectively. (This method is designed to
2082 work like CGI.pm's param() method, if you like that sort of thing.)
2083  
2084 =cut
2085  
2086 ######################################################################
2087  
2088 0 ▶sub get_user_post_ref {
Subroutine get_user_post_ref: not called CC=1 SCAR=6.9
Pod documented
2089 0 return( $_[0]->{$KEY_UI_POST} ); # returns ref for further use
2090 }
2091  
2092 0 ▶sub user_post {
Subroutine user_post: not called CC=2 SCAR=17.9
Pod documented
2093 0 my ($self, $new_value) = @_;
2094 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2095 0 $self->{$KEY_UI_POST} = CGI::MultiValuedHash->new( 0, $new_value );
2096 }
2097 0 return( $self->{$KEY_UI_POST}->clone() );
2098 }
2099  
2100 0 ▶sub user_post_string {
Subroutine user_post_string: not called CC=1 SCAR=6.9
Pod documented
2101 0 return( $_[0]->{$KEY_UI_POST}->to_url_encoded_string() );
2102 }
2103  
2104 0 ▶sub user_post_param {
Subroutine user_post_param: not called CC=4 SCAR=30.0
Pod documented
2105 0 my $self = shift( @_ );
2106 0 my $key = shift( @_ );
2107 0 ▶ if( @_ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 0 0
elsif (wantarray) { } 0 0 0
2108 0 return( $self->{$KEY_UI_POST}->store( $key, @_ ) );
2109 } elsif( wantarray ) {
2110 0 ▶ return( @{$self->{$KEY_UI_POST}->fetch( $key ) || []} );
Condition0%0/2
$self->{$KEY_UI_POST}->fetch($key) || []
l!l
00
MC/DC0%0/1
$self->{$KEY_UI_POST}->fetch($key) || []
$self->{$KEY_UI_POST}->fetch($key)
Truth table0%0/2
A
A= $self->{$KEY_UI_POST}->fetch($key)
Aresult
11
00
2111 } else {
2112 0 return( $self->{$KEY_UI_POST}->fetch_value( $key ) );
2113 }
2114 }
2115  
2116 ######################################################################
2117  
2118 =head2 get_user_cookies_ref()
2119  
2120 This method returns a reference to the user cookies object which you can then
2121 manipulate directly with CGI::MultiValuedHash methods.
2122  
2123 =head2 user_cookies([ VALUE ])
2124  
2125 This method is an accessor to the user cookies, which it returns as a
2126 cloned CGI::MultiValuedHash object. If VALUE is defined then it is used to
2127 initialize a new user query.
2128  
2129 =head2 user_cookies_string()
2130  
2131 This method cookie-url-encodes the user cookies and returns them as a string.
2132  
2133 =head2 user_cookie( NAME[, VALUES] )
2134  
2135 This method is an accessor for individual user cookies. If there are
2136 any VALUES then this method stores them in the cookie with the name NAME and
2137 returns a count of values now associated with NAME. VALUES can be either an array
2138 ref or a literal list and will be handled correctly. If there are no VALUES then
2139 the current value(s) associated with NAME are returned instead. If this method is
2140 called in list context then all of the values are returned as a literal list; in
2141 scalar context, this method returns only the first value. The 3 cases that this
2142 method handles are implemented with the query object's [store( NAME, *), fetch(
2143 NAME ), fetch_value( NAME )] methods, respectively. (This method is designed to
2144 work like CGI.pm's param() method, if you like that sort of thing.)
2145  
2146 =cut
2147  
2148 ######################################################################
2149  
2150 0 ▶sub get_user_cookies_ref {
Subroutine get_user_cookies_ref: not called CC=1 SCAR=6.9
Pod documented
2151 0 return( $_[0]->{$KEY_UI_COOK} ); # returns ref for further use
2152 }
2153  
2154 0 ▶sub user_cookies {
Subroutine user_cookies: not called CC=2 SCAR=17.9
Pod documented
2155 0 my ($self, $new_value) = @_;
2156 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2157 0 $self->{$KEY_UI_COOK} = CGI::MultiValuedHash->new( 0,
2158 $new_value, '; ', '&' );
2159 }
2160 0 return( $self->{$KEY_UI_COOK}->clone() );
2161 }
2162  
2163 0 ▶sub user_cookies_string {
Subroutine user_cookies_string: not called CC=1 SCAR=6.9
Pod documented
2164 0 return( $_[0]->{$KEY_UI_COOK}->to_url_encoded_string( '; ', '&' ) );
2165 }
2166  
2167 0 ▶sub user_cookie {
Subroutine user_cookie: not called CC=4 SCAR=30.0
Pod documented
2168 0 my $self = shift( @_ );
2169 0 my $name = shift( @_ );
2170 0 ▶ if( @_ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 0 0
elsif (wantarray) { } 0 0 0
2171 0 return( $self->{$KEY_UI_COOK}->store( $name, @_ ) );
2172 } elsif( wantarray ) {
2173 0 ▶ return( @{$self->{$KEY_UI_COOK}->fetch( $name ) || []} );
Condition0%0/2
$self->{$KEY_UI_COOK}->fetch($name) || []
l!l
00
MC/DC0%0/1
$self->{$KEY_UI_COOK}->fetch($name) || []
$self->{$KEY_UI_COOK}->fetch($name)
Truth table0%0/2
A
A= $self->{$KEY_UI_COOK}->fetch($name)
Aresult
11
00
2174 } else {
2175 0 return( $self->{$KEY_UI_COOK}->fetch_value( $name ) );
2176 }
2177 }
2178  
2179 ######################################################################
2180  
2181 =head1 METHODS FOR MAKING NEW SELF-REFERENCING URLS
2182  
2183 These methods are accessors for the "url constructor" properties of this object,
2184 which are designed to store components of the various information needed to make
2185 new urls that call this script back in order to change from one interface screen
2186 to another. When the program is reinvoked with one of these urls, this
2187 information becomes part of the user input, particularly the "user path" and
2188 "user query". You normally use the url_as_string() method to do the actual
2189 assembly of these components, but the various "recall" methods also pay attention
2190 to them.
2191  
2192 =head2 url_base([ VALUE ])
2193  
2194 This method is an accessor for the "url base" scalar property of this object,
2195 which it returns. If VALUE is defined, this property is set to it.
2196 When new urls are made, the "url base" is used unchanged as its left end.
2197 Normally it would consist of a protocol, host domain, port (optional),
2198 script name, and would look like "protocol://host[:port][script]".
2199 For example, "http://aardvark.net/main.pl" or "http://aardvark.net:450/main.pl".
2200 This property defaults to "http://localhost/".
2201  
2202 =cut
2203  
2204 ######################################################################
2205  
2206 0 ▶sub url_base {
Subroutine url_base: not called CC=2 SCAR=17.9
Pod documented
2207 0 my ($self, $new_value) = @_;
2208 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2209 0 $self->{$KEY_URL_BASE} = $new_value;
2210 }
2211 0 return( $self->{$KEY_URL_BASE} );
2212 }
2213  
2214 ######################################################################
2215  
2216 =head2 get_url_path_ref()
2217  
2218 This method returns a reference to the url path object which you can then
2219 manipulate directly with File::VirtualPath methods.
2220  
2221 =head2 url_path([ VALUE ])
2222  
2223 This method is an accessor to the url path, which it returns as an array ref.
2224 If VALUE is defined then this property is set to it; it can be an array of path
2225 levels or a string representation.
2226  
2227 =head2 url_path_string([ TRAILER ])
2228  
2229 This method returns a string representation of the url path. If the optional
2230 argument TRAILER is true, then a "/" is appended.
2231  
2232 =head2 navigate_url_path( CHANGE_VECTOR )
2233  
2234 This method updates the url path by taking the current one and applying
2235 CHANGE_VECTOR to it using the FVP's chdir() method. This method returns an array
2236 ref having the changed url path.
2237  
2238 =head2 child_url_path_string( CHANGE_VECTOR[, WANT_TRAILER] )
2239  
2240 This method uses CHANGE_VECTOR to derive a new url path relative to the current
2241 one and returns it as a string. If WANT_TRAILER is true then the string has a
2242 path delimiter appended; otherwise, there is none.
2243  
2244 =cut
2245  
2246 ######################################################################
2247  
2248 0 ▶sub get_url_path_ref {
Subroutine get_url_path_ref: not called CC=1 SCAR=6.9
Pod documented
2249 0 return( $_[0]->{$KEY_URL_PATH} ); # returns ref for further use
2250 }
2251  
2252 0 ▶sub url_path {
Subroutine url_path: not called CC=1 SCAR=6.9
Pod documented
2253 0 my ($self, $new_value) = @_;
2254 0 return( $self->{$KEY_URL_PATH}->path( $new_value ) );
2255 }
2256  
2257 0 ▶sub url_path_string {
Subroutine url_path_string: not called CC=1 SCAR=6.9
Pod documented
2258 0 my ($self, $trailer) = @_;
2259 0 return( $self->{$KEY_URL_PATH}->path_string( $trailer ) );
2260 }
2261  
2262 0 ▶sub navigate_url_path {
Subroutine navigate_url_path: not called CC=1 SCAR=6.9
Pod documented
2263 0 my ($self, $chg_vec) = @_;
2264 0 $self->{$KEY_URL_PATH}->chdir( $chg_vec );
2265 }
2266  
2267 0 ▶sub child_url_path_string {
Subroutine child_url_path_string: not called CC=1 SCAR=6.9
Pod documented
2268 0 my ($self, $chg_vec, $trailer) = @_;
2269 0 return( $self->{$KEY_URL_PATH}->child_path_string( $chg_vec, $trailer ) );
2270 }
2271  
2272 ######################################################################
2273  
2274 =head2 get_url_query_ref()
2275  
2276 This method returns a reference to the "url query" object which you can then
2277 manipulate directly with CGI::MultiValuedHash methods.
2278  
2279 =head2 url_query([ VALUE ])
2280  
2281 This method is an accessor to the "url query", which it returns as a
2282 cloned CGI::MultiValuedHash object. If VALUE is defined then it is used to
2283 initialize a new user query.
2284  
2285 =head2 url_query_string()
2286  
2287 This method url-encodes the url query and returns it as a string.
2288  
2289 =head2 url_query_param( KEY[, VALUES] )
2290  
2291 This method is an accessor for individual url query parameters. If there are
2292 any VALUES then this method stores them in the query under the name KEY and
2293 returns a count of values now associated with KEY. VALUES can be either an array
2294 ref or a literal list and will be handled correctly. If there are no VALUES then
2295 the current value(s) associated with KEY are returned instead. If this method is
2296 called in list context then all of the values are returned as a literal list; in
2297 scalar context, this method returns only the first value. The 3 cases that this
2298 method handles are implemented with the query object's [store( KEY, *), fetch(
2299 KEY ), fetch_value( KEY )] methods, respectively. (This method is designed to
2300 work like CGI.pm's param() method, if you like that sort of thing.)
2301  
2302 =cut
2303  
2304 ######################################################################
2305  
2306 0 ▶sub get_url_query_ref {
Subroutine get_url_query_ref: not called CC=1 SCAR=6.9
Pod documented
2307 0 return( $_[0]->{$KEY_URL_QUER} ); # returns ref for further use
2308 }
2309  
2310 0 ▶sub url_query {
Subroutine url_query: not called CC=2 SCAR=17.9
Pod documented
2311 0 my ($self, $new_value) = @_;
2312 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2313 0 $self->{$KEY_URL_QUER} = CGI::MultiValuedHash->new( 0, $new_value );
2314 }
2315 0 return( $self->{$KEY_URL_QUER}->clone() );
2316 }
2317  
2318 0 ▶sub url_query_string {
Subroutine url_query_string: not called CC=1 SCAR=6.9
Pod documented
2319 0 return( $_[0]->{$KEY_URL_QUER}->to_url_encoded_string() );
2320 }
2321  
2322 0 ▶sub url_query_param {
Subroutine url_query_param: not called CC=4 SCAR=30.0
Pod documented
2323 0 my $self = shift( @_ );
2324 0 my $key = shift( @_ );
2325 0 ▶ if( @_ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 0 0
elsif (wantarray) { } 0 0 0
2326 0 return( $self->{$KEY_URL_QUER}->store( $key, @_ ) );
2327 } elsif( wantarray ) {
2328 0 ▶ return( @{$self->{$KEY_URL_QUER}->fetch( $key ) || []} );
Condition0%0/2
$self->{$KEY_URL_QUER}->fetch($key) || []
l!l
00
MC/DC0%0/1
$self->{$KEY_URL_QUER}->fetch($key) || []
$self->{$KEY_URL_QUER}->fetch($key)
Truth table0%0/2
A
A= $self->{$KEY_URL_QUER}->fetch($key)
Aresult
11
00
2329 } else {
2330 0 return( $self->{$KEY_URL_QUER}->fetch_value( $key ) );
2331 }
2332 }
2333  
2334 ######################################################################
2335  
2336 =head2 url_as_string([ CHANGE_VECTOR ])
2337  
2338 This method assembles the various "url *" properties of this object into a
2339 complete HTTP url and returns it as a string. That is, it returns the cumulative
2340 string representation of those properties. This consists of a url_base(), "path
2341 info", "query string", and would look like "base[info][?query]". For example,
2342 "http://aardvark.net/main.pl/lookup/title?name=plant&cost=low". As of release
2343 0-45, the url path is always in the path_info; previous to that release, it could
2344 optionally have been in the query_string instead. If the optional argument
2345 CHANGE_VECTOR is true then the result of applying it to the url path is used for
2346 the url path.
2347  
2348 =cut
2349  
2350 ######################################################################
2351  
2352 0 ▶sub url_as_string {
Subroutine url_as_string: not called CC=2 SCAR=17.9
Pod documented
2353 0 my ($self, $chg_vec) = @_;
2354 0 ▶ return( $self->_make_an_url( $self->url_query_string(), $chg_vec ?
Branch: 1 branch
BranchTrueFalseTotal
$chg_vec ? : 0 0 0
2355 $self->child_url_path_string( $chg_vec ) : $self->url_path_string() ) );
2356 }
2357  
2358 # _make_an_url( QUERY, PATH )
2359 # This private method contains common code for some url-string-making methods.
2360 # The two arguments refer to the path and query information that the new url
2361 # will have. This method combines these with the url base as appropriate,
2362 # and as of release 0-45 the path always goes in the path_info.
2363  
2364 0 ▶sub _make_an_url {
Subroutine _make_an_url: not called CC=2 SCAR=17.9
2365 0 my ($self, $query_string, $path_info) = @_;
2366 0 my $base = $self->{$KEY_URL_BASE};
2367 0 ▶ return( $base.$path_info.($query_string ? "?$query_string" : '') );
Branch: 1 branch
BranchTrueFalseTotal
$query_string ? : 0 0 0
2368 }
2369  
2370 ######################################################################
2371  
2372 =head1 METHODS FOR MAKING RECALL URLS
2373  
2374 These methods are designed to make HTML for the user to reinvoke this program
2375 with their input intact. They pay attention to both the current user input and
2376 the current url constructor properties. Specifically, these methods act like
2377 url_as_string() in the way they use most url constructor properties, but they
2378 use the user path and user query instead of the url path and url query.
2379  
2380 =head2 recall_url()
2381  
2382 This method creates a callback url that can be used to recall this program with
2383 all query information intact. It is intended for use as the "action" argument
2384 in forms, or as the url for "try again" hyperlinks on error pages. The format
2385 of this url is determined partially by the "url *" properties, including
2386 url_base() and anything describing where the "path" goes, if you use it.
2387 Post data is not replicated here; see the recall_button() method.
2388  
2389 =head2 recall_hyperlink([ LABEL ])
2390  
2391 This method creates an HTML hyperlink that can be used to recall this program
2392 with all query information intact. The optional scalar argument LABEL defines
2393 the text that the hyperlink surrounds, which is the blue text the user will see.
2394 LABEL defaults to "here" if not defined. Post data is not replicated.
2395 The url in the hyperlink is produced by recall_url().
2396  
2397 =head2 recall_button([ LABEL ])
2398  
2399 This method creates an HTML form out of a button and some hidden fields which
2400 can be used to recall this program with all query and post information intact.
2401 The optional scalar argument LABEL defines the button label that the user sees.
2402 LABEL defaults to "here" if not defined. This form submits with "post".
2403 Query and path information is replicated in the "action" url, produced by
2404 recall_url(), and the post information is replicated in the hidden fields.
2405  
2406 =head2 recall_html([ LABEL ])
2407  
2408 This method selectively calls recall_button() or recall_hyperlink() depending
2409 on whether there is any post information in the user input. This is useful
2410 when you want to use the least intensive option required to preserve your user
2411 input and you don't want to figure out the when yourself.
2412  
2413 =cut
2414  
2415 ######################################################################
2416  
2417 0 ▶sub recall_url {
Subroutine recall_url: not called CC=1 SCAR=6.9
Pod documented
2418 0 my ($self) = @_;
2419 0 return( $self->_make_an_url( $self->user_query_string(),
2420 $self->user_path_string() ) );
2421 }
2422  
2423 0 ▶sub recall_hyperlink {
Subroutine recall_hyperlink: not called CC=2 SCAR=17.9
Pod documented
2424 0 my ($self, $label) = @_;
2425 0 ▶ defined( $label ) or $label = 'here';
Branch: 1 branch
BranchTrueFalseTotal
defined $label or $label = "here" 0 0 0
2426 0 my $url = $self->recall_url();
2427 0 return( "<a href=\"$url\">$label</a>" );
2428 }
2429  
2430 0 ▶sub recall_button {
Subroutine recall_button: not called CC=2 SCAR=17.9
Pod documented
2431 0 my ($self, $label) = @_;
2432 0 ▶ defined( $label ) or $label = 'here';
Branch: 1 branch
BranchTrueFalseTotal
defined $label or $label = "here" 0 0 0
2433 0 my $url = $self->recall_url();
2434 0 my $fields = $self->get_user_post_ref()->to_html_encoded_hidden_fields();
2435 0 return( <<__endquote );
2436 <form method="post" action="$url">
2437 $fields
2438 <input type="submit" name="" value="$label" />
2439 </form>
2440 __endquote
2441 }
2442  
2443 0 ▶sub recall_html {
Subroutine recall_html: not called CC=2 SCAR=17.9
Pod documented
2444 0 my ($self, $label) = @_;
2445 0 ▶ return( $self->get_user_post_ref()->keys_count() ?
Branch: 1 branch
BranchTrueFalseTotal
$self->get_user_post_ref->keys_count ? : 0 0 0
2446 $self->recall_button( $label ) : $self->recall_hyperlink( $label ) );
2447 }
2448  
2449 ######################################################################
2450  
2451 =head1 METHODS FOR MAKING NEW HTTP RESPONSES
2452  
2453 These methods are designed to accumulate and assemble the components of an HTTP
2454 response, complete with status code, content type, other headers, and a body.
2455 See the DESCRIPTION for more details.
2456  
2457 =head2 http_status_code([ VALUE ])
2458  
2459 This method is an accessor for the "status code" scalar property of this object,
2460 which it returns. If VALUE is defined, this property is set to it.
2461 This property is used in a new HTTP header to give the result status of the
2462 HTTP request that this program is serving. It defaults to "200 OK" which means
2463 success and that the HTTP body contains the document they requested.
2464 Unlike other HTTP header content, this property is special and must be the very
2465 first thing that the HTTP server returns, on a line like "HTTP/1.0 200 OK".
2466 However, the property also may appear elsewhere in the header, on a line like
2467 "Status: 200 OK".
2468  
2469 =cut
2470  
2471 ######################################################################
2472  
2473 0 ▶sub http_status_code {
Subroutine http_status_code: not called CC=2 SCAR=17.9
Pod documented
2474 0 my ($self, $new_value) = @_;
2475 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2476 0 $self->{$KEY_HTTP_STAT} = $new_value;
2477 }
2478 0 return( $self->{$KEY_HTTP_STAT} );
2479 }
2480  
2481 ######################################################################
2482  
2483 =head2 http_window_target([ VALUE ])
2484  
2485 This method is an accessor for the "window target" scalar property of this object,
2486 which it returns. If VALUE is defined, this property is set to it.
2487 This property is used in a new HTTP header to indicate which browser window or
2488 frame that this this HTTP response should be loaded into. It defaults to the
2489 undefined value, meaning this response ends up in the same window/frame as the
2490 page that called it. This property would be used in a line like
2491 "Window-Target: leftmenu".
2492  
2493 =cut
2494  
2495 ######################################################################
2496  
2497 0 ▶sub http_window_target {
Subroutine http_window_target: not called CC=2 SCAR=17.9
Pod documented
2498 0 my ($self, $new_value) = @_;
2499 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2500 0 $self->{$KEY_HTTP_WITA} = $new_value;
2501 }
2502 0 return( $self->{$KEY_HTTP_WITA} );
2503 }
2504  
2505 ######################################################################
2506  
2507 =head2 http_content_type([ VALUE ])
2508  
2509 This method is an accessor for the "content type" scalar property of this object,
2510 which it returns. If VALUE is defined, this property is set to it.
2511 This property is used in a new HTTP header to indicate the document type that
2512 the HTTP body is, such as text or image. It defaults to "text/html" which means
2513 we are returning an HTML page. This property would be used in a line like
2514 "Content-Type: text/html".
2515  
2516 =cut
2517  
2518 ######################################################################
2519  
2520 0 ▶sub http_content_type {
Subroutine http_content_type: not called CC=2 SCAR=17.9
Pod documented
2521 0 my ($self, $new_value) = @_;
2522 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2523 0 $self->{$KEY_HTTP_COTY} = $new_value;
2524 }
2525 0 return( $self->{$KEY_HTTP_COTY} );
2526 }
2527  
2528 ######################################################################
2529  
2530 =head2 http_redirect_url([ VALUE ])
2531  
2532 This method is an accessor for the "redirect url" scalar property of this object,
2533 which it returns. If VALUE is defined, this property is set to it.
2534 This property is used in a new HTTP header to indicate that we don't have the
2535 document that the user wants, but we do know where they can get it.
2536 If this property is defined then it contains the url we redirect to.
2537 This property would be used in a line like "Location: http://www.cpan.org".
2538  
2539 =cut
2540  
2541 ######################################################################
2542  
2543 0 ▶sub http_redirect_url {
Subroutine http_redirect_url: not called CC=2 SCAR=17.9
Pod documented
2544 0 my ($self, $new_value) = @_;
2545 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2546 0 $self->{$KEY_HTTP_REDI} = $new_value;
2547 }
2548 0 return( $self->{$KEY_HTTP_REDI} );
2549 }
2550  
2551 ######################################################################
2552  
2553 =head2 get_http_cookies_ref()
2554  
2555 This method is an accessor for the "http cookies" array property of this
2556 object, a reference to which it returns. Cookies are used for simple data
2557 persistance on the client side, and are passed back and forth in the HTTP
2558 headers. If this property is defined, then a "Set-Cookie" HTTP header would be
2559 made for each list element. Each array element is treated like a scalar
2560 internally as this class assumes you will encode each cookie prior to insertion.
2561  
2562 =head2 get_http_cookies()
2563  
2564 This method returns a list containing "http cookies" list elements. This list
2565 is returned literally in list context and as an array ref in scalar context.
2566  
2567 =head2 set_http_cookies( VALUE )
2568  
2569 This method allows you to set or replace the current "http cookies" list with a
2570 new one. The argument VALUE can be either an array ref or scalar or literal list.
2571  
2572 =head2 add_http_cookies( VALUES )
2573  
2574 This method will take a list of encoded cookies in the argument VALUES and
2575 append them to the internal "http cookies" list property. VALUES can be either
2576 an array ref or a literal list.
2577  
2578 =cut
2579  
2580 ######################################################################
2581  
2582 0 ▶sub get_http_cookies_ref {
Subroutine get_http_cookies_ref: not called CC=1 SCAR=6.9
Pod documented
2583 0 return( $_[0]->{$KEY_HTTP_COOK} ); # returns ref for further use
2584 }
2585  
2586 0 ▶sub get_http_cookies {
Subroutine get_http_cookies: not called CC=2 SCAR=17.9
Pod documented
2587 0 my @list_copy = @{$_[0]->{$KEY_HTTP_COOK}};
2588 0 ▶ return( wantarray ? @list_copy : \@list_copy );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2589 }
2590  
2591 0 ▶sub set_http_cookies {
Subroutine set_http_cookies: not called CC=2 SCAR=17.9
Pod documented
2592 0 my $self = shift( @_ );
2593 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
2594 0 @{$self->{$KEY_HTTP_COOK}} = @{$ra_values};
2595 }
2596  
2597 0 ▶sub add_http_cookies {
Subroutine add_http_cookies: not called CC=2 SCAR=17.9
Pod documented
2598 0 my $self = shift( @_ );
2599 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
2600 0 push( @{$self->{$KEY_HTTP_COOK}}, @{$ra_values} );
2601 }
2602  
2603 ######################################################################
2604  
2605 =head2 get_http_headers_ref()
2606  
2607 This method is an accessor for the "misc http headers" hash property of this
2608 object, a reference to which it returns. HTTP headers constitute the first of
2609 two main parts of an HTTP response, and says things like the current date, server
2610 type, content type of the document, cookies to set, and more. Some of these have
2611 their own methods, above, if you wish to use them. Each key/value pair in the
2612 hash would be used in a line like "Key: value".
2613  
2614 =head2 get_http_headers([ KEY ])
2615  
2616 This method allows you to get the "misc http headers" hash property of this
2617 object. If KEY is defined then it is taken as a key in the hash and the
2618 associated value is returned. If KEY is not defined then the entire hash is
2619 returned as a list; in scalar context this list is in a new hash ref.
2620  
2621 =head2 set_http_headers( KEY[, VALUE] )
2622  
2623 This method allows you to set the "misc http headers" hash property of this
2624 object. If KEY is a valid HASH ref then all the existing headers information is
2625 replaced with the new hash keys and values. If KEY is defined but it is not a
2626 Hash ref, then KEY and VALUE are inserted together into the existing hash.
2627  
2628 =head2 add_http_headers( KEY[, VALUE] )
2629  
2630 This method allows you to add key/value pairs to the "misc http headers"
2631 hash property of this object. If KEY is a valid HASH ref then the keys and
2632 values it contains are inserted into the existing hash property; any like-named
2633 keys will overwrite existing ones, but different-named ones will coexist.
2634 If KEY is defined but it is not a Hash ref, then KEY and VALUE are inserted
2635 together into the existing hash.
2636  
2637 =cut
2638  
2639 ######################################################################
2640  
2641 0 ▶sub get_http_headers_ref {
Subroutine get_http_headers_ref: not called CC=1 SCAR=6.9
Pod documented
2642 0 return( $_[0]->{$KEY_HTTP_HEAD} ); # returns ref for further use
2643 }
2644  
2645 0 ▶sub get_http_headers {
Subroutine get_http_headers: not called CC=3 SCAR=24.8
Pod documented
2646 0 my ($self, $key) = @_;
2647 0 ▶ if( defined( $key ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key) 0 0 0
2648 0 return( $self->{$KEY_HTTP_HEAD}->{$key} );
2649 }
2650 0 my %hash_copy = %{$self->{$KEY_HTTP_HEAD}};
2651 0 ▶ return( wantarray ? %hash_copy : \%hash_copy );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2652 }
2653  
2654 0 ▶sub set_http_headers {
Subroutine set_http_headers: not called CC=3 SCAR=24.8
Pod documented
2655 0 my ($self, $first, $second) = @_;
2656 0 ▶ if( defined( $first ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first) 0 0 0
2657 0 ▶ if( ref( $first ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first eq 'HASH') { } 0 0 0
2658 0 $self->{$KEY_HTTP_HEAD} = {%{$first}};
2659 } else {
2660 0 $self->{$KEY_HTTP_HEAD}->{$first} = $second;
2661 }
2662 }
2663 }
2664  
2665 0 ▶sub add_http_headers {
Subroutine add_http_headers: not called CC=3 SCAR=24.8
Pod documented
2666 0 my ($self, $first, $second) = @_;
2667 0 ▶ if( defined( $first ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first) 0 0 0
2668 0 ▶ if( ref( $first ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first eq 'HASH') { } 0 0 0
2669 0 @{$self->{$KEY_HTTP_HEAD}}{keys %{$first}} = values %{$first};
2670 } else {
2671 0 $self->{$KEY_HTTP_HEAD}->{$first} = $second;
2672 }
2673 }
2674 }
2675  
2676 ######################################################################
2677  
2678 =head2 http_body([ VALUE ])
2679  
2680 This method is an accessor for the "http body" scalar property of this object,
2681 which it returns. This contitutes the second of two main parts of
2682 an HTTP response, and contains the actual document that the user will view and/or
2683 can save to disk. If this property is defined, then it will be used literally as
2684 the HTTP body part of the output. If this property is not defined then a new
2685 HTTP body of type text/html will be assembled out of the various "page *"
2686 properties instead. This property defaults to undefined.
2687  
2688 =cut
2689  
2690 ######################################################################
2691  
2692 0 ▶sub http_body {
Subroutine http_body: not called CC=2 SCAR=17.9
Pod documented
2693 0 my ($self, $new_value) = @_;
2694 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2695 0 $self->{$KEY_HTTP_BODY} = $new_value;
2696 }
2697 0 return( $self->{$KEY_HTTP_BODY} );
2698 }
2699  
2700 ######################################################################
2701  
2702 =head2 http_body_is_binary([ VALUE ])
2703  
2704 This method is an accessor for the "http body is binary" boolean property of this
2705 object, which it returns. If VALUE is defined, this property is set to it.
2706 If this property is true then it indicates that the HTTP body is binary
2707 and should be output with binmode on. It defaults to false.
2708  
2709 =cut
2710  
2711 ######################################################################
2712  
2713 0 ▶sub http_body_is_binary {
Subroutine http_body_is_binary: not called CC=2 SCAR=17.9
Pod documented
2714 0 my ($self, $new_value) = @_;
2715 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2716 0 $self->{$KEY_HTTP_BINA} = $new_value;
2717 }
2718 0 return( $self->{$KEY_HTTP_BINA} );
2719 }
2720  
2721 ######################################################################
2722  
2723 =head1 METHODS FOR MAKING NEW HTML PAGES
2724  
2725 These methods are designed to accumulate and assemble the components of a new
2726 HTML page, complete with body, title, meta tags, and cascading style sheets.
2727 See the DESCRIPTION for more details.
2728  
2729 =head2 page_prologue([ VALUE ])
2730  
2731 This method is an accessor for the "page prologue" scalar property of this object,
2732 which it returns. If VALUE is defined, this property is set to it.
2733 This property is used as the very first thing in a new HTML page, appearing above
2734 the opening <HTML> tag. The property starts out undefined, and unless you set it
2735 then the default proglogue tag defined by HTML::EasyTags is used instead.
2736 This property doesn't have any effect unless your HTML::EasyTags is v1-06 or later.
2737  
2738 =cut
2739  
2740 ######################################################################
2741  
2742 0 ▶sub page_prologue {
Subroutine page_prologue: not called CC=2 SCAR=17.9
Pod documented
2743 0 my ($self, $new_value) = @_;
2744 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2745 0 $self->{$KEY_PAGE_PROL} = $new_value;
2746 }
2747 0 return( $self->{$KEY_PAGE_PROL} );
2748 }
2749  
2750 ######################################################################
2751  
2752 =head2 page_title([ VALUE ])
2753  
2754 This method is an accessor for the "page title" scalar property of this object,
2755 which it returns. If VALUE is defined, this property is set to it.
2756 This property is used in the header of a new HTML document to define its title.
2757 Specifically, it goes between a <TITLE></TITLE> tag pair.
2758  
2759 =cut
2760  
2761 ######################################################################
2762  
2763 0 ▶sub page_title {
Subroutine page_title: not called CC=2 SCAR=17.9
Pod documented
2764 0 my ($self, $new_value) = @_;
2765 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2766 0 $self->{$KEY_PAGE_TITL} = $new_value;
2767 }
2768 0 return( $self->{$KEY_PAGE_TITL} );
2769 }
2770  
2771 ######################################################################
2772  
2773 =head2 page_author([ VALUE ])
2774  
2775 This method is an accessor for the "page author" scalar property of this object,
2776 which it returns. If VALUE is defined, this property is set to it.
2777 This property is used in the header of a new HTML document to define its author.
2778 Specifically, it is used in a new '<LINK REV="made">' tag if defined.
2779  
2780 =cut
2781  
2782 ######################################################################
2783  
2784 0 ▶sub page_author {
Subroutine page_author: not called CC=2 SCAR=17.9
Pod documented
2785 0 my ($self, $new_value) = @_;
2786 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
2787 0 $self->{$KEY_PAGE_AUTH} = $new_value;
2788 }
2789 0 return( $self->{$KEY_PAGE_AUTH} );
2790 }
2791  
2792 ######################################################################
2793  
2794 =head2 get_page_meta_ref()
2795  
2796 This method is an accessor for the "page meta" hash property of this object,
2797 a reference to which it returns. Meta information is used in the header of a
2798 new HTML document to say things like what the best keywords are for a search
2799 engine to index this page under. Each key/value pair in the hash would have a
2800 '<META NAME="k" VALUE="v">' tag made out of it.
2801  
2802 =head2 get_page_meta([ KEY ])
2803  
2804 This method allows you to get the "page meta" hash property of this object.
2805 If KEY is defined then it is taken as a key in the hash and the associated
2806 value is returned. If KEY is not defined then the entire hash is returned as
2807 a list; in scalar context this list is in a new hash ref.
2808  
2809 =head2 set_page_meta( KEY[, VALUE] )
2810  
2811 This method allows you to set the "page meta" hash property of this object.
2812 If KEY is a valid HASH ref then all the existing meta information is replaced
2813 with the new hash keys and values. If KEY is defined but it is not a Hash ref,
2814 then KEY and VALUE are inserted together into the existing hash.
2815  
2816 =head2 add_page_meta( KEY[, VALUE] )
2817  
2818 This method allows you to add key/value pairs to the "page meta"
2819 hash property of this object. If KEY is a valid HASH ref then the keys and
2820 values it contains are inserted into the existing hash property; any like-named
2821 keys will overwrite existing ones, but different-named ones will coexist.
2822 If KEY is defined but it is not a Hash ref, then KEY and VALUE are inserted
2823 together into the existing hash.
2824  
2825 =cut
2826  
2827 ######################################################################
2828  
2829 0 ▶sub get_page_meta_ref {
Subroutine get_page_meta_ref: not called CC=1 SCAR=6.9
Pod documented
2830 0 return( $_[0]->{$KEY_PAGE_META} ); # returns ref for further use
2831 }
2832  
2833 0 ▶sub get_page_meta {
Subroutine get_page_meta: not called CC=3 SCAR=24.8
Pod documented
2834 0 my ($self, $key) = @_;
2835 0 ▶ if( defined( $key ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key) 0 0 0
2836 0 return( $self->{$KEY_PAGE_META}->{$key} );
2837 }
2838 0 my %hash_copy = %{$self->{$KEY_PAGE_META}};
2839 0 ▶ return( wantarray ? %hash_copy : \%hash_copy );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2840 }
2841  
2842 0 ▶sub set_page_meta {
Subroutine set_page_meta: not called CC=3 SCAR=24.8
Pod documented
2843 0 my ($self, $first, $second) = @_;
2844 0 ▶ if( defined( $first ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first) 0 0 0
2845 0 ▶ if( ref( $first ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first eq 'HASH') { } 0 0 0
2846 0 $self->{$KEY_PAGE_META} = {%{$first}};
2847 } else {
2848 0 $self->{$KEY_PAGE_META}->{$first} = $second;
2849 }
2850 }
2851 }
2852  
2853 0 ▶sub add_page_meta {
Subroutine add_page_meta: not called CC=3 SCAR=24.8
Pod documented
2854 0 my ($self, $first, $second) = @_;
2855 0 ▶ if( defined( $first ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first) 0 0 0
2856 0 ▶ if( ref( $first ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first eq 'HASH') { } 0 0 0
2857 0 @{$self->{$KEY_PAGE_META}}{keys %{$first}} = values %{$first};
2858 } else {
2859 0 $self->{$KEY_PAGE_META}->{$first} = $second;
2860 }
2861 }
2862 }
2863  
2864 ######################################################################
2865  
2866 =head2 get_page_style_sources_ref()
2867  
2868 This method is an accessor for the "page style sources" array property of this
2869 object, a reference to which it returns. Cascading Style Sheet (CSS) definitions
2870 are used in the header of a new HTML document to allow precise control over the
2871 appearance of of page elements, something that HTML itself was not designed for.
2872 This property stores urls for external documents having stylesheet definitions
2873 that you want linked to the current document. If this property is defined, then
2874 a '<LINK REL="stylesheet" SRC="url">' tag would be made for each list element.
2875  
2876 =head2 get_page_style_sources()
2877  
2878 This method returns a list containing "page style sources" list elements. This list
2879 is returned literally in list context and as an array ref in scalar context.
2880  
2881 =head2 set_page_style_sources( VALUE )
2882  
2883 This method allows you to set or replace the current "page style sources"
2884 definitions. The argument VALUE can be either an array ref or literal list.
2885  
2886 =head2 add_page_style_sources( VALUES )
2887  
2888 This method will take a list of "page style sources" definitions
2889 and add them to the internally stored list of the same. VALUES can be either
2890 an array ref or a literal list.
2891  
2892 =cut
2893  
2894 ######################################################################
2895  
2896 0 ▶sub get_page_style_sources_ref {
Subroutine get_page_style_sources_ref: not called CC=1 SCAR=6.9
Pod documented
2897 0 return( $_[0]->{$KEY_PAGE_CSSR} ); # returns ref for further use
2898 }
2899  
2900 0 ▶sub get_page_style_sources {
Subroutine get_page_style_sources: not called CC=2 SCAR=17.9
Pod documented
2901 0 my @array_copy = @{$_[0]->{$KEY_PAGE_CSSR}};
2902 0 ▶ return( wantarray ? @array_copy : \@array_copy );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2903 }
2904  
2905 0 ▶sub set_page_style_sources {
Subroutine set_page_style_sources: not called CC=2 SCAR=17.9
Pod documented
2906 0 my $self = shift( @_ );
2907 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
2908 0 @{$self->{$KEY_PAGE_CSSR}} = @{$ra_values};
2909 }
2910  
2911 0 ▶sub add_page_style_sources {
Subroutine add_page_style_sources: not called CC=2 SCAR=17.9
Pod documented
2912 0 my $self = shift( @_ );
2913 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
2914 0 push( @{$self->{$KEY_PAGE_CSSR}}, @{$ra_values} );
2915 }
2916  
2917 ######################################################################
2918  
2919 =head2 get_page_style_code_ref()
2920  
2921 This method is an accessor for the "page style code" array property of this
2922 object, a reference to which it returns. Cascading Style Sheet (CSS) definitions
2923 are used in the header of a new HTML document to allow precise control over the
2924 appearance of of page elements, something that HTML itself was not designed for.
2925 This property stores CSS definitions that you want embedded in the HTML document
2926 itself. If this property is defined, then a "<STYLE><!-- code --></STYLE>"
2927 multi-line tag is made for them.
2928  
2929 =head2 get_page_style_code()
2930  
2931 This method returns a list containing "page style code" list elements. This list
2932 is returned literally in list context and as an array ref in scalar context.
2933  
2934 =head2 set_page_style_code( VALUE )
2935  
2936 This method allows you to set or replace the current "page style code"
2937 definitions. The argument VALUE can be either an array ref or literal list.
2938  
2939 =head2 add_page_style_code( VALUES )
2940  
2941 This method will take a list of "page style code" definitions
2942 and add them to the internally stored list of the same. VALUES can be either
2943 an array ref or a literal list.
2944  
2945 =cut
2946  
2947 ######################################################################
2948  
2949 0 ▶sub get_page_style_code_ref {
Subroutine get_page_style_code_ref: not called CC=1 SCAR=6.9
Pod documented
2950 0 return( $_[0]->{$KEY_PAGE_CSSC} ); # returns ref for further use
2951 }
2952  
2953 0 ▶sub get_page_style_code {
Subroutine get_page_style_code: not called CC=2 SCAR=17.9
Pod documented
2954 0 my @array_copy = @{$_[0]->{$KEY_PAGE_CSSC}};
2955 0 ▶ return( wantarray ? @array_copy : \@array_copy );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2956 }
2957  
2958 0 ▶sub set_page_style_code {
Subroutine set_page_style_code: not called CC=2 SCAR=17.9
Pod documented
2959 0 my $self = shift( @_ );
2960 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
2961 0 @{$self->{$KEY_PAGE_CSSC}} = @{$ra_values};
2962 }
2963  
2964 0 ▶sub add_page_style_code {
Subroutine add_page_style_code: not called CC=2 SCAR=17.9
Pod documented
2965 0 my $self = shift( @_ );
2966 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
2967 0 push( @{$self->{$KEY_PAGE_CSSC}}, @{$ra_values} );
2968 }
2969  
2970 ######################################################################
2971  
2972 =head2 get_page_head_ref()
2973  
2974 This method is an accessor for the "page head" array property of this object,
2975 a reference to which it returns. While this property actually represents a
2976 scalar value, it is stored as an array for possible efficiency, considering that
2977 new portions may be appended or prepended to it as the program runs.
2978 This property is inserted between the "<HEAD></HEAD>" tags of a new HTML page,
2979 following any other properties that go in that section.
2980  
2981 =head2 get_page_head()
2982  
2983 This method returns a string of the "page body" joined together.
2984  
2985 =head2 set_page_head( VALUE )
2986  
2987 This method allows you to set or replace the current "page head" with a new one.
2988 The argument VALUE can be either an array ref or scalar or literal list.
2989  
2990 =head2 append_page_head( VALUE )
2991  
2992 This method allows you to append content to the current "page head".
2993 The argument VALUE can be either an array ref or scalar or literal list.
2994  
2995 =head2 prepend_page_head( VALUE )
2996  
2997 This method allows you to prepend content to the current "page head".
2998 The argument VALUE can be either an array ref or scalar or literal list.
2999  
3000 =cut
3001  
3002 ######################################################################
3003  
3004 0 ▶sub get_page_head_ref {
Subroutine get_page_head_ref: not called CC=1 SCAR=6.9
Pod documented
3005 0 return( $_[0]->{$KEY_PAGE_HEAD} ); # returns ref for further use
3006 }
3007  
3008 0 ▶sub get_page_head {
Subroutine get_page_head: not called CC=1 SCAR=6.9
Pod documented
3009 0 return( join( '', @{$_[0]->{$KEY_PAGE_HEAD}} ) );
3010 }
3011  
3012 0 ▶sub set_page_head {
Subroutine set_page_head: not called CC=2 SCAR=17.9
Pod documented
3013 0 my $self = shift( @_ );
3014 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
3015 0 @{$self->{$KEY_PAGE_HEAD}} = @{$ra_values};
3016 }
3017  
3018 0 ▶sub append_page_head {
Subroutine append_page_head: not called CC=2 SCAR=17.9
Pod documented
3019 0 my $self = shift( @_ );
3020 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
3021 0 push( @{$self->{$KEY_PAGE_HEAD}}, @{$ra_values} );
3022 }
3023  
3024 0 ▶sub prepend_page_head {
Subroutine prepend_page_head: not called CC=2 SCAR=17.9
Pod documented
3025 0 my $self = shift( @_ );
3026 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
3027 0 unshift( @{$self->{$KEY_PAGE_HEAD}}, @{$ra_values} );
3028 }
3029  
3030 ######################################################################
3031  
3032 =head2 get_page_frameset_attributes_ref()
3033  
3034 This method is an accessor for the "page frameset attributes" hash property of
3035 this object, a reference to which it returns. Each key/value pair in the hash
3036 would become an attribute key/value of the opening <FRAMESET> tag of a new HTML
3037 document. At least it would if this was a frameset document, which it isn't by
3038 default. If there are multiple frames, then this property says how the browser
3039 window is partitioned into a grid with one or more rows and one or more columns
3040 of frames. Valid attributes include 'rows => "*,*,..."', 'cols => "*,*,..."', and
3041 'border => nn'. See also the http_window_target() method.
3042  
3043 =head2 get_page_frameset_attributes([ KEY ])
3044  
3045 This method allows you to get the "page frameset attributes" hash property of
3046 this object. If KEY is defined then it is taken as a key in the hash and the
3047 associated value is returned. If KEY is not defined then the entire hash is
3048 returned as a list; in scalar context this list is in a new hash ref.
3049  
3050 =head2 set_page_frameset_attributes( KEY[, VALUE] )
3051  
3052 This method allows you to set the "page frameset attributes" hash property of
3053 this object. If KEY is a valid HASH ref then all the existing attrib information
3054 is replaced with the new hash keys and values. If KEY is defined but it is not a
3055 Hash ref, then KEY and VALUE are inserted together into the existing hash.
3056  
3057 =head2 add_page_frameset_attributes( KEY[, VALUE] )
3058  
3059 This method allows you to add key/value pairs to the "page frameset attributes"
3060 hash property of this object. If KEY is a valid HASH ref then the keys and
3061 values it contains are inserted into the existing hash property; any like-named
3062 keys will overwrite existing ones, but different-named ones will coexist.
3063 If KEY is defined but it is not a Hash ref, then KEY and VALUE are inserted
3064 together into the existing hash.
3065  
3066 =cut
3067  
3068 ######################################################################
3069  
3070 0 ▶sub get_page_frameset_attributes_ref {
Subroutine get_page_frameset_attributes_ref: not called CC=1 SCAR=6.9
Pod documented
3071 0 return( $_[0]->{$KEY_PAGE_FATR} ); # returns ref for further use
3072 }
3073  
3074 0 ▶sub get_page_frameset_attributes {
Subroutine get_page_frameset_attributes: not called CC=3 SCAR=24.8
Pod documented
3075 0 my ($self, $key) = @_;
3076 0 ▶ if( defined( $key ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key) 0 0 0
3077 0 return( $self->{$KEY_PAGE_FATR}->{$key} );
3078 }
3079 0 my %hash_copy = %{$self->{$KEY_PAGE_FATR}};
3080 0 ▶ return( wantarray ? %hash_copy : \%hash_copy );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
3081 }
3082  
3083 0 ▶sub set_page_frameset_attributes {
Subroutine set_page_frameset_attributes: not called CC=3 SCAR=24.8
Pod documented
3084 0 my ($self, $first, $second) = @_;
3085 0 ▶ if( defined( $first ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first) 0 0 0
3086 0 ▶ if( ref( $first ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first eq 'HASH') { } 0 0 0
3087 0 $self->{$KEY_PAGE_FATR} = {%{$first}};
3088 } else {
3089 0 $self->{$KEY_PAGE_FATR}->{$first} = $second;
3090 }
3091 }
3092 }
3093  
3094 0 ▶sub add_page_frameset_attributes {
Subroutine add_page_frameset_attributes: not called CC=3 SCAR=24.8
Pod documented
3095 0 my ($self, $first, $second) = @_;
3096 0 ▶ if( defined( $first ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first) 0 0 0
3097 0 ▶ if( ref( $first ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first eq 'HASH') { } 0 0 0
3098 0 @{$self->{$KEY_PAGE_FATR}}{keys %{$first}} = values %{$first};
3099 } else {
3100 0 $self->{$KEY_PAGE_FATR}->{$first} = $second;
3101 }
3102 }
3103 }
3104  
3105 ######################################################################
3106  
3107 =head2 get_page_frameset_refs()
3108  
3109 This method is an accessor for the "page frameset" array property of this object,
3110 a list of references to whose elements it returns. Each property element is a
3111 hash ref which contains attributes for a new <FRAME> tag. This property is
3112 inserted between the "<FRAMESET></FRAMESET>" tags of a new HTML page.
3113  
3114 =head2 get_page_frameset()
3115  
3116 This method returns a list of frame descriptors from the "page frameset"
3117 property.
3118  
3119 =head2 set_page_frameset( VALUE )
3120  
3121 This method allows you to set or replace the current "page frameset" list with a
3122 new one. The argument VALUE can be either an array ref or scalar or literal list.
3123  
3124 =head2 append_page_frameset( VALUE )
3125  
3126 This method allows you to append frame descriptors to the current "page frames".
3127 The argument VALUE can be either an array ref or scalar or literal list.
3128  
3129 =head2 prepend_page_frameset( VALUE )
3130  
3131 This method allows you to prepend frame descriptors to the current "page frames".
3132 The argument VALUE can be either an array ref or scalar or literal list.
3133  
3134 =cut
3135  
3136 ######################################################################
3137  
3138 0 ▶sub get_page_frameset_refs {
Subroutine get_page_frameset_refs: not called CC=2 SCAR=17.9
Pod documented
3139 0 my @values = @{$_[0]->{$KEY_PAGE_FRAM}};
3140 0 ▶ return( wantarray ? @values : \@values ); # returns ref for further use
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
3141 }
3142  
3143 0 ▶sub get_page_frameset {
Subroutine get_page_frameset: not called CC=2 SCAR=17.9
Pod documented
3144 0 my @values = map { {%{$_}} } @{$_[0]->{$KEY_PAGE_FRAM}};
3145 0 ▶ return( wantarray ? @values : \@values );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
3146 }
3147  
3148 0 ▶sub set_page_frameset {
Subroutine set_page_frameset: not called CC=2 SCAR=17.9
Pod documented
3149 0 my $self = shift( @_ );
3150 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
3151 0 @{$self->{$KEY_PAGE_FRAM}} = grep { ref( $_ ) eq 'HASH' } @{$ra_values};
3152 }
3153  
3154 0 ▶sub append_page_frameset {
Subroutine append_page_frameset: not called CC=2 SCAR=17.9
Pod documented
3155 0 my $self = shift( @_ );
3156 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
3157 0 push( @{$self->{$KEY_PAGE_FRAM}},
3158 0 grep { ref( $_ ) eq 'HASH' } @{$ra_values} );
3159 }
3160  
3161 0 ▶sub prepend_page_frameset {
Subroutine prepend_page_frameset: not called CC=2 SCAR=17.9
Pod documented
3162 0 my $self = shift( @_ );
3163 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
3164 0 unshift( @{$self->{$KEY_PAGE_FRAM}},
3165 0 grep { ref( $_ ) eq 'HASH' } @{$ra_values} );
3166 }
3167  
3168 ######################################################################
3169  
3170 =head2 get_page_body_attributes_ref()
3171  
3172 This method is an accessor for the "page body attributes" hash property of this
3173 object, a reference to which it returns. Each key/value pair in the hash would
3174 become an attribute key/value of the opening <BODY> tag of a new HTML document.
3175 With the advent of CSS there wasn't much need to have the BODY tag attributes,
3176 but you may wish to do this for older browsers. In the latter case you could
3177 use body attributes to define things like the page background color or picture.
3178  
3179 =head2 get_page_body_attributes([ KEY ])
3180  
3181 This method allows you to get the "page body attributes" hash property of this
3182 object. If KEY is defined then it is taken as a key in the hash and the
3183 associated value is returned. If KEY is not defined then the entire hash is
3184 returned as a list; in scalar context this list is in a new hash ref.
3185  
3186 =head2 set_page_body_attributes( KEY[, VALUE] )
3187  
3188 This method allows you to set the "page body attributes" hash property of this
3189 object. If KEY is a valid HASH ref then all the existing attrib information is
3190 replaced with the new hash keys and values. If KEY is defined but it is not a
3191 Hash ref, then KEY and VALUE are inserted together into the existing hash.
3192  
3193 =head2 add_page_body_attributes( KEY[, VALUE] )
3194  
3195 This method allows you to add key/value pairs to the "page body attributes"
3196 hash property of this object. If KEY is a valid HASH ref then the keys and
3197 values it contains are inserted into the existing hash property; any like-named
3198 keys will overwrite existing ones, but different-named ones will coexist.
3199 If KEY is defined but it is not a Hash ref, then KEY and VALUE are inserted
3200 together into the existing hash.
3201  
3202 =cut
3203  
3204 ######################################################################
3205  
3206 0 ▶sub get_page_body_attributes_ref {
Subroutine get_page_body_attributes_ref: not called CC=1 SCAR=6.9
Pod documented
3207 0 return( $_[0]->{$KEY_PAGE_BATR} ); # returns ref for further use
3208 }
3209  
3210 0 ▶sub get_page_body_attributes {
Subroutine get_page_body_attributes: not called CC=3 SCAR=24.8
Pod documented
3211 0 my ($self, $key) = @_;
3212 0 ▶ if( defined( $key ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key) 0 0 0
3213 0 return( $self->{$KEY_PAGE_BATR}->{$key} );
3214 }
3215 0 my %hash_copy = %{$self->{$KEY_PAGE_BATR}};
3216 0 ▶ return( wantarray ? %hash_copy : \%hash_copy );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
3217 }
3218  
3219 0 ▶sub set_page_body_attributes {
Subroutine set_page_body_attributes: not called CC=3 SCAR=24.8
Pod documented
3220 0 my ($self, $first, $second) = @_;
3221 0 ▶ if( defined( $first ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first) 0 0 0
3222 0 ▶ if( ref( $first ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first eq 'HASH') { } 0 0 0
3223 0 $self->{$KEY_PAGE_BATR} = {%{$first}};
3224 } else {
3225 0 $self->{$KEY_PAGE_BATR}->{$first} = $second;
3226 }
3227 }
3228 }
3229  
3230 0 ▶sub add_page_body_attributes {
Subroutine add_page_body_attributes: not called CC=3 SCAR=24.8
Pod documented
3231 0 my ($self, $first, $second) = @_;
3232 0 ▶ if( defined( $first ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first) 0 0 0
3233 0 ▶ if( ref( $first ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first eq 'HASH') { } 0 0 0
3234 0 @{$self->{$KEY_PAGE_BATR}}{keys %{$first}} = values %{$first};
3235 } else {
3236 0 $self->{$KEY_PAGE_BATR}->{$first} = $second;
3237 }
3238 }
3239 }
3240  
3241 ######################################################################
3242  
3243 =head2 get_page_body_ref()
3244  
3245 This method is an accessor for the "page body" array property of this object,
3246 a reference to which it returns. While this property actually represents a
3247 scalar value, it is stored as an array for possible efficiency, considering that
3248 new portions may be appended or prepended to it as the program runs.
3249 This property is inserted between the "<BODY></BODY>" tags of a new HTML page.
3250  
3251 =head2 get_page_body()
3252  
3253 This method returns a string of the "page body" joined together.
3254  
3255 =head2 set_page_body( VALUE )
3256  
3257 This method allows you to set or replace the current "page body" with a new one.
3258 The argument VALUE can be either an array ref or scalar or literal list.
3259  
3260 =head2 append_page_body( VALUE )
3261  
3262 This method allows you to append content to the current "page body".
3263 The argument VALUE can be either an array ref or scalar or literal list.
3264  
3265 =head2 prepend_page_body( VALUE )
3266  
3267 This method allows you to prepend content to the current "page body".
3268 The argument VALUE can be either an array ref or scalar or literal list.
3269  
3270 =cut
3271  
3272 ######################################################################
3273  
3274 0 ▶sub get_page_body_ref {
Subroutine get_page_body_ref: not called CC=1 SCAR=6.9
Pod documented
3275 0 return( $_[0]->{$KEY_PAGE_BODY} ); # returns ref for further use
3276 }
3277  
3278 0 ▶sub get_page_body {
Subroutine get_page_body: not called CC=1 SCAR=6.9
Pod documented
3279 0 return( join( '', @{$_[0]->{$KEY_PAGE_BODY}} ) );
3280 }
3281  
3282 0 ▶sub set_page_body {
Subroutine set_page_body: not called CC=2 SCAR=17.9
Pod documented
3283 0 my $self = shift( @_ );
3284 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
3285 0 @{$self->{$KEY_PAGE_BODY}} = @{$ra_values};
3286 }
3287  
3288 0 ▶sub append_page_body {
Subroutine append_page_body: not called CC=2 SCAR=17.9
Pod documented
3289 0 my $self = shift( @_ );
3290 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
3291 0 push( @{$self->{$KEY_PAGE_BODY}}, @{$ra_values} );
3292 }
3293  
3294 0 ▶sub prepend_page_body {
Subroutine prepend_page_body: not called CC=2 SCAR=17.9
Pod documented
3295 0 my $self = shift( @_ );
3296 0 ▶ my $ra_values = ref( $_[0] ) eq 'ARRAY' ? $_[0] : \@_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
3297 0 unshift( @{$self->{$KEY_PAGE_BODY}}, @{$ra_values} );
3298 }
3299  
3300 ######################################################################
3301  
3302 =head2 page_search_and_replace( DO_THIS )
3303  
3304 This method performs a customizable search-and-replace of this object's "page *"
3305 properties. The argument DO_THIS is a hash ref whose keys are tokens to look for
3306 and the corresponding values are what to replace the tokens with. Tokens can be
3307 any Perl 5 regular expression and they are applied using "s/[find]/[replace]/g".
3308 Perl will automatically throw an exception if your regular expressions don't
3309 compile, so you should check them for validity before use. If DO_THIS is not a
3310 valid hash ref then this method returns without changing anything. Currently,
3311 this method only affects the "page body" property, which is the most common
3312 activity, but in subsequent releases it may process more properties.
3313  
3314 =cut
3315  
3316 ######################################################################
3317  
3318 0 ▶sub page_search_and_replace {
Subroutine page_search_and_replace: not called CC=3 SCAR=24.8
Pod documented
3319 0 my ($self, $do_this) = @_;
3320 0 ▶ ref( $do_this ) eq 'HASH' or return( undef );
Branch: 1 branch
BranchTrueFalseTotal
ref $do_this eq "HASH" or return undef 0 0 0
3321 0 my $body = join( '', @{$self->{$KEY_PAGE_BODY}} );
3322  
3323 0 foreach my $find_val (keys %{$do_this}) {
3324 0 my $replace_val = $do_this->{$find_val};
3325 0 $body =~ s/$find_val/$replace_val/g;
3326 }
3327  
3328 0 @{$self->{$KEY_PAGE_BODY}} = ($body);
3329 }
3330  
3331 ######################################################################
3332  
3333 =head2 page_as_string()
3334  
3335 This method assembles the various "page *" properties of this object into a
3336 complete HTML page and returns it as a string. That is, it returns the
3337 cumulative string representation of those properties. This consists of a
3338 prologue tag, a pair of "html" tags, and everything in between.
3339 This method requires HTML::EasyTags to do the actual page assembly, and so the
3340 results are consistant with its abilities.
3341  
3342 =cut
3343  
3344 ######################################################################
3345  
3346 0 ▶sub page_as_string {
Subroutine page_as_string: not called CC=8 SCAR=42.8
Pod documented
3347 0 my $self = shift( @_ );
3348 0 my ($title,$author,$meta,$css_src,$css_code,$frameset);
3349  
3350 0 require HTML::EasyTags;
3351 0 my $html = HTML::EasyTags->new();
3352  
3353 # This line is a no-op unless HTML::EasyTags is v1-06 or later.
3354 0 ▶ $self->{$KEY_PAGE_PROL} and $html->prologue_tag( $self->{$KEY_PAGE_PROL} );
Branch: 1 branch
BranchTrueFalseTotal
$self->{$KEY_PAGE_PROL} and $html->prologue_tag($self->{$KEY_PAGE_PROL}) 0 0 0
3355  
3356 0 ▶ $self->{$KEY_PAGE_AUTH} and $author =
Branch: 1 branch
BranchTrueFalseTotal
$self->{$KEY_PAGE_AUTH} and $author = $html->link("rev", "made", "href", "mailto:$self->{$KEY_PAGE_AUTH}") 0 0 0
3357 $html->link( rev => 'made', href => "mailto:$self->{$KEY_PAGE_AUTH}" );
3358  
3359 0 %{$self->{$KEY_PAGE_META}} and $meta = join( '', map {
3360 0 $html->meta_group( name => $_, value => $self->{$KEY_PAGE_META}->{$_} )
3361 0 ▶ } keys %{$self->{$KEY_PAGE_META}} );
Branch: 1 branch
BranchTrueFalseTotal
%{$self->{$KEY_PAGE_META};} and $meta = join("", map({$html->meta_group("name", $_, "value", $self->{$KEY_PAGE_META}{$_});} keys %{$$self{$KEY_PAGE_META};})) 0 0 0
3362  
3363 0 @{$self->{$KEY_PAGE_CSSR}} and $css_src =
3364 $html->link_group( rel => 'stylesheet', type => 'text/css',
3365 0 ▶ href => $self->{$KEY_PAGE_CSSR} );
Branch: 1 branch
BranchTrueFalseTotal
@{$self->{$KEY_PAGE_CSSR};} and $css_src = $html->link_group("rel", "stylesheet", "type", "text/css", "href", $self->{$KEY_PAGE_CSSR}) 0 0 0
3366  
3367 0 @{$self->{$KEY_PAGE_CSSC}} and $css_code = $html->style(
3368 0 ▶ { type => 'text/css' }, $html->comment_tag( $self->{$KEY_PAGE_CSSC} ) );
Branch: 1 branch
BranchTrueFalseTotal
@{$self->{$KEY_PAGE_CSSC};} and $css_code = $html->style({"type", "text/css"}, $html->comment_tag($self->{$KEY_PAGE_CSSC})) 0 0 0
3369  
3370 0 ▶ if( %{$self->{$KEY_PAGE_FATR}} or @{$self->{$KEY_PAGE_FRAM}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (%{$self->{$KEY_PAGE_FATR};} or @{$self->{$KEY_PAGE_FRAM};}) 0 0 0
Condition0%0/3
%{$self->{$KEY_PAGE_FATR};} or @{$self->{$KEY_PAGE_FRAM};}
l!l&&r!l&&!r
000
MC/DC0%0/2
%{$self->{$KEY_PAGE_FATR};} or @{$self->{$KEY_PAGE_FRAM};}
%{$self->{$KEY_PAGE_FATR};} @{$self->{$KEY_PAGE_FRAM};}
Truth table0%0/3
A or B
A= %{$self->{$KEY_PAGE_FATR};}B= @{$self->{$KEY_PAGE_FRAM};}
ABresult
1X1
011
000
3371 0 my @frames = map { $html->frame( $_ ) } @{$self->{$KEY_PAGE_FRAM}};
3372 0 $frameset = {%{$self->{$KEY_PAGE_FATR}}, text => join( '', @frames )};
3373 }
3374  
3375 return( join( '',
3376 $html->start_html(
3377 $self->{$KEY_PAGE_TITL},
3378 0 [ $author, $meta, $css_src, $css_code, @{$self->{$KEY_PAGE_HEAD}} ],
3379 $self->{$KEY_PAGE_BATR},
3380 $frameset,
3381 ),
3382 0 @{$self->{$KEY_PAGE_BODY}},
3383 $html->end_html( $frameset ),
3384 ) );
3385 }
3386  
3387 ######################################################################
3388  
3389 =head1 METHODS FOR DEBUGGING
3390  
3391 =head2 is_debug([ VALUE ])
3392  
3393 This method is an accessor for the "is debug" boolean property of this object,
3394 which it returns. If VALUE is defined, this property is set to it. If this
3395 property is true then it indicates that the program is currently being debugged
3396 by the owner/maintainer; if it is false then the program is being run by a normal
3397 user. How or whether the program reacts to this fact is quite arbitrary.
3398 For example, it may just keep a separate set of usage logs or append "debug"
3399 messages to email or web pages it makes.
3400  
3401 =cut
3402  
3403 ######################################################################
3404  
3405 0 ▶sub is_debug {
Subroutine is_debug: not called CC=2 SCAR=17.9
Pod documented
3406 0 my $self = shift( @_ );
3407 0 ▶ if( defined( my $new_value = shift( @_ ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $new_value = shift @_)) 0 0 0
3408 0 $self->{$KEY_IS_DEBUG} = $new_value;
3409 }
3410 0 return( $self->{$KEY_IS_DEBUG} );
3411 }
3412  
3413 ######################################################################
3414  
3415 =head1 METHODS FOR SEARCH AND REPLACE
3416  
3417 This method supplements the page_search_and_replace() 'Response' method with a
3418 more proprietary solution.
3419  
3420 =head2 search_and_replace_url_path_tokens([ TOKEN ])
3421  
3422 This method performs a specialized search-and-replace of this object's "page
3423 body" property. The nature of this search and replace allows you to to embed
3424 "url paths" in static portions of your application, such as data files, and then
3425 replace them with complete self-referencing urls that go to the application
3426 screen that each url path corresponds to. How it works is that your data files
3427 are formatted like 'E<lt>a href="__url_path__=/pics/green">green picsE<lt>/a>' or
3428 'E<lt>a href="__url_path__=../texts">texts pageE<lt>/a>' or
3429 'E<lt>a href="__url_path__=/jump&url=http://www.cpan.org">CPANE<lt>/a>' and the scalar
3430 argument TOKEN is equal to '__url_path__' (that is its default value also).
3431 This method will search for text like in the above formats, specifically the parts between the double-quotes, and substitute in self-referencing urls like
3432 'E<lt>a href="http://www.aardvark.net/it.pl/pics/green">green picsE<lt>/a>' or
3433 'E<lt>a href="http://www.aardvark.net/it.pl/jump?url=http://www.cpan.org">CPANE<lt>/a>'.
3434 New urls are constructed in a similar fashion to what url_as_string() makes, and
3435 incorporates your existing url base, query string, and so
3436 on. Any query string you provide in the source text is added to the url query
3437 in the output. This specialized search and replace can not be done with
3438 page_search_and_replace() since that would only replace the '__url_path__'
3439 part and leave the rest. The regular expression that is searched for looks
3440 sort of like /"TOKEN=([^&^"]*)&?(.*?)"/.
3441  
3442 =cut
3443  
3444 ######################################################################
3445  
3446 0 ▶sub search_and_replace_url_path_tokens {
Subroutine search_and_replace_url_path_tokens: not called CC=3 SCAR=24.8
Pod documented
3447 0 my ($self, $token) = @_;
3448 0 ▶ $token ||= '__url_path__';
Condition0%0/2
$token ||= "__url_path__"
l!l
00
MC/DC0%0/1
$token ||= "__url_path__"
$token
Truth table0%0/2
A
A= $token
Aresult
11
00
3449 0 my $ra_page_body = $self->get_page_body_ref();
3450 0 my $body = join( '', @{$ra_page_body} );
3451  
3452 0 my $_ple = $self->url_base(); # SIMPLIFIED THIS 0-45
3453 0 my $_pri = '?'; # SIMPLIFIED THIS 0-45
3454 0 my $_que = $self->url_query_string();
3455 0 ▶ $_que and $_que = "&$_que";
Branch: 1 branch
BranchTrueFalseTotal
$_que and $_que = "&$_que" 0 0 0
3456 0 $body =~ s/"$token=([^&^"]*)&?(.*?)"/"$_ple$1$_pri$2$_que"/g;
3457 0 $body =~ s/\?&/\?/g; # ADDED THIS LINE 0-43
3458 0 $body =~ s/\?"/"/g; # ADDED THIS LINE 0-46
3459  
3460 0 @{$ra_page_body} = ($body);
3461 }
3462  
3463 ######################################################################
3464  
3465 =head1 METHODS FOR GLOBAL PREFERENCES
3466  
3467 These methods are designed to be accessors for a few "special" preferences that
3468 are global in the sense that they are stored separately from normal preferences
3469 and they only have to be set once in a parent context to be available to all
3470 child contexts and the application components that use them. Each one has its
3471 own accessor method. The information stored here is of the generic variety that
3472 could be used all over the application, such as the name of the application
3473 instance or the maintainer's name and email address, which can be used with
3474 error messages or other places where the maintainer would be contacted.
3475  
3476 =head2 default_application_title([ VALUE ])
3477  
3478 This method is an accessor for the "app instance title" string property of this
3479 object, which it returns. If VALUE is defined, this property is set to it.
3480 This property can be used on about/error screens or email messages to indicate
3481 the title of this application instance. You can call url_base() or recall_url()
3482 to provide an accompanying url in the emails if you wish. This property
3483 defaults to "Untitled Application".
3484  
3485 =head2 default_maintainer_name([ VALUE ])
3486  
3487 This method is an accessor for the "maintainer name" string property of this
3488 object, which it returns. If VALUE is defined, this property is set to it.
3489 This property can be used on about/error screens or email messages to indicate
3490 the name of the maintainer for this application instance, should you need to
3491 credit them or know who to contact. This property defaults to "Webmaster".
3492  
3493 =head2 default_maintainer_email_address([ VALUE ])
3494  
3495 This method is an accessor for the "maintainer email" string property of this
3496 object, which it returns. If VALUE is defined, this property is set to it.
3497 This property can be used on about/error screens or email messages to indicate
3498 the email address of the maintainer for this application instance, should you
3499 need to contact them or should this application need to send them an email.
3500 This property defaults to "webmaster@localhost".
3501  
3502 =head2 default_maintainer_email_screen_url_path([ VALUE ])
3503  
3504 This method is an accessor for the "maintainer screen" string property of this
3505 object, which it returns. If VALUE is defined, this property is set to it.
3506 This property can be used on about/error pages as an "url path" that goes to
3507 the screen of your application giving information on how to contact the
3508 maintainer. This property defaults to undefined, which means there is no screen
3509 in your app for this purpose; calling code that wants to use this would probably
3510 substitute the literal email address instead.
3511  
3512 =head2 default_smtp_host([ VALUE ])
3513  
3514 This method is an accessor for the "smtp host" string property of this
3515 object, which it returns. If VALUE is defined, this property is set to it.
3516 This property can be used by your application as a default web domain or ip for
3517 the smtp server that it should use to send email with. This property defaults
3518 to "localhost".
3519  
3520 =head2 default_smtp_timeout([ VALUE ])
3521  
3522 This method is an accessor for the "smtp timeout" number property of this
3523 object, which it returns. If VALUE is defined, this property is set to it.
3524 This property can be used by your application when contacting an smtp server
3525 to say how many seconds it should wait before timing out. This property
3526 defaults to 30.
3527  
3528 =head2 maintainer_email_html([ LABEL ])
3529  
3530 This method will selectively make a hyperlink that can be used by your users to
3531 contact the maintainer of this application. If the "maintainer screen" property
3532 is defined then this method will make a hyperlink to that screen. Otherwise,
3533 it makes an "mailto" hyperlink using the "maintainer email" address.
3534  
3535 =cut
3536  
3537 ######################################################################
3538  
3539 0 ▶sub default_application_title {
Subroutine default_application_title: not called CC=2 SCAR=17.9
Pod documented
3540 0 my ($self, $new_value) = @_;
3541 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
3542 0 $self->{$KEY_PREF_APIT} = $new_value;
3543 }
3544 0 return( $self->{$KEY_PREF_APIT} );
3545 }
3546  
3547 0 ▶sub default_maintainer_name {
Subroutine default_maintainer_name: not called CC=2 SCAR=17.9
Pod documented
3548 0 my ($self, $new_value) = @_;
3549 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
3550 0 $self->{$KEY_PREF_MNAM} = $new_value;
3551 }
3552 0 return( $self->{$KEY_PREF_MNAM} );
3553 }
3554  
3555 0 ▶sub default_maintainer_email_address {
Subroutine default_maintainer_email_address: not called CC=2 SCAR=17.9
Pod documented
3556 0 my ($self, $new_value) = @_;
3557 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
3558 0 $self->{$KEY_PREF_MEAD} = $new_value;
3559 }
3560 0 return( $self->{$KEY_PREF_MEAD} );
3561 }
3562  
3563 0 ▶sub default_maintainer_email_screen_url_path {
Subroutine default_maintainer_email_screen_url_path: not called CC=2 SCAR=17.9
Pod documented
3564 0 my ($self, $new_value) = @_;
3565 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
3566 0 $self->{$KEY_PREF_MESP} = $new_value;
3567 }
3568 0 return( $self->{$KEY_PREF_MESP} );
3569 }
3570  
3571 0 ▶sub default_smtp_host {
Subroutine default_smtp_host: not called CC=2 SCAR=17.9
Pod documented
3572 0 my ($self, $new_value) = @_;
3573 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
3574 0 $self->{$KEY_PREF_SMTP} = $new_value;
3575 }
3576 0 return( $self->{$KEY_PREF_SMTP} );
3577 }
3578  
3579 0 ▶sub default_smtp_timeout {
Subroutine default_smtp_timeout: not called CC=2 SCAR=17.9
Pod documented
3580 0 my ($self, $new_value) = @_;
3581 0 ▶ if( defined( $new_value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 0 0 0
3582 0 $self->{$KEY_PREF_TIME} = $new_value;
3583 }
3584 0 return( $self->{$KEY_PREF_TIME} );
3585 }
3586  
3587 0 ▶sub maintainer_email_html {
Subroutine maintainer_email_html: not called CC=3 SCAR=24.8
Pod documented
3588 0 my ($self, $label) = @_;
3589 0 ▶ defined( $label ) or $label = 'e-mail';
Branch: 1 branch
BranchTrueFalseTotal
defined $label or $label = "e-mail" 0 0 0
3590 0 my $addy = $self->default_maintainer_email_address();
3591 0 my $path = $self->default_maintainer_email_screen_url_path();
3592 0 ▶ return( defined( $path ) ?
Branch: 1 branch
BranchTrueFalseTotal
defined $path ? : 0 0 0
3593 0 "<a href=\"@{[$self->url_as_string( $path )]}\">$label</a> ($addy)" :
3594 "<a href=\"mailto:$addy\">$label</a> ($addy)" );
3595 }
3596  
3597 ######################################################################
3598  
3599 =head1 METHODS FOR MISCELLANEOUS OBJECT SERVICES
3600  
3601 =head2 get_misc_objects_ref()
3602  
3603 This method returns a reference to this object's "misc objects" hash property.
3604 This hash stores references to any objects you want to pass between program
3605 components with services that are beyond the scope of this class, such as
3606 persistent database handles. This hash ref is static across all objects of
3607 this class that are derived from one another.
3608  
3609 =head2 replace_misc_objects( HASH_REF )
3610  
3611 This method lets this object have a "misc objects" property in common with
3612 another object that it doesn't already. If the argument HASH_REF is a hash ref,
3613 then this property is set to it.
3614  
3615 =head2 separate_misc_objects()
3616  
3617 This method lets this object stop having a "misc objects" property in common
3618 with another, by replacing that property with a new empty hash ref.
3619  
3620 =cut
3621  
3622 ######################################################################
3623  
3624 0 ▶sub get_misc_objects_ref {
Subroutine get_misc_objects_ref: not called CC=1 SCAR=6.9
Pod documented
3625 0 return( $_[0]->{$KEY_MISC_OBJECTS} );
3626 }
3627  
3628 0 ▶sub replace_misc_objects {
Subroutine replace_misc_objects: not called CC=2 SCAR=17.9
Pod documented
3629 0 ▶ ref( $_[1] ) eq 'HASH' and $_[0]->{$KEY_MISC_OBJECTS} = $_[1];
Branch: 1 branch
BranchTrueFalseTotal
ref $_[1] eq "HASH" and $_[0]{$KEY_MISC_OBJECTS} = $_[1] 0 0 0
3630 }
3631  
3632 0 ▶sub separate_misc_objects {
Subroutine separate_misc_objects: not called CC=1 SCAR=6.9
Pod documented
3633 0 $_[0]->{$KEY_MISC_OBJECTS} = {};
3634 }
3635  
3636 ######################################################################
3637  
3638 1 1;
3639 __END__
« DemoUsage.pm ↑ Summary DemoTextFile.pm »