MessageIndex.template.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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_main()
  13. {
  14. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  15. if (!empty($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0))
  16. {
  17. echo '
  18. <div id="board_', $context['current_board'], '_childboards" class="boardindex_table">
  19. <table class="table_list">
  20. <tbody class="header">
  21. <tr>
  22. <td colspan="4">
  23. <div class="cat_bar">
  24. <h3 class="catbg">', $txt['sub_boards'], '</h3>
  25. </div>
  26. </td>
  27. </tr>
  28. </tbody>
  29. <tbody id="board_', $context['current_board'], '_children" class="content">';
  30. foreach ($context['boards'] as $board)
  31. {
  32. echo '
  33. <tr id="board_', $board['id'], '" class="windowbg2">
  34. <td class="windowbg icon"', !empty($board['children']) ? ' rowspan="2"' : '', '>
  35. <a href="', ($board['is_redirect'] || $context['user']['is_guest'] ? $board['href'] : $scripturl . '?action=unread;board=' . $board['id'] . '.0;children'), '">
  36. <span class="board_', $board['board_class'], '"', !empty($board['board_tooltip']) ? ' title="' . $board['board_tooltip'] . '"' : '', '></span>
  37. </a>
  38. </td>
  39. <td class="info">
  40. <a class="subject" href="', $board['href'], '" id="b', $board['id'], '">', $board['name'], '</a>';
  41. // Has it outstanding posts for approval?
  42. if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics']))
  43. echo '
  44. <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>';
  45. echo '
  46. <p>', $board['description'] , '</p>';
  47. // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
  48. if (!empty($board['moderators']) || !empty($board['moderator_groups']))
  49. echo '
  50. <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>';
  51. // Show some basic information about the number of posts, etc.
  52. echo '
  53. </td>
  54. <td class="windowbg stats">
  55. <p>', comma_format($board['posts']), ' ', $board['is_redirect'] ? $txt['redirects'] : $txt['posts'], ' <br>
  56. ', $board['is_redirect'] ? '' : comma_format($board['topics']) . ' ' . $txt['board_topics'], '
  57. </p>
  58. </td>
  59. <td class="lastpost">';
  60. if (!empty($board['last_post']['id']))
  61. echo '
  62. <p>', $board['last_post']['last_post_message'], '</p>';
  63. echo '
  64. </td>
  65. </tr>';
  66. // Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
  67. if (!empty($board['children']))
  68. {
  69. // Sort the links into an array with new boards bold so it can be imploded.
  70. $children = array();
  71. /* Each child in each board's children has:
  72. id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
  73. foreach ($board['children'] as $child)
  74. {
  75. if (!$child['is_redirect'])
  76. $child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a ' . ($child['new'] ? 'class="new_posts" ' : '') . 'href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>';
  77. else
  78. $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>';
  79. // Has it posts awaiting approval?
  80. if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics']))
  81. $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>';
  82. $children[] = $child['new'] ? '<strong>' . $child['link'] . '</strong>' : $child['link'];
  83. }
  84. echo '
  85. <tr id="board_', $board['id'], '_children" class="windowbg2">
  86. <td colspan="3" class="windowbg children">
  87. <p><strong>', $txt['sub_boards'], '</strong>: ', implode(', ', $children), '</p>
  88. </td>
  89. </tr>';
  90. }
  91. }
  92. echo '
  93. </tbody>
  94. <tbody class="divider">
  95. <tr>
  96. <td colspan="4"></td>
  97. </tr>
  98. </tbody>
  99. </table>
  100. </div>';
  101. }
  102. // They can only mark read if they are logged in and it's enabled!
  103. if (!$context['user']['is_logged'])
  104. unset($context['normal_buttons']['markread']);
  105. if (!$context['no_topic_listing'])
  106. {
  107. echo '
  108. <div class="pagesection">
  109. ', $context['menu_separator'], '<a href="#bot" class="topbottom floatleft">', $txt['go_down'], '</a>
  110. <div class="pagelinks floatleft">', $context['page_index'], '</div>
  111. ', template_button_strip($context['normal_buttons'], 'right'), '
  112. </div>';
  113. if ($context['description'] != '' || !empty($context['moderators']))
  114. {
  115. echo '
  116. <div id="description_board" class="generic_list_wrapper">
  117. <h3 class="floatleft">', $context['name'], '&nbsp;-&nbsp;</h3>
  118. <p>';
  119. if ($context['description'] != '')
  120. echo '
  121. ', $context['description'], '&nbsp;';
  122. if (!empty($context['moderators']))
  123. echo '
  124. ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.';
  125. echo '
  126. </p>
  127. </div>';
  128. }
  129. // If Quick Moderation is enabled start the form.
  130. if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics']))
  131. echo '
  132. <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">';
  133. echo '
  134. <div class="tborder topic_table" id="messageindex">';
  135. if (!empty($settings['display_who_viewing']))
  136. {
  137. echo '
  138. <p class="whoisviewing">';
  139. if ($settings['display_who_viewing'] == 1)
  140. echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members'];
  141. else
  142. echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
  143. echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board'];
  144. echo '
  145. </p>';
  146. }
  147. echo '
  148. <table class="table_grid">
  149. <thead>
  150. <tr class="catbg">';
  151. // Are there actually any topics to show?
  152. if (!empty($context['topics']))
  153. {
  154. echo '
  155. <th scope="col" class="post_icon first_th">&nbsp;</th>
  156. <th scope="col" class="subject lefttext">', $context['topics_headers']['subject'], ' / ', $context['topics_headers']['starter'], '</th>
  157. <th scope="col" class="stats">', $context['topics_headers']['replies'], ' / ', $context['topics_headers']['views'], '</th>';
  158. // Show a "select all" box for quick moderation?
  159. if (empty($context['can_quick_mod']))
  160. echo '
  161. <th scope="col" class="last_post lefttext last_th">', $context['topics_headers']['last_post'], '</th>';
  162. else
  163. echo '
  164. <th scope="col" class="last_post lefttext">', $context['topics_headers']['last_post'], '</th>';
  165. // Show a "select all" box for quick moderation?
  166. if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1)
  167. echo '
  168. <th scope="col" class="moderation last_th"><input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check"></th>';
  169. // If it's on in "image" mode, don't show anything but the column.
  170. elseif (!empty($context['can_quick_mod']))
  171. echo '
  172. <th class="last_th" style="width: 4%">&nbsp;</th>';
  173. }
  174. // No topics.... just say, "sorry bub".
  175. else
  176. echo '
  177. <th scope="col" class="first_th" style="width: 8%">&nbsp;</th>
  178. <th colspan="3"><strong>', $txt['topic_alert_none'], '</strong></th>
  179. <th scope="col" class="last_th" style="width: 8%">&nbsp;</th>';
  180. echo '
  181. </tr>
  182. </thead>
  183. <tbody>';
  184. // If this person can approve items and we have some awaiting approval tell them.
  185. if (!empty($context['unapproved_posts_message']))
  186. {
  187. echo '
  188. <tr class="windowbg2">
  189. <td colspan="', !empty($context['can_quick_mod']) ? '5' : '4', '">
  190. <span class="alert">!</span> ', $context['unapproved_posts_message'], '
  191. </td>
  192. </tr>';
  193. }
  194. foreach ($context['topics'] as $topic)
  195. {
  196. $color_class = 'windowbg';
  197. // Is this topic pending approval, or does it have any posts pending approval?
  198. if ($context['can_approve_posts'] && $topic['unapproved_posts'])
  199. $color_class = (!$topic['approved'] ? 'approvetopic ' : 'approvepost ') . $color_class;
  200. // Sticky topics should get a different color, too.
  201. if ($topic['is_sticky'])
  202. $color_class = 'sticky ' . $color_class;
  203. // Locked topics get special treatment as well.
  204. if ($topic['is_locked'])
  205. $color_class = 'locked ' . $color_class;
  206. // Some columns require a different shade of the color class.
  207. $alternate_class = $color_class . '2';
  208. // @todo - [WIP] Markup can be cleaned up later. CSS can go in the CSS files later.
  209. echo '
  210. <tr>
  211. <td class="', $color_class, ' icon2">
  212. <div>
  213. <img src="', $topic['first_post']['icon_url'], '" alt="">
  214. ', $topic['is_posted_in'] ? '<img class="posted" src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="">' : '', '
  215. </div>
  216. </td>
  217. <td class="', $alternate_class, ' subject">
  218. <div ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" ondblclick="oQuickModifyTopic.modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\');"' : ''), '>';
  219. // Now we handle the icons
  220. echo '
  221. <div class="icons">';
  222. if ($topic['is_watched'])
  223. echo '
  224. <span class="generic_icons watch floatright" title="', $txt['watching_this_topic'], '"></span>';
  225. if ($topic['is_locked'])
  226. echo '
  227. <span class="generic_icons lock floatright"></span>';
  228. if ($topic['is_sticky'])
  229. echo '
  230. <span class="generic_icons sticky floatright"></span>';
  231. if ($topic['is_redirect'])
  232. echo '
  233. <span class="generic_icons move floatright"></span>';
  234. if ($topic['is_poll'])
  235. echo '
  236. <span class="generic_icons poll floatright"></span>';
  237. echo '
  238. </div>';
  239. echo '
  240. <div class="message_index_title">
  241. ', $topic['new'] && $context['user']['is_logged'] ? '<a href="' . $topic['new_href'] . '" id="newicon' . $topic['first_post']['id'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '
  242. <span class="preview', $topic['is_sticky'] ? ' bold_text' : '', '" title="', $topic[(empty($settings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '">
  243. <span id="msg_', $topic['first_post']['id'], '">', $topic['first_post']['link'], ($context['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>
  244. </span>
  245. </div>
  246. <p class="floatleft">', $txt['started_by'], ' ', $topic['first_post']['member']['link'], '
  247. <small id="pages', $topic['first_post']['id'], '">', $topic['pages'], '</small>
  248. </p>
  249. <br class="clear">
  250. </div>
  251. </td>
  252. <td class="', $color_class, ' stats">', $topic['replies'], ' ', $txt['replies'], '<br>', $topic['views'], ' ', $txt['views'], '</td>
  253. <td class="', $alternate_class, ' lastpost">
  254. ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
  255. </td>';
  256. // Show the quick moderation options?
  257. if (!empty($context['can_quick_mod']))
  258. {
  259. echo '
  260. <td class="', $color_class, ' moderation">';
  261. if ($options['display_quick_mod'] == 1)
  262. echo '
  263. <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check">';
  264. else
  265. {
  266. // Check permissions on each and show only the ones they are allowed to use.
  267. if ($topic['quick_mod']['remove'])
  268. echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions[', $topic['id'], ']=remove;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></a>';
  269. if ($topic['quick_mod']['lock'])
  270. echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions[', $topic['id'], ']=lock;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><span class="generic_icons lock" title="', $txt['set_lock'], '"></span></a>';
  271. if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
  272. echo '<br>';
  273. if ($topic['quick_mod']['sticky'])
  274. echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions[', $topic['id'], ']=sticky;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><span class="generic_icons sticky" title="', $txt['set_sticky'], '"></span></a>';
  275. if ($topic['quick_mod']['move'])
  276. echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
  277. }
  278. echo '
  279. </td>';
  280. }
  281. echo '
  282. </tr>';
  283. }
  284. if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
  285. {
  286. echo '
  287. <tr>
  288. <td colspan="5" class="righttext" id="quick_actions">
  289. <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
  290. <option value="">--------</option>';
  291. foreach ($context['qmod_actions'] as $qmod_action)
  292. if ($context['can_' . $qmod_action])
  293. echo '
  294. <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>';
  295. echo '
  296. </select>';
  297. // Show a list of boards they can move the topic to.
  298. if ($context['can_move'])
  299. echo '
  300. <span id="quick_mod_jump_to">&nbsp;</span>';
  301. echo '
  302. <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' &amp;&amp; confirm(\'', $txt['quickmod_confirm'], '\');" class="button_submit qaction">
  303. </td>
  304. </tr>';
  305. }
  306. echo '
  307. </tbody>
  308. </table>
  309. </div>';
  310. // Finish off the form - again.
  311. if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics']))
  312. echo '
  313. <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
  314. </form>';
  315. echo '
  316. <div class="pagesection">
  317. ', template_button_strip($context['normal_buttons'], 'right'), '
  318. ', $context['menu_separator'], '<a href="#main_content_section" class="topbottom floatleft">', $txt['go_up'], '</a>
  319. <div class="pagelinks">', $context['page_index'], '</div>
  320. </div>';
  321. }
  322. // Show breadcrumbs at the bottom too.
  323. theme_linktree();
  324. if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move'])
  325. echo '
  326. <script><!-- // --><![CDATA[
  327. if (typeof(window.XMLHttpRequest) != "undefined")
  328. aJumpTo[aJumpTo.length] = new JumpTo({
  329. sContainerId: "quick_mod_jump_to",
  330. sClassName: "qaction",
  331. sJumpToTemplate: "%dropdown_list%",
  332. iCurBoardId: ', $context['current_board'], ',
  333. iCurBoardChildLevel: ', $context['jump_to']['child_level'], ',
  334. sCurBoardName: "', $context['jump_to']['board_name'], '",
  335. sBoardChildLevelIndicator: "==",
  336. sBoardPrefix: "=> ",
  337. sCatSeparator: "-----------------------------",
  338. sCatPrefix: "",
  339. bNoRedirect: true,
  340. bDisabled: true,
  341. sCustomName: "move_to"
  342. });
  343. // ]]></script>';
  344. // Javascript for inline editing.
  345. echo '
  346. <script src="', $settings['default_theme_url'], '/scripts/topic.js"></script>
  347. <script><!-- // --><![CDATA[
  348. var oQuickModifyTopic = new QuickModifyTopic({
  349. aHidePrefixes: Array("lockicon", "stickyicon", "pages", "newicon"),
  350. bMouseOnDiv: false,
  351. });
  352. // ]]></script>';
  353. template_topic_legend();
  354. }
  355. function template_topic_legend()
  356. {
  357. global $context, $settings, $txt, $modSettings;
  358. echo '
  359. <div class="tborder" id="topic_icons">
  360. <div class="description">
  361. <p class="floatright" id="message_index_jump_to">&nbsp;</p>';
  362. if (empty($context['no_topic_listing']))
  363. echo '
  364. <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? '
  365. <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', '
  366. '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br>
  367. <img src="' . $settings['images_url'] . '/post/moved.png" alt="" class="centericon sizefix"> ' . $txt['moved_topic'] . '<br>
  368. </p>
  369. <p>
  370. <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br>
  371. <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br>
  372. </p>';
  373. if (!empty($context['jump_to']))
  374. echo '
  375. <script><!-- // --><![CDATA[
  376. if (typeof(window.XMLHttpRequest) != "undefined")
  377. aJumpTo[aJumpTo.length] = new JumpTo({
  378. sContainerId: "message_index_jump_to",
  379. sJumpToTemplate: "<label class=\"smalltext\" for=\"%select_id%\">', $context['jump_to']['label'], ':<" + "/label> %dropdown_list%",
  380. iCurBoardId: ', $context['current_board'], ',
  381. iCurBoardChildLevel: ', $context['jump_to']['child_level'], ',
  382. sCurBoardName: "', $context['jump_to']['board_name'], '",
  383. sBoardChildLevelIndicator: "==",
  384. sBoardPrefix: "=> ",
  385. sCatSeparator: "-----------------------------",
  386. sCatPrefix: "",
  387. sGoButtonLabel: "', $txt['quick_mod_go'], '"
  388. });
  389. // ]]></script>';
  390. echo '
  391. <br class="clear">
  392. </div>
  393. </div>';
  394. }
  395. ?>