Recent.template.php 20 KB

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