BoardIndex.template.php 19 KB

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