Skip to content
Newer
Older
100644 385 lines (316 sloc) 15.9 KB
ff90417 @norv Committing the Classic theme files
norv authored
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 RC5';
57
58 /* Set a setting that tells the theme that it can render the tabs. */
59 $settings['use_tabs'] = false;
60
61 /* Use plain buttons - as opposed to text buttons? */
62 $settings['use_buttons'] = false;
63
64 /* Show sticky and lock status separate from topic icons? */
65 $settings['separate_sticky_lock'] = false;
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"' : '', '><head>
85 <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
86 <meta name="description" content="', $context['page_title_html_safe'], '" />
87 <meta name="keywords" content="', $context['meta_keywords'], '" />
88 <title>', $context['page_title_html_safe'], '</title>
89 <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index.css?rc5" />
90 <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/print.css?rc5" media="print" />';
91
92 // Please don't index these Mr Robot.
93 if (!empty($context['robot_no_index']))
94 echo '
95 <meta name="robots" content="noindex" />';
96
97 // Present a canonical url for search engines to prevent duplicate content in their indices.
98 if (!empty($context['canonical_url']))
99 echo '
100 <link rel="canonical" href="', $context['canonical_url'], '" />';
101
102 // Show all the relative links, such as help, search, contents, and the like.
103 echo '
104 <link rel="help" href="', $scripturl, '?action=help" />
105 <link rel="search" href="' . $scripturl . '?action=search" />
106 <link rel="contents" href="', $scripturl, '" />';
107
108 // If RSS feeds are enabled, advertise the presence of one.
109 if (!empty($modSettings['xmlnews_enable']))
110 echo '
111 <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?type=rss;action=.xml" />';
112
113 // If we're viewing a topic, these should be the previous and next topics, respectively.
114 if (!empty($context['current_topic']))
115 echo '
116 <link rel="prev" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=prev" />
117 <link rel="next" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=next" />';
118
119 // If we're in a board, or a topic for that matter, the index will be the board's index.
120 if (!empty($context['current_board']))
121 echo '
122 <link rel="index" href="' . $scripturl . '?board=' . $context['current_board'] . '.0" />';
123
124 echo '
125 <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?rc2"></script>
126 <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/theme.js?rc2"></script>
127 <script type="text/javascript"><!-- // --><![CDATA[
128 var smf_theme_url = "', $settings['theme_url'], '";
129 var smf_default_theme_url = "', $settings['default_theme_url'], '";
130 var smf_images_url = "', $settings['images_url'], '";
131 var smf_scripturl = "', $scripturl, '";
132 var smf_iso_case_folding = ', $context['server']['iso_case_folding'] ? 'true' : 'false', ';
133 var smf_charset = "', $context['character_set'], '";', $context['show_pm_popup'] ? '
134 var fPmPopup = function ()
135 {
136 if (confirm("' . $txt['show_personal_messages'] . '"))
137 window.open(smf_prepareScriptUrl(smf_scripturl) + "action=pm");
138 }
139 addLoadEvent(fPmPopup);' : '', '
140 var ajax_notification_text = "', $txt['ajax_in_progress'], '";
141 var ajax_notification_cancel_text = "', $txt['modify_cancel'], '";
142 // ]]></script>';
143
144 // Output any remaining HTML headers. (from mods, maybe?)
145 echo $context['html_headers'];
146
147 echo '
148 </head>
149 <body>';
150 }
151
152 function template_body_above()
153 {
154 global $context, $settings, $options, $scripturl, $txt, $modSettings;
155
156 echo !empty($settings['forum_width']) ? '
157 <div id="wrapper" style="width: ' . $settings['forum_width'] . '">' : '', '
158 <table cellspacing="0" cellpadding="0" border="0" align="center" width="95%" class="tborder">
159 <tr class="white">
160 <td valign="middle" align="left"><img src="', !empty($settings['header_logo_url']) ? $settings['header_logo_url'] : $settings['images_url'] . '/smflogo.gif', '" alt="" /></td>
161 <td valign="middle">';
162
163 // If the user is logged in, display stuff like their name, new messages, etc.
164 if ($context['user']['is_logged'])
165 {
166 echo '
167 ', $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', $context['allow_pm'] ? ', ' . $txt['msg_alert_you_have'] . ' <a href="' . $scripturl . '?action=pm">' . $context['user']['messages'] . ' ' . ($context['user']['messages'] != 1 ? $txt['msg_alert_messages'] : $txt['message_lowercase']) . '</a>' . $txt['newmessages4'] . ' ' . $context['user']['unread_messages'] . ' ' . ($context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1']) : '', '.';
168
169 // Are there any members waiting for approval?
170 if (!empty($context['unapproved_members']))
171 echo '<br />
172 ', $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'];
173
174 // Is the forum in maintenance mode?
175 if ($context['in_maintenance'] && $context['user']['is_admin'])
176 echo '<br />
177 <strong>', $txt['maintain_mode_on'], '</strong>';
178
179 if (!empty($context['open_mod_reports']) && $context['show_open_reports'])
180 echo '<br />
181 <a href="', $scripturl, '?action=moderate;area=reports">', sprintf($txt['mod_reports_waiting'], $context['open_mod_reports']), '</a>';
182 }
183 // Otherwise they're a guest - so politely ask them to register or login.
184 else
185 echo '
186 ', sprintf($txt['welcome_guest'], $txt['guest_title']);
187
188 echo '
189 <br />', $context['current_time'], '
190 </td>
191 </tr>';
192 if (!empty($settings['site_slogan']))
193 echo'
194 <tr class="windowbg2">
195 <td valign="middle" align="center" colspan="2" height="24" class="tborder sloganarea">
196 ' . $settings['site_slogan'] . '
197 </td>
198 </tr>';
199
200 echo'
201 <tr class="windowbg2">
202 <td colspan="2" class="tborder menuarea">';
203
204 // Show the menu here, according to the menu sub template.
205 template_menu();
206
207 echo '
208 </td>
209 </tr>';
210
211 // Show a random news item? (or you could pick one from news_lines...)
212 if (!empty($settings['enable_news']))
213 echo '
214 <tr class="windowbg2">
215 <td colspan="2" height="24" class="tborder newsarea">
216 <strong>', $txt['news'], ':</strong> ', $context['random_news_line'], '
217 </td>
218 </tr>';
219
220 echo '
221 </table>
222
223 <br />
224 <table cellspacing="0" cellpadding="10" border="0" align="center" width="95%" class="tborder">
225 <tr><td valign="top" class="white">';
226
227 // Show the navigation tree.
228 theme_linktree();
229 }
230
231 function template_body_below()
232 {
233 global $context, $settings, $options, $scripturl, $txt;
234
235 echo '
236 </td></tr>
237 </table>';
238
239 // Show a vB style login for quick login?
240 if ($context['show_quick_login'])
241 {
242 echo '
243 <table cellspacing="0" cellpadding="0" border="0" align="center" width="95%">
244 <tr><td nowrap="nowrap" align="right">
245 <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
246
247 <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '><br />
248 <input type="text" name="user" size="7" class="input_text" />
249 <input type="password" name="passwrd" size="7" class="input_password" />
250 <select name="cookielength">
251 <option value="60">', $txt['one_hour'], '</option>
252 <option value="1440">', $txt['one_day'], '</option>
253 <option value="10080">', $txt['one_week'], '</option>
254 <option value="43200">', $txt['one_month'], '</option>
255 <option value="-1" selected="selected">', $txt['forever'], '</option>
256 </select>
257 <input type="submit" value="', $txt['login'], '" class="button_submit" /><br />
258 ', $txt['quick_login_dec'], '
259 <input type="hidden" name="hash_passwrd" value="" />
260 </form>
261 </td></tr>
262 </table>';
263 }
264
265 // Don't show a login box, just a break.
266 else
267 echo '
268 <br />';
269
270 // Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
271 echo '
272 <br />
273
274 <table cellspacing="0" cellpadding="3" border="0" align="center" width="95%" class="tborder">
275 <tr class="white">
276 <td width="28%" valign="middle" align="right">
277 <a href="http://www.mysql.com/" target="_blank" class="new_win"><img src="', $settings['images_url'], '/mysql.gif" alt="', $txt['powered_by_mysql'], '" width="88" height="31" border="0" /></a>
278 <a href="http://www.php.net/" target="_blank" class="new_win"><img src="', $settings['images_url'], '/php.gif" alt="', $txt['powered_by_php'], '" width="88" height="31" border="0" /></a>
279 </td>
280 <td width="44%" valign="middle" align="center">
281 ', theme_copyright(), '
282 </td>
283 <td width="28%" valign="middle" align="left">
284 <a href="http://validator.w3.org/check/referer" target="_blank" class="new_win"><img src="', $settings['images_url'], '/valid-xhtml10.gif" alt="', $txt['valid_xhtml'], '" width="88" height="31" border="0" /></a>
285 <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank" class="new_win"><img src="', $settings['images_url'], '/valid-css.gif" alt="', $txt['valid_css'], '" width="88" height="31" border="0" /></a>
286 </td>
287 </tr>
288 </table>';
289
290 // Show the load time?
291 if ($context['show_load_time'])
292 echo '
293 <div class="centertext smalltext">
294 ', $txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'], '
295 </div>', !empty($settings['forum_width']) ? '
296 </div>' : '';
297 }
298
299 function template_html_below()
300 {
301 global $context, $settings, $options, $scripturl, $txt, $modSettings;
302
303 // And then we're done!
304 echo '
305 </body>
306 </html>';
307 }
308
309 // Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
310 function theme_linktree()
311 {
312 global $context, $settings, $options;
313
314 // Folder style or inline? Inline has a smaller font.
315 echo '<span class="nav"', $settings['linktree_inline'] ? ' class="fontsmall"' : '', '>';
316
317 // Each tree item has a URL and name. Some may have extra_before and extra_after.
318 foreach ($context['linktree'] as $link_num => $tree)
319 {
320 // Show the | | |-[] Folders.
321 if (!$settings['linktree_inline'])
322 {
323 if ($link_num > 0)
324 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" />';
325 echo '<img src="' . $settings['images_url'] . '/icons/folder_open.gif" alt="+" border="0" />&nbsp; ';
326 }
327
328 // Show something before the link?
329 if (isset($tree['extra_before']))
330 echo $tree['extra_before'];
331
332 // Show the link, including a URL if it should have one.
333 echo '<strong>', $settings['linktree_link'] && isset($tree['url']) ? '<a href="' . $tree['url'] . '" class="nav">' . $tree['name'] . '</a>' : $tree['name'], '</strong>';
334
335 // Show something after the link...?
336 if (isset($tree['extra_after']))
337 echo $tree['extra_after'];
338
339 // Don't show a separator for the last one.
340 if ($link_num != count($context['linktree']) - 1)
341 echo $settings['linktree_inline'] ? ' &nbsp;|&nbsp; ' : '<br />';
342 }
343
344 echo '</span>';
345 }
346
347 // Show the menu up top. Something like [home] [help] [profile] [logout]...
348 function template_menu()
349 {
350 global $context, $settings, $options, $scripturl, $txt;
351
352 // We aren't showing all the buttons in this theme.
353 $hide_buttons = array('pm', 'mlist');
354
355 foreach ($context['menu_buttons'] as $act => $button)
356 if (in_array($act, $hide_buttons))
357 continue;
358 else
359 echo '
360 <a href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>', $settings['use_image_buttons'] ? '<img src="' . $settings['lang_images_url'] . '/' . $act . '.gif" alt="' . $button['title'] . '" border="0" />' : $button['title'], '</a>', !empty($button['is_last']) ? '' : $context['menu_separator'];
361 }
362
363 // Generate a strip of buttons, out of buttons.
364 function template_button_strip($button_strip, $direction = 'top', $strip_options = array())
365 {
366 global $settings, $context, $txt, $scripturl;
367
368 // Compatibility.
369 if (!is_array($strip_options))
370 $strip_options = array('custom_td' => $strip_options);
371
372 // Create the buttons...
373 $buttons = array();
374 foreach ($button_strip as $key => $value)
375 if (!isset($value['test']) || !empty($context[$value['test']]))
376 $buttons[] = '<a href="' . $value['url'] . '"' . (isset($value['active']) ? ' class="active"' : '') . (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>';
377
378 if (empty($button_strip))
379 return '';
380
381 echo '
382 <div ', isset($strip_options['custom_td']) ? $strip_options['custom_td'] : '', '', (empty($buttons) ? ' class="displaynone"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"': ''), '>', implode($context['menu_separator'], $buttons) , '</div>';
383 }
384
385 ?>
Something went wrong with that request. Please try again.