index.template.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2011 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. /* This template is, perhaps, the most important template in the theme. It
  13. contains the main template layer that displays the header and footer of
  14. the forum, namely with main_above and main_below. It also contains the
  15. menu sub template, which appropriately displays the menu; the init sub
  16. template, which is there to set the theme up; (init can be missing.) and
  17. the linktree sub template, which sorts out the link tree.
  18. The init sub template should load any data and set any hardcoded options.
  19. The main_above sub template is what is shown above the main content, and
  20. should contain anything that should be shown up there.
  21. The main_below sub template, conversely, is shown after the main content.
  22. It should probably contain the copyright statement and some other things.
  23. The linktree sub template should display the link tree, using the data
  24. in the $context['linktree'] variable.
  25. The menu sub template should display all the relevant buttons the user
  26. wants and or needs.
  27. For more information on the templating system, please see the site at:
  28. http://www.simplemachines.org/
  29. */
  30. /**
  31. * Initialize the template... mainly little settings.
  32. */
  33. function template_init()
  34. {
  35. global $context, $settings, $options, $txt;
  36. /* Use images from default theme when using templates from the default theme?
  37. if this is 'always', images from the default theme will be used.
  38. if this is 'defaults', images from the default theme will only be used with default templates.
  39. if this is 'never' or isn't set at all, images from the default theme will not be used. */
  40. $settings['use_default_images'] = 'never';
  41. /* What document type definition is being used? (for font size and other issues.)
  42. 'xhtml' for an XHTML 1.0 document type definition.
  43. 'html' for an HTML 4.01 document type definition. */
  44. $settings['doctype'] = 'xhtml';
  45. // The version this template/theme is for. This should probably be the version of SMF it was created for.
  46. $settings['theme_version'] = '2.0';
  47. // Set a setting that tells the theme that it can render the tabs.
  48. $settings['use_tabs'] = true;
  49. // Use plain buttons - as opposed to text buttons?
  50. $settings['use_buttons'] = true;
  51. // Show sticky and lock status separate from topic icons?
  52. $settings['separate_sticky_lock'] = true;
  53. // Does this theme use the strict doctype?
  54. $settings['strict_doctype'] = false;
  55. // Set the following variable to true if this theme requires the optional theme strings file to be loaded.
  56. $settings['require_theme_strings'] = false;
  57. }
  58. /**
  59. * The main sub template above the content.
  60. */
  61. function template_html_above()
  62. {
  63. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  64. // Show right to left and the character set for ease of translating.
  65. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  66. <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
  67. <head>';
  68. // The ?alp21 part of this link is just here to make sure browsers don't cache it wrongly.
  69. echo '
  70. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />';
  71. // Some browsers need an extra stylesheet due to bugs/compatibility issues.
  72. // Note: Commented this out as it will be unnecessary if we go ahead with setting browser as id on <body>.
  73. // foreach (array('ie7', 'ie6', 'webkit') as $cssfix)
  74. // if ($context['browser']['is_' . $cssfix])
  75. // echo '
  76. // <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/', $cssfix, '.css" />';
  77. // RTL languages require an additional stylesheet.
  78. if ($context['right_to_left'])
  79. echo '
  80. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/rtl.css" />';
  81. // load in any css from mods or themes so they can overwrite if wanted
  82. template_css();
  83. // Jquery Librarys
  84. if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn')
  85. echo '
  86. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>';
  87. elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local')
  88. echo '
  89. <script type="text/javascript" src="', $settings['theme_url'], '/scripts/jquery-1.7.1.min.js"></script>';
  90. else
  91. echo '
  92. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  93. <script type="text/javascript"><!-- // --><![CDATA[
  94. window.jQuery || document.write(\'<script src="', $settings['theme_url'], '/scripts/jquery-1.7.1.min.js"><\/script>\');
  95. // ]]></script>';
  96. // Note that the Superfish function seems to like being called by the full syntax.
  97. // It doesn't appear to like being called by short syntax. Please test if contemplating changes.
  98. echo '
  99. <script type="text/javascript" src="', $settings['theme_url'], '/scripts/hoverIntent.js"></script>
  100. <script type="text/javascript" src="', $settings['theme_url'], '/scripts/superfish.js"></script>
  101. <script type="text/javascript" src="', $settings['theme_url'], '/scripts/jquery.bt.js"></script>';
  102. // Here comes the JavaScript bits!
  103. echo '
  104. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?alp21"></script>
  105. <script type="text/javascript" src="', $settings['theme_url'], '/scripts/theme.js?alp21"></script>
  106. <script type="text/javascript"><!-- // --><![CDATA[
  107. var smf_theme_url = "', $settings['theme_url'], '";
  108. var smf_default_theme_url = "', $settings['default_theme_url'], '";
  109. var smf_images_url = "', $settings['images_url'], '";
  110. var smf_scripturl = "', $scripturl, '";
  111. var smf_iso_case_folding = ', $context['server']['iso_case_folding'] ? 'true' : 'false', ';
  112. var smf_charset = "', $context['character_set'], '";
  113. var smf_session_id = "', $context['session_id'], '";
  114. var smf_session_var = "', $context['session_var'], '";
  115. var smf_member_id = "', $context['user']['id'], '";', $context['show_pm_popup'] ? '
  116. var fPmPopup = function ()
  117. {
  118. if (confirm("' . $txt['show_personal_messages'] . '"))
  119. window.open(smf_prepareScriptUrl(smf_scripturl) + "action=pm");
  120. }
  121. addLoadEvent(fPmPopup);' : '', '
  122. var ajax_notification_text = "', $txt['ajax_in_progress'], '";
  123. var ajax_notification_cancel_text = "', $txt['modify_cancel'], '";
  124. // ]]></script>';
  125. echo '
  126. <script type="text/javascript"><!-- // --><![CDATA[
  127. $(document).ready(function() {
  128. $("ul.dropmenu, ul.quickbuttons, div.poster ul").superfish();
  129. });
  130. // ]]></script>';
  131. // load in any javascript files from mods and themes
  132. template_javascript();
  133. echo '
  134. <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
  135. <meta name="description" content="', $context['page_title_html_safe'], '" />', !empty($context['meta_keywords']) ? '
  136. <meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '', '
  137. <title>', $context['page_title_html_safe'], '</title>';
  138. // Please don't index these Mr Robot.
  139. if (!empty($context['robot_no_index']))
  140. echo '
  141. <meta name="robots" content="noindex" />';
  142. // Present a canonical url for search engines to prevent duplicate content in their indices.
  143. if (!empty($context['canonical_url']))
  144. echo '
  145. <link rel="canonical" href="', $context['canonical_url'], '" />';
  146. // Show all the relative links, such as help, search, contents, and the like.
  147. echo '
  148. <link rel="help" href="', $scripturl, '?action=help" />
  149. <link rel="contents" href="', $scripturl, '" />', ($context['allow_search'] ? '
  150. <link rel="search" href="' . $scripturl . '?action=search" />' : '');
  151. // If RSS feeds are enabled, advertise the presence of one.
  152. if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
  153. echo '
  154. <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?type=rss2;action=.xml" />
  155. <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?type=atom;action=.xml" />';
  156. // If we're viewing a topic, these should be the previous and next topics, respectively.
  157. // Note: These have been modified to add additional functionality. Has already been tested live for two years.
  158. // Please see http://www.simplemachines.org/community/index.php?topic=210212.msg2546739#msg2546739
  159. // and
  160. // http://www.simplemachines.org/community/index.php?topic=210212.msg2548628#msg2548628 for further details.
  161. if (!empty($context['links']['next']))
  162. echo '
  163. <link rel="next" href="', $context['links']['next'], '" />';
  164. else if (!empty($context['current_topic']))
  165. echo '
  166. <link rel="next" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=next" />';
  167. if (!empty($context['links']['prev']))
  168. echo '
  169. <link rel="prev" href="', $context['links']['prev'], '" />';
  170. else if (!empty($context['current_topic']))
  171. echo '
  172. <link rel="prev" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=prev" />';
  173. // If we're in a board, or a topic for that matter, the index will be the board's index.
  174. if (!empty($context['current_board']))
  175. echo '
  176. <link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0" />';
  177. // Output any remaining HTML headers. (from mods, maybe?)
  178. echo $context['html_headers'];
  179. echo '
  180. </head>
  181. <body id="', $context['browser_body_id'], '" class="action_', !empty($context['current_action']) ? htmlspecialchars($context['current_action']) : (!empty($context['current_board']) ? 'messageindex' : (!empty($context['current_topic']) ? 'display' : 'home')),
  182. !empty($context['current_board']) ? ' board_' . htmlspecialchars($context['current_board']) : '',
  183. '">';
  184. }
  185. function template_body_above()
  186. {
  187. // Note: Globals updated to allow linking member avatar to their profile.
  188. global $context, $settings, $options, $scripturl, $txt, $modSettings, $member;
  189. // Note: Echo a true top-of-page link. This is much better than just having the standard SMF "Go up" and "Go down" links.
  190. // Not that I have anything against going down, you understand. It's just that if one is going down one should do it properly.
  191. echo '
  192. <a id="top_most"></a>';
  193. // Note: Header div is now full width.
  194. // We could change this later to an HTML5 <header> tag if we use javascript to create some useful HTML5 elements for IE<9.
  195. // Example javascript here: http://www.nickyeoman.com/blog/html/118-html5-tags-in-ie8
  196. // Note: Wrapper has been changed from an id to a class, to enable better theming options, and the ability to set forum width on the theme settings page has been removed.
  197. // Wrapper width is now set directly in index.css, as this is the only practical way of supporting an adaptable layout that will cope with mobile devices as well as desktop.
  198. echo '
  199. <div id="top_section">
  200. <div class="wrapper">
  201. <div class="frame">';
  202. // Note: Markup past this point may be slightly WIP. Wear your armour-plated undies.
  203. if ($context['user']['is_logged'])
  204. {
  205. if (!empty($context['user']['avatar']))
  206. echo '
  207. <a href="', $scripturl, '?action=profile" class="avatar">', $context['user']['avatar']['image'], '</a>';
  208. echo '
  209. <ul>
  210. <li class="greeting">', $txt['hello_member_ndt'], ' <span>', $context['user']['name'], '</span>';
  211. // Is the forum in maintenance mode?
  212. if (($context['allow_moderation_center'] && ($context['in_maintenance'])||!empty ($context['unapproved_members'])||!empty($context['open_mod_reports'])))
  213. {
  214. echo '
  215. <ul id="top_bar_notifications">';
  216. if ($context['in_maintenance'])
  217. echo '
  218. <li class="notice">', $txt['maintain_mode_on'], '</li>';
  219. if (!empty ($context['unapproved_members']))
  220. echo '
  221. <li>', $context['unapproved_members'] == 1 ? $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="', $scripturl, '?action=admin;area=viewmembers;sa=browse;type=approve" style="font-weight: bold;">', $context['unapproved_members'] == 1 ? $txt['approve_member'] : $context['unapproved_members'] . ' ' . $txt['approve_members'], ' ', $txt['approve_members_waiting'], '</a></li>';
  222. if (!empty($context['open_mod_reports']))
  223. echo '
  224. <li><a href="', $scripturl, '?action=moderate;area=reports">', sprintf($txt['mod_reports_waiting'], $context['open_mod_reports']), '</a></li>';
  225. echo '
  226. </ul>';
  227. }
  228. echo '
  229. </li>
  230. <li>', $context['current_time'], '</li>
  231. </ul>';
  232. }
  233. // the upshrink image, right-floated
  234. echo '
  235. <img id="upshrink" src="', $settings['images_url'], '/upshrink.png" alt="*" title="', $txt['upshrink_description'], '" style="display: none;" />';
  236. echo '
  237. <form id="search_form" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
  238. <input type="text" name="search" value="" class="input_text" />&nbsp;
  239. <input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
  240. <input type="hidden" name="advanced" value="0" />';
  241. // Search within current topic?
  242. if (!empty($context['current_topic']))
  243. echo '
  244. <input type="hidden" name="topic" value="', $context['current_topic'], '" />';
  245. // If we're on a certain board, limit it to this board ;).
  246. elseif (!empty($context['current_board']))
  247. echo '
  248. <input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
  249. echo '
  250. </form>';
  251. echo '
  252. </div>
  253. </div>
  254. </div>
  255. <div id="header">
  256. <div class="wrapper">
  257. <div class="frame">
  258. <h1 class="forumtitle">
  259. <a href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? $context['forum_name'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
  260. </h1>
  261. ', empty($settings['site_slogan']) ? '<img id="smflogo" src="' . $settings['images_url'] . '/smflogo.png" alt="Simple Machines Forum" title="Simple Machines Forum" />' : '<div id="siteslogan">' . $settings['site_slogan'] . '</div>', '
  262. <div id="upper_section" ', empty($options['collapse_header']) ? '' : ' style="display: none;"', '>
  263. <div class="news" id="news_collapse">';
  264. // Otherwise they're a guest - this time ask them to either register or login - lazy bums...
  265. if (!empty($context['show_login_bar']))
  266. {
  267. echo '
  268. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
  269. <form id="guest_form" style="float: left; margin-left: 0; width: auto;" action="', $scripturl, '?action=login2;quicklogin" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\', \'' . (!empty($context['login_token']) ? $context['login_token'] : '') . '\');"' : '', '>
  270. <div class="info">', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $scripturl . '?action=login'), '</div>
  271. <input type="text" name="user" size="10" class="input_text" />
  272. <input type="password" name="passwrd" size="10" class="input_password" />
  273. <select name="cookielength">
  274. <option value="60">', $txt['one_hour'], '</option>
  275. <option value="1440">', $txt['one_day'], '</option>
  276. <option value="10080">', $txt['one_week'], '</option>
  277. <option value="43200">', $txt['one_month'], '</option>
  278. <option value="-1" selected="selected">', $txt['forever'], '</option>
  279. </select>
  280. <input type="submit" value="', $txt['login'], '" class="button_submit" /><br />
  281. <div class="info">', $txt['quick_login_dec'], '</div>';
  282. if (!empty($modSettings['enableOpenID']))
  283. echo '
  284. <br /><input type="text" name="openid_identifier" size="25" class="input_text openid_login" />';
  285. echo '
  286. <input type="hidden" name="hash_passwrd" value="" />
  287. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  288. <input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '" />
  289. </form>';
  290. }
  291. // Show a random news item? (or you could pick one from news_lines...)
  292. if (!empty($settings['enable_news']))
  293. echo '
  294. <h2>', $txt['news'], ': </h2>
  295. <p>', $context['random_news_line'], '</p>';
  296. echo '
  297. </div>
  298. </div>';
  299. // Define the upper_section toggle in JavaScript.
  300. echo '
  301. <script type="text/javascript"><!-- // --><![CDATA[
  302. var oMainHeaderToggle = new smc_Toggle({
  303. bToggleEnabled: true,
  304. bCurrentlyCollapsed: ', empty($options['collapse_header']) ? 'false' : 'true', ',
  305. aSwappableContainers: [
  306. \'upper_section\'
  307. ],
  308. aSwapImages: [
  309. {
  310. sId: \'upshrink\',
  311. srcExpanded: smf_images_url + \'/upshrink.png\',
  312. altExpanded: ', JavaScriptEscape($txt['upshrink_description']), ',
  313. srcCollapsed: smf_images_url + \'/upshrink2.png\',
  314. altCollapsed: ', JavaScriptEscape($txt['upshrink_description']), '
  315. }
  316. ],
  317. oThemeOptions: {
  318. bUseThemeSettings: smf_member_id == 0 ? false : true,
  319. sOptionName: \'collapse_header\',
  320. sSessionVar: smf_session_var,
  321. sSessionId: smf_session_id
  322. },
  323. oCookieOptions: {
  324. bUseCookie: smf_member_id == 0 ? true : false,
  325. sCookieName: \'upshrink\'
  326. }
  327. });
  328. // ]]></script>';
  329. // Show the menu here, according to the menu sub template.
  330. template_menu();
  331. echo '
  332. <br class="clear" />
  333. </div>
  334. </div>
  335. </div>';
  336. // The main content should go here.
  337. echo '
  338. <div id="content_section">
  339. <div class="wrapper">
  340. <div class="frame">';
  341. // Custom banners and shoutboxes should be placed here, before the linktree.
  342. // Show the navigation tree.
  343. theme_linktree();
  344. }
  345. function template_body_below()
  346. {
  347. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  348. echo '
  349. </div>
  350. </div>
  351. </div>';
  352. // Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
  353. echo '
  354. <div id="footer_section">
  355. <div class="wrapper">
  356. <div class="frame">
  357. <ul>
  358. <li class="copyright">', theme_copyright(), '</li>
  359. <li><a id="button_xhtml" href="http://validator.w3.org/check?uri=referer" target="_blank" class="new_win" title="', $txt['valid_xhtml'], '"><span>', $txt['xhtml'], '</span></a></li>
  360. ', !empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']) ? '<li><a id="button_rss" href="' . $scripturl . '?action=.xml;type=rss" class="new_win"><span>' . $txt['rss'] . '</span></a></li>' : '', '
  361. <li class="last"><a id="button_wap2" href="', $scripturl , '?wap2" class="new_win"><span>', $txt['wap2'], '</span></a></li>
  362. </ul>
  363. <a class="topmost" href="#top_most"></a>';
  364. // Show the load time?
  365. if ($context['show_load_time'])
  366. echo '
  367. <p>', $txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'], '</p>';
  368. // Note: A bottom-of-page anchor has been inserted here to match the top-of-page anchor.
  369. echo '
  370. </div>
  371. </div>
  372. </div><a id="bottom_most"></a>';
  373. }
  374. function template_html_below()
  375. {
  376. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  377. template_javascript(true);
  378. echo '
  379. </body></html>';
  380. }
  381. /**
  382. * Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
  383. * @param bool $force_show = false
  384. */
  385. function theme_linktree($force_show = false)
  386. {
  387. global $context, $settings, $options, $shown_linktree, $txt, $scripturl;
  388. // If linktree is empty, just return - also allow an override.
  389. if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
  390. return;
  391. echo '
  392. <div class="navigate_section">
  393. <ul>';
  394. // Each tree item has a URL and name. Some may have extra_before and extra_after.
  395. foreach ($context['linktree'] as $link_num => $tree)
  396. {
  397. echo '
  398. <li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';
  399. // Show something before the link?
  400. if (isset($tree['extra_before']))
  401. echo $tree['extra_before'];
  402. // Show the link, including a URL if it should have one.
  403. echo $settings['linktree_link'] && isset($tree['url']) ? '
  404. <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>' : '<span>' . $tree['name'] . '</span>';
  405. // Show something after the link...?
  406. if (isset($tree['extra_after']))
  407. echo $tree['extra_after'];
  408. // Don't show a separator for the last one.
  409. if ($link_num != count($context['linktree']) - 1)
  410. echo ' &#187;';
  411. echo '
  412. </li>';
  413. }
  414. echo '
  415. </ul>';
  416. if ($context['user']['is_logged'])
  417. {
  418. echo '
  419. <ul class="unread_links">
  420. <li><a href="', $scripturl, '?action=unread">'. $txt['unread_since_visit']. '</a>&nbsp;|</li>
  421. <li><a href="', $scripturl, '?action=unreadreplies">'. $txt['show_unread_replies']. '</a></li>
  422. </ul>';
  423. }
  424. echo '
  425. </div>';
  426. $shown_linktree = true;
  427. }
  428. /**
  429. * Show the menu up top. Something like [home] [help] [profile] [logout]...
  430. */
  431. function template_menu()
  432. {
  433. global $context, $settings, $options, $scripturl, $txt;
  434. echo '
  435. <div id="main_menu">
  436. <ul class="dropmenu" id="menu_nav">';
  437. // Note: Menu markup has been cleaned up to remove unnecessary spans and classes.
  438. foreach ($context['menu_buttons'] as $act => $button)
  439. {
  440. echo '
  441. <li id="button_', $act, '">
  442. <a class="', $button['active_button'] ? 'active' : '', !empty($button['is_last']) ? ' last' : '', '" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
  443. ', $button['title'], '
  444. </a>';
  445. if (!empty($button['sub_buttons']))
  446. {
  447. echo '
  448. <ul>';
  449. foreach ($button['sub_buttons'] as $childbutton)
  450. {
  451. echo '
  452. <li>
  453. <a href="', $childbutton['href'], '" ', isset($childbutton['is_last']) ? 'class="last"' : '' , isset($childbutton['target']) ? ' target="' . $childbutton['target'] . '"' : '', '>
  454. ', $childbutton['title'], '
  455. </a>';
  456. // 3rd level menus :)
  457. if (!empty($childbutton['sub_buttons']))
  458. {
  459. echo '
  460. <ul>';
  461. foreach ($childbutton['sub_buttons'] as $grandchildbutton)
  462. echo '
  463. <li>
  464. <a href="', $grandchildbutton['href'], '" ', isset($grandchildbutton['is_last']) ? ' class="last"' : '' , isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
  465. ', $grandchildbutton['title'], '
  466. </a>
  467. </li>';
  468. echo '
  469. </ul>';
  470. }
  471. echo '
  472. </li>';
  473. }
  474. echo '
  475. </ul>';
  476. }
  477. echo '
  478. </li>';
  479. }
  480. echo '
  481. </ul>
  482. </div>';
  483. }
  484. /**
  485. * Generate a strip of buttons.
  486. * @param array $button_strip
  487. * @param string $direction = ''
  488. * @param array $strip_options = array()
  489. */
  490. function template_button_strip($button_strip, $direction = '', $strip_options = array())
  491. {
  492. global $settings, $context, $txt, $scripturl;
  493. if (!is_array($strip_options))
  494. $strip_options = array();
  495. // List the buttons in reverse order for RTL languages.
  496. if ($context['right_to_left'])
  497. $button_strip = array_reverse($button_strip, true);
  498. // Create the buttons...
  499. $buttons = array();
  500. foreach ($button_strip as $key => $value)
  501. {
  502. if (!isset($value['test']) || !empty($context[$value['test']]))
  503. $buttons[] = '
  504. <li><a' . (isset($value['id']) ? ' id="button_strip_' . $value['id'] . '"' : '') . ' class="button_strip_' . $key . (isset($value['active']) ? ' active' : '') . '" href="' . $value['url'] . '"' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '><span>' . $txt[$value['text']] . '</span></a></li>';
  505. }
  506. // No buttons? No button strip either.
  507. if (empty($buttons))
  508. return;
  509. // Can we have a first one too?.
  510. $buttons[0] = str_replace('" href="', ' first" href="', $buttons[0]);
  511. // Make the last one, as easy as possible.
  512. $buttons[count($buttons) - 1] = str_replace('" href="', ' last" href="', $buttons[count($buttons) - 1]);
  513. echo '
  514. <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"': ''), '>
  515. <ul>',
  516. implode('', $buttons), '
  517. </ul>
  518. </div>';
  519. }
  520. /**
  521. * Output the Javascript files
  522. */
  523. function template_javascript($do_defered = false)
  524. {
  525. global $context;
  526. // Use this hook to minify/optimize Javascript files
  527. call_integration_hook('pre_javascript_output');
  528. foreach ($context['javascript_files'] as $filename => $options)
  529. if ((!$do_defered && empty($options['defer'])) || ($do_defered && !empty($options['defer'])))
  530. echo '
  531. <script type="text/javascript" src="', $filename, '"></script>';
  532. }
  533. /**
  534. * Output the Javascript vars
  535. */
  536. function template_javascript_vars()
  537. {
  538. global $context;
  539. call_integration_hook('pre_javascript_vars_output');
  540. foreach ($context['javascript_vars'] as $key => $value)
  541. echo '
  542. var ', $key, ' = ', $value;
  543. }
  544. /**
  545. * Output the CSS files
  546. */
  547. function template_css()
  548. {
  549. global $context;
  550. // Use this hook to minify/optimize CSS files
  551. call_integration_hook('pre_css_output');
  552. foreach ($context['css_files'] as $filename => $options)
  553. echo '
  554. <link rel="stylesheet" type="text/css" href="', $filename, '" />';
  555. }
  556. ?>