Recent.template.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2014 Simple Machines and individual contributors
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. function template_recent()
  13. {
  14. global $context, $settings, $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_poster'], ' <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_action'], '</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, $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. ', !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '<a href="#bot" class="topbottom floatleft">' . $txt['go_down'] . '</a>' : '', '
  84. <div class="pagelinks floatleft">', $context['page_index'], '</div>
  85. ', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '', '
  86. </div>';
  87. // [WIP] There is trial code here to hide the topic icon column. Colspan can be cleaned up later.
  88. echo '
  89. <div class="tborder topic_table" id="unread">
  90. <table class="table_grid" cellspacing="0">
  91. <thead>
  92. <tr class="catbg">
  93. <th scope="col" class="first_th" width="8%" colspan="1">&nbsp;</th>
  94. <th scope="col">
  95. <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' ? ' <span class="sort sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
  96. </th>
  97. <th scope="col" width="14%" align="center">
  98. <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' ? ' <span class="sort sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
  99. </th>';
  100. // Show a "select all" box for quick moderation?
  101. if ($context['showCheckboxes'])
  102. echo '
  103. <th scope="col" width="22%">
  104. <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' ? ' <span class="sort sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
  105. </th>
  106. <th class="last_th">
  107. <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check" />
  108. </th>';
  109. else
  110. echo '
  111. <th scope="col" class="smalltext last_th" width="22%">
  112. <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' ? ' <span class="sort sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
  113. </th>';
  114. echo '
  115. </tr>
  116. </thead>
  117. <tbody>';
  118. foreach ($context['topics'] as $topic)
  119. {
  120. $color_class = 'windowbg';
  121. // Sticky topics should get a different color, too.
  122. if ($topic['is_sticky'])
  123. $color_class = 'sticky ' . $color_class;
  124. // Locked topics get special treatment as well.
  125. if ($topic['is_locked'])
  126. $color_class = 'locked ' . $color_class;
  127. $color_class2 = $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, ' icon2">
  133. <div style="position: relative; width: 40px; margin: auto;">
  134. <img src="', $topic['first_post']['icon_url'], '" alt="" />
  135. ', $topic['is_posted_in'] ? '<img src="'. $settings['images_url']. '/icons/profile_sm.png" alt="" style="position: absolute; z-index: 5; right: 4px; bottom: -3px;" />' : '','
  136. </div>
  137. </td>
  138. <td class="subject ', $color_class2, '">
  139. <div>';
  140. // Now we handle the icons
  141. echo '
  142. <div class="icons">';
  143. if ($topic['is_locked'])
  144. echo '
  145. <span class="generic_icons lock floatright"></span>';
  146. if ($topic['is_sticky'])
  147. echo '
  148. <span class="generic_icons sticky floatright"></span>';
  149. if ($topic['is_poll'])
  150. echo '
  151. <span class="generic_icons poll floatright"></span>';
  152. echo '
  153. </div>';
  154. // [WIP] MEthinks the orange icons look better if they aren't all over the page.
  155. echo '
  156. <a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '"><span class="new_posts">' . $txt['new'] . '</span></a>
  157. ', $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>' : '', '
  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">
  165. ', $topic['replies'], ' ', $txt['replies'], '
  166. <br />
  167. ', $topic['views'], ' ', $txt['views'], '
  168. </td>
  169. <td class="', $color_class2, ' lastpost">
  170. <a href="', $topic['last_post']['href'], '"><span class="generic_icons last_post" title="', $txt['last_post'], '"></span></a>
  171. ', sprintf($txt['last_post_topic'], $topic['last_post']['time'], $topic['last_post']['member']['link']), '
  172. </td>';
  173. if ($context['showCheckboxes'])
  174. echo '
  175. <td class="', $color_class2, ' moderation" valign="middle" align="center">
  176. <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
  177. </td>';
  178. echo '
  179. </tr>';
  180. }
  181. if (empty($context['topics']))
  182. echo '
  183. <tr style="display: none;"><td></td></tr>';
  184. echo '
  185. </tbody>
  186. </table>
  187. </div>
  188. <div class="pagesection">
  189. ', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '', '
  190. ', !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '<a href="#recent" class="topbottom floatleft">' . $txt['go_up'] . '</a>' : '', '
  191. <div class="pagelinks">', $context['page_index'], '</div>
  192. </div>';
  193. }
  194. else
  195. echo '
  196. <div class="cat_bar">
  197. <h3 class="catbg centertext">
  198. ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], '
  199. </h3>
  200. </div>';
  201. if ($context['showCheckboxes'])
  202. echo '
  203. </form>';
  204. echo '
  205. </div>';
  206. if (empty($context['no_topic_listing']))
  207. template_topic_legend();
  208. }
  209. function template_replies()
  210. {
  211. global $context, $settings, $txt, $scripturl, $modSettings;
  212. echo '
  213. <div id="recent">';
  214. if ($context['showCheckboxes'])
  215. echo '
  216. <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;">
  217. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  218. <input type="hidden" name="qaction" value="markread" />
  219. <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '" />';
  220. if (!empty($context['topics']))
  221. {
  222. echo '
  223. <div class="pagesection">
  224. ', !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '<a href="#bot" class="topbottom floatleft">' . $txt['go_down'] . '</a>' : '', '
  225. <div class="pagelinks floatleft">', $context['page_index'], '</div>
  226. ', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '', '
  227. </div>';
  228. // [WIP] There is trial code here to hide the topic icon column. Colspan can be cleaned up later.
  229. echo '
  230. <div class="tborder topic_table" id="unreadreplies">
  231. <table class="table_grid" cellspacing="0">
  232. <thead>
  233. <tr class="catbg">
  234. <th scope="col" class="first_th" width="8%" colspan="1">&nbsp;</th>
  235. <th scope="col">
  236. <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' ? ' <span class="sort sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
  237. </th>
  238. <th scope="col" width="14%" align="center">
  239. <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' ? ' <span class="sort sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
  240. </th>';
  241. // Show a "select all" box for quick moderation?
  242. if ($context['showCheckboxes'])
  243. echo '
  244. <th scope="col" width="22%">
  245. <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' ? ' <span class="sort sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
  246. </th>
  247. <th class="last_th">
  248. <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check" />
  249. </th>';
  250. else
  251. echo '
  252. <th scope="col" class="last_th" width="22%">
  253. <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' ? ' <span class="sort sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
  254. </th>';
  255. echo '
  256. </tr>
  257. </thead>
  258. <tbody>';
  259. foreach ($context['topics'] as $topic)
  260. {
  261. $color_class = 'windowbg';
  262. // Sticky topics should get a different color, too.
  263. if ($topic['is_sticky'])
  264. $color_class = 'sticky ' . $color_class;
  265. // Locked topics get special treatment as well.
  266. if ($topic['is_locked'])
  267. $color_class = 'locked ' . $color_class;
  268. $color_class2 = $color_class . '2';
  269. // [WIP] There is trial code here to hide the topic icon column. Hardly anyone will miss it.
  270. // [WIP] Markup can be cleaned up later. CSS can go in the CSS files later.
  271. echo '
  272. <tr>
  273. <td class="', $color_class, ' icon2">
  274. <div style="position: relative; width: 40px; margin: auto;">
  275. <img src="', $topic['first_post']['icon_url'], '" alt="" />
  276. ', $topic['is_posted_in'] ? '<img class="posted" src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" />' : '','
  277. </div>
  278. </td>
  279. <td class="subject ', $color_class2, '">
  280. <div>';
  281. // Now we handle the icons
  282. echo '
  283. <div class="icons">';
  284. if ($topic['is_locked'])
  285. echo '
  286. <span class="generic_icons lock floatright"></span>';
  287. if ($topic['is_sticky'])
  288. echo '
  289. <span class="generic_icons sticky floatright"></span>';
  290. if ($topic['is_poll'])
  291. echo '
  292. <span class="generic_icons poll floatright"></span>';
  293. echo '
  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">
  306. ', $topic['replies'], ' ', $txt['replies'], '
  307. <br />
  308. ', $topic['views'], ' ', $txt['views'], '
  309. </td>
  310. <td class="', $color_class2, ' lastpost">
  311. <a href="', $topic['last_post']['href'], '"><span class="generic_icons last_post" title="', $txt['last_post'], '"></span></a>
  312. ', sprintf($txt['last_post_topic'], $topic['last_post']['time'], $topic['last_post']['member']['link']), '
  313. </td>';
  314. if ($context['showCheckboxes'])
  315. echo '
  316. <td class="', $color_class2, ' 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. echo '
  323. </tbody>
  324. </table>
  325. </div>
  326. <div class="pagesection">
  327. ', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '', '
  328. ', !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '<a href="#recent" class="topbottom floatleft">' . $txt['go_up'] . '</a>' : '', '
  329. <div class="pagelinks">', $context['page_index'], '</div>
  330. </div>';
  331. }
  332. else
  333. echo '
  334. <div class="cat_bar">
  335. <h3 class="catbg centertext">
  336. ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], '
  337. </h3>
  338. </div>';
  339. if ($context['showCheckboxes'])
  340. echo '
  341. </form>';
  342. echo '
  343. </div>';
  344. if (empty($context['no_topic_listing']))
  345. template_topic_legend();
  346. }
  347. ?>