]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Posting.pm
7f0d94022fcba6058dee0c672e8b3c1107ea786c
1 package Template
::Posting
;
3 ################################################################################
5 # File: shared/Template/Posting.pm #
7 # Authors: Andre Malo <nd@o3media.de>, 2001-06-16 #
9 # Description: show HTML formatted posting #
11 ################################################################################
20 use Encode
::Plain
; $Encode::Plain
::utf8
= 1;
35 use Template
::_thread
;
39 ################################################################################
43 $VERSION = do { my @r =(q
$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x
$#r, @r };
45 ################################################################################
49 use base
qw(Exporter);
55 ### print_posting_as_HTML () ###################################################
57 # print HTML formatted Posting to STDOUT
59 # Params: $threadpath - /path/to/thread_files
60 # $tempfile - template file
61 # $param - Hash-Reference (see doc for details)
65 sub print_posting_as_HTML
($$$) {
66 my ($threadpath, $tempfile, $param) = @_;
68 my $template = new Template
$tempfile;
69 my $assign = $param -> {assign
};
71 my $view = get_view_params
({
72 adminDefault
=> $param -> {adminDefault
}
75 my $fh = new Lock
($threadpath.'t'.$param -> {thread
}.'.xml');
77 unless ($fh -> lock (LH_SHARED
)) {
78 print ${$template -> scrap
(
79 $assign -> {errorDoc
},
80 { $assign -> {errorText
} => $template -> insert
(
91 unless (-f
$fh -> filename
) {
93 print ${$template -> scrap
($assign -> {errorDoc
}, {$assign -> {errorText
} => $template -> insert
($assign->{notAvailable
})})};
96 my $xml = parse_xml_file
($fh -> filename
); #...
100 print ${$template -> scrap
($assign -> {errorDoc
}, {$assign -> {errorText
} => $template -> insert
($assign->{corrupt
})})};
103 my ($mnode, $tnode) = get_message_node
($xml, 't'.$param -> {thread
}, 'm'.$param -> {posting
});
105 unless ($mnode and not $mnode->getAttribute('invisible')) {
106 print ${$template -> scrap
(
107 $assign -> {errorDoc
},
108 { $assign -> {errorText
} => $template -> insert
($assign -> {'notAvailable'}) }
112 my $pnode = $mnode -> getParentNode
;
113 my $header = get_message_header
($mnode);
114 my $msg = parse_single_thread
($tnode, $param -> {showDeleted
}, $view -> {sortedMsg
});
115 my $pheader = ($pnode -> getNodeName
eq 'Message')?get_message_header
($pnode):{};
117 my $formdata = $param -> {form
} -> {data
};
118 my $formact = $param -> {form
} -> {action
};
120 my $body = get_message_body
($xml, 'm'.$param -> {posting
});
122 my $text = message_field
(
124 { quoteChars
=> plain
($view -> {quoteChars
}),
125 quoting
=> $view -> {quoting
},
126 startCite
=> ${$template -> scrap
($assign -> {startCite
})},
127 endCite
=> ${$template -> scrap
($assign -> {endCite
})}
131 my $area = answer_field
(
134 quoteChars
=> plain
($view -> {quoteChars
}),
135 messages
=> $param -> {messages
}
141 $pars -> {$formdata -> {$_} -> {assign
} -> {name
}} = plain
($formdata -> {$_} -> {name
})
155 my $cgi = $param -> {cgi
};
158 thread
=> $param -> {thread
},
159 template
=> $param -> {tree
},
160 start
=> $param -> {posting
},
167 $assign->{parentTitle
} => plain
(defined $pheader->{subject
} ?
$pheader->{subject
} : ''),
168 $assign->{parentCat
} => plain
(defined $pheader->{category
} ?
$pheader->{category
} : ''),
169 $assign->{parentName
} => plain
(defined $pheader->{name
} ?
$pheader->{name
} : ''),
170 $assign->{parentTime
} => plain
(hr_time
($pheader->{time})),
171 $assign->{parentLink
} => query_string
(
172 { $cgi -> {thread
} => $param -> {thread
},
173 $cgi -> {posting
} => ($pnode -> getAttribute
('id') =~ /(\d+)/)[0]
177 print ${$template -> scrap
(
179 { $assign->{name
} => plain
(defined $header->{name
} ?
$header->{name
} : ''),
180 $assign->{email
} => plain
(defined $header->{email
} ?
$header->{email
} : ''),
181 $assign->{home
} => plain
(defined $header->{home
} ?
$header->{home
} : ''),
182 $assign->{image
} => plain
(defined $header->{image
} ?
$header->{image
} : ''),
183 $assign->{time} => plain
(hr_time
($header->{time})),
184 $assign->{message
} => $text,
185 $assign->{messageTitle
} => plain
(defined $header->{subject
} ?
$header->{subject
} : ''),
186 $assign->{messageCat
} => plain
(defined $header->{category
} ?
$header->{category
} : ''),
187 $param->{tree
}->{main
} => html_thread
($msg, $template, $tpar),
188 $formact->{post
}->{assign
} => $formact->{post
}->{url
},
189 $formact->{vote
}->{assign
} => $formact->{vote
}->{url
},
190 $formdata->{posterBody
}->{assign
}->{value
} => $area,
191 $formdata->{uniqueID
} ->{assign
}->{value
} => plain
(unique_id
),
192 $formdata->{followUp
} ->{assign
}->{value
} => plain
($param -> {thread
}.';'.$param -> {posting
}),
193 $formdata->{quoteChar
} ->{assign
}->{value
} => "ÿ".plain
(defined $view -> {quoteChars
} ?
$view -> {quoteChars
} : ''),
194 $formdata->{userID
} ->{assign
}->{value
} => '',
195 $assign->{firsttime
} => $param->{firsttime
} ?
$param->{firsttime
} : '',
196 $assign->{voted
} => $param->{voted
} ?
$param->{voted
} : ''
206 if ($param->{firsttime
}) {
207 my $cache = new Posting
::Cache
($param->{cachepath
});
209 { thread
=> $param -> {thread
},
210 posting
=> $param -> {posting
}
222 ### message_as_HTML () #########################################################
224 # create HTML String for the Messagetext
226 # Params: $xml - XML::DOM::Document object
227 # $template - Template object
228 # $param - Hash reference
229 # (assign, posting, quoteChars, quoting)
231 # Return: HTML String
233 sub message_as_HTML
($$$) {
234 my ($xml, $template, $param) = @_;
236 my $assign = $param -> {assign
};
237 my $body = get_message_body
($xml, $param -> {posting
});
239 my $text = message_field
(
241 { quoteChars
=> plain
($param -> {quoteChars
}),
242 quoting
=> $param -> {quoting
},
243 startCite
=> ${$template -> scrap
($assign -> {startCite
})},
244 endCite
=> ${$template -> scrap
($assign -> {endCite
})}
252 # keep 'require' happy
257 ### end of Template::Posting ###################################################
patrick-canterino.de