]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Posting.pm
style changes
[selfforum.git] / selfforum-cgi / shared / Template / Posting.pm
1 # Template/Posting.pm
2
3 # ====================================================
4 # Autor: n.d.p. / 2001-01-14
5 # lm : n.d.p. / 2001-01-14
6 # ====================================================
7 # Funktion:
8 # HTML-Darstellung eines Postings
9 # ====================================================
10
11 use strict;
12
13 package Template::Posting;
14
15 use vars qw(@ISA @EXPORT);
16
17 use Encode::Posting;
18 use Encode::Plain; $Encode::Plain::utf8 = 1;
19 use Id;
20 use Lock qw(:WRITE);
21 use Posting::_lib qw(get_message_node get_message_header get_message_body parse_single_thread hr_time);
22 use Template;
23 use Template::_conf;
24 use Template::_query;
25 use Template::_thread;
26
27 use XML::DOM;
28
29 # ====================================================
30 # Funktionsexport
31 # ====================================================
32
33 require Exporter;
34 @ISA = qw(Exporter);
35 @EXPORT = qw(print_posting_as_HTML message_as_HTML);
36
37 ################################
38 # sub print_posting_as_HTML
39 #
40 # HTML erzeugen
41 ################################
42
43 sub print_posting_as_HTML ($$$) {
44 my ($threadpath, $tempfile, $param) = @_;
45
46 my $template = new Template $tempfile;
47
48 # Datei sperren... (eigentlich)
49 my $view = get_view_params ({adminDefault => $param -> {adminDefault}
50 });
51
52 my $xml=new XML::DOM::Parser -> parsefile ($threadpath.'t'.$param -> {thread}.'.xml');
53
54 my ($mnode, $tnode) = get_message_node ($xml, 't'.$param -> {thread}, 'm'.$param -> {posting});
55 my $pnode = $mnode -> getParentNode;
56 my $header = get_message_header ($mnode);
57 my $msg = parse_single_thread ($tnode, $param -> {showDeleted}, $view -> {sortedMsg});
58 my $pheader = ($pnode -> getNodeName eq 'Message')?get_message_header ($pnode):{};
59
60 my $assign = $param -> {assign};
61 my $formdata = $param -> {form} -> {data};
62 my $formact = $param -> {form} -> {action};
63
64 my $body = get_message_body ($xml, 'm'.$param -> {posting});
65
66 my $text = message_field ($body,
67 {quoteChars => plain($view -> {quoteChars}),
68 quoting => 1,
69 startCite => ${$template -> scrap ($assign -> {startCite})},
70 endCite => ${$template -> scrap ($assign -> {endCite})}
71 });
72
73 my $area = answer_field ($body,
74 {quoteArea => 1,
75 quoteChars => plain($view -> {quoteChars}),
76 messages => $param -> {messages}
77 });
78
79 my $pars = {};
80
81 for (qw(posterBody uniqueID followUp quoteChar userID posterName posterEmail posterURL posterImage)) {
82 $pars -> {$formdata -> {$_} -> {assign} -> {name}} = plain($formdata -> {$_} -> {name});}
83
84 my $cgi = $param -> {cgi};
85
86 my $tpar = {thread => $param -> {thread},
87 template => $param -> {tree},
88 start => $param -> {posting},
89 cgi => $cgi};
90
91 my $plink = %$pheader?(query_string ({$cgi -> {thread} => $param -> {thread}, $cgi -> {posting} => ($pnode -> getAttribute ('id') =~ /(\d+)/)[0]})):'';
92
93 print ${$template -> scrap ($assign->{mainDoc},
94 {$assign->{name} => plain($header->{name}),
95 $assign->{email} => plain($header->{email}),
96 $assign->{home} => plain($header->{home}),
97 $assign->{image} => plain($header->{image}),
98 $assign->{time} => plain(hr_time($header->{time})),
99 $assign->{message} => $text,
100 $assign->{messageTitle} => plain($header->{subject}),
101 $assign->{parentTitle} => plain($pheader->{subject}),
102 $assign->{messageCat} => plain($header->{category}),
103 $assign->{parentCat} => plain($pheader->{category}),
104 $assign->{parentName} => plain($pheader->{name}),
105 $assign->{parentLink} => $plink,
106 $assign->{parentTime} => plain(hr_time($pheader->{time})),
107 $param->{tree}->{main} => html_thread ($msg, $template, $tpar),
108 $formact->{post}->{assign} => $formact->{post}->{url},
109 $formact->{vote}->{assign} => $formact->{vote}->{url},
110 $formdata->{posterBody}->{assign}->{value} => $area,
111 $formdata->{uniqueID} ->{assign}->{value} => plain(unique_id),
112 $formdata->{followUp} ->{assign}->{value} => plain($param -> {thread}.';'.$param -> {posting}),
113 $formdata->{quoteChar} ->{assign}->{value} => "ÿ".plain($view -> {quoteChars}),
114 $formdata->{userID} ->{assign}->{value} => '',
115 }, $pars)};
116
117 }
118
119 ################################
120 # sub message_as_HTML
121 #
122 # HTML erzeugen
123 ################################
124
125 sub message_as_HTML ($$$) {
126 my ($xml, $template, $param) = @_;
127
128 my $assign = $param -> {assign};
129 my $body = get_message_body ($xml, $param -> {posting});
130
131 my $text = message_field ($body,
132 {quoteChars => '»» ',
133 quoting => 1,
134 startCite => ${$template -> scrap ($assign -> {startCite})},
135 endCite => ${$template -> scrap ($assign -> {endCite})}
136 });
137
138 # Rueckgabe
139 $text;
140 }
141
142 # ====================================================
143 # Modulinitialisierung
144 # ====================================================
145
146 # making require happy
147 1;
148
149 # ====================================================
150 # end of Template::Posting
151 # ====================================================

patrick-canterino.de