]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Forum.pm
245bb5e469e8a68cad7f55d71067c9434c3f0d52
[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-06-16 #
8 # #
9 # Description: print Forum main file to STDOUT #
10 # #
11 ################################################################################
12
13 use strict;
14 use vars qw(
15 @EXPORT
16 $VERSION
17 );
18
19 use Lock qw(:READ);
20 use Encode::Plain; $Encode::Plain::utf8 = 1;
21 use Posting::_lib qw(
22 get_all_threads
23 long_hr_time
24 );
25 use Template;
26 use Template::_conf;
27 use Template::_thread;
28
29 ################################################################################
30 #
31 # Version check
32 #
33 $VERSION = do { my @r =(q$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
34
35 ################################################################################
36 #
37 # Export
38 #
39 use base qw(Exporter);
40 @EXPORT = qw(print_forum_as_HTML);
41
42 ### print_forum_as_HTML () #####################################################
43 #
44 # print Forum main file to STDOUT
45 #
46 # Params: $mainfile - main xml file name
47 # $tempfile - template file name
48 # $param - hash reference (see doc for details)
49 #
50 # Return: ~none~
51 #
52 sub print_forum_as_HTML ($$$) {
53 my ($mainfile, $tempfile, $param) = @_;
54 my $assign = $param -> {assign};
55
56 my $template = new Template $tempfile;
57
58 my ($threads, $stat);
59
60 unless ($stat = lock_file ($mainfile)) {
61 if (defined $stat) {
62 violent_unlock_file ($mainfile);
63 print ${$template -> scrap (
64 $assign -> {errorDoc},
65 { $assign -> {errorText} => $template -> insert ($assign -> {'occupied'}) }
66 )};
67 }
68 else {
69 print ${$template -> scrap (
70 $assign -> {errorDoc},
71 { $assign -> {errorText} => $template -> insert ($assign -> {'notAvailable'}) }
72 )};
73 }}
74
75 else {
76 my $view = get_view_params (
77 { adminDefault => $param -> {adminDefault} }
78 );
79
80 # set process priority, remove if you don't need...
81 #
82 eval {setpriority 0,0,1};
83
84 $threads = get_all_threads ($mainfile, $param -> {showDeleted}, $view -> {sortedMsg});
85 violent_unlock_file ($mainfile) unless (unlock_file ($mainfile));
86
87 print ${$template -> scrap (
88 $assign -> {mainDocStart},
89 { $assign -> {loadingTime} => plain (long_hr_time (time)) }
90 )
91 },"\n<dl>";
92
93 my $tpar = {
94 template => $param -> {tree},
95 cgi => $param -> {cgi},
96 start => -1
97 };
98
99 my @threads;
100
101 unless ($view -> {sortedThreads}) {
102 @threads = sort {$b <=> $a} keys %$threads;}
103 else {
104 @threads = sort {$a <=> $b} keys %$threads;}
105
106 for (@threads) {
107 $tpar -> {thread} = "$_";
108 print ${html_thread ($threads -> {$_}, $template, $tpar)},"\n",'<dd>&nbsp;</dd>',"\n";}
109
110 print "</dl>\n",${$template -> scrap ($assign -> {mainDocEnd})};}
111
112 return;
113 }
114
115 # keep 'require' happy
116 1;
117
118 #
119 #
120 ### end of Template::Forum #####################################################

patrick-canterino.de