comparison forum/Themes/default/Recent.template.php @ 76:e3e11437ecea website

Add forum code
author Chris Cannam
date Sun, 07 Jul 2013 11:25:48 +0200
parents
children
comparison
equal deleted inserted replaced
75:72f59aa7e503 76:e3e11437ecea
1 <?php
2 /**
3 * Simple Machines Forum (SMF)
4 *
5 * @package SMF
6 * @author Simple Machines
7 * @copyright 2011 Simple Machines
8 * @license http://www.simplemachines.org/about/smf/license.php BSD
9 *
10 * @version 2.0
11 */
12
13 function template_main()
14 {
15 global $context, $settings, $options, $txt, $scripturl;
16
17 echo '
18 <div id="recent" class="main_section">
19 <div class="cat_bar">
20 <h3 class="catbg">
21 <span class="ie6_header floatleft"><img src="', $settings['images_url'], '/post/xx.gif" alt="" class="icon" />',$txt['recent_posts'],'</span>
22 </h3>
23 </div>
24 <div class="pagesection">
25 <span>', $txt['pages'], ': ', $context['page_index'], '</span>
26 </div>';
27
28 foreach ($context['posts'] as $post)
29 {
30 echo '
31 <div class="', $post['alternate'] == 0 ? 'windowbg' : 'windowbg2', ' core_posts">
32 <span class="topslice"><span></span></span>
33 <div class="content">
34 <div class="counter">', $post['counter'], '</div>
35 <div class="topic_details">
36 <h5>', $post['board']['link'], ' / ', $post['link'], '</h5>
37 <span class="smalltext">&#171;&nbsp;', $txt['last_post'], ' ', $txt['by'], ' <strong>', $post['poster']['link'], ' </strong> ', $txt['on'], '<em> ', $post['time'], '</em>&nbsp;&#187;</span>
38 </div>
39 <div class="list_posts">', $post['message'], '</div>
40 </div>';
41
42 if ($post['can_reply'] || $post['can_mark_notify'] || $post['can_delete'])
43 echo '
44 <div class="quickbuttons_wrap">
45 <ul class="reset smalltext quickbuttons">';
46
47 // If they *can* reply?
48 if ($post['can_reply'])
49 echo '
50 <li class="reply_button"><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span>', $txt['reply'], '</span></a></li>';
51
52 // If they *can* quote?
53 if ($post['can_quote'])
54 echo '
55 <li class="quote_button"><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span>', $txt['quote'], '</span></a></li>';
56
57 // Can we request notification of topics?
58 if ($post['can_mark_notify'])
59 echo '
60 <li class="notify_button"><a href="', $scripturl, '?action=notify;topic=', $post['topic'], '.', $post['start'], '"><span>', $txt['notify'], '</span></a></li>';
61
62 // How about... even... remove it entirely?!
63 if ($post['can_delete'])
64 echo '
65 <li class="remove_button"><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['remove_message'], '?\');"><span>', $txt['remove'], '</span></a></li>';
66
67 if ($post['can_reply'] || $post['can_mark_notify'] || $post['can_delete'])
68 echo '
69 </ul>
70 </div>';
71
72 echo '
73 <span class="botslice clear"><span></span></span>
74 </div>';
75
76 }
77
78 echo '
79 <div class="pagesection">
80 <span>', $txt['pages'], ': ', $context['page_index'], '</span>
81 </div>
82 </div>';
83 }
84
85 function template_unread()
86 {
87 global $context, $settings, $options, $txt, $scripturl, $modSettings;
88
89 echo '
90 <div id="recent" class="main_content">';
91
92 $showCheckboxes = !empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $settings['show_mark_read'];
93
94 if ($showCheckboxes)
95 echo '
96 <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;">
97 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
98 <input type="hidden" name="qaction" value="markread" />
99 <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '" />';
100
101 if ($settings['show_mark_read'])
102 {
103 // Generate the button strip.
104 $mark_read = array(
105 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
106 );
107
108 if ($showCheckboxes)
109 $mark_read['markselectread'] = array(
110 'text' => 'quick_mod_markread',
111 'image' => 'markselectedread.gif',
112 'lang' => true,
113 'url' => 'javascript:document.quickModForm.submit();',
114 );
115 }
116
117 if (!empty($context['topics']))
118 {
119 echo '
120 <div class="pagesection">';
121
122 if (!empty($mark_read) && !empty($settings['use_tabs']))
123 template_button_strip($mark_read, 'right');
124
125 echo '
126 <span>', $txt['pages'], ': ', $context['page_index'], '</span>
127 </div>';
128
129 echo '
130 <div class="tborder topic_table" id="unread">
131 <table class="table_grid" cellspacing="0">
132 <thead>
133 <tr class="catbg">
134 <th scope="col" class="first_th" width="8%" colspan="2">&nbsp;</th>
135 <th scope="col">
136 <a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['subject'], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
137 </th>
138 <th scope="col" width="14%" align="center">
139 <a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=replies', $context['sort_by'] == 'replies' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['replies'], $context['sort_by'] == 'replies' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
140 </th>';
141
142 // Show a "select all" box for quick moderation?
143 if ($showCheckboxes)
144 echo '
145 <th scope="col" width="22%">
146 <a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] == 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
147 </th>
148 <th class="last_th">
149 <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check" />
150 </th>';
151 else
152 echo '
153 <th scope="col" class="smalltext last_th" width="22%">
154 <a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] == 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
155 </th>';
156 echo '
157 </tr>
158 </thead>
159 <tbody>';
160
161 foreach ($context['topics'] as $topic)
162 {
163 // Calculate the color class of the topic.
164 $color_class = '';
165 if (strpos($topic['class'], 'sticky') !== false)
166 $color_class = 'stickybg';
167 if (strpos($topic['class'], 'locked') !== false)
168 $color_class .= 'lockedbg';
169
170 $color_class2 = !empty($color_class) ? $color_class . '2' : '';
171
172 echo '
173 <tr>
174 <td class="', $color_class, ' icon1 windowbg">
175 <img src="', $settings['images_url'], '/topic/', $topic['class'], '.gif" alt="" />
176 </td>
177 <td class="', $color_class, ' icon2 windowbg">
178 <img src="', $topic['first_post']['icon_url'], '" alt="" />
179 </td>
180 <td class="subject ', $color_class2, ' windowbg2">
181 <div>
182 ', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
183 <a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '"><img src="', $settings['lang_images_url'], '/new.gif" alt="', $txt['new'], '" /></a>
184 <p>
185 ', $txt['started_by'], ' <strong>', $topic['first_post']['member']['link'], '</strong>
186 ', $txt['in'], ' <em>', $topic['board']['link'], '</em>
187 <small id="pages', $topic['first_post']['id'], '">', $topic['pages'], '</small>
188 </p>
189 </div>
190 </td>
191 <td class="', $color_class, ' stats windowbg">
192 ', $topic['replies'], ' ', $txt['replies'], '
193 <br />
194 ', $topic['views'], ' ', $txt['views'], '
195 </td>
196 <td class="', $color_class2, ' lastpost windowbg2">
197 <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" style="float: right;" /></a>
198 ', $topic['last_post']['time'], '<br />
199 ', $txt['by'], ' ', $topic['last_post']['member']['link'], '
200 </td>';
201
202 if ($showCheckboxes)
203 echo '
204 <td class="windowbg2" valign="middle" align="center">
205 <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
206 </td>';
207 echo '
208 </tr>';
209 }
210
211 if (!empty($context['topics']) && !$context['showing_all_topics'])
212 $mark_read['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.gif', 'lang' => true, 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
213
214 if (empty($settings['use_tabs']) && !empty($mark_read))
215 echo '
216 <tr class="catbg">
217 <td colspan="', $showCheckboxes ? '6' : '5', '" align="right">
218 ', template_button_strip($mark_read, 'top'), '
219 </td>
220 </tr>';
221
222 if (empty($context['topics']))
223 echo '
224 <tr style="display: none;"><td></td></tr>';
225
226 echo '
227 </tbody>
228 </table>
229 </div>
230 <div class="pagesection" id="readbuttons">';
231
232 if (!empty($settings['use_tabs']) && !empty($mark_read))
233 template_button_strip($mark_read, 'right');
234
235 echo '
236 <span>', $txt['pages'], ': ', $context['page_index'], '</span>
237 </div>';
238 }
239 else
240 echo '
241 <div class="cat_bar">
242 <h3 class="catbg centertext">
243 ', $context['showing_all_topics'] ? $txt['msg_alert_none'] : $txt['unread_topics_visit_none'], '
244 </h3>
245 </div>';
246
247 if ($showCheckboxes)
248 echo '
249 </form>';
250
251 echo '
252 <div class="description " id="topic_icons">
253 <p class="smalltext floatleft">
254 ', !empty($modSettings['enableParticipation']) ? '
255 <img src="' . $settings['images_url'] . '/topic/my_normal_post.gif" alt="" align="middle" /> ' . $txt['participation_caption'] . '<br />' : '', '
256 <img src="', $settings['images_url'], '/topic/normal_post.gif" alt="" align="middle" /> ', $txt['normal_topic'], '<br />
257 <img src="', $settings['images_url'], '/topic/hot_post.gif" alt="" align="middle" /> ', sprintf($txt['hot_topics'], $modSettings['hotTopicPosts']), '<br />
258 <img src="', $settings['images_url'], '/topic/veryhot_post.gif" alt="" align="middle" /> ', sprintf($txt['very_hot_topics'], $modSettings['hotTopicVeryPosts']), '
259 </p>
260 <p class="smalltext para2">
261 <img src="', $settings['images_url'], '/icons/quick_lock.gif" alt="" align="middle" /> ', $txt['locked_topic'], '<br />', ($modSettings['enableStickyTopics'] == '1' ? '
262 <img src="' . $settings['images_url'] . '/icons/quick_sticky.gif" alt="" align="middle" /> ' . $txt['sticky_topic'] . '<br />' : ''), ($modSettings['pollMode'] == '1' ? '
263 <img src="' . $settings['images_url'] . '/topic/normal_poll.gif" alt="" align="middle" /> ' . $txt['poll'] : ''), '
264 </p>
265 </div>
266 </div>';
267 }
268
269 function template_replies()
270 {
271 global $context, $settings, $options, $txt, $scripturl, $modSettings;
272
273 echo '
274 <div id="recent">';
275
276 $showCheckboxes = !empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $settings['show_mark_read'];
277
278 if ($showCheckboxes)
279 echo '
280 <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;">
281 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
282 <input type="hidden" name="qaction" value="markread" />
283 <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '" />';
284
285 if (isset($context['topics_to_mark']) && !empty($settings['show_mark_read']))
286 {
287 // Generate the button strip.
288 $mark_read = array(
289 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
290 );
291
292 if ($showCheckboxes)
293 $mark_read['markselectread'] = array(
294 'text' => 'quick_mod_markread',
295 'image' => 'markselectedread.gif',
296 'lang' => true,
297 'url' => 'javascript:document.quickModForm.submit();',
298 );
299 }
300
301 if (!empty($context['topics']))
302 {
303 echo '
304 <div class="pagesection">';
305
306 if (!empty($mark_read) && !empty($settings['use_tabs']))
307 template_button_strip($mark_read, 'right');
308
309 echo '
310 <span>', $txt['pages'], ': ', $context['page_index'], '</span>
311 </div>';
312
313 echo '
314 <div class="tborder topic_table" id="unreadreplies">
315 <table class="table_grid" cellspacing="0">
316 <thead>
317 <tr class="catbg">
318 <th scope="col" class="first_th" width="8%" colspan="2">&nbsp;</th>
319 <th scope="col">
320 <a href="', $scripturl, '?action=unreadreplies', $context['querystring_board_limits'], ';sort=subject', $context['sort_by'] === 'subject' && $context['sort_direction'] === 'up' ? ';desc' : '', '">', $txt['subject'], $context['sort_by'] === 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
321 </th>
322 <th scope="col" width="14%" align="center">
323 <a href="', $scripturl, '?action=unreadreplies', $context['querystring_board_limits'], ';sort=replies', $context['sort_by'] === 'replies' && $context['sort_direction'] === 'up' ? ';desc' : '', '">', $txt['replies'], $context['sort_by'] === 'replies' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
324 </th>';
325
326 // Show a "select all" box for quick moderation?
327 if ($showCheckboxes)
328 echo '
329 <th scope="col" width="22%">
330 <a href="', $scripturl, '?action=unreadreplies', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] === 'last_post' && $context['sort_direction'] === 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] === 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
331 </th>
332 <th class="last_th">
333 <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check" />
334 </th>';
335 else
336 echo '
337 <th scope="col" class="last_th" width="22%">
338 <a href="', $scripturl, '?action=unreadreplies', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] === 'last_post' && $context['sort_direction'] === 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] === 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
339 </th>';
340 echo '
341 </tr>
342 </thead>
343 <tbody>';
344
345 foreach ($context['topics'] as $topic)
346 {
347 // Calculate the color class of the topic.
348 $color_class = '';
349 if (strpos($topic['class'], 'sticky') !== false)
350 $color_class = 'stickybg';
351 if (strpos($topic['class'], 'locked') !== false)
352 $color_class .= 'lockedbg';
353
354 $color_class2 = !empty($color_class) ? $color_class . '2' : '';
355
356 echo '
357 <tr>
358 <td class="', $color_class, ' icon1 windowbg">
359 <img src="', $settings['images_url'], '/topic/', $topic['class'], '.gif" alt="" />
360 </td>
361 <td class="', $color_class, ' icon2 windowbg">
362 <img src="', $topic['first_post']['icon_url'], '" alt="" />
363 </td>
364 <td class="subject ', $color_class2, ' windowbg2">
365 <div>
366 ', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
367 <a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '"><img src="', $settings['lang_images_url'], '/new.gif" alt="', $txt['new'], '" /></a>
368 <p>
369 ', $txt['started_by'], ' <strong>', $topic['first_post']['member']['link'], '</strong>
370 ', $txt['in'], ' <em>', $topic['board']['link'], '</em>
371 <small id="pages', $topic['first_post']['id'], '">', $topic['pages'], '</small>
372 </p>
373 </div>
374 </td>
375 <td class="', $color_class, ' stats windowbg">
376 ', $topic['replies'], ' ', $txt['replies'], '
377 <br />
378 ', $topic['views'], ' ', $txt['views'], '
379 </td>
380 <td class="', $color_class2, ' lastpost windowbg2">
381 <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" style="float: right;" /></a>
382 ', $topic['last_post']['time'], '<br />
383 ', $txt['by'], ' ', $topic['last_post']['member']['link'], '
384 </td>';
385
386 if ($showCheckboxes)
387 echo '
388 <td class="windowbg2" valign="middle" align="center">
389 <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
390 </td>';
391 echo '
392 </tr>';
393 }
394
395 if (empty($settings['use_tabs']) && !empty($mark_read))
396 echo '
397 <tr class="catbg">
398 <td colspan="', $showCheckboxes ? '6' : '5', '" align="right">
399 ', template_button_strip($mark_read, 'top'), '
400 </td>
401 </tr>';
402
403 echo '
404 </tbody>
405 </table>
406 </div>
407 <div class="pagesection">';
408
409 if (!empty($settings['use_tabs']) && !empty($mark_read))
410 template_button_strip($mark_read, 'right');
411
412 echo '
413 <span>', $txt['pages'], ': ', $context['page_index'], '</span>
414 </div>';
415 }
416 else
417 echo '
418 <div class="cat_bar">
419 <h3 class="catbg centertext">
420 ', $context['showing_all_topics'] ? $txt['msg_alert_none'] : $txt['unread_topics_visit_none'], '
421 </h3>
422 </div>';
423
424 if ($showCheckboxes)
425 echo '
426 </form>';
427
428 echo '
429 <div class="description flow_auto" id="topic_icons">
430 <p class="smalltext floatleft">
431 ', !empty($modSettings['enableParticipation']) ? '
432 <img src="' . $settings['images_url'] . '/topic/my_normal_post.gif" alt="" align="middle" /> ' . $txt['participation_caption'] . '<br />' : '', '
433 <img src="', $settings['images_url'], '/topic/normal_post.gif" alt="" align="middle" /> ', $txt['normal_topic'], '<br />
434 <img src="', $settings['images_url'], '/topic/hot_post.gif" alt="" align="middle" /> ', sprintf($txt['hot_topics'], $modSettings['hotTopicPosts']), '<br />
435 <img src="', $settings['images_url'], '/topic/veryhot_post.gif" alt="" align="middle" /> ', sprintf($txt['very_hot_topics'], $modSettings['hotTopicVeryPosts']), '
436 </p>
437 <p class="smalltext para2">
438 <img src="', $settings['images_url'], '/icons/quick_lock.gif" alt="" align="middle" /> ', $txt['locked_topic'], '<br />', ($modSettings['enableStickyTopics'] == '1' ? '
439 <img src="' . $settings['images_url'] . '/icons/quick_sticky.gif" alt="" align="middle" /> ' . $txt['sticky_topic'] . '<br />' : '') . ($modSettings['pollMode'] == '1' ? '
440 <img src="' . $settings['images_url'] . '/topic/normal_poll.gif" alt="" align="middle" /> ' . $txt['poll'] : '') . '
441 </p>
442 </div>
443 </div>';
444 }
445
446 ?>