lib/PurpleWiki/View/xhtml.pm untested

filter: Statementstmt 0.0% 0 / 65 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 111 CC 14 SCAR 47.3
CC
14
Cov
0%
_htmlHeader
182.0
view
6.0
_htmlFooter
2.0
CRAP 113.8
1 # PurpleWiki::View::xhtml.pm
2 #
3 # $Id: xhtml.pm 366 2004-05-19 19:22:17Z eekim $
4 #
5 # Copyright (c) Blue Oxen Associates 2002-2004. All rights reserved.
6 #
7 # This file is part of PurpleWiki. PurpleWiki is derived from:
8 #
9 # UseModWiki v0.92 (c) Clifford A. Adams 2000-2001
10 # AtisWiki v0.3 (c) Markus Denker 1998
11 # CVWiki CVS-patches (c) Peter Merel 1997
12 # The Original WikiWikiWeb (c) Ward Cunningham
13 #
14 # PurpleWiki is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the
26 # Free Software Foundation, Inc.
27 # 59 Temple Place, Suite 330
28 # Boston, MA 02111-1307 USA
29  
30 package PurpleWiki::View::xhtml;
31 use 5.005;
32 use strict;
33 use warnings;
34 use PurpleWiki::View::Driver;
35 use PurpleWiki::View::wikihtml;
36  
37 ############### Package Globals ###############
38  
39 our $VERSION;
40 $VERSION = sprintf("%d", q$Id: xhtml.pm 366 2004-05-19 19:22:17Z eekim $ =~ /\s(\d+)\s/);
41  
42 # Note that we don't inherit directly from Driver.pm like the other drivers.
43 our @ISA = qw(PurpleWiki::View::wikihtml);
44  
45  
46 ############### Overloaded Methods ###############
47  
48 sub view {
49 my ($self, $wikiTree) = @_;
50  
51 if (not defined $self->{css_file}) {
52 $self->{css_file} = "";
53 }
54  
55 $self->SUPER::view($wikiTree);
56 $self->{outputString} = $self->_htmlHeader($wikiTree) .
57 $self->{outputString} . $self->_htmlFooter();
58  
59 return $self->{outputString};
60 }
61  
62  
63 ############### Private Methods ###############
64  
65 sub _htmlHeader {
66 my ($self, $wikiTree) = @_;
67 my $outputString;
68  
69 $outputString = qq(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ) .
70 qq(Strict//EN"\n) .
71 qq("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n) .
72 qq(<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">) .
73 qq(<head>\n);
74 $outputString .= '<title>' . $wikiTree->title . "</title>\n"
75 if ($wikiTree->title);
76 if ($self->{css_file}) {
77 $outputString .= '<link rel="stylesheet" href="';
78 $outputString .= $self->{css_file};
79 $outputString .= '" type="text/css" />' . "\n";
80 }
81 $outputString .= "</head>\n<body>\n";
82 if ($wikiTree->title) {
83 $outputString .= '<h1 class="title">';
84 $outputString .= $wikiTree->title;
85 $outputString .= "</h1>\n";
86 }
87 if ($wikiTree->subtitle) {
88 $outputString .= '<h2 class="subtitle">';
89 $outputString .= $wikiTree->subtitle;
90 $outputString .= "</h2>\n";
91 }
92 if ($wikiTree->authors) {
93 $outputString .= '<p class="authors">';
94 foreach my $author (@{$wikiTree->authors}) {
95 $outputString .= $author->[0];
96 $outputString .= ' &lt;' . $author->[1] . '&gt;'
97 if (scalar @{$author} > 1);
98 $outputString .= "<br />\n";
99 }
100 $outputString .= "</p>\n";
101 }
102 if ($wikiTree->id || $wikiTree->version || $wikiTree->date) {
103 $outputString .= '<p class="docinfo">';
104 if ($wikiTree->id) {
105 $outputString .= $wikiTree->id;
106 if ($wikiTree->version) {
107 $outputString .= "<br />\n";
108 }
109 }
110 if ($wikiTree->version) {
111 $outputString .= $wikiTree->version;
112 if ($wikiTree->date) {
113 $outputString .= "<br />\n";
114 }
115 }
116 $outputString .= $wikiTree->date if ($wikiTree->date);
117 $outputString .= "</p>\n";
118 }
119 return $outputString;
120 }
121  
122 sub _htmlFooter {
123 return "</body>\n</html>\n";
124 }
125 1;
126 __END__