blib/lib/LibWeb/Themes/Default.pm

filter: Statementstmt 69.5% 112 / 161 Branchbran 27.2% 12 / 44 Conditioncond 30.5% 44 / 144 MC/DCmcdc 0.0% 0 / 82 Subroutinesub 85.7% 12 / 14 Podpod 0.0% 0 / 9 totaltotal 39.6% 180 / 454 CC 87 SCAR 56.7
CC
87
Cov
48%
tabber
930.0
enlighted_titled_table
24.8
titled_table
21.7
CRAP 290.4
↑ Summary blib/lib/LibWeb/Session.pm »
1 #==============================================================================
2 # LibWeb::Themes::Default -- Default HTML widgets and theme for libweb
3 # applications
4  
5 package LibWeb::Themes::Default;
6  
7 # Copyright (C) 2000 Colin Kong
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #=============================================================================
23  
24 # $Id: Default.pm,v 1.6 2000/07/19 20:31:57 ckyc Exp $
25  
26 2 $VERSION = '0.02';
27  
28 #-#############################
29 # Use standard libraries.
30 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 2 ▶use vars qw($VERSION @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
32 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 #-#############################
35 # Use custom libraries.
36 2 require LibWeb::Core;
37  
38 #-#############################
39 # Inheritance.
40 2 @ISA = qw(LibWeb::Core);
41  
42 #-#############################
43 # Methods.
44 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
45 #
46 # Params: $class [, $rc_file]
47 #
48 # - $class is the class/package name of this package, be it a string
49 # or a reference.
50 # - $rc_file is the absolute path to the rc file for LibWeb.
51 #
52 # Usage: my $object = new LibWeb::HTML::Themes([$rc_file]);
53 #
54 1 my ($class, $Class, $self);
55 1 $class = shift;
56 1 ▶ $Class = ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
57
58 # Inherit instance variables from the base class.
59 1 $self = $Class->SUPER::new(shift);
60 1 bless($self, $Class);
61 }
62  
63 0 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
64  
65 5 ▶sub _parse_content {
Subroutine _parse_content: called CC=5 SCAR=17.3
66 5 my ($ref, @content_display);
67 5 my $content = $_[0];
68
69 5 eval {
70 5 foreach (@$content) {
71 5 $ref = ref($_);
72 0 ▶ if ( $ref eq 'SCALAR' ) { push(@content_display, $$_); }
Branch: 2 branches
BranchTrueFalseTotal
if ($ref eq 'SCALAR') { } 0 5 5
elsif ($ref eq 'ARRAY') { } 0 5 5
73 0 elsif ( $ref eq 'ARRAY' ) { push(@content_display, @$_); }
74 5 else { push(@content_display, $_); }
75 }
76 };
77 5 ▶ croak "$@" if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 5 5
78 5 return \@content_display;
79 }
80  
81 1 ▶sub table {
Subroutine table: called CC=6 SCAR=19.2
Pod undocumented
82 #
83 # Params: -content=>, [ -bg_color=>, -align=>, -valign=>, -width=> ]
84 #
85 # -content must be an ARRAY ref. to elements which are
86 # scalar/SCALAR ref./ARRAY ref. to plain HTML.
87 # -bg_color default is SITE_BG_COLOR.
88 # -align is the content's horizontal alignment; default is `left'.
89 # -valign is the content's vertical alignment; default is `top'.
90 # -width default is 100%.
91 #
92 # Return a SCALAR ref. to a formatted table in HTML format.
93 #
94 1 my ($self, $content, $bg_color, $align, $valign, $width,
95 $content_display);
96 1 $self = shift;
97 1 ($content, $bg_color, $align, $valign, $width)
98 = $self->rearrange( ['CONTENT', 'BG_COLOR', 'ALIGN', 'VALIGN', 'WIDTH'], @_ );
99
100 1 ▶ $content ||= [' '];
Condition50%1/2
$content ||= [" "]
l!l
01
MC/DC0%0/1
$content ||= [" "]
$content
Truth table50%1/2
A
A= $content
Aresult
11
00
101 1 ▶ $bg_color ||= $self->{SITE_BG_COLOR};
Condition33%1/3
$bg_color ||= $self->{"SITE_BG_COLOR"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$bg_color ||= $self->{"SITE_BG_COLOR"}
$bg_color $self->{"SITE_BG_COLOR"}
Truth table33%1/3
A ||= B
A= $bg_colorB= $self->{"SITE_BG_COLOR"}
ABresult
1X1
011
000
102 1 ▶ $align ||= 'left';
Condition50%1/2
$align ||= "left"
l!l
01
MC/DC0%0/1
$align ||= "left"
$align
Truth table50%1/2
A
A= $align
Aresult
11
00
103 1 ▶ $valign ||= 'top';
Condition50%1/2
$valign ||= "top"
l!l
01
MC/DC0%0/1
$valign ||= "top"
$valign
Truth table50%1/2
A
A= $valign
Aresult
11
00
104 1 ▶ $width ||= '100%';
Condition50%1/2
$width ||= "100%"
l!l
01
MC/DC0%0/1
$width ||= "100%"
$width
Truth table50%1/2
A
A= $width
Aresult
11
00
105
106 1 $content_display = _parse_content($content);
107
108 #<!-- start HTML for table -->
109 1 return \<<HTML;
110 <table border=0 cellpadding=0 cellspacing=0 width="$width" bgcolor="$bg_color">
111 <Tr><td align="$align" valign="$valign">
112 @$content_display
113 </td></Tr>
114 </table>
115  
116 HTML
117 #<!-- end HTML for the table -->
118 }
119  
120 1 ▶sub titled_table {
Subroutine titled_table: called CC=14 SCAR=30.8
Pod undocumented
121 #
122 # Params: -title=>, -content=>, [ -title_space=>, -title_align=>,
123 # -title_bg_color=>, -title_txt_color=>,
124 # -bg_color=>, align=>, valign=>,
125 # -cellpadding=>, -width=> ]
126 #
127 # -content must be an ARRAY ref. to elements which are
128 # scalar/SCALAR ref./ARRAY ref. to plain HTML.
129 # -title_space is the space (&nbsp;) prepended before (if -title_align is `left')
130 # or append after (if -title_align is `right') the title. It's always 0 if
131 # -title_align is `center'. Default is 2, i.e. `&nbsp;&nbsp;'.
132 # -title_align default is center.
133 # -title_bg_color default is SITE_1ST_COLOR.
134 # -title_txt_color default is SITE_BG_COLOR.
135 # -bg_color default is if SITE_BG_COLOR.
136 # -align is the content's horizontal alignment; default is `left'.
137 # -valign is the content's vertical alignment; default is `top'.
138 # -cellpadding is the distance between the content and the `border' of table,
139 # default is 1.
140 # -width default is 100%.
141 #
142 # Return a SCALAR ref. to a formatted table in HTML format.
143 #
144 1 my ($self,
145 $title, $content, $title_space, $title_align, $title_bg_color,
146 $title_txt_color, $bg_color, $align, $valign, $cellpadding, $width,
147 $title_spacer, $content_display);
148 1 $self = shift;
149 1 ($title, $content, $title_space, $title_align, $title_bg_color,
150 $title_txt_color, $bg_color, $align, $valign, $cellpadding, $width)
151 = $self->rearrange( ['TITLE', 'CONTENT', 'TITLE_SPACE', 'TITLE_ALIGN',
152 'TITLE_BG_COLOR', 'TITLE_TXT_COLOR', 'BG_COLOR',
153 'ALIGN', 'VALIGN', 'CELLPADDING', 'WIDTH'],
154 @_ );
155
156 1 ▶ $title ||= " ";
Condition50%1/2
$title ||= " "
l!l
01
MC/DC0%0/1
$title ||= " "
$title
Truth table50%1/2
A
A= $title
Aresult
11
00
157 1 ▶ $content ||= [' '];
Condition50%1/2
$content ||= [" "]
l!l
01
MC/DC0%0/1
$content ||= [" "]
$content
Truth table50%1/2
A
A= $content
Aresult
11
00
158 1 ▶ $title_align ||= 'center';
Condition50%1/2
$title_align ||= "center"
l!l
01
MC/DC0%0/1
$title_align ||= "center"
$title_align
Truth table50%1/2
A
A= $title_align
Aresult
11
00
159 1 ▶ unless ( defined($title_space) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $title_space) 1 0 1
160 1 ▶ $title_space = ( uc($title_align) eq 'CENTER' ) ? 0 : 2;
Branch: 1 branch
BranchTrueFalseTotal
uc $title_align eq 'CENTER' ? : 1 0 1
161 }
162 1 $title_spacer = '&nbsp;' x $title_space;
163 0 ▶ if ( uc($title_align) eq 'RIGHT' ) { $title = '<b>'.$title.'</b>'.$title_spacer; }
Branch: 1 branch
BranchTrueFalseTotal
if (uc $title_align eq 'RIGHT') { } 0 1 1
164 1 else { $title = $title_spacer.'<b>'.$title.'</b>'; }
165 1 ▶ $title_bg_color ||= $self->{SITE_1ST_COLOR};
Condition33%1/3
$title_bg_color ||= $self->{"SITE_1ST_COLOR"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$title_bg_color ||= $self->{"SITE_1ST_COLOR"}
$title_bg_color $self->{"SITE_1ST_COLOR"}
Truth table33%1/3
A ||= B
A= $title_bg_colorB= $self->{"SITE_1ST_COLOR"}
ABresult
1X1
011
000
166 1 ▶ $title_txt_color ||= $self->{SITE_BG_COLOR};
Condition33%1/3
$title_txt_color ||= $self->{"SITE_BG_COLOR"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$title_txt_color ||= $self->{"SITE_BG_COLOR"}
$title_txt_color $self->{"SITE_BG_COLOR"}
Truth table33%1/3
A ||= B
A= $title_txt_colorB= $self->{"SITE_BG_COLOR"}
ABresult
1X1
011
000
167 1 ▶ $bg_color ||= $self->{SITE_BG_COLOR};
Condition33%1/3
$bg_color ||= $self->{"SITE_BG_COLOR"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$bg_color ||= $self->{"SITE_BG_COLOR"}
$bg_color $self->{"SITE_BG_COLOR"}
Truth table33%1/3
A ||= B
A= $bg_colorB= $self->{"SITE_BG_COLOR"}
ABresult
1X1
011
000
168 1 ▶ $align ||= 'left';
Condition50%1/2
$align ||= "left"
l!l
01
MC/DC0%0/1
$align ||= "left"
$align
Truth table50%1/2
A
A= $align
Aresult
11
00
169 1 ▶ $valign ||= 'top';
Condition50%1/2
$valign ||= "top"
l!l
01
MC/DC0%0/1
$valign ||= "top"
$valign
Truth table50%1/2
A
A= $valign
Aresult
11
00
170 1 ▶ $cellpadding ||= 1;
Condition50%1/2
$cellpadding ||= 1
l!l
01
MC/DC0%0/1
$cellpadding ||= 1
$cellpadding
Truth table50%1/2
A
A= $cellpadding
Aresult
11
00
171 1 ▶ $width ||= '100%';
Condition50%1/2
$width ||= "100%"
l!l
01
MC/DC0%0/1
$width ||= "100%"
$width
Truth table50%1/2
A
A= $width
Aresult
11
00
172
173 1 $content_display = _parse_content($content);
174
175 #<!-- start HTML for titled_table -->
176 1 return \<<HTML;
177 <table border=0 cellpadding=0 cellspacing=0 width="$width" bgcolor="$bg_color">
178  
179 <Tr><td>
180 <table border=0 cellpadding=0 cellspacing=0 width="100%" bgcolor="$title_bg_color">
181 <Tr><td align="$title_align" bgcolor="$title_bg_color">
182 <font color="$title_txt_color">$title</font>
183 </td></Tr></table>
184 </td></Tr>
185  
186 <Tr><td>
187 <table bgcolor="$bg_color" cellpadding="$cellpadding" cellspacing=0 width="100%" border=0>
188 <Tr><td align="$align" valign="$valign">
189 @$content_display
190 </td></Tr></table>
191 </td></Tr>
192  
193 </table>
194  
195 HTML
196 #<!-- end HTML for the titled_table -->
197 }
198  
199 1 ▶sub titled_table_enlighted {
Subroutine titled_table_enlighted: called CC=1 SCAR=0.0
Pod undocumented
200 1 shift->enlighted_titled_table(@_);
201 }
202  
203 1 ▶sub enlighted_titled_table {
Subroutine enlighted_titled_table: called CC=15 SCAR=32.1
Pod undocumented
204 #
205 # Params: -title=>, -content=>, [ -title_space=>, -title_align=>,
206 # -title_bg_color=>,
207 # -title_txt_color=>, -title_border_color=>,
208 # -bg_color=>, -align=>, -valign=>,
209 # -cellpadding=>, -width=> ]
210 #
211 # -content must be an ARRAY ref. to elements which are
212 # scalar/SCALAR ref./ARRAY ref. to plain HTML.
213 # -title_space is the space (&nbsp;) prepended before (if -title_align is `left')
214 # or append after (if -title_align is `right') the title; default is 2,
215 # i.e. `&nbsp;&nbsp;'. It's always 0 if -title_align if `center'.
216 # -title_align default is center.
217 # -title_bg_color default is SITE_LIQUID_COLOR3.
218 # -title_txt_color default is SITE_LIQUID_COLOR5.
219 # -title_border_color default is SITE_LIQUID_COLOR5.
220 # -bg_color default is if SITE_BG_COLOR.
221 # -align is the content's horizontal alignment; default is `left'.
222 # -valign is the content's vertical alignment; default is `top'.
223 # -cellpadding is the distance between the content and the `border' of table,
224 # default is 1.
225 # -width default is 100%.
226 #
227 # Return a SCALAR ref. to a formatted table in HTML format.
228 #
229 1 my ($self,
230 $title, $content, $title_space, $title_align, $title_bg_color,
231 $title_txt_color, $title_border_color, $bg_color, $align, $valign,
232 $cellpadding, $width,
233 $title_spacer, $content_display);
234 1 $self = shift;
235 1 ($title, $content, $title_space, $title_align, $title_bg_color,
236 $title_txt_color, $title_border_color, $bg_color, $align, $valign,
237 $cellpadding, $width)
238 = $self->rearrange( ['TITLE', 'CONTENT', 'TITLE_SPACE', 'TITLE_ALIGN',
239 'TITLE_BG_COLOR', 'TITLE_TXT_COLOR', 'TITLE_BORDER_COLOR',
240 'BG_COLOR', 'ALIGN', 'VALIGN', 'CELLPADDING', 'WIDTH'],
241 @_ );
242
243 1 ▶ $title ||= " ";
Condition50%1/2
$title ||= " "
l!l
01
MC/DC0%0/1
$title ||= " "
$title
Truth table50%1/2
A
A= $title
Aresult
11
00
244 1 ▶ $content ||= [' '];
Condition50%1/2
$content ||= [" "]
l!l
01
MC/DC0%0/1
$content ||= [" "]
$content
Truth table50%1/2
A
A= $content
Aresult
11
00
245 1 ▶ $title_align ||= 'center';
Condition50%1/2
$title_align ||= "center"
l!l
01
MC/DC0%0/1
$title_align ||= "center"
$title_align
Truth table50%1/2
A
A= $title_align
Aresult
11
00
246 1 ▶ unless ( defined($title_space) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $title_space) 1 0 1
247 1 ▶ $title_space = ( uc($title_align) eq 'CENTER' ) ? 0 : 2;
Branch: 1 branch
BranchTrueFalseTotal
uc $title_align eq 'CENTER' ? : 1 0 1
248 }
249 1 $title_spacer = '&nbsp;' x $title_space;
250 0 ▶ if ( uc($title_align) eq 'RIGHT' ) { $title = "<b>${title}</b>${title_spacer}"; }
Branch: 1 branch
BranchTrueFalseTotal
if (uc $title_align eq 'RIGHT') { } 0 1 1
251 1 else { $title = "${title_spacer}<b>${title}</b>"; }
252 1 ▶ $title_bg_color ||= $self->{SITE_LIQUID_COLOR3};
Condition33%1/3
$title_bg_color ||= $self->{"SITE_LIQUID_COLOR3"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$title_bg_color ||= $self->{"SITE_LIQUID_COLOR3"}
$title_bg_color $self->{"SITE_LIQUID_COLOR3"}
Truth table33%1/3
A ||= B
A= $title_bg_colorB= $self->{"SITE_LIQUID_COLOR3"}
ABresult
1X1
011
000
253 1 ▶ $title_txt_color ||= $self->{SITE_LIQUID_COLOR5};
Condition33%1/3
$title_txt_color ||= $self->{"SITE_LIQUID_COLOR5"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$title_txt_color ||= $self->{"SITE_LIQUID_COLOR5"}
$title_txt_color $self->{"SITE_LIQUID_COLOR5"}
Truth table33%1/3
A ||= B
A= $title_txt_colorB= $self->{"SITE_LIQUID_COLOR5"}
ABresult
1X1
011
000
254 1 ▶ $title_border_color ||= $self->{SITE_LIQUID_COLOR5};
Condition33%1/3
$title_border_color ||= $self->{"SITE_LIQUID_COLOR5"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$title_border_color ||= $self->{"SITE_LIQUID_COLOR5"}
$title_border_color $self->{"SITE_LIQUID_COLOR5"}
Truth table33%1/3
A ||= B
A= $title_border_colorB= $self->{"SITE_LIQUID_COLOR5"}
ABresult
1X1
011
000
255 1 ▶ $bg_color ||= $self->{SITE_BG_COLOR};
Condition33%1/3
$bg_color ||= $self->{"SITE_BG_COLOR"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$bg_color ||= $self->{"SITE_BG_COLOR"}
$bg_color $self->{"SITE_BG_COLOR"}
Truth table33%1/3
A ||= B
A= $bg_colorB= $self->{"SITE_BG_COLOR"}
ABresult
1X1
011
000
256 1 ▶ $align ||= 'left';
Condition50%1/2
$align ||= "left"
l!l
01
MC/DC0%0/1
$align ||= "left"
$align
Truth table50%1/2
A
A= $align
Aresult
11
00
257 1 ▶ $valign ||= 'top';
Condition50%1/2
$valign ||= "top"
l!l
01
MC/DC0%0/1
$valign ||= "top"
$valign
Truth table50%1/2
A
A= $valign
Aresult
11
00
258 1 ▶ $cellpadding ||= 1;
Condition50%1/2
$cellpadding ||= 1
l!l
01
MC/DC0%0/1
$cellpadding ||= 1
$cellpadding
Truth table50%1/2
A
A= $cellpadding
Aresult
11
00
259 1 ▶ $width ||= '100%';
Condition50%1/2
$width ||= "100%"
l!l
01
MC/DC0%0/1
$width ||= "100%"
$width
Truth table50%1/2
A
A= $width
Aresult
11
00
260
261 1 $content_display = _parse_content($content);
262
263 #<!-- start HTML for titled_table_enlighted -->
264 1 return \<<HTML;
265 <table border=0 cellpadding=0 cellspacing=0 width="$width" bgcolor="$bg_color">
266  
267 <Tr><td>
268 <table border=0 cellpadding=1 cellspacing=0 width="100%" bgcolor="$title_border_color">
269 <Tr><td>
270 <table border=0 cellpadding=0 cellspacing=0 width="100%" bgcolor="$title_bg_color">
271 <Tr><td bgcolor="$title_bg_color" align="$title_align">
272 <font color="$title_txt_color">$title</font>
273 </td></Tr>
274 </table>
275 </td></Tr>
276 </table>
277 </td></Tr>
278  
279 <Tr><td>
280 <table bgcolor="$bg_color" cellpadding="$cellpadding" cellspacing=0 width="100%" border=0>
281 <Tr><td align="$align" valign="$valign">
282 @$content_display
283 </td></Tr>
284 </table>
285 </td></Tr>
286  
287 </table>
288  
289 HTML
290 #<!-- end HTML for the titled_table_enlighted -->
291 }
292  
293 1 ▶sub bordered_table {
Subroutine bordered_table: called CC=8 SCAR=23.2
Pod undocumented
294 #
295 # Params: -content=>, [ -border_color=>, -bg_color=>, align=>, -valign=>,
296 # -cellpadding=>, -width=> ]
297 #
298 # -content must be an ARRAY ref. to elements which are
299 # scalar/SCALAR ref./ARRAY ref. to plain HTML.
300 # -border_color default is SITE_LIQUID_COLOR2.
301 # -bg_color default is if SITE_BG_COLOR.
302 # -align is the content's horizontal alignment; default is `left'.
303 # -valign is the content's vertical alignment; default is `top'.
304 # -cellpadding is the distance between the content and the `border' of table,
305 # default is 2.
306 # -width default is 100%.
307 #
308 # Return a SCALAR ref. to a formatted table in HTML format.
309 #
310 1 my ($self,
311 $content, $border_color, $bg_color, $align, $valign, $cellpadding, $width,
312 $content_display);
313 1 $self = shift;
314 1 ($content, $border_color, $bg_color, $align, $valign, $cellpadding, $width)
315 = $self->rearrange( ['CONTENT', 'BORDER_COLOR', 'BG_COLOR', 'ALIGN', 'VALIGN',
316 'CELLPADDING', 'WIDTH'], @_ );
317
318 1 ▶ $content ||= [' '];
Condition50%1/2
$content ||= [" "]
l!l
01
MC/DC0%0/1
$content ||= [" "]
$content
Truth table50%1/2
A
A= $content
Aresult
11
00
319 1 ▶ $border_color ||= $self->{SITE_LIQUID_COLOR2};
Condition33%1/3
$border_color ||= $self->{"SITE_LIQUID_COLOR2"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$border_color ||= $self->{"SITE_LIQUID_COLOR2"}
$border_color $self->{"SITE_LIQUID_COLOR2"}
Truth table33%1/3
A ||= B
A= $border_colorB= $self->{"SITE_LIQUID_COLOR2"}
ABresult
1X1
011
000
320 1 ▶ $bg_color ||= $self->{SITE_BG_COLOR};
Condition33%1/3
$bg_color ||= $self->{"SITE_BG_COLOR"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$bg_color ||= $self->{"SITE_BG_COLOR"}
$bg_color $self->{"SITE_BG_COLOR"}
Truth table33%1/3
A ||= B
A= $bg_colorB= $self->{"SITE_BG_COLOR"}
ABresult
1X1
011
000
321 1 ▶ $align ||= 'left';
Condition50%1/2
$align ||= "left"
l!l
01
MC/DC0%0/1
$align ||= "left"
$align
Truth table50%1/2
A
A= $align
Aresult
11
00
322 1 ▶ $valign ||= 'top';
Condition50%1/2
$valign ||= "top"
l!l
01
MC/DC0%0/1
$valign ||= "top"
$valign
Truth table50%1/2
A
A= $valign
Aresult
11
00
323 1 ▶ $cellpadding ||= 2;
Condition50%1/2
$cellpadding ||= 2
l!l
01
MC/DC0%0/1
$cellpadding ||= 2
$cellpadding
Truth table50%1/2
A
A= $cellpadding
Aresult
11
00
324 1 ▶ $width ||= '100%';
Condition50%1/2
$width ||= "100%"
l!l
01
MC/DC0%0/1
$width ||= "100%"
$width
Truth table50%1/2
A
A= $width
Aresult
11
00
325
326 1 $content_display = _parse_content($content);
327
328 #<!-- start HTML for bordered_table -->
329 1 return \<<HTML;
330 <table border=0 cellpadding=1 cellspacing=0 bgcolor="$border_color" width="$width">
331  
332 <Tr><td>
333 <table bgcolor="$bg_color" cellpadding="$cellpadding" cellspacing=0 width="100%" border=0>
334 <Tr><td align="$align" valign="$valign" bgcolor="$bg_color">
335 @$content_display
336 </td></Tr></table>
337 </td></Tr>
338  
339 </table>
340  
341 HTML
342 #<!-- end HTML for the bordered_table -->
343 }
344  
345 1 ▶sub titled_bordered_table {
Subroutine titled_bordered_table: called CC=1 SCAR=0.0
Pod undocumented
346 1 shift->bordered_titled_table(@_);
347 }
348  
349 1 ▶sub bordered_titled_table {
Subroutine bordered_titled_table: called CC=14 SCAR=30.8
Pod undocumented
350 #
351 # Params: -title=>, -content=>, [ -title_space=>, -title_align=>,
352 # -border_color=>,
353 # -title_txt_color=>,
354 # -bg_color=>, -align=>, -valign=>,
355 # -cellpadding=>, -width=> ]
356 #
357 # -content must be an ARRAY ref. to elements which are
358 # scalar/SCALAR ref./ARRAY ref. to plain HTML.
359 # -title_space is the space (&nbsp;) prepended before (if -title_align is `left')
360 # or append after (if -title_align is `right') the title; default is 2, i.e.
361 # `&nbsp;&nbsp;'. If -title_align is `center', -title_space is always 0.
362 # -title_align default is center.
363 # -border_color default is SITE_1ST_COLOR.
364 # -title_txt_color default is SITE_BG_COLOR.
365 # -bg_color default is if SITE_BG_COLOR.
366 # -align is the content's horizontal alignment; default is `left'.
367 # -valign is the content's vertical alignment; default is `top'.
368 # -cellpadding is the distance between the content and the `border' of table,
369 # default is 1.
370 # -width default is 100%.
371 #
372 # Return a SCALAR ref. to a formatted table in HTML format.
373 #
374 1 my ($self,
375 $title, $content, $title_space, $title_align, $border_color,
376 $title_txt_color, $bg_color, $align, $valign, $cellpadding, $width,
377 $title_spacer, $content_display);
378 1 $self = shift;
379 1 ($title, $content, $title_space, $title_align, $border_color,
380 $title_txt_color, $bg_color, $align, $valign, $cellpadding, $width)
381 = $self->rearrange( ['TITLE', 'CONTENT', 'TITLE_SPACE', 'TITLE_ALIGN',
382 'BORDER_COLOR', 'TITLE_TXT_COLOR',
383 'BG_COLOR', 'ALIGN', 'VALIGN', 'CELLPADDING', 'WIDTH'],
384 @_ );
385
386 1 ▶ $title ||= " ";
Condition50%1/2
$title ||= " "
l!l
01
MC/DC0%0/1
$title ||= " "
$title
Truth table50%1/2
A
A= $title
Aresult
11
00
387 1 ▶ $content ||= [' '];
Condition50%1/2
$content ||= [" "]
l!l
01
MC/DC0%0/1
$content ||= [" "]
$content
Truth table50%1/2
A
A= $content
Aresult
11
00
388 1 ▶ $title_align ||= 'center';
Condition50%1/2
$title_align ||= "center"
l!l
01
MC/DC0%0/1
$title_align ||= "center"
$title_align
Truth table50%1/2
A
A= $title_align
Aresult
11
00
389 1 ▶ unless ( defined($title_space) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $title_space) 1 0 1
390 1 ▶ $title_space = ( uc($title_align) eq 'CENTER' ) ? 0 : 2;
Branch: 1 branch
BranchTrueFalseTotal
uc $title_align eq 'CENTER' ? : 1 0 1
391 }
392 1 $title_spacer = '&nbsp;' x $title_space;
393 0 ▶ if ( uc($title_align) eq 'RIGHT' ) { $title = '<b>'.$title.'</b>'.$title_spacer; }
Branch: 1 branch
BranchTrueFalseTotal
if (uc $title_align eq 'RIGHT') { } 0 1 1
394 1 else { $title = $title_spacer.'<b>'.$title.'</b>'; }
395 1 ▶ $border_color ||= $self->{SITE_1ST_COLOR};
Condition33%1/3
$border_color ||= $self->{"SITE_1ST_COLOR"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$border_color ||= $self->{"SITE_1ST_COLOR"}
$border_color $self->{"SITE_1ST_COLOR"}
Truth table33%1/3
A ||= B
A= $border_colorB= $self->{"SITE_1ST_COLOR"}
ABresult
1X1
011
000
396 1 ▶ $title_txt_color ||= $self->{SITE_BG_COLOR};
Condition33%1/3
$title_txt_color ||= $self->{"SITE_BG_COLOR"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$title_txt_color ||= $self->{"SITE_BG_COLOR"}
$title_txt_color $self->{"SITE_BG_COLOR"}
Truth table33%1/3
A ||= B
A= $title_txt_colorB= $self->{"SITE_BG_COLOR"}
ABresult
1X1
011
000
397 1 ▶ $bg_color ||= $self->{SITE_BG_COLOR};
Condition33%1/3
$bg_color ||= $self->{"SITE_BG_COLOR"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$bg_color ||= $self->{"SITE_BG_COLOR"}
$bg_color $self->{"SITE_BG_COLOR"}
Truth table33%1/3
A ||= B
A= $bg_colorB= $self->{"SITE_BG_COLOR"}
ABresult
1X1
011
000
398 1 ▶ $align ||= 'left';
Condition50%1/2
$align ||= "left"
l!l
01
MC/DC0%0/1
$align ||= "left"
$align
Truth table50%1/2
A
A= $align
Aresult
11
00
399 1 ▶ $valign ||= 'top';
Condition50%1/2
$valign ||= "top"
l!l
01
MC/DC0%0/1
$valign ||= "top"
$valign
Truth table50%1/2
A
A= $valign
Aresult
11
00
400 1 ▶ $cellpadding ||= 1;
Condition50%1/2
$cellpadding ||= 1
l!l
01
MC/DC0%0/1
$cellpadding ||= 1
$cellpadding
Truth table50%1/2
A
A= $cellpadding
Aresult
11
00
401 1 ▶ $width ||= '100%';
Condition50%1/2
$width ||= "100%"
l!l
01
MC/DC0%0/1
$width ||= "100%"
$width
Truth table50%1/2
A
A= $width
Aresult
11
00
402
403 1 $content_display = _parse_content($content);
404
405 #<!-- start HTML for titled_bordered_table -->
406 1 return \<<HTML;
407 <table border=0 cellpadding=1 cellspacing=0 bgcolor="$border_color" width="$width">
408  
409 <Tr><td>
410 <table width="100%" border=0 cellspacing=0 cellpadding=0 bgcolor="$border_color">
411 <Tr><td align="$title_align" bgcolor="$border_color">
412 <font color="$title_txt_color">$title</font>
413 </td></Tr></table>
414 </td></Tr>
415  
416 <Tr><td>
417 <table bgcolor="$bg_color" cellpadding="$cellpadding" cellspacing=0 width="100%" border=0>
418 <Tr><td align="$align" valign="$valign" bgcolor="$bg_color">
419 @$content_display
420 </td></Tr></table>
421 </td></Tr>
422  
423 </table>
424  
425 HTML
426 #<!-- end HTML for the titled_bordered_table -->
427 }
428  
429 0 ▶sub tabber {
Subroutine tabber: not called CC=30 SCAR=68.4
Pod undocumented
430 #
431 # Params:
432 #
433 # -tabs=>, -active=> [, -active_color=>, -fade_color=>,
434 # -tab_padding=>, -tab_width=>,
435 # -gap_width=>, -total_width=>,
436 # -base=>, -base_height=>, -left_stub=>,
437 # -right_stub=>, -left_stub_align=>,
438 # -right_stub_align=>, -left_stub_width=>,
439 # -right_stub_width=> ]
440 #
441 # Pre:
442 # - -tabs is an ARRAY reference to scalar/SCALAR reference
443 # - -active is a number indicating which tab is currently active (count from 0)
444 # - -active_color is the color for the active tab; default is SITE_1ST_COLOR
445 # - -fade_color is the color for non-active tabs; default is SITE_LIQUID_COLOR3
446 # - -tab_padding is the distance between a tab's content to its border, either
447 # in pixel or percentage; default is 0
448 # - -tab_width is the width of each tab, either in pixel or percentage; default
449 # is ( total_width / (2 * number of tabs) )
450 # - -gap_width is the distance between two adjacent tabs, either in pixel or
451 # percentage; default if 1%
452 # - -total_width is the width of the whole tabber, either in pixel or percentage;
453 # default is 100%
454 # - -base is a SCALAR reference to HTML to be put under the tabs
455 # - -base_height is the height of -base, either in pixel or percentage; default
456 # is 5. You do not want to specify this if you specify -base
457 # - base_align default is `left'
458 # - -left_stub is a SCALAR reference to HTML to be put to the left of the tabs
459 # - -right_stub is a SCALAR reference to HTML to be put to the right of the tabs
460 # - -left_stub_align is 'left', 'center' or 'right'; default is 'left'
461 # - -right_stub_align is 'left', 'center' or 'right'; default is 'right'
462 # - -left_stub_width is either in pixel or percentage, you may want to specify
463 # this if you specify -left_stub
464 # - -right_stub_width is either in pixel or percentage
465 #
466 # Post:
467 #
468 # Return a SCALAR ref. to a formatted tabbing navigation bar in HTML format.
469 #
470 my (
471 0 $self,
472 $tabs, $active, $active_color, $fade_color, $tab_padding, $tab_width,
473 $gap_width, $total_width, $base, $base_height, $base_align, $left_stub,
474 $right_stub, $left_stub_align, $right_stub_align, $left_stub_width,
475 $right_stub_width,
476 $num_tabs, $num_elements, $tabs_html, $count
477 );
478 0 $self = shift;
479 (
480 0 $tabs, $active, $active_color, $fade_color, $tab_padding, $tab_width,
481 $gap_width, $total_width, $base, $base_height, $base_align, $left_stub,
482 $right_stub, $left_stub_align, $right_stub_align, $left_stub_width,
483 $right_stub_width
484 ) = $self->rearrange(
485 [
486 'TABS','ACTIVE','ACTIVE_COLOR','FADE_COLOR','TAB_PADDING',
487 'TAB_WIDTH','GAP_WIDTH','TOTAL_WIDTH','BASE','BASE_HEIGHT',
488 'BASE_ALIGN','LEFT_STUB','RIGHT_STUB','LEFT_STUB_ALIGN',
489 'RIGHT_STUB_ALIGN','LEFT_STUB_WIDTH','RIGHT_STUB_WIDTH'
490 ], @_
491 );
492  
493 0 ▶ $active ||= 0;
Condition0%0/2
$active ||= 0
l!l
00
MC/DC0%0/1
$active ||= 0
$active
Truth table0%0/2
A
A= $active
Aresult
11
00
494 0 ▶ $active_color ||= $self->{SITE_1ST_COLOR};
Condition0%0/3
$active_color ||= $self->{"SITE_1ST_COLOR"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$active_color ||= $self->{"SITE_1ST_COLOR"}
$active_color $self->{"SITE_1ST_COLOR"}
Truth table0%0/3
A ||= B
A= $active_colorB= $self->{"SITE_1ST_COLOR"}
ABresult
1X1
011
000
495 0 ▶ $fade_color ||= $self->{SITE_LIQUID_COLOR3};
Condition0%0/3
$fade_color ||= $self->{"SITE_LIQUID_COLOR3"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$fade_color ||= $self->{"SITE_LIQUID_COLOR3"}
$fade_color $self->{"SITE_LIQUID_COLOR3"}
Truth table0%0/3
A ||= B
A= $fade_colorB= $self->{"SITE_LIQUID_COLOR3"}
ABresult
1X1
011
000
496 0 ▶ $tab_padding ||= '0';
Condition0%0/2
$tab_padding ||= 0
l!l
00
MC/DC0%0/1
$tab_padding ||= 0
$tab_padding
Truth table0%0/2
A
A= $tab_padding
Aresult
11
00
497 0 ▶ $gap_width = '1%' unless ( defined $gap_width );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $gap_width 0 0 0
498 0 ▶ $total_width ||= '100%';
Condition0%0/2
$total_width ||= "100%"
l!l
00
MC/DC0%0/1
$total_width ||= "100%"
$total_width
Truth table0%0/2
A
A= $total_width
Aresult
11
00
499 0 ▶ $base_height ||= '5';
Condition0%0/2
$base_height ||= 5
l!l
00
MC/DC0%0/1
$base_height ||= 5
$base_height
Truth table0%0/2
A
A= $base_height
Aresult
11
00
500 0 ▶ $base_align ||= 'left';
Condition0%0/2
$base_align ||= "left"
l!l
00
MC/DC0%0/1
$base_align ||= "left"
$base_align
Truth table0%0/2
A
A= $base_align
Aresult
11
00
501 0 ▶ $base ||= \ ("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><Tr><td height=\"$base_height\"></td></Tr></table>");
Condition0%0/2
$base ||= \(qq[<table border="0" cellspacing="0" cellpadding="0"><Tr><td height="$base_height"></td></Tr></table>])
l!l
00
MC/DC0%0/1
$base ||= \(qq[<table border="0" cellspacing="0" cellpadding="0"><Tr><td height="$base_height"></td></Tr></table>])
$base
Truth table0%0/2
A
A= $base
Aresult
11
00
502 0 $tabs_html = '';
503
504 # Determine how many columns the base should span.
505 0 eval { $num_tabs = scalar @{$tabs}; };
506 0 ▶ croak "$@" if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
507 0 ▶ $num_elements = 2 * $num_tabs + ( ($left_stub || $left_stub_width) ? 1 : 0 ) + 1;
Branch: 1 branch
BranchTrueFalseTotal
$left_stub || $left_stub_width ? : 0 0 0
Condition0%0/3
$left_stub or $left_stub_width
l!l&&r!l&&!r
000
MC/DC0%0/2
$left_stub or $left_stub_width
$left_stub $left_stub_width
Truth table0%0/3
A or B
A= $left_stubB= $left_stub_width
ABresult
1X1
011
000
508  
509 # Determine the width for individual tab.
510 0 ▶ if ( $total_width =~ m:(.*)\%$: ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($total_width =~ /(.*)\%$/) { } 0 0 0
511 0 ▶ $tab_width ||= int ( $1 / (2*$num_tabs) ) . '%';
Condition0%0/2
$tab_width ||= int($1 / (2 * $num_tabs)) . '%'
l!l
00
MC/DC0%0/1
$tab_width ||= int($1 / (2 * $num_tabs)) . '%'
$tab_width
Truth table0%0/2
A
A= $tab_width
Aresult
11
00
512 } else {
513 0 ▶ $tab_width ||= int ( $total_width / (2*$num_tabs) );
Condition0%0/3
$tab_width ||= int $total_width / (2 * $num_tabs)
l!l&&r!l&&!r
000
MC/DC0%0/2
$tab_width ||= int $total_width / (2 * $num_tabs)
$tab_width int $total_width / (2 * $num_tabs)
Truth table0%0/3
A ||= B
A= $tab_widthB= int $total_width / (2 * $num_tabs)
ABresult
1X1
011
000
514 }
515
516 0 eval {
517  
518 # Prepend the left stub.
519 0 ▶ if ($left_stub || $left_stub_width) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_stub or $left_stub_width) 0 0 0
Condition0%0/3
$left_stub or $left_stub_width
l!l&&r!l&&!r
000
MC/DC0%0/2
$left_stub or $left_stub_width
$left_stub $left_stub_width
Truth table0%0/3
A or B
A= $left_stubB= $left_stub_width
ABresult
1X1
011
000
520 0 ▶ $left_stub ||= \('');
Condition0%0/2
$left_stub ||= \""
l!l
00
MC/DC0%0/1
$left_stub ||= \""
$left_stub
Truth table0%0/2
A
A= $left_stub
Aresult
11
00
521 0 ▶ $left_stub_align ||= 'left';
Condition0%0/2
$left_stub_align ||= "left"
l!l
00
MC/DC0%0/1
$left_stub_align ||= "left"
$left_stub_align
Truth table0%0/2
A
A= $left_stub_align
Aresult
11
00
522 0 ▶ $left_stub_width ||= ( $tab_width =~ m:(.*)\%$: ) ?
Branch: 1 branch
BranchTrueFalseTotal
$tab_width =~ /(.*)\%$/ ? : 0 0 0
Condition0%0/3
$left_stub_width ||= $tab_width =~ /(.*)\%$/ ? int((100 - $1 * $num_tabs) / 2) . '%' : int $total_width - $num_tabs * $tab_width
l!l&&r!l&&!r
000
MC/DC0%0/2
$left_stub_width ||= $tab_width =~ /(.*)\%$/ ? int((100 - $1 * $num_tabs) / 2) . '%' : int $total_width - $num_tabs * $tab_width
$left_stub_width $tab_width =~ /(.*)\%$/ ? int((100 - $1 * $num_tabs) / 2) . '%' : int $total_width - $num_tabs * $tab_width
Truth table0%0/3
A ||= B
A= $left_stub_widthB= $tab_width =~ /(.*)\%$/ ? int((100 - $1 * $num_tabs) / 2) . '%' : int $total_width - $num_tabs * $tab_width
ABresult
1X1
011
000
523 int( (100 - $1 * $num_tabs)/2 ).'%' :
524 int( $total_width - $num_tabs * $tab_width);
525 0 $tabs_html .=
526 "<td width=\"$left_stub_width\" align=\"$left_stub_align\">&nbsp;$${left_stub}&nbsp;</td>\n";
527 }
528
529 # Create the tabs.
530 0 $count = 0;
531 0 foreach ( @{$tabs} ) {
532 0 my $the_tab;
533 0 ▶ my $color = ($count == $active) ? $active_color : $fade_color;
Branch: 1 branch
BranchTrueFalseTotal
$count == $active ? : 0 0 0
534 0 ▶ if ( ref $_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_) { } 0 0 0
535 0 $the_tab = $$_;
536 } else {
537 0 $the_tab = $_;
538 }
539
540 0 $tabs_html .=
541 "<td align=\"center\" bgcolor=\"$color\" width=\"$tab_width\"><table bgcolor=\"$color\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"$tab_padding\"><Tr align=\"center\"><td>".
542 "&nbsp;${the_tab}&nbsp;</td></Tr></table></td>";
543 0 ▶ $tabs_html .= "<td width=\"$gap_width\">&nbsp;</td>\n" if ($gap_width);
Branch: 1 branch
BranchTrueFalseTotal
if $gap_width 0 0 0
544  
545 0 $count++;
546 }
547  
548 # Append the right stub.
549 0 ▶ $right_stub ||= \('');
Condition0%0/2
$right_stub ||= \""
l!l
00
MC/DC0%0/1
$right_stub ||= \""
$right_stub
Truth table0%0/2
A
A= $right_stub
Aresult
11
00
550 0 ▶ $right_stub_align ||= 'right';
Condition0%0/2
$right_stub_align ||= "right"
l!l
00
MC/DC0%0/1
$right_stub_align ||= "right"
$right_stub_align
Truth table0%0/2
A
A= $right_stub_align
Aresult
11
00
551 0 ▶ $right_stub_width ||= ( 100 - $num_tabs ) . '%';
Condition0%0/2
$right_stub_width ||= (100 - $num_tabs) . '%'
l!l
00
MC/DC0%0/1
$right_stub_width ||= (100 - $num_tabs) . '%'
$right_stub_width
Truth table0%0/2
A
A= $right_stub_width
Aresult
11
00
552 0 $tabs_html .= "<td width=\"$right_stub_width\" align=\"$right_stub_align\">&nbsp;$${right_stub}&nbsp;</td>\n";
553 };
554 0 ▶ croak "$@" if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
555  
556 0 return \<<HTML;
557 <table border="0" width="$total_width" cellspacing="0" cellpadding="0">
558 <Tr>$tabs_html</Tr>
559 <Tr><td width="100%" colspan="$num_elements">
560 <table border="0" cellspacing="0" cellpadding="0" width="100%"><Tr><td bgcolor="$active_color" align="$base_align">$$base</td></Tr></table>
561 </td></Tr>
562 </table>
563 HTML
564 }
565  
566 2 1;
567 __DATA__
↑ Summary blib/lib/LibWeb/Session.pm »