| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WebEditor::OldFeatures::MakeHTML; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 1067 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 39 |  | 
| 4 | 1 |  |  | 1 |  | 7 | use vars qw($VERSION); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 792 |  | 
| 5 |  |  |  |  |  |  | $VERSION = sprintf("%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/); | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | sub makehtmlpage_additional { | 
| 8 | 0 |  |  | 0 | 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 |  | 0 |  |  |  | my $lang    = $args{lang}    || $c->project->sitelanguages->[0]; | 
| 17 | 0 |  | 0 |  |  |  | my $basedir = $args{basedir} || $c->paths->pubhtmldir; | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 0 |  |  |  |  |  | my($id, $mainid, $template, $addtemplatevars) = | 
| 20 |  |  |  |  |  |  | @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 | 0 |  |  |  |  | if ($p) { | 
| 26 | 0 | 0 | 0 |  |  |  | if ($p->is_site && defined $p->IndexDoc && $p->IndexDoc eq $mainid) { | 
|  |  | 0 | 0 |  |  |  |  | 
|  |  |  | 0 |  |  |  |  | 
|  |  |  | 0 |  |  |  |  | 
| 27 | 0 |  |  |  |  |  | $htmlfile = $basedir."/html/".$lang."/index.html"; | 
| 28 |  |  |  |  |  |  | } elsif ($p->is_folder && defined $p->IndexDoc && $p->IndexDoc eq $mainid) { | 
| 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 | 0 |  |  |  |  | if (-e $c->paths->site_templatebase."/$printtemplate") { | 
| 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 | 0 |  |  |  |  | open(HTML, ">$tmpfile") or die("Publish: can't write to $tmpfile: $!"); | 
| 48 | 0 |  |  |  |  |  | $converter->(\*HTML); | 
| 49 | 0 |  |  |  |  |  | $self->_tpl("site", $printtemplate, $addtemplatevars, \*HTML); | 
| 50 | 0 |  |  |  |  |  | close HTML; | 
| 51 |  |  |  |  |  |  |  | 
| 52 | 0 | 0 |  |  |  |  | if (File::Compare::compare($phtmlfile, $tmpfile) == 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 | 0 |  |  |  |  | rename $tmpfile, $phtmlfile or die "Can't rename $tmpfile to $phtmlfile: $!"; | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | } | 
| 62 |  |  |  |  |  |  |  | 
| 63 | 0 | 0 |  |  |  |  | if (defined $htmlfile) { | 
| 64 | 0 |  |  |  |  |  | require File::Compare; | 
| 65 | 0 |  |  |  |  |  | my $tmpfile  = "$htmlfile~"; | 
| 66 | 0 | 0 |  |  |  |  | open(HTML, ">$tmpfile") or $self->error("Publish: can't writeopen $tmpfile: $!"); | 
| 67 | 0 |  |  |  |  |  | $converter->(\*HTML); | 
| 68 | 0 |  |  |  |  |  | $self->_tpl("site", $template, $addtemplatevars, \*HTML); | 
| 69 | 0 |  |  |  |  |  | close HTML; | 
| 70 |  |  |  |  |  |  |  | 
| 71 | 0 | 0 |  |  |  |  | if (File::Compare::compare($htmlfile, $tmpfile) == 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 | 0 |  |  |  |  | rename $tmpfile, $htmlfile or die "Can't rename $tmpfile to $htmlfile: $!"; | 
| 77 | 0 |  |  |  |  |  | $msg = " ($lang: $htmlfile) "; | 
| 78 |  |  |  |  |  |  | } | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | } | 
| 81 | 0 |  |  |  |  |  | $msg; | 
| 82 |  |  |  |  |  |  | } | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | 1; |