line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::AppBuilder::Header; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Perl standard modules |
4
|
1
|
|
|
1
|
|
24858
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
6
|
1
|
|
|
1
|
|
2733
|
use Getopt::Std; |
|
1
|
|
|
|
|
54
|
|
|
1
|
|
|
|
|
73
|
|
7
|
1
|
|
|
1
|
|
891
|
use POSIX qw(strftime); |
|
1
|
|
|
|
|
6914
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
1194
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
9
|
1
|
|
|
1
|
|
1733
|
use CGI::AppBuilder; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use CGI::AppBuilder::Message qw(:echo_msg); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = 0.12; |
13
|
|
|
|
|
|
|
require Exporter; |
14
|
|
|
|
|
|
|
our @ISA = qw(Exporter CGI::AppBuilder); |
15
|
|
|
|
|
|
|
our @EXPORT = qw(); |
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw(build_html_header |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
19
|
|
|
|
|
|
|
all => [@EXPORT_OK] |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
CGI::AppBuilder::Header - Configuration initializer |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use CGI::AppBuilder::Header; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $ab = CGI::AppBuilder::Header->new( |
31
|
|
|
|
|
|
|
'ifn', 'my_init.cfg', 'opt', 'vhS:a:'); |
32
|
|
|
|
|
|
|
my ($q, $ar, $ar_log) = $ab->start_app($0, \%ARGV); |
33
|
|
|
|
|
|
|
print $ab->disp_form($q, $ar); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
This class provides methods for reading and parsing configuration |
38
|
|
|
|
|
|
|
files. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 new (ifn => 'file.cfg', opt => 'hvS:') |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This is a inherited method from CGI::AppBuilder. See the same method |
45
|
|
|
|
|
|
|
in CGI::AppBuilder for more details. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new { |
50
|
|
|
|
|
|
|
my ($s, %args) = @_; |
51
|
|
|
|
|
|
|
return $s->SUPER::new(%args); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head3 build_html_header ($q, $ar) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Input variables: |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$q - CGI object |
59
|
|
|
|
|
|
|
$ar - array ref for parameters |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Variables used or routines called: |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Debug::EchoMessage |
64
|
|
|
|
|
|
|
echo_msg - echo messages |
65
|
|
|
|
|
|
|
set_param - get a parameter from hash array |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
How to use: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $ifn = 'myConfig.ini'; |
70
|
|
|
|
|
|
|
my ($q,$ar) = $s->get_inputs($ifn); |
71
|
|
|
|
|
|
|
my $hrf = $self->build_html_header($q, $ar); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Return: hash array or array ref |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This method performs the following tasks: |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1) check the following parameters: page_title, page_style, |
78
|
|
|
|
|
|
|
page_meta, page_author, page_target, js_src, |
79
|
|
|
|
|
|
|
2) writes log records to log files |
80
|
|
|
|
|
|
|
3) close database connection if it finds DB handler in {dbh} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub build_html_header { |
85
|
|
|
|
|
|
|
my $s = shift; |
86
|
|
|
|
|
|
|
my ($q, $ar) = @_; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# 4. start HTML header |
89
|
|
|
|
|
|
|
my $title = $s->set_param('page_title', $ar); |
90
|
|
|
|
|
|
|
$title = "Untitled Page" if ! $title; |
91
|
|
|
|
|
|
|
my $style = $s->set_param('page_style', $ar); |
92
|
|
|
|
|
|
|
$style = '' if ! $style; |
93
|
|
|
|
|
|
|
my $author = $s->set_param('page_author', $ar); |
94
|
|
|
|
|
|
|
$author = 'Hanming.Tu@Premier-Research.COM' if ! $author; |
95
|
|
|
|
|
|
|
my $target = $s->set_param('page_target', $ar); |
96
|
|
|
|
|
|
|
# $target = '_blank' if ! $target; |
97
|
|
|
|
|
|
|
my $js_src = $s->set_param('js_src', $ar); |
98
|
|
|
|
|
|
|
my $yr = strftime "%Y", localtime time; |
99
|
|
|
|
|
|
|
my $meta_txt = $s->set_param('page_meta', $ar); |
100
|
|
|
|
|
|
|
my $mrf = {}; |
101
|
|
|
|
|
|
|
if ($meta_txt) { |
102
|
|
|
|
|
|
|
$mrf = eval $meta_txt; |
103
|
|
|
|
|
|
|
$mrf->{'keywords'} = 'Perl Modules'; |
104
|
|
|
|
|
|
|
$mrf->{'copyright'}= "copyright $yr Hanming Tu"; |
105
|
|
|
|
|
|
|
} else { |
106
|
|
|
|
|
|
|
$mrf = {'keywords'=>'Perl Modules', |
107
|
|
|
|
|
|
|
'copyright'=>"copyright $yr Hanming Tu"}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
my %ar_hdr = (-title=>$title, -author=>$author, -meta=>$mrf); |
110
|
|
|
|
|
|
|
$ar_hdr{-target}= $target if $target; |
111
|
|
|
|
|
|
|
$ar_hdr{-style} = ($style =~ /^ |