Recent.template.php 20 KB

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