annotate forum/Themes/babylon/index.template.php @ 90:0f68499767c1 website

Subrepo
author Chris Cannam
date Thu, 19 Jun 2014 15:06:58 +0100
parents e3e11437ecea
children
rev   line source
Chris@76 1 <?php
Chris@76 2 // Version: 1.1; index
Chris@76 3
Chris@76 4 /* This template is, perhaps, the most important template in the theme. It
Chris@76 5 contains the main template layer that displays the header and footer of
Chris@76 6 the forum, namely with main_above and main_below. It also contains the
Chris@76 7 menu sub template, which appropriately displays the menu; the init sub
Chris@76 8 template, which is there to set the theme up; (init can be missing.) and
Chris@76 9 the linktree sub template, which sorts out the link tree.
Chris@76 10
Chris@76 11 The init sub template should load any data and set any hardcoded options.
Chris@76 12
Chris@76 13 The main_above sub template is what is shown above the main content, and
Chris@76 14 should contain anything that should be shown up there.
Chris@76 15
Chris@76 16 The main_below sub template, conversely, is shown after the main content.
Chris@76 17 It should probably contain the copyright statement and some other things.
Chris@76 18
Chris@76 19 The linktree sub template should display the link tree, using the data
Chris@76 20 in the $context['linktree'] variable.
Chris@76 21
Chris@76 22 The menu sub template should display all the relevant buttons the user
Chris@76 23 wants and or needs.
Chris@76 24
Chris@76 25 For more information on the templating system, please see the site at:
Chris@76 26 http://www.simplemachines.org/
Chris@76 27 */
Chris@76 28
Chris@76 29 // Initialize the template... mainly little settings.
Chris@76 30 function template_init()
Chris@76 31 {
Chris@76 32 global $context, $settings, $options, $txt;
Chris@76 33
Chris@76 34 /* Use images from default theme when using templates from the default theme?
Chris@76 35 if this is 'always', images from the default theme will be used.
Chris@76 36 if this is 'defaults', images from the default theme will only be used with default templates.
Chris@76 37 if this is 'never' or isn't set at all, images from the default theme will not be used. */
Chris@76 38 $settings['use_default_images'] = 'never';
Chris@76 39
Chris@76 40 /* What document type definition is being used? (for font size and other issues.)
Chris@76 41 'xhtml' for an XHTML 1.0 document type definition.
Chris@76 42 'html' for an HTML 4.01 document type definition. */
Chris@76 43 $settings['doctype'] = 'xhtml';
Chris@76 44
Chris@76 45 /* The version this template/theme is for.
Chris@76 46 This should probably be the version of SMF it was created for. */
Chris@76 47 $settings['theme_version'] = '1.1';
Chris@76 48
Chris@76 49 /* Set a setting that tells the theme that it can render the tabs. */
Chris@76 50 $settings['use_tabs'] = false;
Chris@76 51
Chris@76 52 /* Use plain buttons - as oppossed to text buttons? */
Chris@76 53 $settings['use_buttons'] = false;
Chris@76 54
Chris@76 55 /* Show sticky and lock status seperate from topic icons? */
Chris@76 56 $settings['seperate_sticky_lock'] = false;
Chris@76 57 }
Chris@76 58
Chris@76 59 // The main sub template above the content.
Chris@76 60 function template_main_above()
Chris@76 61 {
Chris@76 62 global $context, $settings, $options, $scripturl, $txt, $modSettings;
Chris@76 63
Chris@76 64 // Show right to left and the character set for ease of translating.
Chris@76 65 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Chris@76 66 <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '><head>
Chris@76 67 <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
Chris@76 68 <meta name="description" content="', $context['page_title'], '" />', empty($context['robot_no_index']) ? '' : '
Chris@76 69 <meta name="robots" content="noindex" />', '
Chris@76 70 <meta name="keywords" content="PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum" />
Chris@76 71 <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/script.js?fin11"></script>
Chris@76 72 <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
Chris@76 73 var smf_theme_url = "', $settings['theme_url'], '";
Chris@76 74 var smf_images_url = "', $settings['images_url'], '";
Chris@76 75 var smf_scripturl = "', $scripturl, '";
Chris@76 76 var smf_iso_case_folding = ', $context['server']['iso_case_folding'] ? 'true' : 'false', ';
Chris@76 77 var smf_charset = "', $context['character_set'], '";
Chris@76 78 // ]]></script>
Chris@76 79 <title>', $context['page_title'], '</title>';
Chris@76 80
Chris@76 81 // The ?fin11 part of this link is just here to make sure browsers don't cache it wrongly.
Chris@76 82 echo '
Chris@76 83 <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style.css?fin11" />
Chris@76 84 <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?fin11" media="print" />';
Chris@76 85
Chris@76 86 /* Internet Explorer 4/5 and Opera 6 just don't do font sizes properly. (they are big...)
Chris@76 87 Thus, in Internet Explorer 4, 5, and Opera 6 this will show fonts one size smaller than usual.
Chris@76 88 Note that this is affected by whether IE 6 is in standards compliance mode.. if not, it will also be big.
Chris@76 89 Standards compliance mode happens when you use xhtml... */
Chris@76 90 if ($context['browser']['needs_size_fix'])
Chris@76 91 echo '
Chris@76 92 <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/fonts-compat.css" />';
Chris@76 93
Chris@76 94 // Show all the relative links, such as help, search, contents, and the like.
Chris@76 95 echo '
Chris@76 96 <link rel="help" href="', $scripturl, '?action=help" target="_blank" />
Chris@76 97 <link rel="search" href="' . $scripturl . '?action=search" />
Chris@76 98 <link rel="contents" href="', $scripturl, '" />';
Chris@76 99
Chris@76 100 // If RSS feeds are enabled, advertise the presence of one.
Chris@76 101 if (!empty($modSettings['xmlnews_enable']))
Chris@76 102 echo '
Chris@76 103 <link rel="alternate" type="application/rss+xml" title="', $context['forum_name'], ' - RSS" href="', $scripturl, '?type=rss;action=.xml" />';
Chris@76 104
Chris@76 105 // If we're viewing a topic, these should be the previous and next topics, respectively.
Chris@76 106 if (!empty($context['current_topic']))
Chris@76 107 echo '
Chris@76 108 <link rel="prev" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=prev" />
Chris@76 109 <link rel="next" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=next" />';
Chris@76 110
Chris@76 111 // If we're in a board, or a topic for that matter, the index will be the board's index.
Chris@76 112 if (!empty($context['current_board']))
Chris@76 113 echo '
Chris@76 114 <link rel="index" href="' . $scripturl . '?board=' . $context['current_board'] . '.0" />';
Chris@76 115
Chris@76 116 // We'll have to use the cookie to remember the header...
Chris@76 117 if ($context['user']['is_guest'])
Chris@76 118 $options['collapse_header'] = !empty($_COOKIE['upshrink']);
Chris@76 119
Chris@76 120 // Output any remaining HTML headers. (from mods, maybe?)
Chris@76 121 echo $context['html_headers'], '
Chris@76 122
Chris@76 123 <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
Chris@76 124 var current_header = ', empty($options['collapse_header']) ? 'false' : 'true', ';
Chris@76 125
Chris@76 126 function shrinkHeader(mode)
Chris@76 127 {';
Chris@76 128
Chris@76 129 // Guests don't have theme options!!
Chris@76 130 if ($context['user']['is_guest'])
Chris@76 131 echo '
Chris@76 132 document.cookie = "upshrink=" + (mode ? 1 : 0);';
Chris@76 133 else
Chris@76 134 echo '
Chris@76 135 smf_setThemeOption("collapse_header", mode ? 1 : 0, null, "', $context['session_id'], '");';
Chris@76 136
Chris@76 137 echo '
Chris@76 138 document.getElementById("upshrink").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");
Chris@76 139
Chris@76 140 document.getElementById("upshrinkHeader").style.display = mode ? "none" : "";
Chris@76 141
Chris@76 142 current_header = mode;
Chris@76 143 }
Chris@76 144 // ]]></script>
Chris@76 145 </head>
Chris@76 146 <body>';
Chris@76 147
Chris@76 148 // Because of the way width/padding are calculated, we have to tell Internet Explorer 4 and 5 that the content should be 100% wide. (or else it will assume about 108%!)
Chris@76 149 echo '
Chris@76 150 <div id="headerarea" style="padding: 12px 30px 4px 30px;', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? ' width: 100%;' : '', '">';
Chris@76 151
Chris@76 152 // The logo and the three info boxes.
Chris@76 153 echo '
Chris@76 154 <table cellspacing="0" cellpadding="0" border="0" width="100%" style="position: relative;">
Chris@76 155 <tr>
Chris@76 156 <td colspan="2" valign="bottom" style="padding: 5px; white-space: nowrap;">';
Chris@76 157
Chris@76 158 // This part is the logo and forum name. You should be able to change this to whatever you want...
Chris@76 159 echo '
Chris@76 160 <img src="', $settings['images_url'], '/smflogo.gif" style="width: 250px; float: ', !$context['right_to_left'] ? 'right' : 'left', ';" alt="" />';
Chris@76 161 if (empty($settings['header_logo_url']))
Chris@76 162 echo '
Chris@76 163 <span style="font-family: Georgia, sans-serif; font-size: xx-large;">', $context['forum_name'], '</span>';
Chris@76 164 else
Chris@76 165 echo '
Chris@76 166 <img src="', $settings['header_logo_url'], '" alt="', $context['forum_name'], '" border="0" />';
Chris@76 167
Chris@76 168 echo '
Chris@76 169 </td>
Chris@76 170 </tr>
Chris@76 171 <tr id="upshrinkHeader"', empty($options['collapse_header']) ? '' : ' style="display: none;"', '>
Chris@76 172 <td valign="top">
Chris@76 173 <div class="headertitles" style="margin-right: 5px; position: relative;"><img src="', $settings['images_url'], '/blank.gif" height="12" alt="" /></div>
Chris@76 174 <div class="headerbodies" style="position: relative; margin-right: 5px; background-image: url(', $settings['images_url'], '/box_bg.gif);">
Chris@76 175 <img src="', $settings['images_url'], '/', $context['user']['language'], '/userinfo.gif" style="position: absolute; left: ', $context['browser']['is_ie5'] || $context['browser']['is_ie4'] ? '0' : '-1px', '; top: -16px; clear: both;" alt="" />
Chris@76 176 <table width="99%" cellpadding="0" cellspacing="5" border="0"><tr>';
Chris@76 177
Chris@76 178 if (!empty($context['user']['avatar']))
Chris@76 179 echo '<td valign="middle">', $context['user']['avatar']['image'], '</td>';
Chris@76 180
Chris@76 181 echo '<td valign="top" class="smalltext" style="width: 100%; font-family: verdana, arial, sans-serif;">';
Chris@76 182
Chris@76 183 // If the user is logged in, display stuff like their name, new messages, etc.
Chris@76 184 if ($context['user']['is_logged'])
Chris@76 185 {
Chris@76 186 echo '
Chris@76 187 ', $txt['hello_member'], ' <b>', $context['user']['name'], '</b>';
Chris@76 188
Chris@76 189 // Only tell them about their messages if they can read their messages!
Chris@76 190 if ($context['allow_pm'])
Chris@76 191 echo ', ', $txt[152], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt[153] : $txt[471], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'];
Chris@76 192 echo '.<br />';
Chris@76 193
Chris@76 194 // Is the forum in maintenance mode?
Chris@76 195 if ($context['in_maintenance'] && $context['user']['is_admin'])
Chris@76 196 echo '
Chris@76 197 <b>', $txt[616], '</b><br />';
Chris@76 198
Chris@76 199 // Are there any members waiting for approval?
Chris@76 200 if (!empty($context['unapproved_members']))
Chris@76 201 echo '
Chris@76 202 ', $context['unapproved_members'] == 1 ? $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="', $scripturl, '?action=viewmembers;sa=browse;type=approve">', $context['unapproved_members'] == 1 ? $txt['approve_member'] : $context['unapproved_members'] . ' ' . $txt['approve_members'], '</a> ', $txt['approve_members_waiting'], '<br />';
Chris@76 203
Chris@76 204 // Show the total time logged in?
Chris@76 205 if (!empty($context['user']['total_time_logged_in']))
Chris@76 206 {
Chris@76 207 echo '
Chris@76 208 ', $txt['totalTimeLogged1'];
Chris@76 209
Chris@76 210 // If days is just zero, don't bother to show it.
Chris@76 211 if ($context['user']['total_time_logged_in']['days'] > 0)
Chris@76 212 echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];
Chris@76 213
Chris@76 214 // Same with hours - only show it if it's above zero.
Chris@76 215 if ($context['user']['total_time_logged_in']['hours'] > 0)
Chris@76 216 echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];
Chris@76 217
Chris@76 218 // But, let's always show minutes - Time wasted here: 0 minutes ;).
Chris@76 219 echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '<br />';
Chris@76 220 }
Chris@76 221
Chris@76 222 echo '
Chris@76 223 <a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a><br />
Chris@76 224 <a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a><br />
Chris@76 225 ', $context['current_time'];
Chris@76 226 }
Chris@76 227 // Otherwise they're a guest - so politely ask them to register or login.
Chris@76 228 else
Chris@76 229 {
Chris@76 230 echo '
Chris@76 231 ', $txt['welcome_guest'], '<br />
Chris@76 232 ', $context['current_time'], '<br />
Chris@76 233
Chris@76 234 <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/sha1.js"></script>
Chris@76 235
Chris@76 236 <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" style="margin: 3px 1ex 1px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
Chris@76 237 <div style="text-align: right;">
Chris@76 238 <input type="text" name="user" size="10" /> <input type="password" name="passwrd" size="10" />
Chris@76 239 <select name="cookielength">
Chris@76 240 <option value="60">', $txt['smf53'], '</option>
Chris@76 241 <option value="1440">', $txt['smf47'], '</option>
Chris@76 242 <option value="10080">', $txt['smf48'], '</option>
Chris@76 243 <option value="43200">', $txt['smf49'], '</option>
Chris@76 244 <option value="-1" selected="selected">', $txt['smf50'], '</option>
Chris@76 245 </select>
Chris@76 246 <input type="submit" value="', $txt[34], '" /><br />
Chris@76 247 ', $txt['smf52'], '
Chris@76 248 <input type="hidden" name="hash_passwrd" value="" />
Chris@76 249 </div>
Chris@76 250 </form>';
Chris@76 251 }
Chris@76 252
Chris@76 253 echo '
Chris@76 254 </td></tr></table>
Chris@76 255 </div>
Chris@76 256
Chris@76 257 <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">
Chris@76 258 <div style="margin-top: 7px;">
Chris@76 259 <b>', $txt[182], ': </b><input type="text" name="search" value="" style="width: 190px;" />&nbsp;
Chris@76 260 <input type="submit" name="submit" value="', $txt[182], '" style="width: 8ex;" />&nbsp;
Chris@76 261 <a href="', $scripturl, '?action=search;advanced">', $txt['smf298'], '</a>
Chris@76 262 <input type="hidden" name="advanced" value="0" />';
Chris@76 263
Chris@76 264 // Search within current topic?
Chris@76 265 if (!empty($context['current_topic']))
Chris@76 266 echo '
Chris@76 267 <input type="hidden" name="topic" value="', $context['current_topic'], '" />';
Chris@76 268
Chris@76 269 // If we're on a certain board, limit it to this board ;).
Chris@76 270 elseif (!empty($context['current_board']))
Chris@76 271 echo '
Chris@76 272 <input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
Chris@76 273
Chris@76 274 echo '
Chris@76 275 </div>
Chris@76 276 </form>
Chris@76 277
Chris@76 278 </td>
Chris@76 279 <td style="width: 262px; ', !$context['right_to_left'] ? 'padding-left' : 'padding-right', ': 6px;" valign="top">';
Chris@76 280
Chris@76 281 // Show a random news item? (or you could pick one from news_lines...)
Chris@76 282 if (!empty($settings['enable_news']))
Chris@76 283 echo '
Chris@76 284 <div class="headertitles" style="width: 260px;"><img src="', $settings['images_url'], '/blank.gif" height="12" alt="" /></div>
Chris@76 285 <div class="headerbodies" style="width: 260px; position: relative; background-image: url(', $settings['images_url'], '/box_bg.gif); margin-bottom: 8px;">
Chris@76 286 <img src="', $settings['images_url'], '/', $context['user']['language'], '/newsbox.gif" style="position: absolute; left: -1px; top: -16px;" alt="" />
Chris@76 287 <div style="height: 50px; overflow: auto; padding: 5px;" class="smalltext">', $context['random_news_line'], '</div>
Chris@76 288 </div>';
Chris@76 289
Chris@76 290 // The "key stats" box.
Chris@76 291 echo '
Chris@76 292 <div class="headertitles" style="width: 260px;"><img src="', $settings['images_url'], '/blank.gif" height="12" alt="" /></div>
Chris@76 293 <div class="headerbodies" style="width: 260px; position: relative; background-image: url(', $settings['images_url'], '/box_bg.gif);">
Chris@76 294 <img src="', $settings['images_url'], '/', $context['user']['language'], '/keystats.gif" style="position: absolute; left: -1px; top: -16px;" alt="" />
Chris@76 295 <div style="', !$context['browser']['is_ie'] ? 'min-height: 35px;' : 'height: 4em;', ' padding: 5px;" class="smalltext">
Chris@76 296 <b>', $context['common_stats']['total_posts'], '</b> ', $txt[95], ' ', $txt['smf88'], ' <b>', $context['common_stats']['total_topics'], '</b> ', $txt[64], ' ', $txt[525], ' <span style="white-space: nowrap;"><b>', $context['common_stats']['total_members'], '</b> ', $txt[19], '</span><br />
Chris@76 297 ', $txt[656], ': <b> ', $context['common_stats']['latest_member']['link'], '</b>
Chris@76 298 </div>
Chris@76 299 </div>';
Chris@76 300
Chris@76 301 echo '
Chris@76 302 </td>
Chris@76 303 </tr>
Chris@76 304 </table>
Chris@76 305
Chris@76 306 <a href="javascript:void(0);" onclick="shrinkHeader(!current_header); return false;"><img id="upshrink" src="', $settings['images_url'], '/', empty($options['collapse_header']) ? 'upshrink.gif' : 'upshrink2.gif', '" alt="*" title="', $txt['upshrink_description'], '" style="margin: 2px 2ex 2px 0;" border="0" /></a>';
Chris@76 307
Chris@76 308 // Show the menu here, according to the menu sub template.
Chris@76 309 template_menu();
Chris@76 310
Chris@76 311 echo '
Chris@76 312 </div>';
Chris@76 313
Chris@76 314 // The main content should go here. A table is used because IE 6 just can't handle a div.
Chris@76 315 echo '
Chris@76 316 <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
Chris@76 317 <td id="bodyarea" style="padding: 1ex 20px 2ex 20px;">';
Chris@76 318 }
Chris@76 319
Chris@76 320 function template_main_below()
Chris@76 321 {
Chris@76 322 global $context, $settings, $options, $scripturl, $txt;
Chris@76 323
Chris@76 324 echo '</td>
Chris@76 325 </tr></table>';
Chris@76 326
Chris@76 327 // Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
Chris@76 328 echo '
Chris@76 329
Chris@76 330 <div id="footerarea" style="text-align: center; padding-bottom: 1ex;', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? ' width: 100%;' : '', '">
Chris@76 331 <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
Chris@76 332 function smfFooterHighlight(element, value)
Chris@76 333 {
Chris@76 334 element.src = smf_images_url + "/" + (value ? "h_" : "") + element.id + ".gif";
Chris@76 335 }
Chris@76 336 // ]]></script>
Chris@76 337 <table cellspacing="0" cellpadding="3" border="0" width="100%">
Chris@76 338 <tr>
Chris@76 339 <td width="28%" valign="middle" align="', !$context['right_to_left'] ? 'right' : 'left', '">
Chris@76 340 <a href="http://www.mysql.com/" target="_blank"><img id="powered-mysql" src="', $settings['images_url'], '/powered-mysql.gif" alt="', $txt['powered_by_mysql'], '" width="54" height="20" style="margin: 5px 16px;" border="0" onmouseover="smfFooterHighlight(this, true);" onmouseout="smfFooterHighlight(this, false);" /></a>
Chris@76 341 <a href="http://www.php.net/" target="_blank"><img id="powered-php" src="', $settings['images_url'], '/powered-php.gif" alt="', $txt['powered_by_php'], '" width="54" height="20" style="margin: 5px 16px;" border="0" onmouseover="smfFooterHighlight(this, true);" onmouseout="smfFooterHighlight(this, false);" /></a>
Chris@76 342 </td>
Chris@76 343 <td valign="middle" align="center" style="white-space: nowrap;">
Chris@76 344 ', theme_copyright(), '
Chris@76 345 </td>
Chris@76 346 <td width="28%" valign="middle" align="', !$context['right_to_left'] ? 'left' : 'right', '">
Chris@76 347 <a href="http://validator.w3.org/check/referer" target="_blank"><img id="valid-xhtml10" src="', $settings['images_url'], '/valid-xhtml10.gif" alt="', $txt['valid_xhtml'], '" width="54" height="20" style="margin: 5px 16px;" border="0" onmouseover="smfFooterHighlight(this, true);" onmouseout="smfFooterHighlight(this, false);" /></a>
Chris@76 348 <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank"><img id="valid-css" src="', $settings['images_url'], '/valid-css.gif" alt="', $txt['valid_css'], '" width="54" height="20" style="margin: 5px 16px;" border="0" onmouseover="smfFooterHighlight(this, true);" onmouseout="smfFooterHighlight(this, false);" /></a>
Chris@76 349 </td>
Chris@76 350 </tr>
Chris@76 351 </table>';
Chris@76 352
Chris@76 353 // Show the load time?
Chris@76 354 if ($context['show_load_time'])
Chris@76 355 echo '
Chris@76 356 <span class="smalltext">', $txt['smf301'], $context['load_time'], $txt['smf302'], $context['load_queries'], $txt['smf302b'], '</span>';
Chris@76 357
Chris@76 358 echo '
Chris@76 359 </div>';
Chris@76 360
Chris@76 361 // This is an interesting bug in Internet Explorer AND Safari. Rather annoying, it makes overflows just not tall enough.
Chris@76 362 if (($context['browser']['is_ie'] && !$context['browser']['is_ie4']) || $context['browser']['is_mac_ie'] || $context['browser']['is_safari'] || $context['browser']['is_firefox'])
Chris@76 363 {
Chris@76 364 // The purpose of this code is to fix the height of overflow: auto div blocks, because IE can't figure it out for itself.
Chris@76 365 echo '
Chris@76 366 <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[';
Chris@76 367
Chris@76 368 // Unfortunately, Safari does not have a "getComputedStyle" implementation yet, so we have to just do it to code...
Chris@76 369 if ($context['browser']['is_safari'])
Chris@76 370 echo '
Chris@76 371 window.addEventListener("load", smf_codeFix, false);
Chris@76 372
Chris@76 373 function smf_codeFix()
Chris@76 374 {
Chris@76 375 var codeFix = document.getElementsByTagName ? document.getElementsByTagName("div") : document.all.tags("div");
Chris@76 376
Chris@76 377 for (var i = 0; i < codeFix.length; i++)
Chris@76 378 {
Chris@76 379 if ((codeFix[i].className == "code" || codeFix[i].className == "post" || codeFix[i].className == "signature") && codeFix[i].offsetHeight < 20)
Chris@76 380 codeFix[i].style.height = (codeFix[i].offsetHeight + 20) + "px";
Chris@76 381 }
Chris@76 382 }';
Chris@76 383 elseif ($context['browser']['is_firefox'])
Chris@76 384 echo '
Chris@76 385 window.addEventListener("load", smf_codeFix, false);
Chris@76 386 function smf_codeFix()
Chris@76 387 {
Chris@76 388 var codeFix = document.getElementsByTagName ? document.getElementsByTagName("div") : document.all.tags("div");
Chris@76 389
Chris@76 390 for (var i = 0; i < codeFix.length; i++)
Chris@76 391 {
Chris@76 392 if (codeFix[i].className == "code" && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0))
Chris@76 393 codeFix[i].style.overflow = "scroll";
Chris@76 394 }
Chris@76 395 }';
Chris@76 396 else
Chris@76 397 {
Chris@76 398 echo '
Chris@76 399 var window_oldOnload = window.onload;
Chris@76 400 window.onload = smf_codeFix;
Chris@76 401
Chris@76 402 function smf_codeFix()
Chris@76 403 {
Chris@76 404 var codeFix = document.getElementsByTagName ? document.getElementsByTagName("div") : document.all.tags("div");
Chris@76 405
Chris@76 406 for (var i = codeFix.length - 1; i > 0; i--)
Chris@76 407 {
Chris@76 408 if (codeFix[i].currentStyle.overflow == "auto" && (codeFix[i].currentStyle.height == "" || codeFix[i].currentStyle.height == "auto") && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0) && (codeFix[i].offsetHeight != 0 || codeFix[i].className == "code"))
Chris@76 409 codeFix[i].style.height = (codeFix[i].offsetHeight + 36) + "px";
Chris@76 410 }
Chris@76 411
Chris@76 412 if (window_oldOnload)
Chris@76 413 {
Chris@76 414 window_oldOnload();
Chris@76 415 window_oldOnload = null;
Chris@76 416 }
Chris@76 417 }';
Chris@76 418 }
Chris@76 419
Chris@76 420 echo '
Chris@76 421 // ]]></script>';
Chris@76 422 }
Chris@76 423
Chris@76 424 // The following will be used to let the user know that some AJAX process is running
Chris@76 425 echo '
Chris@76 426 <div id="ajax_in_progress" style="display: none;', $context['browser']['is_ie'] && !$context['browser']['is_ie7'] ? 'position: absolute;' : '', '">', $txt['ajax_in_progress'], '</div>
Chris@76 427 </body>
Chris@76 428 </html>';
Chris@76 429 }
Chris@76 430
Chris@76 431 // Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
Chris@76 432 function theme_linktree()
Chris@76 433 {
Chris@76 434 global $context, $settings, $options;
Chris@76 435
Chris@76 436 // Folder style or inline? Inline has a smaller font.
Chris@76 437 echo '<span class="nav"', $settings['linktree_inline'] ? ' style="font-size: smaller;"' : '', '>';
Chris@76 438
Chris@76 439 // Each tree item has a URL and name. Some may have extra_before and extra_after.
Chris@76 440 foreach ($context['linktree'] as $link_num => $tree)
Chris@76 441 {
Chris@76 442 // Show the | | |-[] Folders.
Chris@76 443 if (!$settings['linktree_inline'])
Chris@76 444 {
Chris@76 445 if ($link_num > 0)
Chris@76 446 echo str_repeat('<img src="' . $settings['images_url'] . '/icons/linktree_main.gif" alt="| " border="0" />', $link_num - 1), '<img src="' . $settings['images_url'] . '/icons/linktree_side.gif" alt="|-" border="0" />';
Chris@76 447 echo '<img src="' . $settings['images_url'] . '/icons/folder_open.gif" alt="+" border="0" />&nbsp; ';
Chris@76 448 }
Chris@76 449
Chris@76 450 // Show something before the link?
Chris@76 451 if (isset($tree['extra_before']))
Chris@76 452 echo $tree['extra_before'];
Chris@76 453
Chris@76 454 // Show the link, including a URL if it should have one.
Chris@76 455 echo '<b>', $settings['linktree_link'] && isset($tree['url']) ? '<a href="' . $tree['url'] . '" class="nav">' . $tree['name'] . '</a>' : $tree['name'], '</b>';
Chris@76 456
Chris@76 457 // Show something after the link...?
Chris@76 458 if (isset($tree['extra_after']))
Chris@76 459 echo $tree['extra_after'];
Chris@76 460
Chris@76 461 // Don't show a separator for the last one.
Chris@76 462 if ($link_num != count($context['linktree']) - 1)
Chris@76 463 echo $settings['linktree_inline'] ? ' &nbsp;|&nbsp; ' : '<br />';
Chris@76 464 }
Chris@76 465
Chris@76 466 echo '</span>';
Chris@76 467 }
Chris@76 468
Chris@76 469 // Show the menu up top. Something like [home] [help] [profile] [logout]...
Chris@76 470 function template_menu()
Chris@76 471 {
Chris@76 472 global $context, $settings, $options, $scripturl, $txt;
Chris@76 473
Chris@76 474 // Show the [home] and [help] buttons.
Chris@76 475 echo '
Chris@76 476 <a href="', $scripturl, '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/home.gif" alt="' . $txt[103] . '" style="margin: 2px 0;" border="0" />' : $txt[103]), '</a>', $context['menu_separator'], '
Chris@76 477 <a href="', $scripturl, '?action=help">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/help.gif" alt="' . $txt[119] . '" style="margin: 2px 0;" border="0" />' : $txt[119]), '</a>', $context['menu_separator'];
Chris@76 478
Chris@76 479 // How about the [search] button?
Chris@76 480 if ($context['allow_search'])
Chris@76 481 echo '
Chris@76 482 <a href="', $scripturl, '?action=search">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/search.gif" alt="' . $txt[182] . '" style="margin: 2px 0;" border="0" />' : $txt[182]), '</a>', $context['menu_separator'];
Chris@76 483
Chris@76 484 // Is the user allowed to administrate at all? ([admin])
Chris@76 485 if ($context['allow_admin'])
Chris@76 486 echo '
Chris@76 487 <a href="', $scripturl, '?action=admin">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/admin.gif" alt="' . $txt[2] . '" style="margin: 2px 0;" border="0" />' : $txt[2]), '</a>', $context['menu_separator'];
Chris@76 488
Chris@76 489 // Edit Profile... [profile]
Chris@76 490 if ($context['allow_edit_profile'])
Chris@76 491 echo '
Chris@76 492 <a href="', $scripturl, '?action=profile">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/profile.gif" alt="' . $txt[79] . '" style="margin: 2px 0;" border="0" />' : $txt[467]), '</a>', $context['menu_separator'];
Chris@76 493
Chris@76 494 // The [calendar]!
Chris@76 495 if ($context['allow_calendar'])
Chris@76 496 echo '
Chris@76 497 <a href="', $scripturl, '?action=calendar">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/calendar.gif" alt="' . $txt['calendar24'] . '" style="margin: 2px 0;" border="0" />' : $txt['calendar24']), '</a>', $context['menu_separator'];
Chris@76 498
Chris@76 499 // If the user is a guest, show [login] and [register] buttons.
Chris@76 500 if ($context['user']['is_guest'])
Chris@76 501 {
Chris@76 502 echo '
Chris@76 503 <a href="', $scripturl, '?action=login">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/login.gif" alt="' . $txt[34] . '" style="margin: 2px 0;" border="0" />' : $txt[34]), '</a>', $context['menu_separator'], '
Chris@76 504 <a href="', $scripturl, '?action=register">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/register.gif" alt="' . $txt[97] . '" style="margin: 2px 0;" border="0" />' : $txt[97]), '</a>';
Chris@76 505 }
Chris@76 506 // Otherwise, they might want to [logout]...
Chris@76 507 else
Chris@76 508 echo '
Chris@76 509 <a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/logout.gif" alt="' . $txt[108] . '" style="margin: 2px 0;" border="0" />' : $txt[108]), '</a>';
Chris@76 510 }
Chris@76 511
Chris@76 512 // Generate a strip of buttons, out of buttons.
Chris@76 513 function template_button_strip($button_strip, $direction = 'top', $force_reset = false, $custom_td = '')
Chris@76 514 {
Chris@76 515 global $settings, $buttons, $context, $txt, $scripturl;
Chris@76 516
Chris@76 517 if (empty($button_strip))
Chris@76 518 return '';
Chris@76 519
Chris@76 520 // Create the buttons...
Chris@76 521 foreach ($button_strip as $key => $value)
Chris@76 522 {
Chris@76 523 if (isset($value['test']) && empty($context[$value['test']]))
Chris@76 524 {
Chris@76 525 unset($button_strip[$key]);
Chris@76 526 continue;
Chris@76 527 }
Chris@76 528 elseif (!isset($buttons[$key]) || $force_reset)
Chris@76 529 $buttons[$key] = '<a href="' . $value['url'] . '" ' .( isset($value['custom']) ? $value['custom'] : '') . '>' . ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . ($value['lang'] ? $context['user']['language'] . '/' : '') . $value['image'] . '" alt="' . $txt[$value['text']] . '" border="0" />' : $txt[$value['text']]) . '</a>';
Chris@76 530
Chris@76 531 $button_strip[$key] = $buttons[$key];
Chris@76 532 }
Chris@76 533
Chris@76 534 echo '
Chris@76 535 <td ', $custom_td, '>', implode($context['menu_separator'], $button_strip) , '</td>';
Chris@76 536 }
Chris@76 537
Chris@76 538 ?>