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

patrick-canterino.de