Mercurial > hg > vamp-website
comparison forum/Themes/default/index.template.php @ 76:e3e11437ecea website
Add forum code
| author | Chris Cannam |
|---|---|
| date | Sun, 07 Jul 2013 11:25:48 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 75:72f59aa7e503 | 76:e3e11437ecea |
|---|---|
| 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.0 | |
| 11 */ | |
| 12 | |
| 13 /* This template is, perhaps, the most important template in the theme. It | |
| 14 contains the main template layer that displays the header and footer of | |
| 15 the forum, namely with main_above and main_below. It also contains the | |
| 16 menu sub template, which appropriately displays the menu; the init sub | |
| 17 template, which is there to set the theme up; (init can be missing.) and | |
| 18 the linktree sub template, which sorts out the link tree. | |
| 19 | |
| 20 The init sub template should load any data and set any hardcoded options. | |
| 21 | |
| 22 The main_above sub template is what is shown above the main content, and | |
| 23 should contain anything that should be shown up there. | |
| 24 | |
| 25 The main_below sub template, conversely, is shown after the main content. | |
| 26 It should probably contain the copyright statement and some other things. | |
| 27 | |
| 28 The linktree sub template should display the link tree, using the data | |
| 29 in the $context['linktree'] variable. | |
| 30 | |
| 31 The menu sub template should display all the relevant buttons the user | |
| 32 wants and or needs. | |
| 33 | |
| 34 For more information on the templating system, please see the site at: | |
| 35 http://www.simplemachines.org/ | |
| 36 */ | |
| 37 | |
| 38 // Initialize the template... mainly little settings. | |
| 39 function template_init() | |
| 40 { | |
| 41 global $context, $settings, $options, $txt; | |
| 42 | |
| 43 /* Use images from default theme when using templates from the default theme? | |
| 44 if this is 'always', images from the default theme will be used. | |
| 45 if this is 'defaults', images from the default theme will only be used with default templates. | |
| 46 if this is 'never' or isn't set at all, images from the default theme will not be used. */ | |
| 47 $settings['use_default_images'] = 'never'; | |
| 48 | |
| 49 /* What document type definition is being used? (for font size and other issues.) | |
| 50 'xhtml' for an XHTML 1.0 document type definition. | |
| 51 'html' for an HTML 4.01 document type definition. */ | |
| 52 $settings['doctype'] = 'xhtml'; | |
| 53 | |
| 54 /* The version this template/theme is for. | |
| 55 This should probably be the version of SMF it was created for. */ | |
| 56 $settings['theme_version'] = '2.0'; | |
| 57 | |
| 58 /* Set a setting that tells the theme that it can render the tabs. */ | |
| 59 $settings['use_tabs'] = true; | |
| 60 | |
| 61 /* Use plain buttons - as opposed to text buttons? */ | |
| 62 $settings['use_buttons'] = true; | |
| 63 | |
| 64 /* Show sticky and lock status separate from topic icons? */ | |
| 65 $settings['separate_sticky_lock'] = true; | |
| 66 | |
| 67 /* Does this theme use the strict doctype? */ | |
| 68 $settings['strict_doctype'] = false; | |
| 69 | |
| 70 /* Does this theme use post previews on the message index? */ | |
| 71 $settings['message_index_preview'] = false; | |
| 72 | |
| 73 /* Set the following variable to true if this theme requires the optional theme strings file to be loaded. */ | |
| 74 $settings['require_theme_strings'] = false; | |
| 75 } | |
| 76 | |
| 77 // The main sub template above the content. | |
| 78 function template_html_above() | |
| 79 { | |
| 80 global $context, $settings, $options, $scripturl, $txt, $modSettings; | |
| 81 | |
| 82 // Show right to left and the character set for ease of translating. | |
| 83 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| 84 <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '> | |
| 85 <head>'; | |
| 86 | |
| 87 // The ?fin20 part of this link is just here to make sure browsers don't cache it wrongly. | |
| 88 echo ' | |
| 89 <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />'; | |
| 90 | |
| 91 // Some browsers need an extra stylesheet due to bugs/compatibility issues. | |
| 92 foreach (array('ie7', 'ie6', 'webkit') as $cssfix) | |
| 93 if ($context['browser']['is_' . $cssfix]) | |
| 94 echo ' | |
| 95 <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/', $cssfix, '.css" />'; | |
| 96 | |
| 97 // RTL languages require an additional stylesheet. | |
| 98 if ($context['right_to_left']) | |
| 99 echo ' | |
| 100 <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/rtl.css" />'; | |
| 101 | |
| 102 // Here comes the JavaScript bits! | |
| 103 echo ' | |
| 104 <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?fin20"></script> | |
| 105 <script type="text/javascript" src="', $settings['theme_url'], '/scripts/theme.js?fin20"></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'], '";', $context['show_pm_popup'] ? ' | |
| 113 var fPmPopup = function () | |
| 114 { | |
| 115 if (confirm("' . $txt['show_personal_messages'] . '")) | |
| 116 window.open(smf_prepareScriptUrl(smf_scripturl) + "action=pm"); | |
| 117 } | |
| 118 addLoadEvent(fPmPopup);' : '', ' | |
| 119 var ajax_notification_text = "', $txt['ajax_in_progress'], '"; | |
| 120 var ajax_notification_cancel_text = "', $txt['modify_cancel'], '"; | |
| 121 // ]]></script>'; | |
| 122 | |
| 123 echo ' | |
| 124 <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" /> | |
| 125 <meta name="description" content="', $context['page_title_html_safe'], '" />', !empty($context['meta_keywords']) ? ' | |
| 126 <meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '', ' | |
| 127 <title>', $context['page_title_html_safe'], '</title>'; | |
| 128 | |
| 129 // Please don't index these Mr Robot. | |
| 130 if (!empty($context['robot_no_index'])) | |
| 131 echo ' | |
| 132 <meta name="robots" content="noindex" />'; | |
| 133 | |
| 134 // Present a canonical url for search engines to prevent duplicate content in their indices. | |
| 135 if (!empty($context['canonical_url'])) | |
| 136 echo ' | |
| 137 <link rel="canonical" href="', $context['canonical_url'], '" />'; | |
| 138 | |
| 139 // Show all the relative links, such as help, search, contents, and the like. | |
| 140 echo ' | |
| 141 <link rel="help" href="', $scripturl, '?action=help" /> | |
| 142 <link rel="search" href="', $scripturl, '?action=search" /> | |
| 143 <link rel="contents" href="', $scripturl, '" />'; | |
| 144 | |
| 145 // If RSS feeds are enabled, advertise the presence of one. | |
| 146 if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) | |
| 147 echo ' | |
| 148 <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?type=rss;action=.xml" />'; | |
| 149 | |
| 150 // If we're viewing a topic, these should be the previous and next topics, respectively. | |
| 151 if (!empty($context['current_topic'])) | |
| 152 echo ' | |
| 153 <link rel="prev" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=prev" /> | |
| 154 <link rel="next" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=next" />'; | |
| 155 | |
| 156 // If we're in a board, or a topic for that matter, the index will be the board's index. | |
| 157 if (!empty($context['current_board'])) | |
| 158 echo ' | |
| 159 <link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0" />'; | |
| 160 | |
| 161 // Output any remaining HTML headers. (from mods, maybe?) | |
| 162 echo $context['html_headers']; | |
| 163 | |
| 164 echo ' | |
| 165 </head> | |
| 166 <body>'; | |
| 167 } | |
| 168 | |
| 169 function template_body_above() | |
| 170 { | |
| 171 global $context, $settings, $options, $scripturl, $txt, $modSettings; | |
| 172 | |
| 173 echo !empty($settings['forum_width']) ? ' | |
| 174 <div id="wrapper" style="width: ' . $settings['forum_width'] . '">' : '', ' | |
| 175 <div id="header"><div class="frame"> | |
| 176 <div id="top_section"> | |
| 177 <h1 class="forumtitle"> | |
| 178 <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> | |
| 179 </h1>'; | |
| 180 | |
| 181 // the upshrink image, right-floated | |
| 182 echo ' | |
| 183 <img id="upshrink" src="', $settings['images_url'], '/upshrink.png" alt="*" title="', $txt['upshrink_description'], '" style="display: none;" />'; | |
| 184 echo ' | |
| 185 ', empty($settings['site_slogan']) ? '<img id="smflogo" src="' . $settings['images_url'] . '/smflogo.png" alt="Simple Machines Forum" title="Simple Machines Forum" />' : '<div id="siteslogan" class="floatright">' . $settings['site_slogan'] . '</div>', ' | |
| 186 </div> | |
| 187 <div id="upper_section" class="middletext"', empty($options['collapse_header']) ? '' : ' style="display: none;"', '> | |
| 188 <div class="user">'; | |
| 189 | |
| 190 // If the user is logged in, display stuff like their name, new messages, etc. | |
| 191 if ($context['user']['is_logged']) | |
| 192 { | |
| 193 if (!empty($context['user']['avatar'])) | |
| 194 echo ' | |
| 195 <p class="avatar">', $context['user']['avatar']['image'], '</p>'; | |
| 196 echo ' | |
| 197 <ul class="reset"> | |
| 198 <li class="greeting">', $txt['hello_member_ndt'], ' <span>', $context['user']['name'], '</span></li> | |
| 199 <li><a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a></li> | |
| 200 <li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>'; | |
| 201 | |
| 202 // Is the forum in maintenance mode? | |
| 203 if ($context['in_maintenance'] && $context['user']['is_admin']) | |
| 204 echo ' | |
| 205 <li class="notice">', $txt['maintain_mode_on'], '</li>'; | |
| 206 | |
| 207 // Are there any members waiting for approval? | |
| 208 if (!empty($context['unapproved_members'])) | |
| 209 echo ' | |
| 210 <li>', $context['unapproved_members'] == 1 ? $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="', $scripturl, '?action=admin;area=viewmembers;sa=browse;type=approve">', $context['unapproved_members'] == 1 ? $txt['approve_member'] : $context['unapproved_members'] . ' ' . $txt['approve_members'], '</a> ', $txt['approve_members_waiting'], '</li>'; | |
| 211 | |
| 212 if (!empty($context['open_mod_reports']) && $context['show_open_reports']) | |
| 213 echo ' | |
| 214 <li><a href="', $scripturl, '?action=moderate;area=reports">', sprintf($txt['mod_reports_waiting'], $context['open_mod_reports']), '</a></li>'; | |
| 215 | |
| 216 echo ' | |
| 217 <li>', $context['current_time'], '</li> | |
| 218 </ul>'; | |
| 219 } | |
| 220 // Otherwise they're a guest - this time ask them to either register or login - lazy bums... | |
| 221 elseif (!empty($context['show_login_bar'])) | |
| 222 { | |
| 223 echo ' | |
| 224 <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script> | |
| 225 <form id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '> | |
| 226 <div class="info">', sprintf($txt['welcome_guest'], $txt['guest_title']), '</div> | |
| 227 <input type="text" name="user" size="10" class="input_text" /> | |
| 228 <input type="password" name="passwrd" size="10" class="input_password" /> | |
| 229 <select name="cookielength"> | |
| 230 <option value="60">', $txt['one_hour'], '</option> | |
| 231 <option value="1440">', $txt['one_day'], '</option> | |
| 232 <option value="10080">', $txt['one_week'], '</option> | |
| 233 <option value="43200">', $txt['one_month'], '</option> | |
| 234 <option value="-1" selected="selected">', $txt['forever'], '</option> | |
| 235 </select> | |
| 236 <input type="submit" value="', $txt['login'], '" class="button_submit" /><br /> | |
| 237 <div class="info">', $txt['quick_login_dec'], '</div>'; | |
| 238 | |
| 239 if (!empty($modSettings['enableOpenID'])) | |
| 240 echo ' | |
| 241 <br /><input type="text" name="openid_identifier" id="openid_url" size="25" class="input_text openid_login" />'; | |
| 242 | |
| 243 echo ' | |
| 244 <input type="hidden" name="hash_passwrd" value="" /> | |
| 245 </form>'; | |
| 246 } | |
| 247 | |
| 248 echo ' | |
| 249 </div> | |
| 250 <div class="news normaltext"> | |
| 251 <form id="search_form" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> | |
| 252 <input type="text" name="search" value="" class="input_text" /> | |
| 253 <input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" /> | |
| 254 <input type="hidden" name="advanced" value="0" />'; | |
| 255 | |
| 256 // Search within current topic? | |
| 257 if (!empty($context['current_topic'])) | |
| 258 echo ' | |
| 259 <input type="hidden" name="topic" value="', $context['current_topic'], '" />'; | |
| 260 // If we're on a certain board, limit it to this board ;). | |
| 261 elseif (!empty($context['current_board'])) | |
| 262 echo ' | |
| 263 <input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />'; | |
| 264 | |
| 265 echo '</form>'; | |
| 266 | |
| 267 // Show a random news item? (or you could pick one from news_lines...) | |
| 268 if (!empty($settings['enable_news'])) | |
| 269 echo ' | |
| 270 <h2>', $txt['news'], ': </h2> | |
| 271 <p>', $context['random_news_line'], '</p>'; | |
| 272 | |
| 273 echo ' | |
| 274 </div> | |
| 275 </div> | |
| 276 <br class="clear" />'; | |
| 277 | |
| 278 // Define the upper_section toggle in JavaScript. | |
| 279 echo ' | |
| 280 <script type="text/javascript"><!-- // --><![CDATA[ | |
| 281 var oMainHeaderToggle = new smc_Toggle({ | |
| 282 bToggleEnabled: true, | |
| 283 bCurrentlyCollapsed: ', empty($options['collapse_header']) ? 'false' : 'true', ', | |
| 284 aSwappableContainers: [ | |
| 285 \'upper_section\' | |
| 286 ], | |
| 287 aSwapImages: [ | |
| 288 { | |
| 289 sId: \'upshrink\', | |
| 290 srcExpanded: smf_images_url + \'/upshrink.png\', | |
| 291 altExpanded: ', JavaScriptEscape($txt['upshrink_description']), ', | |
| 292 srcCollapsed: smf_images_url + \'/upshrink2.png\', | |
| 293 altCollapsed: ', JavaScriptEscape($txt['upshrink_description']), ' | |
| 294 } | |
| 295 ], | |
| 296 oThemeOptions: { | |
| 297 bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ', | |
| 298 sOptionName: \'collapse_header\', | |
| 299 sSessionVar: ', JavaScriptEscape($context['session_var']), ', | |
| 300 sSessionId: ', JavaScriptEscape($context['session_id']), ' | |
| 301 }, | |
| 302 oCookieOptions: { | |
| 303 bUseCookie: ', $context['user']['is_guest'] ? 'true' : 'false', ', | |
| 304 sCookieName: \'upshrink\' | |
| 305 } | |
| 306 }); | |
| 307 // ]]></script>'; | |
| 308 | |
| 309 // Show the menu here, according to the menu sub template. | |
| 310 template_menu(); | |
| 311 | |
| 312 echo ' | |
| 313 <br class="clear" /> | |
| 314 </div></div>'; | |
| 315 | |
| 316 // The main content should go here. | |
| 317 echo ' | |
| 318 <div id="content_section"><div class="frame"> | |
| 319 <div id="main_content_section">'; | |
| 320 | |
| 321 // Custom banners and shoutboxes should be placed here, before the linktree. | |
| 322 | |
| 323 // Show the navigation tree. | |
| 324 theme_linktree(); | |
| 325 } | |
| 326 | |
| 327 function template_body_below() | |
| 328 { | |
| 329 global $context, $settings, $options, $scripturl, $txt, $modSettings; | |
| 330 | |
| 331 echo ' | |
| 332 </div> | |
| 333 </div></div>'; | |
| 334 | |
| 335 // Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere! | |
| 336 echo ' | |
| 337 <div id="footer_section"><div class="frame"> | |
| 338 <ul class="reset"> | |
| 339 <li class="copyright">', theme_copyright(), '</li> | |
| 340 <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> | |
| 341 ', !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>' : '', ' | |
| 342 <li class="last"><a id="button_wap2" href="', $scripturl , '?wap2" class="new_win"><span>', $txt['wap2'], '</span></a></li> | |
| 343 </ul>'; | |
| 344 | |
| 345 // Show the load time? | |
| 346 if ($context['show_load_time']) | |
| 347 echo ' | |
| 348 <p>', $txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'], '</p>'; | |
| 349 | |
| 350 echo ' | |
| 351 </div></div>', !empty($settings['forum_width']) ? ' | |
| 352 </div>' : ''; | |
| 353 } | |
| 354 | |
| 355 function template_html_below() | |
| 356 { | |
| 357 global $context, $settings, $options, $scripturl, $txt, $modSettings; | |
| 358 | |
| 359 echo ' | |
| 360 </body></html>'; | |
| 361 } | |
| 362 | |
| 363 // Show a linktree. This is that thing that shows "My Community | General Category | General Discussion".. | |
| 364 function theme_linktree($force_show = false) | |
| 365 { | |
| 366 global $context, $settings, $options, $shown_linktree; | |
| 367 | |
| 368 // If linktree is empty, just return - also allow an override. | |
| 369 if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) | |
| 370 return; | |
| 371 | |
| 372 echo ' | |
| 373 <div class="navigate_section"> | |
| 374 <ul>'; | |
| 375 | |
| 376 // Each tree item has a URL and name. Some may have extra_before and extra_after. | |
| 377 foreach ($context['linktree'] as $link_num => $tree) | |
| 378 { | |
| 379 echo ' | |
| 380 <li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>'; | |
| 381 | |
| 382 // Show something before the link? | |
| 383 if (isset($tree['extra_before'])) | |
| 384 echo $tree['extra_before']; | |
| 385 | |
| 386 // Show the link, including a URL if it should have one. | |
| 387 echo $settings['linktree_link'] && isset($tree['url']) ? ' | |
| 388 <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>' : '<span>' . $tree['name'] . '</span>'; | |
| 389 | |
| 390 // Show something after the link...? | |
| 391 if (isset($tree['extra_after'])) | |
| 392 echo $tree['extra_after']; | |
| 393 | |
| 394 // Don't show a separator for the last one. | |
| 395 if ($link_num != count($context['linktree']) - 1) | |
| 396 echo ' »'; | |
| 397 | |
| 398 echo ' | |
| 399 </li>'; | |
| 400 } | |
| 401 echo ' | |
| 402 </ul> | |
| 403 </div>'; | |
| 404 | |
| 405 $shown_linktree = true; | |
| 406 } | |
| 407 | |
| 408 // Show the menu up top. Something like [home] [help] [profile] [logout]... | |
| 409 function template_menu() | |
| 410 { | |
| 411 global $context, $settings, $options, $scripturl, $txt; | |
| 412 | |
| 413 echo ' | |
| 414 <div id="main_menu"> | |
| 415 <ul class="dropmenu" id="menu_nav">'; | |
| 416 | |
| 417 foreach ($context['menu_buttons'] as $act => $button) | |
| 418 { | |
| 419 echo ' | |
| 420 <li id="button_', $act, '"> | |
| 421 <a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '> | |
| 422 <span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span> | |
| 423 </a>'; | |
| 424 if (!empty($button['sub_buttons'])) | |
| 425 { | |
| 426 echo ' | |
| 427 <ul>'; | |
| 428 | |
| 429 foreach ($button['sub_buttons'] as $childbutton) | |
| 430 { | |
| 431 echo ' | |
| 432 <li> | |
| 433 <a href="', $childbutton['href'], '"', isset($childbutton['target']) ? ' target="' . $childbutton['target'] . '"' : '', '> | |
| 434 <span', isset($childbutton['is_last']) ? ' class="last"' : '', '>', $childbutton['title'], !empty($childbutton['sub_buttons']) ? '...' : '', '</span> | |
| 435 </a>'; | |
| 436 // 3rd level menus :) | |
| 437 if (!empty($childbutton['sub_buttons'])) | |
| 438 { | |
| 439 echo ' | |
| 440 <ul>'; | |
| 441 | |
| 442 foreach ($childbutton['sub_buttons'] as $grandchildbutton) | |
| 443 echo ' | |
| 444 <li> | |
| 445 <a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '> | |
| 446 <span', isset($grandchildbutton['is_last']) ? ' class="last"' : '', '>', $grandchildbutton['title'], '</span> | |
| 447 </a> | |
| 448 </li>'; | |
| 449 | |
| 450 echo ' | |
| 451 </ul>'; | |
| 452 } | |
| 453 | |
| 454 echo ' | |
| 455 </li>'; | |
| 456 } | |
| 457 echo ' | |
| 458 </ul>'; | |
| 459 } | |
| 460 echo ' | |
| 461 </li>'; | |
| 462 } | |
| 463 | |
| 464 echo ' | |
| 465 </ul> | |
| 466 </div>'; | |
| 467 } | |
| 468 | |
| 469 // Generate a strip of buttons. | |
| 470 function template_button_strip($button_strip, $direction = 'top', $strip_options = array()) | |
| 471 { | |
| 472 global $settings, $context, $txt, $scripturl; | |
| 473 | |
| 474 if (!is_array($strip_options)) | |
| 475 $strip_options = array(); | |
| 476 | |
| 477 // List the buttons in reverse order for RTL languages. | |
| 478 if ($context['right_to_left']) | |
| 479 $button_strip = array_reverse($button_strip, true); | |
| 480 | |
| 481 // Create the buttons... | |
| 482 $buttons = array(); | |
| 483 foreach ($button_strip as $key => $value) | |
| 484 { | |
| 485 if (!isset($value['test']) || !empty($context[$value['test']])) | |
| 486 $buttons[] = ' | |
| 487 <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>'; | |
| 488 } | |
| 489 | |
| 490 // No buttons? No button strip either. | |
| 491 if (empty($buttons)) | |
| 492 return; | |
| 493 | |
| 494 // Make the last one, as easy as possible. | |
| 495 $buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]); | |
| 496 | |
| 497 echo ' | |
| 498 <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"': ''), '> | |
| 499 <ul>', | |
| 500 implode('', $buttons), ' | |
| 501 </ul> | |
| 502 </div>'; | |
| 503 } | |
| 504 | |
| 505 ?> |
