2
|
1 |
<?php
|
|
2 |
/*
|
|
3 |
* Decir
|
|
4 |
* Version 0.1
|
|
5 |
* Copyright (C) 2007 Dan Fuhry
|
|
6 |
* functions_viewtopic.php - Postbit compiler
|
|
7 |
*
|
|
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
|
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
|
13 |
*/
|
|
14 |
|
|
15 |
/**
|
|
16 |
* Internally used in viewtopic; called by paginate()
|
|
17 |
* @package Decir
|
|
18 |
* @subpackage Presentation/UI
|
|
19 |
* @access private
|
|
20 |
*/
|
|
21 |
|
|
22 |
class DecirPostbit
|
|
23 |
{
|
|
24 |
var $post_template = '
|
|
25 |
<!-- Start of post: {POST_ID} -->
|
|
26 |
|
|
27 |
<a name="{POST_ID}" id="{POST_ID}"></a>
|
|
28 |
<div class="post tblholder">
|
|
29 |
<table border="0" cellspacing="1" cellpadding="4" style="width: 100%;">
|
|
30 |
<!-- BEGIN post_deleted -->
|
|
31 |
<tr>
|
|
32 |
<td class="row3" valign="top" style="height: 100%;">
|
|
33 |
<i>This post was deleted by {LAST_EDITED_BY}.<br />
|
|
34 |
<b>Reason:</b> {EDIT_REASON}</i>
|
|
35 |
<!-- BEGIN show_post -->
|
|
36 |
<br />
|
|
37 |
<br />
|
|
38 |
<b>The deleted post is shown below:</b>
|
|
39 |
<!-- END show_post -->
|
|
40 |
</td>
|
|
41 |
<td class="row1" style="width: 120px;" valign="top">
|
|
42 |
{USER_LINK}
|
|
43 |
</td>
|
|
44 |
</tr>
|
|
45 |
<!-- END post_deleted -->
|
|
46 |
<!-- BEGIN show_post -->
|
|
47 |
<tr>
|
|
48 |
<th colspan="2" style="text-align: left;">Posted: {TIMESTAMP}</th>
|
|
49 |
</tr>
|
|
50 |
<tr>
|
|
51 |
<td class="row3" valign="top" style="height: 100%;">
|
|
52 |
<table border="0" width="100%" style="height: 100%; background-color: transparent;">
|
|
53 |
<tr>
|
|
54 |
<td valign="top" colspan="2">
|
|
55 |
{POST_TEXT}
|
|
56 |
</td>
|
|
57 |
</tr>
|
|
58 |
<!-- BEGINNOT post_deleted -->
|
|
59 |
<tr>
|
|
60 |
<td valign="bottom" style="text-align: left; font-size: smaller;">
|
|
61 |
<!-- BEGIN post_edited -->
|
|
62 |
<i>Last edited by {LAST_EDITED_BY}; edited <b>{EDIT_COUNT}</b> time{EDIT_COUNT_S} in total<br />
|
|
63 |
<b>Reason:</b> {EDIT_REASON}</i>
|
|
64 |
<!-- END post_edited -->
|
|
65 |
</td>
|
|
66 |
<td valign="bottom" style="text-align: right;">
|
|
67 |
<small><a href="{EDIT_LINK}">edit</a> | <a href="{DELETE_LINK}">delete</a> | <a href="{QUOTE_LINK}">+ quote</a></small>
|
|
68 |
</td>
|
|
69 |
</tr>
|
|
70 |
<!-- BEGINELSE post_deleted -->
|
|
71 |
<tr>
|
|
72 |
<td valign="bottom" style="text-align: left; font-size: smaller;">
|
|
73 |
</td>
|
|
74 |
<td valign="bottom" style="text-align: right;">
|
|
75 |
<small><a href="{RESTORE_LINK}">restore post</a> | <a href="{DELETE_LINK}">physically delete</a></small>
|
|
76 |
</td>
|
|
77 |
</tr>
|
|
78 |
<!-- END post_deleted -->
|
|
79 |
</table>
|
|
80 |
</td>
|
|
81 |
<td class="row1" style="width: 120px;" valign="top">
|
|
82 |
<div class="menu_nojs">
|
|
83 |
{USER_LINK}
|
|
84 |
<ul>
|
|
85 |
<li><a>View profile</a></li>
|
|
86 |
<li><a>Visit homepage</a></li>
|
|
87 |
<li><a href="{QUOTE_LINK}">Quote this post</a></li>
|
|
88 |
<li><a>Vote to ban this user</a></li>
|
|
89 |
<li><a>Send private message</a></li>
|
|
90 |
<li><a>View all messages posted by {USERNAME}</a></li>
|
|
91 |
</ul>
|
|
92 |
</div>
|
|
93 |
<span class="menuclear"></span>
|
|
94 |
{USER_TITLE}<br />
|
|
95 |
<br />
|
|
96 |
Joined: {REG_TIME}
|
|
97 |
<!-- BEGIN whos_online_support -->
|
|
98 |
<br />
|
|
99 |
<!-- BEGIN user_is_online -->
|
|
100 |
<span style="color: #007900;"><b>Online</b></span>
|
|
101 |
<!-- BEGINELSE user_is_online -->
|
|
102 |
<span style="color: #666666;">Offline</span>
|
|
103 |
<!-- END user_is_online -->
|
|
104 |
<!-- END whos_online_support -->
|
|
105 |
</td>
|
|
106 |
</tr>
|
|
107 |
<!-- END show_post -->
|
|
108 |
</table>
|
|
109 |
</div>
|
|
110 |
|
|
111 |
<!-- End of post: {POST_ID} -->
|
|
112 |
';
|
|
113 |
|
|
114 |
var $parser;
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Constructor. Sets up parser object.
|
|
118 |
*/
|
|
119 |
|
|
120 |
function __construct()
|
|
121 |
{
|
|
122 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
|
123 |
$this->parser = $template->makeParserText($this->post_template);
|
|
124 |
}
|
|
125 |
|
|
126 |
/**
|
|
127 |
* Renders a post.
|
|
128 |
* @todo document
|
|
129 |
* @access private
|
|
130 |
*/
|
|
131 |
|
|
132 |
function _render($_, $row)
|
|
133 |
{
|
|
134 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
|
135 |
global $whos_online;
|
|
136 |
|
|
137 |
$poster_name = ( $row['poster_id'] == 1 ) ? $row['poster_name'] : $row['username'];
|
|
138 |
$datetime = date('F d, Y h:i a', $row['timestamp']);
|
|
139 |
$post_text = render_bbcode($row['post_text'], $row['bbcode_uid']);
|
|
140 |
$post_text = RenderMan::smilieyize($post_text);
|
|
141 |
$regtime = date('F Y', $row['reg_time']);
|
|
142 |
|
|
143 |
$user_color = '#0000AA';
|
|
144 |
switch ( $row['user_level'] )
|
|
145 |
{
|
|
146 |
case USER_LEVEL_ADMIN: $user_color = '#AA0000'; break;
|
|
147 |
case USER_LEVEL_MOD: $user_color = '#00AA00'; break;
|
|
148 |
}
|
|
149 |
if ( $row['poster_id'] > 1 )
|
|
150 |
{
|
|
151 |
$user_link = "<a style='color: $user_color; background-color: transparent; display: inline; padding: 0;' href='".makeUrlNS('User', str_replace(' ', '_', $poster_name))."'><big>$poster_name</big></a>";
|
|
152 |
}
|
|
153 |
else
|
|
154 |
{
|
|
155 |
$user_link = '<big>'.$poster_name.'</big>';
|
|
156 |
}
|
|
157 |
$quote_link = makeUrlNS('Special', 'Forum/New/Quote/' . $row['post_id'], false, true);
|
|
158 |
$edit_link = makeUrlNS('Special', 'Forum/Edit/' . $row['post_id'], false, true);
|
|
159 |
$delete_link = makeUrlNS('Special', 'Forum/Delete/' . $row['post_id'], false, true);
|
|
160 |
$restore_link = makeUrlNS('Special', 'Forum/Delete/' . $row['post_id'], 'act=restore', true);
|
|
161 |
$user_title = 'Anonymous user';
|
|
162 |
switch ( $row['user_level'] )
|
|
163 |
{
|
|
164 |
case USER_LEVEL_ADMIN: $user_title = 'Administrator'; break;
|
|
165 |
case USER_LEVEL_MOD: $user_title = 'Moderator'; break;
|
|
166 |
case USER_LEVEL_MEMBER:$user_title = 'Member'; break;
|
|
167 |
case USER_LEVEL_GUEST: $user_title = 'Guest'; break;
|
|
168 |
}
|
|
169 |
$leb_link = '';
|
|
170 |
if ( $row['editor'] )
|
|
171 |
{
|
|
172 |
$userpage_url = makeUrlNS('User', sanitize_page_id($row['editor']), false, true);
|
|
173 |
$row['editor'] = htmlspecialchars($row['editor']);
|
|
174 |
$leb_link = "<a href=\"$userpage_url\">{$row['editor']}</a>";
|
|
175 |
}
|
|
176 |
$this->parser->assign_vars(Array(
|
|
177 |
'POST_ID' => (string)$row['post_id'],
|
|
178 |
'USERNAME' => $poster_name,
|
|
179 |
'USER_LINK' => $user_link,
|
|
180 |
'REG_TIME' => $regtime,
|
|
181 |
'TIMESTAMP' => $datetime,
|
|
182 |
'POST_TEXT' => $post_text,
|
|
183 |
'USER_TITLE' => $user_title,
|
|
184 |
'QUOTE_LINK' => $quote_link,
|
|
185 |
'EDIT_LINK' => $edit_link,
|
|
186 |
'DELETE_LINK' => $delete_link,
|
|
187 |
'RESTORE_LINK' => $restore_link,
|
|
188 |
'EDIT_COUNT' => $row['edit_count'],
|
|
189 |
'EDIT_COUNT_S' => ( $row['edit_count'] == 1 ? '' : 's' ),
|
|
190 |
'LAST_EDITED_BY' => $leb_link,
|
|
191 |
'EDIT_REASON' => htmlspecialchars($row['edit_reason'])
|
|
192 |
));
|
|
193 |
// Decir can integrate with the Who's Online plugin
|
|
194 |
$who_support = $plugins->loaded('WhosOnline') && $row['user_level'] >= USER_LEVEL_GUEST;
|
|
195 |
$user_online = false;
|
|
196 |
if ( $who_support && in_array($row['username'], $whos_online['users']) )
|
|
197 |
{
|
|
198 |
$user_online = true;
|
|
199 |
}
|
|
200 |
elseif ( $row['poster_id'] < 2 )
|
|
201 |
{
|
|
202 |
$who_support = false;
|
|
203 |
}
|
|
204 |
$this->parser->assign_bool(Array(
|
|
205 |
'whos_online_support' => $who_support,
|
|
206 |
'user_is_online' => $user_online,
|
|
207 |
'post_edited' => ( $row['edit_count'] > 0 ),
|
|
208 |
'post_deleted' => ( $row['post_deleted'] == 1 ),
|
|
209 |
// FIXME: This should check something on ACLs
|
|
210 |
'show_post' => ( $row['post_deleted'] != 1 || $session->user_level >= USER_LEVEL_MOD )
|
|
211 |
));
|
|
212 |
return $this->parser->run();
|
|
213 |
}
|
|
214 |
}
|
|
215 |
|
|
216 |
?>
|