]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Forum.pm
Conf.pm: turned $Bin into $Config (we're now interested in config path not longer...
[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(get_all_threads long_hr_time);
18 use Template;
19 use Template::_conf;
20 use Template::_thread;
21
22 ################################################################################
23 #
24 # Export
25 #
26 use base qw(Exporter);
27 @Template::Forum::EXPORT = qw(print_forum_as_HTML);
28
29 ### sub print_forum_as_HTML ($$$) ##############################################
30 #
31 # print Forum main file to STDOUT
32 #
33 # Params: $mainfile - main xml file name
34 # $tempfile - template file name
35 # $param - hash reference (see doc for details)
36 #
37 # Return: ~none~
38 #
39 sub print_forum_as_HTML ($$$) {
40 my ($mainfile, $tempfile, $param) = @_;
41 my $assign = $param -> {assign};
42
43 my $template = new Template $tempfile;
44
45 my ($threads, $stat);
46
47 unless ($stat = lock_file ($mainfile)) {
48 if (defined $stat) {
49 violent_unlock_file ($mainfile);
50 print ${$template -> scrap (
51 $assign -> {errorDoc},
52 { $assign -> {errorText} => $template -> insert ($assign -> {'occupied'}) }
53 )};
54 }
55 else {
56 print ${$template -> scrap (
57 $assign -> {errorDoc},
58 { $assign -> {errorText} => $template -> insert ($assign -> {'notAvailable'}) }
59 )};
60 }}
61
62 else {
63 my $view = get_view_params (
64 { adminDefault => $param -> {adminDefault} }
65 );
66
67 $threads = get_all_threads ($mainfile, $param -> {showDeleted}, $view -> {sortedMsg});
68 violent_unlock_file ($mainfile) unless (unlock_file ($mainfile));
69
70 print ${$template -> scrap (
71 $assign -> {mainDocStart},
72 { $assign -> {loadingTime} => plain (long_hr_time (time)) }
73 )
74 },"\n<dl>";
75
76 my $tpar = {
77 template => $param -> {tree},
78 cgi => $param -> {cgi},
79 start => -1
80 };
81
82 my @threads;
83
84 unless ($view -> {sortedThreads}) {
85 @threads = sort {$b <=> $a} keys %$threads;}
86 else {
87 @threads = sort {$a <=> $b} keys %$threads;}
88
89 for (@threads) {
90 $tpar -> {thread} = "$_";
91 print ${html_thread ($threads -> {$_}, $template, $tpar)},"\n",'<dd>&nbsp;</dd>',"\n";}
92
93 print "</dl>\n",${$template -> scrap ($assign -> {mainDocEnd})};}
94
95 return;
96 }
97
98 # keep require happy
99 1;
100
101 #
102 #
103 ### end of Template::Forum #####################################################

patrick-canterino.de