]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Forum.pm
if is_email and is_URL are called without a parameter, now $_ will be evaluated
[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;
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 my $main = new Lock ($mainfile);
60
61 unless ($main -> lock (LH_SHARED)) {
62 unless ($main -> masterlocked) {
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 ($main -> filename, $param -> {showDeleted}, $view -> {sortedMsg});
85 $main -> unlock;
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