1 # Copyright 2002-2010 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 UserTag forum-userlink PosNumber 0
9 UserTag forum-userlink addAttr
10 UserTag forum-userlink Version 1.7
11 UserTag forum-userlink Routine <<EOR
14 return $row->{name} || $Variable->{FORUM_ANON_NAME} || 'Anonymous Coward'
15 if $row->{anon} or ! $row->{username};
16 my $realname = tag_data('userdb', 'handle', $row->{username})
17 || tag_data('userdb', 'fname', $row->{username});
18 return $realname || $row->{username};
22 UserTag forum Order top
24 UserTag forum hasEndTag
25 UserTag forum NoReparse 1
26 UserTag forum Version 1.7
27 UserTag forum Routine <<EOR
32 my ($id, $opt, $tpl) = @_;
44 $tpl =~ s{\[forum[-_]header\](.*)\[/forum[-_]header\]}{}is
45 and $forum_header = $1;
46 $tpl =~ s{\[forum[-_]footer\](.*)\[/forum[-_]footer\]}{}is
47 and $forum_footer = $1;
48 $tpl =~ s{\[forum[-_]link\](.*)\[/forum[-_]link\]}{}is
50 $tpl =~ s{\[forum[-_]scrub\](.*)\[/forum[-_]scrub\]}{}is
51 and $forum_scrub = $1;
53 $forum_header ||= $opt->{header_template} || <<EOF;
56 <td class=contentbar1>
77 {TOP_URL?}<A HREF="{TOP_URL}">Top</A> |{/TOP_URL?}
78 {PARENT_URL?}<A HREF="{PARENT_URL}">Parent</A> |{/PARENT_URL?}
79 <A HREF="{REPLY_URL}">Reply</A>
87 $forum_link ||= $opt->{link_template} || <<EOF;
88 <A HREF="{DISPLAY_URL}">{SUBJECT}</a> by {USERINFO} on {DATE}
91 $opt->{threshold_message} ||= errmsg("Message below your threshold");
92 $forum_scrub ||= $opt->{scrub_template} || <<EOF;
93 <A HREF="{DISPLAY_URL}">$opt->{threshold_message}</a>
96 $tpl ||= $opt->{template} || <<EOF;
97 <table cellspacing=0 cellpadding=2>
99 <td class=contentbar1>
100 <A HREF="{DISPLAY_URL}"><b>{SUBJECT}</b></A>
104 <td class=contentbar1 align=right>
105 <small>[ <A HREF="{REPLY_URL}"><b>Reply</b></A> ]</font></small>
121 $forum_footer ||= <<EOF;
122 <!-- end of forum -->
128 my $Tag = new Vend::Tags;
131 $opt->{reply_page} ||= 'forum/reply';
132 $opt->{submit_page} ||= 'forum/submit';
133 $opt->{display_page} ||= $Global::Variable->{MV_PAGE};
134 $opt->{date_format} ||= '%B %e, %Y @%H:%M';
138 $row->{reply_url} = $Tag->area({
139 href => $opt->{reply_page},
142 if($row->{code} ne $row->{artid}) {
143 $row->{top_url} = $Tag->area( {
144 href => $opt->{display_page},
145 arg => $row->{artid},
149 $row->{parent_url} = $Tag->area( {
150 href => $opt->{display_page},
151 arg => $row->{parent},
154 $row->{display_url} = $Tag->area({
155 href => $opt->{display_page},
158 $row->{userinfo} = $Tag->forum_userlink($row);
159 $row->{date} = $Tag->convert_date({
160 fmt => $opt->{date_format},
161 body => $row->{created},
163 my $lev = $row->{mv_level};
164 my $children = $row->{mv_children};
165 my $last = $row->{mv_last};
168 my $num_uls = scalar(@uls);
169 $row->{msg1} = "lastlevel=$lastlevel lev=$lev children=$children uls=$num_uls";
171 $pre .= join "", splice (@uls);
173 elsif ($lastlevel < $lev) {
176 elsif ($lastlevel > $lev) {
178 $pre .= join "", splice (@uls,$lev);
183 $num_uls = scalar(@uls);
184 $row->{msg2} = "lastlevel=$lastlevel lev=$lev children=$children uls=$num_uls";
189 $post .= join "", splice (@uls, $lev);
191 $num_uls = scalar(@uls);
192 $row->{msg3} = "lastlevel=$lastlevel lev=$lev children=$children uls=$num_uls";
193 $row->{forum_prepend} = $pre;
194 $row->{forum_append} = $post;
198 my $fdb = database_exists_ref('forum')
199 or die "No forum DB!";
201 my $record = $fdb->row_hash($id);
202 return undef unless $record;
204 $menu_row->(undef, $record);
207 $opt->{full} = 1 if ! defined $opt->{full};
209 push @out, $Tag->uc_attr_list($record, $forum_header);
215 subordinate => 'code',
216 full => $opt->{full},
217 sort => $opt->{sort} || 'code',
220 iterator => $menu_row,
226 my $rows = $o{object}{mv_results};
227 $opt->{scrub_score} ||= 0;
228 $opt->{show_score} ||= 1;
229 if(! defined $opt->{show_level}) {
230 if($record->{code} == $record->{artid}) {
231 $opt->{show_level} = 0;
234 $opt->{show_level} = 2;
238 for(\$tpl, \$forum_link, \$forum_scrub) {
239 $$_ = "{FORUM_PREPEND}$$_" unless $$_ =~ /\{FORUM_PREPEND\}/;
240 $$_ .= '{FORUM_APPEND}' unless $$_ =~ /\{FORUM_APPEND\}/;
243 for my $record (@$rows) {
246 if($record->{score} <= $opt->{scrub_score}) {
247 $this_tpl = $forum_scrub;
249 elsif($record->{score} >= $opt->{show_score}) {
252 elsif($record->{mv_level} <= $opt->{show_level}) {
256 $this_tpl = $forum_link;
258 push @out, $Tag->uc_attr_list($record, $this_tpl);
260 push @out, join "", @uls;
261 push @out, $Tag->uc_attr_list($opt, $forum_footer);
262 return join "\n", @out;