| 1 | # Zet Maximum template parser | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # 2002-2009 | ||||||||||||||||||||||||||||
| 4 | # Version 0.7.2 production | ||||||||||||||||||||||||||||
| 5 | # Author Maxim Kashliak (max@zmaximum.ru) | ||||||||||||||||||||||||||||
| 6 | # Aleksey V. Ivanov (avimail@zmaximum.ru) | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # For latest releases, documentation, faqs, etc see the homepage at | ||||||||||||||||||||||||||||
| 9 | # http://perl.zmaximum.ru | ||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||
| 12 | package ZM::Template; | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use vars qw($AUTOLOAD); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | $ZM::Template::VERSION = '0.7.2'; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | sub new() | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 25 | 0 | my %baseHtml=@_; | |||||||||||||||||||||||||||
| 26 | 0 | ▶ | $baseHtml{tag}="__" if (!defined $baseHtml{tag} || $baseHtml{tag} eq ""); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $baseHtml{"tag"} or $baseHtml{"tag"} eq ""
MC/DC0%0/2
not defined $baseHtml{"tag"} or $baseHtml{"tag"} eq ""
not defined $baseHtml{"tag"}
$baseHtml{"tag"} eq ""
Truth table0%0/3
not(A) or B
A= not defined $baseHtml{"tag"}B= $baseHtml{"tag"} eq ""
| |||||||||||||||||||||||||||||
| 27 | 0 | $baseHtml{_loops_filled}=0; | |||||||||||||||||||||||||||
| 28 | 0 | bless \%baseHtml, $class; | |||||||||||||||||||||||||||
| 29 | 0 | return \%baseHtml | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | sub src() | ||||||||||||||||||||||||||||
| 33 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
src: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ($#_ !=1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||
| 36 | 0 | die_msg("Error! template function requires a single parameter\n"); | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 40 | 0 | my $src = shift; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | my $suxx=$/; | |||||||||||||||||||||||||||
| 43 | 0 | undef $/; | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | open(HTML, "<$src") || die_msg("Cannot open html template file!<br>($src)"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | my $tmplString = <HTML>; | |||||||||||||||||||||||||||
| 46 | 0 | close HTML; | |||||||||||||||||||||||||||
| 47 | 0 | $/=$suxx; | |||||||||||||||||||||||||||
| 48 | # ÏÂÒÁÂÏÔËÁ SSI ÄÅÒÅËÔÉ× ×ÎÕÔÒÉ ÔÅÍÐÌÅÊÔÁ | ||||||||||||||||||||||||||||
| 49 | 0 | eval('require ZM::SSI;'); | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | $tmplString = ZM::SSI::parse($tmplString) unless $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | # ÚÁÄÁÅÍ ÐÁÐËÕ ÄÌÑ ÈÒÁÎÅÎÉÑ ËÅÛÁ, ÅÓÌÉ ÏÎÁ ÎÅ ÂÙÌÁ ÕËÁÚÁÎÁ ÐÒÉ ÓÏÚÄÁÎÉÉ ÏÂßÅËÔÁ | ||||||||||||||||||||||||||||
| 52 | 0 | ▶ | unless (defined $self->{cacheDIR}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||
| 54 | 0 | $src=~s/\/.*?$//; | |||||||||||||||||||||||||||
| 55 | 0 | $self->{cacheDIR}=$src.'/cache'; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | $self->srcString($tmplString); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | sub srcString | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
srcString: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 63 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 64 | 0 | my $str = shift; | |||||||||||||||||||||||||||
| 65 | 0 | $self->{html}=$str; | |||||||||||||||||||||||||||
| 66 | 0 | _parse_tokens($self,$str); | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | sub srcStringSSI | ||||||||||||||||||||||||||||
| 69 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
srcStringSSI: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 70 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 71 | 0 | my $str = shift; | |||||||||||||||||||||||||||
| 72 | 0 | eval('require ZM::SSI;'); | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | $str = ZM::SSI::parse($str) unless $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | $self->{html}=$str; | |||||||||||||||||||||||||||
| 75 | 0 | _parse_tokens($self,$str); | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | sub listAllTokens | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
listAllTokens: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 82 | 0 | return(keys %{$self->{tokens}}); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | sub _parse_tokens | ||||||||||||||||||||||||||||
| 86 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_parse_tokens: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 87 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 88 | 0 | my $htmlString=shift; | |||||||||||||||||||||||||||
| 89 | 0 | my ($padding, $token, $remainder); | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | # while ($htmlString =~ /.*?(($self->{tag}x_.+?$self->{tag}\n)|($self->{tag}([^_]).*?$self->{tag}))/sg) | ||||||||||||||||||||||||||||
| 92 | # while ($htmlString =~ /.*?$self->{tag}((x_)?.+?)$self->{tag}/sg) #orig | ||||||||||||||||||||||||||||
| 93 | 0 | ▶ | while ($htmlString =~ /.*?$self->{tag}([\da-zA-Z]([\_\-]*[\da-zA-Z])*?)$self->{tag}/sg) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||
| 95 | 0 | $token = $1; | |||||||||||||||||||||||||||
| 96 | 0 | $token =~ s/\n$//g; # chomp $token (chomp bust as $/ undef'd) | |||||||||||||||||||||||||||
| 97 | # $token =~ s/(^$self->{tag}|$self->{tag}$)//g; | ||||||||||||||||||||||||||||
| 98 | 0 | $self->{tokens}{$token}=1; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | sub AUTOLOAD | ||||||||||||||||||||||||||||
| 103 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 104 | 0 | my $token = $AUTOLOAD; | |||||||||||||||||||||||||||
| 105 | 0 | my ($self, $value, $block) = @_; | |||||||||||||||||||||||||||
| 106 | 0 | $token =~ s/.*:://; | |||||||||||||||||||||||||||
| 107 | # ÚÄÅÓØ ÎÁÄÏ ÐÒÏ×ÅÒÉÔØ ÎÅ ×ÙÇÌÑÄÉÔ ÌÉ ÎÁÛÁ ÚÁÍÅÎÁ ËÁË ÔÏËÅÎ, ÉÎÁÞÅ ÏÎÁ ÓÏÔÒÅÔÓÑ × ÐÏÓÌÅÄÓÔ×ÉÉ | ||||||||||||||||||||||||||||
| 108 | #while ($value =~ /.*?$self->{tag}([^_].*?)$self->{tag}/s) | ||||||||||||||||||||||||||||
| 109 | #{ | ||||||||||||||||||||||||||||
| 110 | # my $vtoken = $1; | ||||||||||||||||||||||||||||
| 111 | # $vtoken =~ s/\n$//g; | ||||||||||||||||||||||||||||
| 112 | # $nottokens{$vtoken}=1; | ||||||||||||||||||||||||||||
| 113 | #} | ||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if (defined $self->{tokens}{$token}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if (defined $block and $block ne "") | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $block and $block ne ""
MC/DC0%0/2
defined $block and $block ne ""
defined $block
$block ne ""
Truth table0%0/3
A and B
A= defined $blockB= $block ne ""
| |||||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||||
| 118 | 0 | my $bl_new=$block."_new"; | |||||||||||||||||||||||||||
| 119 | 0 | $bl_new=~s/^x_//; #ÎÁÄÏ ÏÂÏÊÔÉÓØ ÂÅÚ ÒÅÇÅËÓÐÁ | |||||||||||||||||||||||||||
| 120 | 0 | my $loop; | |||||||||||||||||||||||||||
| 121 | 0 | ▶ | if (defined $self->{loops}{$bl_new}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | { | ||||||||||||||||||||||||||||
| 123 | 0 | my $flag=0; | |||||||||||||||||||||||||||
| 124 | 0 | foreach $loop(@{$self->{loops}{$bl_new}}) | |||||||||||||||||||||||||||
| 125 | { | ||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if(strstr($loop,"$self->{tag}".$token."$self->{tag}")) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | { | ||||||||||||||||||||||||||||
| 128 | 0 | $flag++; | |||||||||||||||||||||||||||
| 129 | 0 | last; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 0 | ▶ | $self->_post_loop($block) unless($flag); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | 0 | $self->_set_loop($token,$value,$block); | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | else | ||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||
| 138 | 0 | $self->{html}=$self->set_to_str($token,$value,$self->{html}); | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | sub setif | ||||||||||||||||||||||||||||
| 144 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
setif: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 145 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 146 | 0 | my $token = shift; | |||||||||||||||||||||||||||
| 147 | 0 | my $loop = shift; | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if(!defined $loop or $loop eq "") | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $loop or $loop eq ""
MC/DC0%0/2
not defined $loop or $loop eq ""
not defined $loop
$loop eq ""
Truth table0%0/3
not(A) or B
A= not defined $loopB= $loop eq ""
| |||||||||||||||||||||||||||||
| 150 | { | ||||||||||||||||||||||||||||
| 151 | 0 | $self->{ifs}->{$token}=1; | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | else | ||||||||||||||||||||||||||||
| 154 | { | ||||||||||||||||||||||||||||
| 155 | 0 | $self->{ifs_loop}->{$loop}->{$token}=1; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | sub delif | ||||||||||||||||||||||||||||
| 160 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
delif: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 161 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 162 | 0 | my $token = shift; | |||||||||||||||||||||||||||
| 163 | 0 | my $loop = shift; | |||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if(!defined $loop or $loop eq "") | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $loop or $loop eq ""
MC/DC0%0/2
not defined $loop or $loop eq ""
not defined $loop
$loop eq ""
Truth table0%0/3
not(A) or B
A= not defined $loopB= $loop eq ""
| |||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||
| 167 | 0 | delete $self->{ifs}->{$token}; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | else | ||||||||||||||||||||||||||||
| 170 | { | ||||||||||||||||||||||||||||
| 171 | 0 | delete $self->{ifs_loop}->{$loop}->{$token}; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | sub fromfile | ||||||||||||||||||||||||||||
| 176 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
fromfile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 177 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 178 | 0 | my $token = shift; | |||||||||||||||||||||||||||
| 179 | 0 | my $file = shift; | |||||||||||||||||||||||||||
| 180 | 0 | my $block = shift; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 0 | ▶ | open (my $f,"<$file") or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | my $suxx=$/; | |||||||||||||||||||||||||||
| 184 | 0 | undef $/; | |||||||||||||||||||||||||||
| 185 | 0 | my $filecontent=<$f>; | |||||||||||||||||||||||||||
| 186 | 0 | $/=$suxx; | |||||||||||||||||||||||||||
| 187 | 0 | close($f); | |||||||||||||||||||||||||||
| 188 | 0 | $self->$token($filecontent,$block); | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | sub _set_loop | ||||||||||||||||||||||||||||
| 192 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_set_loop: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||
| 193 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 194 | 0 | my $token=shift; | |||||||||||||||||||||||||||
| 195 | 0 | my $value=shift; | |||||||||||||||||||||||||||
| 196 | 0 | my $block=shift; | |||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 0 | $block=~s/^x_//; | |||||||||||||||||||||||||||
| 199 | 0 | my ($loop, $loop_name, $loop_begin, $num, $loop2, $loop3, $loop_after, $loops_ref); | |||||||||||||||||||||||||||
| 200 | 0 | my @loops=(); | |||||||||||||||||||||||||||
| 201 | 0 | ▶ | if(defined $self->{loops}{$block."_new"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||
| 203 | # ÅÓÌÉ ÕÖÅ ×ÙÓÔÁ×ÌÑÌÉÓØ ÔÏËÅÎÙ × ÜÔÏÍ ÃÉËÌÅ | ||||||||||||||||||||||||||||
| 204 | 0 | $loops_ref=$self->{loops}{$block."_new"}; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | else | ||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||
| 208 | # ÅÓÌÉ ÅÝÅ ÎÅ ×ÓÔÁ×ÌÑÌÉÓØ ÔÏËÅÎÙ × ÜÔÏÍ ÃÉËÌÅ, | ||||||||||||||||||||||||||||
| 209 | # ÔÏ ×ÙÄÉÒÁÅÍ ÔÅÌÏ ÃÉËÌÁ ÉÚ ×ÓÅÇÏ ÛÁÂÌÏÎÁ | ||||||||||||||||||||||||||||
| 210 | 0 | $loop_name="$self->{tag}x_".$block."$self->{tag}"; | |||||||||||||||||||||||||||
| 211 | # ÍÙ ÉÝÅÍ ×ÓÅ ÃÉËÌÙ Ó ÔÁËÉÍ ÉÍÅÎÅÍ ×Ï ×ÓÅÍ ÄÏËÕÍÅÎÔÅ | ||||||||||||||||||||||||||||
| 212 | 0 | $loop_after=$self->{html}; | |||||||||||||||||||||||||||
| 213 | 0 | ▶ | while($loop_begin=strstr($loop_after,$loop_name)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||
| 215 | 0 | $loop_begin=substr($loop_begin,length($loop_name)); | |||||||||||||||||||||||||||
| 216 | 0 | ($loop,$loop_after)=str_split($loop_begin,$loop_name); | |||||||||||||||||||||||||||
| 217 | 0 | push(@{$loops_ref},$loop); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | 0 | my $loop_number=0; | |||||||||||||||||||||||||||
| 221 | 0 | foreach $loop(@$loops_ref) | |||||||||||||||||||||||||||
| 222 | { | ||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if(strstr($loop,"$self->{tag}z_".$block."$self->{tag}")) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||
| 225 | 0 | $self->{strnum}{$block}++; | |||||||||||||||||||||||||||
| 226 | 0 | $num=$self->{strnum}{$block}; | |||||||||||||||||||||||||||
| 227 | 0 | $loop2=$loop3=$loop; | |||||||||||||||||||||||||||
| 228 | 0 | ▶ | while(($num)&&(($loop2=str_before($loop3,"$self->{tag}z_".$block."$self->{tag}")) ne $loop3)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$num and ($loop2 = str_before($loop3, qq[$self->{"tag"}z_] . $block . qq[$self->{"tag"}])) ne $loop3
MC/DC0%0/2
$num and ($loop2 = str_before($loop3, qq[$self->{"tag"}z_] . $block . qq[$self->{"tag"}])) ne $loop3
$num
($loop2 = str_before($loop3, qq[$self->{"tag"}z_] . $block . qq[$self->{"tag"}])) ne $loop3
Truth table0%0/3
A and B
A= $numB= ($loop2 = str_before($loop3, qq[$self->{"tag"}z_] . $block . qq[$self->{"tag"}])) ne $loop3
| |||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||
| 230 | 0 | $num--; | |||||||||||||||||||||||||||
| 231 | 0 | $loop3=str_after($loop3,"$self->{tag}z_".$block."$self->{tag}"); | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if($num==0) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 234 | { | ||||||||||||||||||||||||||||
| 235 | 0 | $loop=$loop2; | |||||||||||||||||||||||||||
| 236 | #$self->{strnum}{$block}++; | ||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | elsif($num>=1) | ||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||
| 240 | #$loop=str_before($loop,"$self->{tag}z_".$block."$self->{tag}"); | ||||||||||||||||||||||||||||
| 241 | 0 | $loop=$loop3; | |||||||||||||||||||||||||||
| 242 | 0 | $self->{strcount}{$block}=$self->{strnum}{$block}-1; #ÚÁÐÏÍÎÉÍ ÎÏÍÅÒ ÐÏÓÌÅÄÎÅÇÏ ÂÌÏËÁ ÐÅÒÅÄ ÐÅÒÅÈÏÄÏÍ ÎÁ ÐÅÒ×ÙÊ | |||||||||||||||||||||||||||
| 243 | 0 | $self->{strnum}{$block}=0; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | 0 | $self->{loops}{$block.'_new'}[$loop_number]=$self->set_to_str($token,$value,$loop); | |||||||||||||||||||||||||||
| 247 | 0 | $loop_number++; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | sub _post_loop | ||||||||||||||||||||||||||||
| 252 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_post_loop: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 253 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 254 | 0 | my $block=shift; | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | $block=~s/^x_//; | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | my ($text,$pos, $before_loop, $loop, $loop_name, $after_loop); | |||||||||||||||||||||||||||
| 259 | 0 | my $loop_number; | |||||||||||||||||||||||||||
| 260 | 0 | ▶ | if($self->{strnum}{$block}>1) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 261 | { | ||||||||||||||||||||||||||||
| 262 | 0 | $loop_number=$self->{strnum}{$block}-1; | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | ▶ | elsif(defined $self->{strnum}{$block} && $self->{strnum}{$block}==0) | |||||||||||||||||||||||||||
|
Condition0%0/3
defined $self->{"strnum"}{$block} and $self->{"strnum"}{$block} == 0
MC/DC0%0/2
defined $self->{"strnum"}{$block} and $self->{"strnum"}{$block} == 0
defined $self->{"strnum"}{$block}
$self->{"strnum"}{$block} == 0
Truth table0%0/3
A and B
A= defined $self->{"strnum"}{$block}B= $self->{"strnum"}{$block} == 0
| |||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||
| 266 | 0 | $loop_number=$self->{strcount}{$block}; | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | else | ||||||||||||||||||||||||||||
| 269 | { | ||||||||||||||||||||||||||||
| 270 | 0 | $loop_number=0; | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | 0 | my $i=0; | |||||||||||||||||||||||||||
| 273 | 0 | foreach $text (@{$self->{loops}{$block."_new"}}) | |||||||||||||||||||||||||||
| 274 | { | ||||||||||||||||||||||||||||
| 275 | #Find and post inner loops | ||||||||||||||||||||||||||||
| 276 | 0 | my %found_loops; | |||||||||||||||||||||||||||
| 277 | 0 | ▶ | while($pos=strstr($text,"$self->{tag}x_")) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 278 | { | ||||||||||||||||||||||||||||
| 279 | 0 | $before_loop=substr($text,0,length($text)-length($pos)); | |||||||||||||||||||||||||||
| 280 | 0 | $loop_name=substr($pos,4); | |||||||||||||||||||||||||||
| 281 | 0 | $loop_name=substr($loop_name,0,length($loop_name)-length(strstr($loop_name,"$self->{tag}"))); | |||||||||||||||||||||||||||
| 282 | 0 | $loop=strstr($text,"$self->{tag}x_".$loop_name."$self->{tag}"); | |||||||||||||||||||||||||||
| 283 | 0 | $after_loop=str_after(str_after($loop,"$self->{tag}x_".$loop_name."$self->{tag}"),"$self->{tag}x_".$loop_name."$self->{tag}"); | |||||||||||||||||||||||||||
| 284 | 0 | $loop=substr($loop,0,length($loop)-length($after_loop)); | |||||||||||||||||||||||||||
| 285 | 0 | ▶ | $self->_post_loop($loop_name) if (defined $self->{loops}{$loop_name.'_new'}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | 0 | $found_loops{$loop_name}++; | |||||||||||||||||||||||||||
| 287 | 0 | $text=$before_loop.$self->{loops}{$loop_name}[$loop_number].$after_loop; | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | # delete inner loops | ||||||||||||||||||||||||||||
| 290 | 0 | foreach $loop_name (keys %found_loops) | |||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||
| 292 | 0 | delete $self->{loops}{$loop_name}; | |||||||||||||||||||||||||||
| 293 | 0 | delete $self->{strnum}{$loop_name}; | |||||||||||||||||||||||||||
| 294 | 0 | delete $self->{strcount}{$loop_name}; | |||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | 0 | $text=_fill_ifs($self,$text,'x_'.$block); | |||||||||||||||||||||||||||
| 297 | #$self->{loops}{$block."_new"}=$text; | ||||||||||||||||||||||||||||
| 298 | #POST | ||||||||||||||||||||||||||||
| 299 | 0 | $self->{loops}{$block}[$i] .= $text; | |||||||||||||||||||||||||||
| 300 | 0 | $i++; | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | 0 | delete $self->{ifs_loop}->{'x_'.$block}; # we must clear IFs for this loop | |||||||||||||||||||||||||||
| 303 | 0 | delete $self->{loops}{$block.'_new'}; | |||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | sub set_to_str | ||||||||||||||||||||||||||||
| 307 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
set_to_str: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 308 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 309 | 0 | my $token=shift; | |||||||||||||||||||||||||||
| 310 | 0 | my $value=shift; | |||||||||||||||||||||||||||
| 311 | 0 | my $str=shift; | |||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 0 | my $ret=""; | |||||||||||||||||||||||||||
| 314 | 0 | my $sub_str; | |||||||||||||||||||||||||||
| 315 | my $loop_name; | ||||||||||||||||||||||||||||
| 316 | 0 | ▶ | while(($sub_str=str_before($str,"$self->{tag}x_")) ne $str) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 317 | { | ||||||||||||||||||||||||||||
| 318 | # ÐÏÌÕÞÁÅÍ ÉÍÑ ÃÉËÌÁ | ||||||||||||||||||||||||||||
| 319 | 0 | $loop_name=str_before(substr($str,length($sub_str)+4),"$self->{tag}"); | |||||||||||||||||||||||||||
| 320 | # ÚÁÍÅÎÑÅÍ ÐÅÒÅÍÅÎÎÕÀ ÐÅÒÅÄ ÃÉËÌÏÍ, ÅÓÌÉ ÏÎÁ ÔÁÍ ÅÓÔØ | ||||||||||||||||||||||||||||
| 321 | 0 | $ret.=str_replace("$self->{tag}".$token."$self->{tag}",$value,$sub_str); | |||||||||||||||||||||||||||
| 322 | 0 | $ret.="$self->{tag}x_".$loop_name."$self->{tag}".str_before(substr($str,length($sub_str)+length($loop_name)+6),"$self->{tag}x_".$loop_name."$self->{tag}")."$self->{tag}x_".$loop_name."$self->{tag}"; | |||||||||||||||||||||||||||
| 323 | 0 | $str=str_after(substr($str,length($sub_str)+length($loop_name)+6),"$self->{tag}x_".$loop_name."$self->{tag}"); | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | 0 | $ret.=str_replace("$self->{tag}".$token."$self->{tag}",$value,$str); | |||||||||||||||||||||||||||
| 326 | 0 | return($ret); | |||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | sub _fill_ifs | ||||||||||||||||||||||||||||
| 330 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_fill_ifs: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 331 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 332 | 0 | my $text=shift; | |||||||||||||||||||||||||||
| 333 | 0 | my $l_name=shift; | |||||||||||||||||||||||||||
| 334 | 0 | my ($pos,$before_loop,$if_name,$loop,$loop_name,$after_loop,$h_ifs); | |||||||||||||||||||||||||||
| 335 | 0 | ▶ | if(!defined $l_name || $l_name eq '') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $l_name or $l_name eq ""
MC/DC0%0/2
not defined $l_name or $l_name eq ""
not defined $l_name
$l_name eq ""
Truth table0%0/3
not(A) or B
A= not defined $l_nameB= $l_name eq ""
| |||||||||||||||||||||||||||||
| 336 | { | ||||||||||||||||||||||||||||
| 337 | 0 | $h_ifs=$self->{ifs}; | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | else | ||||||||||||||||||||||||||||
| 340 | { | ||||||||||||||||||||||||||||
| 341 | # ÎÁÄÏ ÚÁÐÏÌÎÉÔØ IF ÄÌÑ ÃÉËÌÁ | ||||||||||||||||||||||||||||
| 342 | 0 | $h_ifs=$self->{ifs_loop}->{$l_name}; | |||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | # ÕÄÁÌÑÅÍ ÎÅÚÁÐÏÌÎÅÎÎÙÅ IF É ×ÓÔÁ×ÌÑÅÍ ÚÁÐÏÌÎÅÎÎÙÅ × ÏËÏÎÞÁÔÅÌØÎÙÊ ÔÅËÓÔ | ||||||||||||||||||||||||||||
| 345 | 0 | ▶ | while($pos=strstr($text,"$self->{tag}if_")) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 346 | { | ||||||||||||||||||||||||||||
| 347 | 0 | $before_loop=substr($text,0,length($text)-length($pos)); | |||||||||||||||||||||||||||
| 348 | 0 | $loop_name=substr($pos,5); | |||||||||||||||||||||||||||
| 349 | 0 | $loop_name=substr($loop_name,0,length($loop_name)-length(strstr($loop_name,"$self->{tag}"))); | |||||||||||||||||||||||||||
| 350 | 0 | $if_name="$self->{tag}if_".$loop_name."$self->{tag}"; | |||||||||||||||||||||||||||
| 351 | 0 | $loop=$pos; | |||||||||||||||||||||||||||
| 352 | 0 | $after_loop=str_after(str_after($loop,$if_name),$if_name); | |||||||||||||||||||||||||||
| 353 | 0 | $loop=substr($loop,length($if_name),length($loop)-length($after_loop)-length($if_name)*2); | |||||||||||||||||||||||||||
| 354 | 0 | ▶ | unless(defined $h_ifs->{$loop_name}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 355 | { | ||||||||||||||||||||||||||||
| 356 | #IF ÎÅ ×ÙÓÔÁ×ÌÑÌÓÑ | ||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if($pos=strstr($loop,"$self->{tag}else_".$loop_name)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | { | ||||||||||||||||||||||||||||
| 359 | #else ÅÓÔØ É ÅÇÏ ÎÁÄÏ ÏÓÔÁ×ÉÔØ | ||||||||||||||||||||||||||||
| 360 | 0 | $loop=substr($pos,9+length($loop_name)); | |||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||
| 362 | else | ||||||||||||||||||||||||||||
| 363 | { | ||||||||||||||||||||||||||||
| 364 | #else ÎÅÔ | ||||||||||||||||||||||||||||
| 365 | 0 | $loop=""; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | else | ||||||||||||||||||||||||||||
| 369 | { | ||||||||||||||||||||||||||||
| 370 | #ÕÂÉÒÁÅÍ ÓÏÄÅÒÖÉÍÏÅ ELSE, ÅÓÌÉ ÔÁËÏ×ÏÊ ÅÓÔØ | ||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if($pos=strstr($loop,"$self->{tag}else_".$loop_name)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 372 | { | ||||||||||||||||||||||||||||
| 373 | #else ÅÓÔØ É ÅÇÏ ÎÁÄÏ ÏÓÔÁ×ÉÔØ | ||||||||||||||||||||||||||||
| 374 | 0 | $loop=str_before($loop,$pos); | |||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | #undef $h_ifs->{$loop_name} if(!defined $l_name || $l_name eq '') | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||
| 379 | 0 | $text=$before_loop.$loop.$after_loop; | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | 0 | return($text); | |||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | sub _fill_loops | ||||||||||||||||||||||||||||
| 385 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_fill_loops: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 386 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 387 | 0 | my $text=shift; | |||||||||||||||||||||||||||
| 388 | 0 | ▶ | unless($self->{_loops_filled}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 389 | { | ||||||||||||||||||||||||||||
| 390 | 0 | my ($pos, $before_loop, $loop_name, $loop, $after_loop); | |||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | # ÐÏÓÔÉÍ ÔÅ ÌÕÐÙ, ÞÔÏ ÚÁÐÏÎÉÌÉÓØ, ÎÏ ÎÅ ÚÁÐÏÌÎÉÌÉÓØ | ||||||||||||||||||||||||||||
| 393 | 0 | foreach(keys %{$self->{loops}}) | |||||||||||||||||||||||||||
| 394 | { | ||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if (($loop_name=str_before($_,"_new")) ne $_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | { | ||||||||||||||||||||||||||||
| 397 | 0 | ▶ | $self->_post_loop($loop_name) if($self->{loops}{$_} ne ""); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||
| 400 | # ÕÄÁÌÑÅÍ ÎÅÚÁÐÏÌÎÅÎÎÙÅ ÌÕÐÙ É ×ÓÔÁ×ÌÑÅÍ ÚÁÐÏÌÎÅÎÎÙÅ × ÏËÏÎÞÁÔÅÌØÎÙÊ ÔÅËÓÔ | ||||||||||||||||||||||||||||
| 401 | 0 | ▶ | while($pos=strstr($text,"$self->{tag}x_")) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 402 | { | ||||||||||||||||||||||||||||
| 403 | 0 | $before_loop=substr($text,0,length($text)-length($pos)); | |||||||||||||||||||||||||||
| 404 | 0 | $loop_name=substr($pos,4); | |||||||||||||||||||||||||||
| 405 | 0 | $loop_name=substr($loop_name,0,length($loop_name)-length(strstr($loop_name,"$self->{tag}"))); | |||||||||||||||||||||||||||
| 406 | #$loop=strstr($text,"$self->{tag}x_".$loop_name."$self->{tag}"); | ||||||||||||||||||||||||||||
| 407 | 0 | $loop=$pos; | |||||||||||||||||||||||||||
| 408 | 0 | $after_loop=str_after(str_after($loop,"$self->{tag}x_".$loop_name."$self->{tag}"),"$self->{tag}x_".$loop_name."$self->{tag}"); | |||||||||||||||||||||||||||
| 409 | 0 | $loop=substr($loop,0,length($loop)-length($after_loop)); | |||||||||||||||||||||||||||
| 410 | 0 | $text=$before_loop.shift(@{$self->{loops}{$loop_name}}).$after_loop; | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | 0 | my $tag=$self->{tag}; | |||||||||||||||||||||||||||
| 413 | 0 | my $if_name; | |||||||||||||||||||||||||||
| 414 | 0 | $text=_fill_ifs($self,$text); | |||||||||||||||||||||||||||
| 415 | 0 | $text=~s/($tag)[\da-zA-Z\-][\w\-]*?($tag)//g; | |||||||||||||||||||||||||||
| 416 | 0 | $self->{_loops_filled}=1; | |||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | 0 | return($text); | |||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | sub strstr | ||||||||||||||||||||||||||||
| 423 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
strstr: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 424 | 0 | my $str=shift; | |||||||||||||||||||||||||||
| 425 | 0 | my $str2=shift; | |||||||||||||||||||||||||||
| 426 | 0 | my $index=index($str,$str2); | |||||||||||||||||||||||||||
| 427 | 0 | ▶ | if ($index>-1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 428 | { | ||||||||||||||||||||||||||||
| 429 | 0 | $str=substr($str,$index,length($str)-$index); | |||||||||||||||||||||||||||
| 430 | 0 | return($str); | |||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||
| 432 | else | ||||||||||||||||||||||||||||
| 433 | { | ||||||||||||||||||||||||||||
| 434 | 0 | return undef; | |||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | sub str_before | ||||||||||||||||||||||||||||
| 439 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
str_before: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 440 | 0 | my $str=shift; | |||||||||||||||||||||||||||
| 441 | 0 | my $str2=shift; | |||||||||||||||||||||||||||
| 442 | 0 | my $indx=index($str,$str2); | |||||||||||||||||||||||||||
| 443 | 0 | ▶ | if($indx!=-1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 444 | { | ||||||||||||||||||||||||||||
| 445 | 0 | $str=substr($str,0,$indx); | |||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | 0 | return $str; | |||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||
| 449 | sub str_split | ||||||||||||||||||||||||||||
| 450 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
str_split: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 451 | 0 | my $str=shift; | |||||||||||||||||||||||||||
| 452 | 0 | my $str2=shift; | |||||||||||||||||||||||||||
| 453 | 0 | my $indx=index($str,$str2); | |||||||||||||||||||||||||||
| 454 | 0 | ▶ | if($indx!=-1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 455 | { | ||||||||||||||||||||||||||||
| 456 | 0 | my $lstr2=length($str2); | |||||||||||||||||||||||||||
| 457 | 0 | $str2=substr($str,$indx+$lstr2,length($str)-$indx-$lstr2); | |||||||||||||||||||||||||||
| 458 | 0 | $str=substr($str,0,$indx); | |||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||
| 460 | else | ||||||||||||||||||||||||||||
| 461 | { | ||||||||||||||||||||||||||||
| 462 | 0 | $str2=''; | |||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||
| 464 | 0 | return ($str,$str2); | |||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||
| 466 | sub str_3_split | ||||||||||||||||||||||||||||
| 467 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
str_3_split: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 468 | 0 | my $str=shift; | |||||||||||||||||||||||||||
| 469 | 0 | my $str1=shift; | |||||||||||||||||||||||||||
| 470 | 0 | my $str2=shift; | |||||||||||||||||||||||||||
| 471 | 0 | ($str1,$str)=str_split($str,$str1); | |||||||||||||||||||||||||||
| 472 | 0 | ▶ | if($str ne '') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 473 | { | ||||||||||||||||||||||||||||
| 474 | 0 | ($str2,$str)=str_split($str,$str2); | |||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||
| 476 | else | ||||||||||||||||||||||||||||
| 477 | { | ||||||||||||||||||||||||||||
| 478 | 0 | $str2=''; | |||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||
| 480 | 0 | return($str1,$str2,$str); | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | sub str_after | ||||||||||||||||||||||||||||
| 483 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
str_after: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 484 | 0 | my $str=shift; | |||||||||||||||||||||||||||
| 485 | 0 | my $str2=shift; | |||||||||||||||||||||||||||
| 486 | 0 | my $indx=index($str,$str2); | |||||||||||||||||||||||||||
| 487 | 0 | ▶ | if($indx!=-1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 488 | { | ||||||||||||||||||||||||||||
| 489 | 0 | $str=substr($str,$indx+length($str2),length($str)-$indx-length($str2)); | |||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||
| 491 | 0 | return($str); | |||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | sub str_between | ||||||||||||||||||||||||||||
| 496 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
str_between: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 497 | 0 | my $str=shift; | |||||||||||||||||||||||||||
| 498 | 0 | my $str1=shift; | |||||||||||||||||||||||||||
| 499 | 0 | my $str2=shift; | |||||||||||||||||||||||||||
| 500 | 0 | my $ret=str_after($str,$str1); | |||||||||||||||||||||||||||
| 501 | 0 | return(str_before($ret,$str2)); | |||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | sub str_replace | ||||||||||||||||||||||||||||
| 505 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
str_replace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 506 | 0 | my $str=shift; | |||||||||||||||||||||||||||
| 507 | 0 | my $str1=shift; | |||||||||||||||||||||||||||
| 508 | 0 | my $str2=shift; | |||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | 0 | $str2=~s/$str/$str1/g; | |||||||||||||||||||||||||||
| 511 | 0 | return($str2); | |||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | sub output() | ||||||||||||||||||||||||||||
| 515 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
output: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 516 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 517 | 0 | my $hdr; | |||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | 0 | foreach $hdr (@_) | |||||||||||||||||||||||||||
| 520 | { | ||||||||||||||||||||||||||||
| 521 | 0 | print "$hdr\n"; | |||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 525 | # $self->{html}=$self->_fill_loops($self->{html}); | ||||||||||||||||||||||||||||
| 526 | 0 | print $self->htmlString(); | |||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | sub setCache | ||||||||||||||||||||||||||||
| 530 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
setCache: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 531 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 532 | 0 | my $cacheKey = shift; | |||||||||||||||||||||||||||
| 533 | 0 | ▶ | return 0 unless (defined $self->{cacheDIR}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 534 | 0 | ▶ | mkdir($self->{cacheDIR}) unless(-d $self->{cacheDIR}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 535 | 0 | my $encodedKey=encode_base64($cacheKey); | |||||||||||||||||||||||||||
| 536 | # chomp($encodedKey); | ||||||||||||||||||||||||||||
| 537 | 0 | $encodedKey=~s/[\n\s]//sg; | |||||||||||||||||||||||||||
| 538 | 0 | open(my $f,'>'.$self->{cacheDIR}.'/'.$encodedKey); | |||||||||||||||||||||||||||
| 539 | 0 | print $f $self->htmlString(); | |||||||||||||||||||||||||||
| 540 | 0 | close($f); | |||||||||||||||||||||||||||
| 541 | 0 | return 1; | |||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | sub getCache | ||||||||||||||||||||||||||||
| 545 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getCache: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 546 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 547 | 0 | my $cacheKey = shift; | |||||||||||||||||||||||||||
| 548 | 0 | ▶ | return 0 unless (defined $self->{cacheDIR}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 549 | 0 | my $encodedKey=encode_base64($cacheKey); | |||||||||||||||||||||||||||
| 550 | # chomp($encodedKey); | ||||||||||||||||||||||||||||
| 551 | 0 | $encodedKey=~s/[\n\s]//sg; | |||||||||||||||||||||||||||
| 552 | 0 | my $cacheFile = $self->{cacheDIR}.'/'.$encodedKey; | |||||||||||||||||||||||||||
| 553 | 0 | ▶ | return 0 unless(-f $cacheFile); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 554 | 0 | my $suxx=$/; | |||||||||||||||||||||||||||
| 555 | 0 | undef $/; | |||||||||||||||||||||||||||
| 556 | 0 | open(my $f, $cacheFile); | |||||||||||||||||||||||||||
| 557 | 0 | $self->{html}=<$f>; | |||||||||||||||||||||||||||
| 558 | 0 | close($f); | |||||||||||||||||||||||||||
| 559 | 0 | $/=$suxx; | |||||||||||||||||||||||||||
| 560 | 0 | $self->{_loops_filled}=1; | |||||||||||||||||||||||||||
| 561 | 0 | return 1; | |||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | sub rmCache | ||||||||||||||||||||||||||||
| 565 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
rmCache: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 566 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 567 | 0 | my $cacheKey = shift; | |||||||||||||||||||||||||||
| 568 | 0 | my $encodedKey=encode_base64($cacheKey); | |||||||||||||||||||||||||||
| 569 | 0 | $encodedKey=~s/[\n\s]//sg; | |||||||||||||||||||||||||||
| 570 | # chomp($encodedKey); | ||||||||||||||||||||||||||||
| 571 | 0 | return unlink($self->{cacheDIR}.'/'.$encodedKey); | |||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | sub clearCache | ||||||||||||||||||||||||||||
| 575 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
clearCache: not called CC=2 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 576 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 577 | 0 | ▶ | return 0 unless (defined $self->{cacheDIR}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 578 | 0 | ▶ | unlink (glob($self->{cacheDIR}.'/*')); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||
| 579 | 0 | return 1; | |||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||
| 582 | sub htmlString() | ||||||||||||||||||||||||||||
| 583 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
htmlString: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 584 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 585 | 0 | $self->{html}=$self->_fill_loops($self->{html}); | |||||||||||||||||||||||||||
| 586 | 0 | return $self->{html}; | |||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | sub DESTROY() | ||||||||||||||||||||||||||||
| 590 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | sub die_msg | ||||||||||||||||||||||||||||
| 594 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
die_msg: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 595 | 0 | my $msg = shift; | |||||||||||||||||||||||||||
| 596 | 0 | print "Content-type: text/html\n\n"; | |||||||||||||||||||||||||||
| 597 | 0 | print <<EOF; | |||||||||||||||||||||||||||
| 598 | <HTML> | ||||||||||||||||||||||||||||
| 599 | <HEAD></HEAD> | ||||||||||||||||||||||||||||
| 600 | <BODY> | ||||||||||||||||||||||||||||
| 601 | <b>ZM::Template Error:</b> $msg | ||||||||||||||||||||||||||||
| 602 | </BODY> | ||||||||||||||||||||||||||||
| 603 | </HTML> | ||||||||||||||||||||||||||||
| 604 | EOF | ||||||||||||||||||||||||||||
| 605 | 0 | exit; | |||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||
| 608 | 1 | 1; | |||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||
| 610 | __END__ | ||||||||||||||||||||||||||||