author | Dan |
Wed, 17 Oct 2007 23:17:09 -0400 | |
changeset 3 | 88b85b9b9272 |
parent 2 | 253118325c65 |
permissions | -rw-r--r-- |
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 /> |
|
3
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
96 |
<!-- BEGIN user_is_registered --> |
2 | 97 |
Joined: {REG_TIME} |
3
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
98 |
<!-- END user_is_registered --> |
2 | 99 |
<!-- BEGIN whos_online_support --> |
100 |
<br /> |
|
101 |
<!-- BEGIN user_is_online --> |
|
102 |
<span style="color: #007900;"><b>Online</b></span> |
|
103 |
<!-- BEGINELSE user_is_online --> |
|
104 |
<span style="color: #666666;">Offline</span> |
|
105 |
<!-- END user_is_online --> |
|
106 |
<!-- END whos_online_support --> |
|
107 |
</td> |
|
108 |
</tr> |
|
109 |
<!-- END show_post --> |
|
110 |
</table> |
|
111 |
</div> |
|
112 |
||
113 |
<!-- End of post: {POST_ID} --> |
|
114 |
'; |
|
115 |
||
116 |
var $parser; |
|
117 |
||
118 |
/** |
|
119 |
* Constructor. Sets up parser object. |
|
120 |
*/ |
|
121 |
||
122 |
function __construct() |
|
123 |
{ |
|
124 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
125 |
$this->parser = $template->makeParserText($this->post_template); |
|
126 |
} |
|
127 |
||
128 |
/** |
|
129 |
* Renders a post. |
|
130 |
* @todo document |
|
131 |
* @access private |
|
132 |
*/ |
|
133 |
||
134 |
function _render($_, $row) |
|
135 |
{ |
|
136 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
137 |
global $whos_online; |
|
138 |
||
3
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
139 |
if ( $row['deleted'] == 1 && !$session->get_permissions('decir_see_deleted_post') ) |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
140 |
{ |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
141 |
return ''; |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
142 |
} |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
143 |
|
2 | 144 |
$poster_name = ( $row['poster_id'] == 1 ) ? $row['poster_name'] : $row['username']; |
145 |
$datetime = date('F d, Y h:i a', $row['timestamp']); |
|
146 |
$post_text = render_bbcode($row['post_text'], $row['bbcode_uid']); |
|
147 |
$post_text = RenderMan::smilieyize($post_text); |
|
148 |
$regtime = date('F Y', $row['reg_time']); |
|
149 |
||
150 |
$user_color = '#0000AA'; |
|
151 |
switch ( $row['user_level'] ) |
|
152 |
{ |
|
153 |
case USER_LEVEL_ADMIN: $user_color = '#AA0000'; break; |
|
154 |
case USER_LEVEL_MOD: $user_color = '#00AA00'; break; |
|
155 |
} |
|
156 |
if ( $row['poster_id'] > 1 ) |
|
157 |
{ |
|
158 |
$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>"; |
|
159 |
} |
|
160 |
else |
|
161 |
{ |
|
162 |
$user_link = '<big>'.$poster_name.'</big>'; |
|
163 |
} |
|
164 |
$quote_link = makeUrlNS('Special', 'Forum/New/Quote/' . $row['post_id'], false, true); |
|
165 |
$edit_link = makeUrlNS('Special', 'Forum/Edit/' . $row['post_id'], false, true); |
|
166 |
$delete_link = makeUrlNS('Special', 'Forum/Delete/' . $row['post_id'], false, true); |
|
167 |
$restore_link = makeUrlNS('Special', 'Forum/Delete/' . $row['post_id'], 'act=restore', true); |
|
168 |
$user_title = 'Anonymous user'; |
|
169 |
switch ( $row['user_level'] ) |
|
170 |
{ |
|
171 |
case USER_LEVEL_ADMIN: $user_title = 'Administrator'; break; |
|
172 |
case USER_LEVEL_MOD: $user_title = 'Moderator'; break; |
|
173 |
case USER_LEVEL_MEMBER:$user_title = 'Member'; break; |
|
174 |
case USER_LEVEL_GUEST: $user_title = 'Guest'; break; |
|
175 |
} |
|
176 |
$leb_link = ''; |
|
177 |
if ( $row['editor'] ) |
|
178 |
{ |
|
179 |
$userpage_url = makeUrlNS('User', sanitize_page_id($row['editor']), false, true); |
|
180 |
$row['editor'] = htmlspecialchars($row['editor']); |
|
181 |
$leb_link = "<a href=\"$userpage_url\">{$row['editor']}</a>"; |
|
182 |
} |
|
183 |
$this->parser->assign_vars(Array( |
|
184 |
'POST_ID' => (string)$row['post_id'], |
|
185 |
'USERNAME' => $poster_name, |
|
186 |
'USER_LINK' => $user_link, |
|
187 |
'REG_TIME' => $regtime, |
|
188 |
'TIMESTAMP' => $datetime, |
|
189 |
'POST_TEXT' => $post_text, |
|
190 |
'USER_TITLE' => $user_title, |
|
191 |
'QUOTE_LINK' => $quote_link, |
|
192 |
'EDIT_LINK' => $edit_link, |
|
193 |
'DELETE_LINK' => $delete_link, |
|
194 |
'RESTORE_LINK' => $restore_link, |
|
195 |
'EDIT_COUNT' => $row['edit_count'], |
|
196 |
'EDIT_COUNT_S' => ( $row['edit_count'] == 1 ? '' : 's' ), |
|
197 |
'LAST_EDITED_BY' => $leb_link, |
|
198 |
'EDIT_REASON' => htmlspecialchars($row['edit_reason']) |
|
199 |
)); |
|
200 |
// Decir can integrate with the Who's Online plugin |
|
201 |
$who_support = $plugins->loaded('WhosOnline') && $row['user_level'] >= USER_LEVEL_GUEST; |
|
202 |
$user_online = false; |
|
203 |
if ( $who_support && in_array($row['username'], $whos_online['users']) ) |
|
204 |
{ |
|
205 |
$user_online = true; |
|
206 |
} |
|
207 |
elseif ( $row['poster_id'] < 2 ) |
|
208 |
{ |
|
209 |
$who_support = false; |
|
210 |
} |
|
3
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
211 |
|
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
212 |
// die('<pre>' . print_r($session, true) . '</pre>'); |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
213 |
|
2 | 214 |
$this->parser->assign_bool(Array( |
215 |
'whos_online_support' => $who_support, |
|
216 |
'user_is_online' => $user_online, |
|
217 |
'post_edited' => ( $row['edit_count'] > 0 ), |
|
218 |
'post_deleted' => ( $row['post_deleted'] == 1 ), |
|
3
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
219 |
'show_post' => ( $session->get_permissions('decir_see_deleted_post_full') || $row['post_deleted'] != 1 ), |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
220 |
'user_is_registered' => ( $row['poster_id'] > 1 ) |
2 | 221 |
)); |
222 |
return $this->parser->run(); |
|
223 |
} |
|
224 |
} |
|
225 |
||
226 |
?> |