BoardIndex.template.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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_boardindex_outer_above()
  13. {
  14. template_newsfader();
  15. }
  16. function template_newsfader()
  17. {
  18. global $context, $settings, $options, $txt, $scripturl, $modSettings;
  19. // Show the news fader? (assuming there are things to show...)
  20. if (!empty($settings['show_newsfader']) && !empty($context['news_lines']))
  21. {
  22. echo '
  23. <div id="newsfader">
  24. <div class="cat_bar">
  25. <h3 class="catbg">
  26. <span id="newsupshrink" class="toggle_up floatright" alt="*" title="', $txt['hide'], '" align="bottom" style="display: none;"></span>
  27. ', $txt['news'], '
  28. </h3>
  29. </div>
  30. <div class="roundframe rfix" id="smfFadeScrollerCont">
  31. <ul class="reset" id="smfFadeScroller">
  32. <li>
  33. ', implode('</li><li>', $context['news_lines']), '
  34. </li>
  35. </ul>
  36. </div>
  37. </div>
  38. <script src="', $settings['default_theme_url'], '/scripts/fader.js"></script>
  39. <script><!-- // --><![CDATA[
  40. // Create a news fader object.
  41. var oNewsFader = new smc_NewsFader({
  42. sFaderControlId: \'smfFadeScroller\',
  43. sItemTemplate: ', JavaScriptEscape('%1$s'), ',
  44. iFadeDelay: ', empty($settings['newsfader_time']) ? 5000 : $settings['newsfader_time'], '
  45. });
  46. // Create the news fader toggle.
  47. var smfNewsFadeToggle = new smc_Toggle({
  48. bToggleEnabled: true,
  49. bCurrentlyCollapsed: ', empty($options['collapse_news_fader']) ? 'false' : 'true', ',
  50. aSwappableContainers: [
  51. \'smfFadeScrollerCont\'
  52. ],
  53. aSwapImages: [
  54. {
  55. sId: \'newsupshrink\',
  56. altExpanded: ', JavaScriptEscape($txt['hide']), ',
  57. altCollapsed: ', JavaScriptEscape($txt['show']), '
  58. }
  59. ],
  60. oThemeOptions: {
  61. bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
  62. sOptionName: \'collapse_news_fader\',
  63. sSessionVar: smf_session_var,
  64. sSessionId: smf_session_id
  65. },
  66. oCookieOptions: {
  67. bUseCookie: ', $context['user']['is_guest'] ? 'true' : 'false', ',
  68. sCookieName: \'newsupshrink\'
  69. }
  70. });
  71. // ]]></script>
  72. ';
  73. }
  74. }
  75. function template_main()
  76. {
  77. global $context, $settings, $txt, $scripturl, $modSettings;
  78. echo '
  79. <div id="boardindex_table" class="boardindex_table">
  80. <table class="table_list">';
  81. /* Each category in categories is made up of:
  82. id, href, link, name, is_collapsed (is it collapsed?), can_collapse (is it okay if it is?),
  83. new (is it new?), collapse_href (href to collapse/expand), collapse_image (up/down image),
  84. and boards. (see below.) */
  85. foreach ($context['categories'] as $category)
  86. {
  87. // If theres no parent boards we can see, avoid showing an empty category (unless its collapsed)
  88. if (empty($category['boards']) && !$category['is_collapsed'])
  89. continue;
  90. echo '
  91. <tbody class="header" id="category_', $category['id'], '">
  92. <tr>
  93. <td colspan="4">
  94. <div class="cat_bar">
  95. <h3 class="catbg">';
  96. // If this category even can collapse, show a link to collapse it.
  97. if ($category['can_collapse'])
  98. echo '
  99. <a class="collapse" href="', $category['collapse_href'], '" title="' ,$category['is_collapsed'] ? $txt['show'] : $txt['hide'] ,'">', $category['collapse_image'], '</a>';
  100. echo '
  101. ', $category['link'], '
  102. </h3>', !empty($category['description']) ? '
  103. <div class="desc">' . $category['description'] . '</div>' : '', '
  104. </div>
  105. </td>
  106. </tr>
  107. </tbody>';
  108. // Assuming the category hasn't been collapsed...
  109. if (!$category['is_collapsed'])
  110. {
  111. echo '
  112. <tbody class="content" id="category_', $category['id'], '_boards">';
  113. /* Each board in each category's boards has:
  114. new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
  115. children (see below.), link_children (easier to use.), children_new (are they new?),
  116. topics (# of), posts (# of), link, href, and last_post. (see below.) */
  117. foreach ($category['boards'] as $board)
  118. {
  119. echo '
  120. <tr id="board_', $board['id'], '" class="windowbg2">
  121. <td class="windowbg icon"', !empty($board['children']) ? ' rowspan="2"' : '', '>
  122. <a href="', ($board['is_redirect'] || $context['user']['is_guest'] ? $board['href'] : $scripturl . '?action=unread;board=' . $board['id'] . '.0;children'), '">
  123. <span class="board_', $board['board_class'], '"', !empty($board['board_tooltip']) ? ' title="' . $board['board_tooltip'] . '"' : '', '></span>
  124. </a>
  125. </td>
  126. <td class="info">
  127. <a class="subject" href="', $board['href'], '" id="b', $board['id'], '">', $board['name'], '</a>';
  128. // Has it outstanding posts for approval?
  129. if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics']))
  130. echo '
  131. <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>';
  132. echo '
  133. <p>', $board['description'] , '</p>';
  134. // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
  135. if (!empty($board['link_moderators']))
  136. echo '
  137. <p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>';
  138. // Show some basic information about the number of posts, etc.
  139. echo '
  140. </td>
  141. <td class="windowbg stats">
  142. <p>', comma_format($board['posts']), ' ', $board['is_redirect'] ? $txt['redirects'] : $txt['posts'], '
  143. ', $board['is_redirect'] ? '' : '<br> ' . comma_format($board['topics']) . ' ' . $txt['board_topics'], '
  144. </p>
  145. </td>
  146. <td class="lastpost">';
  147. if (!empty($board['last_post']['id']))
  148. echo '
  149. <p>', $board['last_post']['last_post_message'], '</p>';
  150. echo '
  151. </td>
  152. </tr>';
  153. // Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
  154. if (!empty($board['children']))
  155. {
  156. // Sort the links into an array with new boards bold so it can be imploded.
  157. $children = array();
  158. /* Each child in each board's children has:
  159. id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
  160. foreach ($board['children'] as $child)
  161. {
  162. if (!$child['is_redirect'])
  163. $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 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>';
  164. else
  165. $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>';
  166. // Has it posts awaiting approval?
  167. if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics']))
  168. $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>';
  169. $children[] = $child['new'] ? '<strong>' . $child['link'] . '</strong>' : $child['link'];
  170. }
  171. echo '
  172. <tr id="board_', $board['id'], '_children" class="windowbg2">
  173. <td colspan="3" class="windowbg children">
  174. <p><strong>', $txt['sub_boards'], '</strong>: ', implode(', ', $children), '</p>
  175. </td>
  176. </tr>';
  177. }
  178. }
  179. echo '
  180. </tbody>';
  181. }
  182. echo '
  183. <tbody class="divider">
  184. <tr>
  185. <td colspan="4"></td>
  186. </tr>
  187. </tbody>';
  188. }
  189. echo '
  190. </table>
  191. </div>';
  192. // Show the mark all as read button?
  193. if ($context['user']['is_logged'] && !empty($context['categories']))
  194. echo '
  195. <div class="mark_read">', template_button_strip($context['mark_read_button'], 'right'), '</div>';
  196. }
  197. function template_boardindex_outer_below()
  198. {
  199. template_info_center();
  200. }
  201. function template_info_center()
  202. {
  203. global $context, $settings, $options, $txt, $scripturl, $modSettings;
  204. if (empty($context['info_center']))
  205. return;
  206. // Here's where the "Info Center" starts...
  207. echo '
  208. <div class="roundframe" id="info_center">
  209. <div class="title_bar">
  210. <h3 class="titlebg">
  211. <span class="toggle_up floatright" id="upshrink_ic" title="', $txt['hide'], '" style="display: none;"></span>
  212. <a href="#" id="upshrink_link">', sprintf($txt['info_center_title'], $context['forum_name_html_safe']), '</a>
  213. </h3>
  214. </div>
  215. <div id="upshrinkHeaderIC"', empty($options['collapse_header_ic']) ? '' : ' style="display: none;"', '>';
  216. foreach ($context['info_center'] as $block)
  217. {
  218. $func = 'template_ic_block_' . $block;
  219. $func();
  220. }
  221. echo '
  222. </div>
  223. </div>';
  224. // Info center collapse object.
  225. echo '
  226. <script><!-- // --><![CDATA[
  227. var oInfoCenterToggle = new smc_Toggle({
  228. bToggleEnabled: true,
  229. bCurrentlyCollapsed: ', empty($options['collapse_header_ic']) ? 'false' : 'true', ',
  230. aSwappableContainers: [
  231. \'upshrinkHeaderIC\'
  232. ],
  233. aSwapImages: [
  234. {
  235. sId: \'upshrink_ic\',
  236. altExpanded: ', JavaScriptEscape($txt['hide']), ',
  237. altCollapsed: ', JavaScriptEscape($txt['show']), '
  238. }
  239. ],
  240. aSwapLinks: [
  241. {
  242. sId: \'upshrink_link\',
  243. msgExpanded: ', JavaScriptEscape(sprintf($txt['info_center_title'], $context['forum_name_html_safe'])), ',
  244. msgCollapsed: ', JavaScriptEscape(sprintf($txt['info_center_title'], $context['forum_name_html_safe'])), '
  245. }
  246. ],
  247. oThemeOptions: {
  248. bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
  249. sOptionName: \'collapse_header_ic\',
  250. sSessionId: smf_session_id,
  251. sSessionVar: smf_session_var,
  252. },
  253. oCookieOptions: {
  254. bUseCookie: ', $context['user']['is_guest'] ? 'true' : 'false', ',
  255. sCookieName: \'upshrinkIC\'
  256. }
  257. });
  258. // ]]></script>';
  259. }
  260. function template_ic_block_recent()
  261. {
  262. global $context, $scripturl, $settings, $txt;
  263. // This is the "Recent Posts" bar.
  264. echo '
  265. <div class="sub_bar">
  266. <h4 class="subg">
  267. <a href="', $scripturl, '?action=recent"><img class="icon" src="', $settings['images_url'], '/post/xx.png" alt="">', $txt['recent_posts'], '</a>
  268. </h4>
  269. </div>
  270. <div id="recent_posts_content">';
  271. // Only show one post.
  272. if ($settings['number_recent_posts'] == 1)
  273. {
  274. // latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
  275. echo '
  276. <p id="infocenter_onepost" class="inline">
  277. <a href="', $scripturl, '?action=recent">', $txt['recent_view'], '</a>&nbsp;&quot;', sprintf($txt['is_recent_updated'], '&quot;' . $context['latest_post']['link'], '&quot;'), ' (', $context['latest_post']['time'], ')<br>
  278. </p>';
  279. }
  280. // Show lots of posts.
  281. elseif (!empty($context['latest_posts']))
  282. {
  283. echo '
  284. <table id="ic_recentposts">
  285. <tr>
  286. <th class="recentpost first_th">', $txt['message'], '</th>
  287. <th class="recentposter">', $txt['author'], '</th>
  288. <th class="recentboard">', $txt['board'], '</th>
  289. <th class="recenttime last_th">', $txt['date'], '</th>
  290. </tr>';
  291. /* Each post in latest_posts has:
  292. board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
  293. subject, short_subject (shortened with...), time, link, and href. */
  294. foreach ($context['latest_posts'] as $post)
  295. echo '
  296. <tr>
  297. <td class="recentpost"><strong>', $post['link'], '</strong></td>
  298. <td class="recentposter">', $post['poster']['link'], '</td>
  299. <td class="recentboard">', $post['board']['link'], '</td>
  300. <td class="recenttime">', $post['time'], '</td>
  301. </tr>';
  302. echo '
  303. </table>';
  304. }
  305. echo '
  306. </div>';
  307. }
  308. function template_ic_block_calendar()
  309. {
  310. global $context, $scripturl, $txt, $settings;
  311. // Show information about events, birthdays, and holidays on the calendar.
  312. echo '
  313. <div class="sub_bar">
  314. <h4 class="subg">
  315. <a href="', $scripturl, '?action=calendar' . '"><img class="icon" src="', $settings['images_url'], '/icons/calendar.png', '" alt="">', $context['calendar_only_today'] ? $txt['calendar_today'] : $txt['calendar_upcoming'], '</a>
  316. </h4>
  317. </div>';
  318. // Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P.
  319. if (!empty($context['calendar_holidays']))
  320. echo '
  321. <p class="inline holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), '</p>';
  322. // People's birthdays. Like mine. And yours, I guess. Kidding.
  323. if (!empty($context['calendar_birthdays']))
  324. {
  325. echo '
  326. <p class="inline">
  327. <span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>';
  328. // Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?)
  329. foreach ($context['calendar_birthdays'] as $member)
  330. echo '
  331. <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', ';
  332. echo '
  333. </p>';
  334. }
  335. // Events like community get-togethers.
  336. if (!empty($context['calendar_events']))
  337. {
  338. echo '
  339. <p class="inline">
  340. <span class="event">', $context['calendar_only_today'] ? $txt['events'] : $txt['events_upcoming'], '</span> ';
  341. // Each event in calendar_events should have:
  342. // title, href, is_last, can_edit (are they allowed?), modify_href, and is_today.
  343. foreach ($context['calendar_events'] as $event)
  344. echo '
  345. ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><img src="' . $settings['images_url'] . '/icons/calendar_modify.png" alt="*" class="centericon"></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br>' : ', ';
  346. echo '
  347. </p>';
  348. }
  349. }
  350. function template_ic_block_stats()
  351. {
  352. global $scripturl, $txt, $context, $settings;
  353. // Show statistical style information...
  354. echo '
  355. <div class="sub_bar">
  356. <h4 class="subg">
  357. <a href="', $scripturl, '?action=stats" title="', $txt['more_stats'], '"><span class="stats_icon boards"></span>', $txt['forum_stats'], '</a>
  358. </h4>
  359. </div>
  360. <p class="inline">
  361. ', $context['common_stats']['boardindex_total_posts'], '', !empty($settings['show_latest_member']) ? ' - '. $txt['latest_member'] . ': <strong> ' . $context['common_stats']['latest_member']['link'] . '</strong>' : '', '<br>
  362. ', (!empty($context['latest_post']) ? $txt['latest_post'] . ': <strong>&quot;' . $context['latest_post']['link'] . '&quot;</strong> (' . $context['latest_post']['time'] . ')<br>' : ''), '
  363. <a href="', $scripturl, '?action=recent">', $txt['recent_view'], '</a>
  364. </p>';
  365. }
  366. function template_ic_block_online()
  367. {
  368. global $context, $scripturl, $txt, $modSettings, $settings;
  369. // "Users online" - in order of activity.
  370. echo '
  371. <div class="sub_bar">
  372. <h4 class="subg">
  373. ', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', '<span class="stats_icon people"></span>', $txt['online_users'], '', $context['show_who'] ? '</a>' : '', '
  374. </h4>
  375. </div>
  376. <p class="inline">
  377. ', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', '<strong>', $txt['online'], ': </strong>', comma_format($context['num_guests']), ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($context['num_users_online']), ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];
  378. // Handle hidden users and buddies.
  379. $bracketList = array();
  380. if ($context['show_buddies'])
  381. $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
  382. if (!empty($context['num_spiders']))
  383. $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
  384. if (!empty($context['num_users_hidden']))
  385. $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']);
  386. if (!empty($bracketList))
  387. echo ' (' . implode(', ', $bracketList) . ')';
  388. echo $context['show_who'] ? '</a>' : '', '
  389. &nbsp;-&nbsp;', $txt['most_online_today'], ': <strong>', comma_format($modSettings['mostOnlineToday']), '</strong>&nbsp;-&nbsp;
  390. ', $txt['most_online_ever'], ': ', comma_format($modSettings['mostOnline']), ' (', timeformat($modSettings['mostDate']), ')<br>';
  391. // Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
  392. if (!empty($context['users_online']))
  393. {
  394. echo '
  395. ', sprintf($txt['users_active'], $modSettings['lastActive']), ': ', implode(', ', $context['list_users_online']);
  396. // Showing membergroups?
  397. if (!empty($settings['show_group_key']) && !empty($context['membergroups']))
  398. echo '
  399. <span class="membergroups">' . implode(',&nbsp;', $context['membergroups']). '</span>';
  400. }
  401. echo '
  402. </p>';
  403. }
  404. ?>