Recent.template.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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.png" 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><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '" class="reply_button"><span>', $txt['reply'], '</span></a></li>';
  46. // If they *can* quote?
  47. if ($post['can_quote'])
  48. echo '
  49. <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '" class="quote_button"><span>', $txt['quote'], '</span></a></li>';
  50. // Can we request notification of topics?
  51. if ($post['can_mark_notify'])
  52. echo '
  53. <li><a href="', $scripturl, '?action=notify;topic=', $post['topic'], '.', $post['start'], '" class="notify_button"><span>', $txt['notify'], '</span></a></li>';
  54. // How about... even... remove it entirely?!
  55. if ($post['can_delete'])
  56. echo '
  57. <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['remove_message'], '?\');" class="remove_button"><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.png', '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.png',
  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 class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" 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 class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" 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 class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" 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 class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" 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'], '.png" 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 title="', $topic[(empty($settings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><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'], '"><span class="new_posts">' . $txt['new'] . '</span></a>
  158. <p>
  159. ', $topic['first_post']['started_by'], '
  160. <small id="pages', $topic['first_post']['id'], '">', $topic['pages'], '</small>
  161. </p>
  162. </div>
  163. </td>
  164. <td class="', $color_class, ' stats windowbg">
  165. ', $topic['replies'], ' ', $txt['replies'], '
  166. <br />
  167. ', $topic['views'], ' ', $txt['views'], '
  168. </td>
  169. <td class="', $color_class2, ' lastpost windowbg2">
  170. <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.png" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" class="floatright" /></a>
  171. ', $topic['last_post']['time'], '<br />
  172. ', $txt['by'], ' ', $topic['last_post']['member']['link'], '
  173. </td>';
  174. if ($showCheckboxes)
  175. echo '
  176. <td class="' . (!empty($color_class) ? $color_class : 'windowbg2') . '" valign="middle" align="center">
  177. <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
  178. </td>';
  179. echo '
  180. </tr>';
  181. }
  182. if (!empty($context['topics']) && !$context['showing_all_topics'])
  183. $mark_read['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'lang' => true, 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
  184. if (empty($settings['use_tabs']) && !empty($mark_read))
  185. echo '
  186. <tr class="catbg">
  187. <td colspan="', $showCheckboxes ? '6' : '5', '" align="right">
  188. ', template_button_strip($mark_read, 'top'), '
  189. </td>
  190. </tr>';
  191. if (empty($context['topics']))
  192. echo '
  193. <tr style="display: none;"><td></td></tr>';
  194. echo '
  195. </tbody>
  196. </table>
  197. </div>
  198. <div class="pagesection" id="readbuttons">';
  199. if (!empty($settings['use_tabs']) && !empty($mark_read))
  200. template_button_strip($mark_read, 'right');
  201. echo '
  202. <span>', $txt['pages'], ': ', $context['page_index'], '</span>
  203. </div>';
  204. }
  205. else
  206. echo '
  207. <div class="cat_bar">
  208. <h3 class="catbg centertext">
  209. ', $context['showing_all_topics'] ? $txt['msg_alert_none'] : $txt['unread_topics_visit_none'], '
  210. </h3>
  211. </div>';
  212. if ($showCheckboxes)
  213. echo '
  214. </form>';
  215. echo '
  216. <div class="description " id="topic_icons">
  217. <p class="smalltext floatleft">
  218. ', !empty($modSettings['enableParticipation']) ? '
  219. <img src="' . $settings['images_url'] . '/topic/my_normal_post.png" alt="" class="centericon" /> ' . $txt['participation_caption'] . '<br />' : '', '
  220. <img src="', $settings['images_url'], '/topic/normal_post.png" alt="" class="centericon" /> ', $txt['normal_topic'], '<br />
  221. <img src="', $settings['images_url'], '/topic/hot_post.png" alt="" class="centericon" /> ', sprintf($txt['hot_topics'], $modSettings['hotTopicPosts']), '<br />
  222. <img src="', $settings['images_url'], '/topic/veryhot_post.png" alt="" class="centericon" /> ', sprintf($txt['very_hot_topics'], $modSettings['hotTopicVeryPosts']), '
  223. </p>
  224. <p class="smalltext para2">
  225. <img src="', $settings['images_url'], '/icons/quick_lock.png" alt="" class="centericon" /> ', $txt['locked_topic'], '<br />', ($modSettings['enableStickyTopics'] == '1' ? '
  226. <img src="' . $settings['images_url'] . '/icons/quick_sticky.png" alt="" class="centericon" /> ' . $txt['sticky_topic'] . '<br />' : ''), ($modSettings['pollMode'] == '1' ? '
  227. <img src="' . $settings['images_url'] . '/topic/normal_poll.png" alt="" class="centericon" /> ' . $txt['poll'] : ''), '
  228. </p>
  229. </div>
  230. </div>';
  231. }
  232. function template_replies()
  233. {
  234. global $context, $settings, $options, $txt, $scripturl, $modSettings;
  235. echo '
  236. <div id="recent">';
  237. $showCheckboxes = !empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $settings['show_mark_read'];
  238. if ($showCheckboxes)
  239. echo '
  240. <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;">
  241. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  242. <input type="hidden" name="qaction" value="markread" />
  243. <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '" />';
  244. if (isset($context['topics_to_mark']) && !empty($settings['show_mark_read']))
  245. {
  246. // Generate the button strip.
  247. $mark_read = array(
  248. 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
  249. );
  250. if ($showCheckboxes)
  251. $mark_read['markselectread'] = array(
  252. 'text' => 'quick_mod_markread',
  253. 'image' => 'markselectedread.png',
  254. 'lang' => true,
  255. 'url' => 'javascript:document.quickModForm.submit();',
  256. );
  257. }
  258. if (!empty($context['topics']))
  259. {
  260. echo '
  261. <div class="pagesection">';
  262. if (!empty($mark_read) && !empty($settings['use_tabs']))
  263. template_button_strip($mark_read, 'right');
  264. echo '
  265. <span>', $txt['pages'], ': ', $context['page_index'], '</span>
  266. </div>';
  267. echo '
  268. <div class="tborder topic_table" id="unreadreplies">
  269. <table class="table_grid" cellspacing="0">
  270. <thead>
  271. <tr class="catbg">
  272. <th scope="col" class="first_th" width="8%" colspan="2">&nbsp;</th>
  273. <th scope="col">
  274. <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 class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" alt="" />' : '', '</a>
  275. </th>
  276. <th scope="col" width="14%" align="center">
  277. <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 class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" alt="" />' : '', '</a>
  278. </th>';
  279. // Show a "select all" box for quick moderation?
  280. if ($showCheckboxes)
  281. echo '
  282. <th scope="col" width="22%">
  283. <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 class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" alt="" />' : '', '</a>
  284. </th>
  285. <th class="last_th">
  286. <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check" />
  287. </th>';
  288. else
  289. echo '
  290. <th scope="col" class="last_th" width="22%">
  291. <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 class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" alt="" />' : '', '</a>
  292. </th>';
  293. echo '
  294. </tr>
  295. </thead>
  296. <tbody>';
  297. foreach ($context['topics'] as $topic)
  298. {
  299. // Calculate the color class of the topic.
  300. $color_class = '';
  301. if (strpos($topic['class'], 'sticky') !== false)
  302. $color_class = 'stickybg';
  303. if (strpos($topic['class'], 'locked') !== false)
  304. $color_class .= 'lockedbg';
  305. $color_class2 = !empty($color_class) ? $color_class . '2' : '';
  306. echo '
  307. <tr>
  308. <td class="', $color_class, ' icon1 windowbg">
  309. <img src="', $settings['images_url'], '/topic/', $topic['class'], '.png" alt="" />
  310. </td>
  311. <td class="', $color_class, ' icon2 windowbg">
  312. <img src="', $topic['first_post']['icon_url'], '" alt="" />
  313. </td>
  314. <td class="subject ', $color_class2, ' windowbg2">
  315. <div>
  316. ', $topic['is_sticky'] ? '<strong>' : '', '<span title="', $topic[(empty($settings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
  317. <a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '"><span class="new_posts">' . $txt['new'] . '</span></a>
  318. <p>
  319. ', $topic['first_post']['started_by'], '
  320. <small id="pages', $topic['first_post']['id'], '">', $topic['pages'], '</small>
  321. </p>
  322. </div>
  323. </td>
  324. <td class="', $color_class, ' stats windowbg">
  325. ', $topic['replies'], ' ', $txt['replies'], '
  326. <br />
  327. ', $topic['views'], ' ', $txt['views'], '
  328. </td>
  329. <td class="', $color_class2, ' lastpost windowbg2">
  330. <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.png" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" class="floatright" /></a>
  331. ', $topic['last_post']['time'], '<br />
  332. ', $txt['by'], ' ', $topic['last_post']['member']['link'], '
  333. </td>';
  334. if ($showCheckboxes)
  335. echo '
  336. <td class="' . (!empty($color_class) ? $color_class : 'windowbg2') . '" valign="middle" align="center">
  337. <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
  338. </td>';
  339. echo '
  340. </tr>';
  341. }
  342. if (empty($settings['use_tabs']) && !empty($mark_read))
  343. echo '
  344. <tr class="catbg">
  345. <td colspan="', $showCheckboxes ? '6' : '5', '" align="right">
  346. ', template_button_strip($mark_read, 'top'), '
  347. </td>
  348. </tr>';
  349. echo '
  350. </tbody>
  351. </table>
  352. </div>
  353. <div class="pagesection">';
  354. if (!empty($settings['use_tabs']) && !empty($mark_read))
  355. template_button_strip($mark_read, 'right');
  356. echo '
  357. <span>', $txt['pages'], ': ', $context['page_index'], '</span>
  358. </div>';
  359. }
  360. else
  361. echo '
  362. <div class="cat_bar">
  363. <h3 class="catbg centertext">
  364. ', $context['showing_all_topics'] ? $txt['msg_alert_none'] : $txt['unread_topics_visit_none'], '
  365. </h3>
  366. </div>';
  367. if ($showCheckboxes)
  368. echo '
  369. </form>';
  370. echo '
  371. <div class="description flow_auto" id="topic_icons">
  372. <p class="smalltext floatleft">
  373. ', !empty($modSettings['enableParticipation']) ? '
  374. <img src="' . $settings['images_url'] . '/topic/my_normal_post.png" alt="" class="centericon" /> ' . $txt['participation_caption'] . '<br />' : '', '
  375. <img src="', $settings['images_url'], '/topic/normal_post.png" alt="" class="centericon" /> ', $txt['normal_topic'], '<br />
  376. <img src="', $settings['images_url'], '/topic/hot_post.png" alt="" class="centericon" /> ', sprintf($txt['hot_topics'], $modSettings['hotTopicPosts']), '<br />
  377. <img src="', $settings['images_url'], '/topic/veryhot_post.png" alt="" class="centericon" /> ', sprintf($txt['very_hot_topics'], $modSettings['hotTopicVeryPosts']), '
  378. </p>
  379. <p class="smalltext para2">
  380. <img src="', $settings['images_url'], '/icons/quick_lock.png" alt="" class="centericon" /> ', $txt['locked_topic'], '<br />', ($modSettings['enableStickyTopics'] == '1' ? '
  381. <img src="' . $settings['images_url'] . '/icons/quick_sticky.png" alt="" class="centericon" /> ' . $txt['sticky_topic'] . '<br />' : '') . ($modSettings['pollMode'] == '1' ? '
  382. <img src="' . $settings['images_url'] . '/topic/normal_poll.png" alt="" class="centericon" /> ' . $txt['poll'] : '') . '
  383. </p>
  384. </div>
  385. </div>';
  386. }
  387. ?>