| 1 | package App::ZofCMS::Plugin::TOC; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '1.001010'; # VERSION | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use HTML::Template; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 0 | ▶ | sub new { return bless {}, shift; } | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 0 | my ( $self, $template, $query, $config ) = @_; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | return | ||||||||||||||||||||||||||||
| 16 | 0 | ▶ | unless $template->{page_toc}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | my $html = <<"END_HTML"; | |||||||||||||||||||||||||||
| 19 | <ul class="page_toc"> | ||||||||||||||||||||||||||||
| 20 | <tmpl_loop name="toc">\t<li<tmpl_if name="class"> class="<tmpl_var name="class">"</tmpl_if>><a href="<tmpl_var name="url">"><tmpl_var name="name"></a></li> | ||||||||||||||||||||||||||||
| 21 | </tmpl_loop></ul> | ||||||||||||||||||||||||||||
| 22 | END_HTML | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | my $t = HTML::Template->new_scalar_ref( \$html ); | |||||||||||||||||||||||||||
| 25 | $t->param( | ||||||||||||||||||||||||||||
| 26 | toc => [ | ||||||||||||||||||||||||||||
| 27 | map +{ | ||||||||||||||||||||||||||||
| 28 | url => $_->[0], | ||||||||||||||||||||||||||||
| 29 | name => $_->[1], | ||||||||||||||||||||||||||||
| 30 | class => $_->[2], | ||||||||||||||||||||||||||||
| 31 | 0 | }, map $self->_make_entry, @{ delete $template->{page_toc} }, | |||||||||||||||||||||||||||
| 32 | ], | ||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | $template->{t}{page_toc} = $t->output; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | return; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub _make_entry { | ||||||||||||||||||||||||||
|
Subroutine
_make_entry: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ( not ref or @$_ == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $_ or @$_ == 1
MC/DC0%0/2
not ref $_ or @$_ == 1
not ref $_
@$_ == 1
Truth table0%0/3
not(A) or B
A= not ref $_B= @$_ == 1
| |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $_ = [ $_ ] unless ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | my $name = $_->[0]; | |||||||||||||||||||||||||||
| 45 | 0 | $name =~ s/^#//; | |||||||||||||||||||||||||||
| 46 | 0 | $name = ucfirst $name; | |||||||||||||||||||||||||||
| 47 | 0 | $name =~ s/[-_](.)/ \u$1/g; | |||||||||||||||||||||||||||
| 48 | 0 | $_->[1] = $name; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | 0 | return $_; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 1 | 1; | |||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||