]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Forum.pm
added version checks, fixed a small bug in Template.pm
[selfforum.git] / selfforum-cgi / shared / Template / Forum.pm
1 package Template::Forum;
2
3 ################################################################################
4 # #
5 # File: shared/Template/Forum.pm #
6 # #
7 # Authors: André Malo <nd@o3media.de>, 2001-04-19 #
8 # #
9 # Description: print Forum main file to STDOUT #
10 # #
11 ################################################################################
12
13 use strict;
14
15 use Lock qw(:READ);
16 use Encode::Plain; $Encode::Plain::utf8 = 1;
17 use Posting::_lib qw(
18 get_all_threads
19 long_hr_time
20 );
21 use Template;
22 use Template::_conf;
23 use Template::_thread;
24
25 ################################################################################
26 #
27 # Export
28 #
29 use base qw(Exporter);
30 @Template::Forum::EXPORT = qw(print_forum_as_HTML);
31
32 ### sub print_forum_as_HTML ($$$) ##############################################
33 #
34 # print Forum main file to STDOUT
35 #
36 # Params: $mainfile - main xml file name
37 # $tempfile - template file name
38 # $param - hash reference (see doc for details)
39 #
40 # Return: ~none~
41 #
42 sub print_forum_as_HTML ($$$) {
43 my ($mainfile, $tempfile, $param) = @_;
44 my $assign = $param -> {assign};
45
46 my $template = new Template $tempfile;
47
48 my ($threads, $stat);
49
50 unless ($stat = lock_file ($mainfile)) {
51 if (defined $stat) {
52 violent_unlock_file ($mainfile);
53 print ${$template -> scrap (
54 $assign -> {errorDoc},
55 { $assign -> {errorText} => $template -> insert ($assign -> {'occupied'}) }
56 )};
57 }
58 else {
59 print ${$template -> scrap (
60 $assign -> {errorDoc},
61 { $assign -> {errorText} => $template -> insert ($assign -> {'notAvailable'}) }
62 )};
63 }}
64
65 else {
66 my $view = get_view_params (
67 { adminDefault => $param -> {adminDefault} }
68 );
69
70 $threads = get_all_threads ($mainfile, $param -> {showDeleted}, $view -> {sortedMsg});
71 violent_unlock_file ($mainfile) unless (unlock_file ($mainfile));
72
73 print ${$template -> scrap (
74 $assign -> {mainDocStart},
75 { $assign -> {loadingTime} => plain (long_hr_time (time)) }
76 )
77 },"\n<dl>";
78
79 my $tpar = {
80 template => $param -> {tree},
81 cgi => $param -> {cgi},
82 start => -1
83 };
84
85 my @threads;
86
87 unless ($view -> {sortedThreads}) {
88 @threads = sort {$b <=> $a} keys %$threads;}
89 else {
90 @threads = sort {$a <=> $b} keys %$threads;}
91
92 for (@threads) {
93 $tpar -> {thread} = "$_";
94 print ${html_thread ($threads -> {$_}, $template, $tpar)},"\n",'<dd>&nbsp;</dd>',"\n";}
95
96 print "</dl>\n",${$template -> scrap ($assign -> {mainDocEnd})};}
97
98 return;
99 }
100
101 # keep require happy
102 1;
103
104 #
105 #
106 ### end of Template::Forum #####################################################

patrick-canterino.de