Recent.template.php 20 KB

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