Recent.template.php 16 KB

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