Recent.template.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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. if ($context['showCheckboxes'])
  78. echo '
  79. <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;">
  80. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  81. <input type="hidden" name="qaction" value="markread" />
  82. <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '" />';
  83. if (!empty($context['topics']))
  84. {
  85. echo '
  86. <div class="pagesection">';
  87. if (!empty($context['recent_buttons']) && !empty($settings['use_tabs']))
  88. template_button_strip($context['recent_buttons'], 'right');
  89. echo '
  90. <div class="pagelinks floatleft">', $txt['pages'], ': ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . ' &nbsp;&nbsp;<a href="#bot"><strong>' . $txt['go_down'] . '</strong></a>' : '', '</div>
  91. </div>';
  92. // [WIP] There is trial code here to hide the topic icon column. Colspan can be cleaned up later.
  93. echo '
  94. <div class="tborder topic_table" id="unread">
  95. <table class="table_grid" cellspacing="0">
  96. <thead>
  97. <tr class="catbg">
  98. <th scope="col" class="first_th" width="8%" colspan="1">&nbsp;</th>
  99. <th scope="col">
  100. <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>
  101. </th>
  102. <th scope="col" width="14%" align="center">
  103. <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>
  104. </th>';
  105. // Show a "select all" box for quick moderation?
  106. if ($context['showCheckboxes'])
  107. echo '
  108. <th scope="col" width="22%">
  109. <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>
  110. </th>
  111. <th class="last_th">
  112. <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check" />
  113. </th>';
  114. else
  115. echo '
  116. <th scope="col" class="smalltext last_th" width="22%">
  117. <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>
  118. </th>';
  119. echo '
  120. </tr>
  121. </thead>
  122. <tbody>';
  123. foreach ($context['topics'] as $topic)
  124. {
  125. // Calculate the color class of the topic.
  126. $color_class = '';
  127. if (strpos($topic['class'], 'sticky') !== false)
  128. $color_class = 'stickybg';
  129. if (strpos($topic['class'], 'locked') !== false)
  130. $color_class .= 'lockedbg';
  131. $color_class2 = !empty($color_class) ? $color_class . '2' : '';
  132. // [WIP] There is trial code here to hide the topic icon column. Hardly anyone will miss it.
  133. // [WIP] Markup can be cleaned up later. CSS can go in the CSS files later.
  134. echo '
  135. <tr>
  136. <td class="', $color_class, ' icon1 windowbg" style="display: none;">
  137. <img src="', $settings['images_url'], '/topic/', $topic['class'], '.png" alt="" />
  138. </td>
  139. <td class="', $color_class, ' icon2 windowbg">
  140. <div style="position: relative; width: 40px; margin: auto;">
  141. <img src="', $topic['first_post']['icon_url'], '" alt="" />
  142. ', $topic['is_posted_in'] ? '<img src="'. $settings['images_url']. '/icons/profile_sm.png" alt="" style="position: absolute; z-index: 5; right: 4px; bottom: -3px;" />' : '','
  143. </div>
  144. </td>
  145. <td class="subject ', $color_class2, ' windowbg2">
  146. <div>';
  147. // [WIP] MEthinks the orange icons look better if they aren't all over the page.
  148. echo '
  149. <a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '"><span class="new_posts">' . $txt['new'] . '</span></a>
  150. ', $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>' : '', '
  151. <p>
  152. ', $topic['first_post']['started_by'], '
  153. <small id="pages', $topic['first_post']['id'], '">', $topic['pages'], '</small>
  154. </p>
  155. </div>
  156. </td>
  157. <td class="', $color_class, ' stats windowbg">
  158. ', $topic['replies'], ' ', $txt['replies'], '
  159. <br />
  160. ', $topic['views'], ' ', $txt['views'], '
  161. </td>
  162. <td class="', $color_class2, ' lastpost windowbg2">
  163. <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>
  164. ', $topic['last_post']['time'], '<br />
  165. ', $txt['by'], ' ', $topic['last_post']['member']['link'], '
  166. </td>';
  167. if ($context['showCheckboxes'])
  168. echo '
  169. <td class="' . (!empty($color_class) ? $color_class : 'windowbg2') . ' moderation" valign="middle" align="center">
  170. <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
  171. </td>';
  172. echo '
  173. </tr>';
  174. }
  175. if (empty($settings['use_tabs']) && !empty($context['recent_buttons']))
  176. echo '
  177. <tr class="catbg">
  178. <td colspan="', $context['showCheckboxes'] ? '6' : '5', '" align="right">
  179. ', template_button_strip($context['recent_buttons'], 'top'), '
  180. </td>
  181. </tr>';
  182. if (empty($context['topics']))
  183. echo '
  184. <tr style="display: none;"><td></td></tr>';
  185. echo '
  186. </tbody>
  187. </table>
  188. </div>
  189. <div class="pagesection" id="readbuttons">';
  190. if (!empty($settings['use_tabs']) && !empty($context['recent_buttons']))
  191. template_button_strip($context['recent_buttons'], 'right');
  192. echo '
  193. <div class="pagelinks floatleft">', $txt['pages'], ': ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . ' &nbsp;&nbsp;<a href="#top"><strong>' . $txt['go_up'] . '</strong></a>' : '', '</div>
  194. </div>';
  195. }
  196. else
  197. echo '
  198. <div class="cat_bar">
  199. <h3 class="catbg centertext">
  200. ', $context['showing_all_topics'] ? $txt['msg_alert_none'] : $txt['unread_topics_visit_none'], '
  201. </h3>
  202. </div>';
  203. if ($context['showCheckboxes'])
  204. echo '
  205. </form>';
  206. echo '
  207. <div class="description " id="topic_icons">
  208. <p class="smalltext floatleft">
  209. ', !empty($modSettings['enableParticipation']) ? '
  210. <img src="' . $settings['images_url'] . '/topic/my_normal_post.png" alt="" class="centericon" /> ' . $txt['participation_caption'] . '<br />' : '', '
  211. <img src="', $settings['images_url'], '/topic/normal_post.png" alt="" class="centericon" /> ', $txt['normal_topic'], '<br />
  212. <img src="', $settings['images_url'], '/topic/hot_post.png" alt="" class="centericon" /> ', sprintf($txt['hot_topics'], $modSettings['hotTopicPosts']), '<br />
  213. <img src="', $settings['images_url'], '/topic/veryhot_post.png" alt="" class="centericon" /> ', sprintf($txt['very_hot_topics'], $modSettings['hotTopicVeryPosts']), '
  214. </p>
  215. <p class="smalltext para2">
  216. <img src="', $settings['images_url'], '/icons/quick_lock.png" alt="" class="centericon" /> ', $txt['locked_topic'], '<br />', ($modSettings['enableStickyTopics'] == '1' ? '
  217. <img src="' . $settings['images_url'] . '/icons/quick_sticky.png" alt="" class="centericon" /> ' . $txt['sticky_topic'] . '<br />' : ''), ($modSettings['pollMode'] == '1' ? '
  218. <img src="' . $settings['images_url'] . '/topic/normal_poll.png" alt="" class="centericon" /> ' . $txt['poll'] : ''), '
  219. </p>
  220. </div>
  221. </div>';
  222. }
  223. function template_replies()
  224. {
  225. global $context, $settings, $options, $txt, $scripturl, $modSettings;
  226. echo '
  227. <div id="recent">';
  228. if ($context['showCheckboxes'])
  229. echo '
  230. <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;">
  231. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  232. <input type="hidden" name="qaction" value="markread" />
  233. <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '" />';
  234. if (!empty($context['topics']))
  235. {
  236. echo '
  237. <div class="pagesection">';
  238. if (!empty($context['recent_buttons']) && !empty($settings['use_tabs']))
  239. template_button_strip($context['recent_buttons'], 'right');
  240. echo '
  241. <div class="pagelinks floatleft">', $txt['pages'], ': ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . ' &nbsp;&nbsp;<a href="#bot"><strong>' . $txt['go_down'] . '</strong></a>' : '', '</div>
  242. </div>';
  243. // [WIP] There is trial code here to hide the topic icon column. Colspan can be cleaned up later.
  244. echo '
  245. <div class="tborder topic_table" id="unreadreplies">
  246. <table class="table_grid" cellspacing="0">
  247. <thead>
  248. <tr class="catbg">
  249. <th scope="col" class="first_th" width="8%" colspan="1">&nbsp;</th>
  250. <th scope="col">
  251. <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>
  252. </th>
  253. <th scope="col" width="14%" align="center">
  254. <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>
  255. </th>';
  256. // Show a "select all" box for quick moderation?
  257. if ($context['showCheckboxes'])
  258. echo '
  259. <th scope="col" width="22%">
  260. <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>
  261. </th>
  262. <th class="last_th">
  263. <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check" />
  264. </th>';
  265. else
  266. echo '
  267. <th scope="col" class="last_th" width="22%">
  268. <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>
  269. </th>';
  270. echo '
  271. </tr>
  272. </thead>
  273. <tbody>';
  274. foreach ($context['topics'] as $topic)
  275. {
  276. // Calculate the color class of the topic.
  277. $color_class = '';
  278. if (strpos($topic['class'], 'sticky') !== false)
  279. $color_class = 'stickybg';
  280. if (strpos($topic['class'], 'locked') !== false)
  281. $color_class .= 'lockedbg';
  282. $color_class2 = !empty($color_class) ? $color_class . '2' : '';
  283. // [WIP] There is trial code here to hide the topic icon column. Hardly anyone will miss it.
  284. // [WIP] Markup can be cleaned up later. CSS can go in the CSS files later.
  285. echo '
  286. <tr>
  287. <td class="', $color_class, ' icon1 windowbg" style="display: none;">
  288. <img src="', $settings['images_url'], '/topic/', $topic['class'], '.png" alt="" />
  289. </td>
  290. <td class="', $color_class, ' icon2 windowbg">
  291. <div style="position: relative; width: 40px; margin: auto;">
  292. <img src="', $topic['first_post']['icon_url'], '" alt="" />
  293. ', $topic['is_posted_in'] ? '<img src="'. $settings['images_url']. '/icons/profile_sm.png" alt="" style="position: absolute; z-index: 5; right: 4px; bottom: -3px;" />' : '','
  294. </div>
  295. </td>
  296. <td class="subject ', $color_class2, ' windowbg2">
  297. <div>';
  298. // [WIP] MEthinks the orange icons look better if they aren't all over the page.
  299. echo '
  300. <a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '"><span class="new_posts">' . $txt['new'] . '</span></a>
  301. ', $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>' : '', '
  302. <p>
  303. ', $topic['first_post']['started_by'], '
  304. <small id="pages', $topic['first_post']['id'], '">', $topic['pages'], '</small>
  305. </p>
  306. </div>
  307. </td>
  308. <td class="', $color_class, ' stats windowbg">
  309. ', $topic['replies'], ' ', $txt['replies'], '
  310. <br />
  311. ', $topic['views'], ' ', $txt['views'], '
  312. </td>
  313. <td class="', $color_class2, ' lastpost windowbg2">
  314. <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>
  315. ', $topic['last_post']['time'], '<br />
  316. ', $txt['by'], ' ', $topic['last_post']['member']['link'], '
  317. </td>';
  318. if ($context['showCheckboxes'])
  319. echo '
  320. <td class="' . (!empty($color_class) ? $color_class : 'windowbg2') . ' moderation" valign="middle" align="center">
  321. <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
  322. </td>';
  323. echo '
  324. </tr>';
  325. }
  326. if (empty($settings['use_tabs']) && !empty($context['recent_buttons']))
  327. echo '
  328. <tr class="catbg">
  329. <td colspan="', $context['showCheckboxes'] ? '6' : '5', '" align="right">
  330. ', template_button_strip($context['recent_buttons'], 'top'), '
  331. </td>
  332. </tr>';
  333. echo '
  334. </tbody>
  335. </table>
  336. </div>
  337. <div class="pagesection">';
  338. if (!empty($settings['use_tabs']) && !empty($context['recent_buttons']))
  339. template_button_strip($context['recent_buttons'], 'right');
  340. echo '
  341. <div class="pagelinks floatleft">', $txt['pages'], ': ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . ' &nbsp;&nbsp;<a href="#top"><strong>' . $txt['go_up'] . '</strong></a>' : '', '</div>
  342. </div>';
  343. }
  344. else
  345. echo '
  346. <div class="cat_bar">
  347. <h3 class="catbg centertext">
  348. ', $context['showing_all_topics'] ? $txt['msg_alert_none'] : $txt['unread_topics_visit_none'], '
  349. </h3>
  350. </div>';
  351. if ($context['showCheckboxes'])
  352. echo '
  353. </form>';
  354. echo '
  355. <div class="description flow_auto" id="topic_icons">
  356. <p class="smalltext floatleft">
  357. ', !empty($modSettings['enableParticipation']) ? '
  358. <img src="' . $settings['images_url'] . '/topic/my_normal_post.png" alt="" class="centericon" /> ' . $txt['participation_caption'] . '<br />' : '', '
  359. <img src="', $settings['images_url'], '/topic/normal_post.png" alt="" class="centericon" /> ', $txt['normal_topic'], '<br />
  360. <img src="', $settings['images_url'], '/topic/hot_post.png" alt="" class="centericon" /> ', sprintf($txt['hot_topics'], $modSettings['hotTopicPosts']), '<br />
  361. <img src="', $settings['images_url'], '/topic/veryhot_post.png" alt="" class="centericon" /> ', sprintf($txt['very_hot_topics'], $modSettings['hotTopicVeryPosts']), '
  362. </p>
  363. <p class="smalltext para2">
  364. <img src="', $settings['images_url'], '/icons/quick_lock.png" alt="" class="centericon" /> ', $txt['locked_topic'], '<br />', ($modSettings['enableStickyTopics'] == '1' ? '
  365. <img src="' . $settings['images_url'] . '/icons/quick_sticky.png" alt="" class="centericon" /> ' . $txt['sticky_topic'] . '<br />' : '') . ($modSettings['pollMode'] == '1' ? '
  366. <img src="' . $settings['images_url'] . '/topic/normal_poll.png" alt="" class="centericon" /> ' . $txt['poll'] : '') . '
  367. </p>
  368. </div>
  369. </div>';
  370. }
  371. ?>