2
0

BoardIndex.template.php 18 KB

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