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

patrick-canterino.de