WebEditor/OldFeatures/MakeHTML.pm

filter: Statementstmt 14.8% 8 / 54 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 66.6% 2 / 3 Podpod 0.0% 0 / 1 totaltotal 9.2% 10 / 108 CC 18 SCAR 57.3
CC
18
Cov
9%
makehtmlpage_additional
342.0
BEGIN
1.0
BEGIN
1.0
CRAP 307.9
« Apache/AuthenWE.pm ↑ Summary WebEditor/OldFeatures/CustomPublish.pm »
1 package WebEditor::OldFeatures::MakeHTML;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 $VERSION = sprintf("%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/);
6  
7 0 ▶sub makehtmlpage_additional {
Subroutine makehtmlpage_additional: not called CC=18 SCAR=58.3
Pod undocumented
8 0 my $self = shift;
9  
10 0 my $root = $self->Root;
11 0 my $objdb = $root->ObjDB;
12 0 my $c = $self->C;
13  
14 0 my(%args) = @_;
15  
16 0 ▶ my $lang = $args{lang} || $c->project->sitelanguages->[0];
Condition0%0/3
$args{'lang'} || $c->project->sitelanguages->[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'lang'} || $c->project->sitelanguages->[0]
$args{'lang'} $c->project->sitelanguages->[0]
Truth table0%0/3
A || B
A= $args{'lang'}B= $c->project->sitelanguages->[0]
ABresult
1X1
011
000
17 0 ▶ my $basedir = $args{basedir} || $c->paths->pubhtmldir;
Condition0%0/3
$args{'basedir'} || $c->paths->pubhtmldir
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'basedir'} || $c->paths->pubhtmldir
$args{'basedir'} $c->paths->pubhtmldir
Truth table0%0/3
A || B
A= $args{'basedir'}B= $c->paths->pubhtmldir
ABresult
1X1
011
000
18  
19 my($id, $mainid, $template, $addtemplatevars) =
20 0 @args{qw(id mainid template addtemplatevars)};
21  
22 0 my $htmlfile;
23 # Die Homepage noch einmal als index.html erzeugen
24 0 my $p = ($objdb->parents($mainid))[0];
25 0 ▶ if ($p) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p) 0 0 0
26 0 ▶ if ($p->is_site && defined $p->IndexDoc && $p->IndexDoc eq $mainid) {
Branch: 2 branches
BranchTrueFalseTotal
if ($p->is_site and defined $p->IndexDoc and $p->IndexDoc eq $mainid) { } 0 0 0
elsif ($p->is_folder and defined $p->IndexDoc and $p->IndexDoc eq $mainid) { } 0 0 0
Condition0%0/6
$p->is_site and defined $p->IndexDoc and $p->IndexDoc eq $mainid
!ll&&!rl&&r
000
$p->is_site and defined $p->IndexDoc
!ll&&!rl&&r
000
MC/DC0%0/3
$p->is_site and defined $p->IndexDoc and $p->IndexDoc eq $mainid
$p->is_site defined $p->IndexDoc $p->IndexDoc eq $mainid
Truth table0%0/4
A and B and C
A= $p->is_siteB= defined $p->IndexDocC= $p->IndexDoc eq $mainid
ABCresult
0XX0
10X0
1100
1111
27 0 $htmlfile = $basedir."/html/".$lang."/index.html";
28 ▶ } elsif ($p->is_folder && defined $p->IndexDoc && $p->IndexDoc eq $mainid) {
Condition0%0/6
$p->is_folder and defined $p->IndexDoc and $p->IndexDoc eq $mainid
!ll&&!rl&&r
000
$p->is_folder and defined $p->IndexDoc
!ll&&!rl&&r
000
MC/DC0%0/3
$p->is_folder and defined $p->IndexDoc and $p->IndexDoc eq $mainid
$p->is_folder defined $p->IndexDoc $p->IndexDoc eq $mainid
Truth table0%0/4
A and B and C
A= $p->is_folderB= defined $p->IndexDocC= $p->IndexDoc eq $mainid
ABCresult
0XX0
10X0
1100
1111
29 0 $htmlfile = $basedir."/html/".$lang."/" . $p->Id . ".html";
30 }
31 }
32  
33 0 my $msg = "";
34  
35 0 my $converter = $self->get_fh_charset_converter;
36  
37 # gibt es von diesem Template noch ein Print-Template?
38 # dann nochmal die Print-Version erzeugen:
39 0 my $printtemplate = $template;
40 0 $printtemplate =~ s/\.tpl\.html$/_p\.tpl\.html/;
41 0 ▶ if (-e $c->paths->site_templatebase."/$printtemplate") {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $c->paths->site_templatebase . "/$printtemplate") 0 0 0
42 0 $msg .= "$printtemplate --- ";
43 0 require File::Compare;
44 0 my $phtmlfile = $basedir."/html/".$lang."/".$mainid."_p.html";
45 0 $msg .= "$phtmlfile --- ";
46 0 my $tmpfile = "$phtmlfile~";
47 0 ▶ open(HTML, ">$tmpfile") or die("Publish: can't write to $tmpfile: $!");
Branch: 1 branch
BranchTrueFalseTotal
open HTML, ">$tmpfile" or die "Publish: can't write to ${tmpfile}: $!" 0 0 0
48 0 $converter->(\*HTML);
49 0 $self->_tpl("site", $printtemplate, $addtemplatevars, \*HTML);
50 0 close HTML;
51  
52 0 ▶ if (File::Compare::compare($phtmlfile, $tmpfile) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (File::Compare::compare($phtmlfile, $tmpfile) == 0) { } 0 0 0
53 # no change --- delete $tmpfile
54 0 unlink $tmpfile;
55 0 $msg .= " ($lang: keine Änderung) ";
56 } else {
57 0 unlink $phtmlfile; # do not fail --- maybe file does not exist
58 0 ▶ rename $tmpfile, $phtmlfile or die "Can't rename $tmpfile to $phtmlfile: $!";
Branch: 1 branch
BranchTrueFalseTotal
rename $tmpfile, $phtmlfile or die "Can't rename $tmpfile to ${phtmlfile}: $!" 0 0 0
59 }
60  
61 }
62  
63 0 ▶ if (defined $htmlfile) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $htmlfile) 0 0 0
64 0 require File::Compare;
65 0 my $tmpfile = "$htmlfile~";
66 0 ▶ open(HTML, ">$tmpfile") or $self->error("Publish: can't writeopen $tmpfile: $!");
Branch: 1 branch
BranchTrueFalseTotal
open HTML, ">$tmpfile" or $self->error("Publish: can't writeopen ${tmpfile}: $!") 0 0 0
67 0 $converter->(\*HTML);
68 0 $self->_tpl("site", $template, $addtemplatevars, \*HTML);
69 0 close HTML;
70  
71 0 ▶ if (File::Compare::compare($htmlfile, $tmpfile) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (File::Compare::compare($htmlfile, $tmpfile) == 0) { } 0 0 0
72 # no change --- delete $tmpfile
73 0 unlink $tmpfile;
74 } else {
75 0 unlink $htmlfile; # do not fail --- maybe file does not exist
76 0 ▶ rename $tmpfile, $htmlfile or die "Can't rename $tmpfile to $htmlfile: $!";
Branch: 1 branch
BranchTrueFalseTotal
rename $tmpfile, $htmlfile or die "Can't rename $tmpfile to ${htmlfile}: $!" 0 0 0
77 0 $msg = " ($lang: $htmlfile) ";
78 }
79  
80 }
81 0 $msg;
82 }
83  
84 1 1;
« Apache/AuthenWE.pm ↑ Summary WebEditor/OldFeatures/CustomPublish.pm »