Issues (1027)

Themes/default/index.template.php (3 issues)

1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines http://www.simplemachines.org
7
 * @copyright 2019 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 RC2
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
	https://www.simplemachines.org/
36
*/
37
38
/**
39
 * Initialize the template... mainly little settings.
40
 */
41
function template_init()
42
{
43
	global $settings, $txt;
44
45
	/* $context, $options and $txt may be available for use, but may not be fully populated yet. */
46
47
	// The version this template/theme is for. This should probably be the version of SMF it was created for.
48
	$settings['theme_version'] = '2.1';
49
50
	// Set the following variable to true if this theme requires the optional theme strings file to be loaded.
51
	$settings['require_theme_strings'] = false;
52
53
	// Set the following variable to true if this theme wants to display the avatar of the user that posted the last and the first post on the message index and recent pages.
54
	$settings['avatars_on_indexes'] = false;
55
56
	// Set the following variable to true if this theme wants to display the avatar of the user that posted the last post on the board index.
57
	$settings['avatars_on_boardIndex'] = false;
58
59
	// This defines the formatting for the page indexes used throughout the forum.
60
	$settings['page_index'] = array(
61
		'extra_before' => '<span class="pages">' . $txt['pages'] . '</span>',
62
		'previous_page' => '<span class="main_icons previous_page"></span>',
63
		'current_page' => '<span class="current_page">%1$d</span> ',
64
		'page' => '<a class="nav_page" href="{URL}">%2$s</a> ',
65
		'expand_pages' => '<span class="expand_pages" onclick="expandPages(this, {LINK}, {FIRST_PAGE}, {LAST_PAGE}, {PER_PAGE});"> ... </span>',
66
		'next_page' => '<span class="main_icons next_page"></span>',
67
		'extra_after' => '',
68
	);
69
70
	// Allow css/js files to be disabled for this specific theme.
71
	// Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference.
72
	if (!isset($settings['disable_files']))
73
		$settings['disable_files'] = array();
74
}
75
76
/**
77
 * The main sub template above the content.
78
 */
79
function template_html_above()
80
{
81
	global $context, $scripturl, $txt, $modSettings;
82
83
	// Show right to left, the language code, and the character set for ease of translating.
84
	echo '<!DOCTYPE html>
85
<html', $context['right_to_left'] ? ' dir="rtl"' : '', !empty($txt['lang_locale']) ? ' lang="' . str_replace("_", "-", substr($txt['lang_locale'], 0, strcspn($txt['lang_locale'], "."))) . '"' : '', '>
86
<head>
87
	<meta charset="', $context['character_set'], '">';
88
89
	/*
90
		You don't need to manually load index.css, this will be set up for you.
91
		Note that RTL will also be loaded for you.
92
		To load other CSS and JS files you should use the functions
93
		loadCSSFile() and loadJavaScriptFile() respectively.
94
		This approach will let you take advantage of SMF's automatic CSS
95
		minimization and other benefits. You can, of course, manually add any
96
		other files you want after template_css() has been run.
97
98
	*	Short example:
99
			- CSS: loadCSSFile('filename.css', array('minimize' => true));
100
			- JS:  loadJavaScriptFile('filename.css', array('minimize' => true));
101
			You can also read more detailed usages of the parameters for these 
102
			functions on the SMF wiki.
103
104
	*	Themes:
105
			The most efficient way of writing multi themes is to use a master
106
			index.css plus variant.css files. If you've set them up properly
107
			(through $settings['theme_variants']), the variant files will be loaded
108
			for you automatically.
109
110
	*	MODs:
111
			If you want to load CSS or JS files in here, the best way is to use the
112
			'integrate_load_theme' hook for adding multiple files, or using
113
			'integrate_pre_css_output', 'integrate_pre_javascript_output' for a single file.
114
	*/
115
116
	// load in any css from mods or themes so they can overwrite if wanted
117
	template_css();
118
119
	// load in any javascript files from mods and themes
120
	template_javascript();
121
122
	echo '
123
	<title>', $context['page_title_html_safe'], '</title>
124
	<meta name="viewport" content="width=device-width, initial-scale=1">';
125
126
	// Content related meta tags, like description, keywords, Open Graph stuff, etc...
127
	foreach ($context['meta_tags'] as $meta_tag)
128
	{
129
		echo '
130
	<meta';
131
132
		foreach ($meta_tag as $meta_key => $meta_value)
133
			echo ' ', $meta_key, '="', $meta_value, '"';
134
135
		echo '>';
136
	}
137
138
	/*	What is your Lollipop's color?
139
		Theme Authors, you can change the color here to make sure your theme's main color gets visible on tab */
140
	echo '
141
	<meta name="theme-color" content="#557EA0">';
142
143
	// Please don't index these Mr Robot.
144
	if (!empty($context['robot_no_index']))
145
		echo '
146
	<meta name="robots" content="noindex">';
147
148
	// Present a canonical url for search engines to prevent duplicate content in their indices.
149
	if (!empty($context['canonical_url']))
150
		echo '
151
	<link rel="canonical" href="', $context['canonical_url'], '">';
152
153
	// Show all the relative links, such as help, search, contents, and the like.
154
	echo '
155
	<link rel="help" href="', $scripturl, '?action=help">
156
	<link rel="contents" href="', $scripturl, '">', ($context['allow_search'] ? '
157
	<link rel="search" href="' . $scripturl . '?action=search">' : '');
158
159
	// If RSS feeds are enabled, advertise the presence of one.
160
	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
161
		echo '
162
	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?action=.xml;type=rss2', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">
163
	<link rel="alternate" type="application/atom+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?action=.xml;type=atom', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">';
164
165
	// If we're viewing a topic, these should be the previous and next topics, respectively.
166
	if (!empty($context['links']['next']))
167
		echo '
168
	<link rel="next" href="', $context['links']['next'], '">';
169
170
	if (!empty($context['links']['prev']))
171
		echo '
172
	<link rel="prev" href="', $context['links']['prev'], '">';
173
174
	// If we're in a board, or a topic for that matter, the index will be the board's index.
175
	if (!empty($context['current_board']))
176
		echo '
177
	<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">';
178
179
	// Output any remaining HTML headers. (from mods, maybe?)
180
	echo $context['html_headers'];
181
182
	echo '
183
</head>
184
<body id="', $context['browser_body_id'], '" class="action_', !empty($context['current_action']) ? $context['current_action'] : (!empty($context['current_board']) ?
185
		'messageindex' : (!empty($context['current_topic']) ? 'display' : 'home')), !empty($context['current_board']) ? ' board_' . $context['current_board'] : '', '">
186
<div id="footerfix">';
187
}
188
189
/**
190
 * The upper part of the main template layer. This is the stuff that shows above the main forum content.
191
 */
192
function template_body_above()
193
{
194
	global $context, $settings, $scripturl, $txt, $modSettings, $maintenance;
195
196
	// Wrapper div now echoes permanently for better layout options. h1 a is now target for "Go up" links.
197
	echo '
198
	<div id="top_section">
199
		<div class="inner_wrap">';
200
201
	// If the user is logged in, display some things that might be useful.
202
	if ($context['user']['is_logged'])
203
	{
204
		// Firstly, the user's menu
205
		echo '
206
			<ul class="floatleft" id="top_info">
207
				<li>
208
					<a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">';
209
210
		if (!empty($context['user']['avatar']))
211
			echo $context['user']['avatar']['image'];
212
213
		echo $context['user']['name'], '</a>
214
					<div id="profile_menu" class="top_menu"></div>
215
				</li>';
216
217
		// Secondly, PMs if we're doing them
218
		if ($context['allow_pm'])
219
			echo '
220
				<li>
221
					<a href="', $scripturl, '?action=pm"', !empty($context['self_pm']) ? ' class="active"' : '', ' id="pm_menu_top">', $txt['pm_short'], !empty($context['user']['unread_messages']) ? ' <span class="amt">' . $context['user']['unread_messages'] . '</span>' : '', '</a>
222
					<div id="pm_menu" class="top_menu scrollable"></div>
223
				</li>';
224
225
		// Thirdly, alerts
226
		echo '
227
				<li>
228
					<a href="', $scripturl, '?action=profile;area=showalerts;u=', $context['user']['id'], '"', !empty($context['self_alerts']) ? ' class="active"' : '', ' id="alerts_menu_top">', $txt['alerts'], !empty($context['user']['alerts']) ? ' <span class="amt">' . $context['user']['alerts'] . '</span>' : '', '</a>
229
					<div id="alerts_menu" class="top_menu scrollable"></div>
230
				</li>';
231
232
		// And now we're done.
233
		echo '
234
			</ul>';
235
	}
236
	// Otherwise they're a guest. Ask them to either register or login.
237
	elseif (empty($maintenance))
238
		echo '
239
			<ul class="floatleft welcome">
240
				<li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li>
241
			</ul>';
242
	else
243
		// In maintenance mode, only login is allowed and don't show OverlayDiv
244
		echo '
245
			<ul class="floatleft welcome">
246
				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl . '?action=login', 'return true;'), '</li>
247
			</ul>';
248
249
	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
250
	{
251
		echo '
252
			<form id="languages_form" method="get" class="floatright">
253
				<select id="language_select" name="language" onchange="this.form.submit()">';
254
255
		foreach ($context['languages'] as $language)
256
			echo '
257
					<option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>';
258
259
		echo '
260
				</select>
261
				<noscript>
262
					<input type="submit" value="', $txt['quick_mod_go'], '">
263
				</noscript>
264
			</form>';
265
	}
266
267
	if ($context['allow_search'])
268
	{
269
		echo '
270
			<form id="search_form" class="floatright" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
271
				<input type="search" name="search" value="">&nbsp;';
272
273
		// Using the quick search dropdown?
274
		$selected = !empty($context['current_topic']) ? 'current_topic' : (!empty($context['current_board']) ? 'current_board' : 'all');
275
276
		echo '
277
				<select name="search_selection">
278
					<option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>';
279
280
		// Can't limit it to a specific topic if we are not in one
281
		if (!empty($context['current_topic']))
282
			echo '
283
					<option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>';
284
285
		// Can't limit it to a specific board if we are not in one
286
		if (!empty($context['current_board']))
287
			echo '
288
					<option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisboard'], '</option>';
289
290
		// Can't search for members if we can't see the memberlist
291
		if (!empty($context['allow_memberlist']))
292
			echo '
293
					<option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>';
294
295
		echo '
296
				</select>';
297
298
		// Search within current topic?
299
		if (!empty($context['current_topic']))
300
			echo '
301
				<input type="hidden" name="sd_topic" value="', $context['current_topic'], '">';
302
303
		// If we're on a certain board, limit it to this board ;).
304
		elseif (!empty($context['current_board']))
305
			echo '
306
				<input type="hidden" name="sd_brd" value="', $context['current_board'], '">';
307
308
		echo '
309
				<input type="submit" name="search2" value="', $txt['search'], '" class="button">
310
				<input type="hidden" name="advanced" value="0">
311
			</form>';
312
	}
313
314
	echo '
315
		</div><!-- .inner_wrap -->
316
	</div><!-- #top_section -->';
317
318
	echo '
319
	<div id="header">
320
		<h1 class="forumtitle">
321
			<a id="top" href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? $context['forum_name_html_safe'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name_html_safe'] . '">', '</a>
322
		</h1>';
323
324
	echo '
325
		', empty($settings['site_slogan']) ? '<img id="smflogo" src="' . $settings['images_url'] . '/smflogo.svg" alt="Simple Machines Forum" title="Simple Machines Forum">' : '<div id="siteslogan">' . $settings['site_slogan'] . '</div>', '';
326
327
	echo '
328
	</div>
329
	<div id="wrapper">
330
		<div id="upper_section">
331
			<div id="inner_section">
332
				<div id="inner_wrap">
333
					<div class="user">
334
						', $context['current_time'], '
335
					</div>';
336
337
	// Show a random news item? (or you could pick one from news_lines...)
338
	if (!empty($settings['enable_news']) && !empty($context['random_news_line']))
339
		echo '
340
					<div class="news">
341
						<h2>', $txt['news'], ': </h2>
342
						<p>', $context['random_news_line'], '</p>
343
					</div>';
344
345
	echo '
346
					<hr class="clear">
347
				</div>';
348
349
	// Show the menu here, according to the menu sub template, followed by the navigation tree.
350
	// Load mobile menu here
351
	echo '
352
				<a class="menu_icon mobile_user_menu"></a>
353
				<div id="main_menu">
354
					<div id="mobile_user_menu" class="popup_container">
355
						<div class="popup_window description">
356
							<div class="popup_heading">', $txt['mobile_user_menu'], '
357
								<a href="javascript:void(0);" class="main_icons hide_popup"></a>
358
							</div>
359
							', template_menu(), '
0 ignored issues
show
Are you sure the usage of template_menu() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
360
						</div>
361
					</div>
362
				</div>';
363
364
	theme_linktree();
365
366
	echo '
367
			</div><!-- #inner_section -->
368
		</div><!-- #upper_section -->';
369
370
	// The main content should go here.
371
	echo '
372
		<div id="content_section">
373
			<div id="main_content_section">';
374
}
375
376
/**
377
 * The stuff shown immediately below the main content, including the footer
378
 */
379
function template_body_below()
380
{
381
	global $context, $txt, $scripturl, $modSettings;
382
383
	echo '
384
			</div><!-- #main_content_section -->
385
		</div><!-- #content_section -->
386
	</div><!-- #wrapper -->
387
</div><!-- #footerfix -->';
388
389
	// Show the footer with copyright, terms and help links.
390
	echo '
391
	<div id="footer">
392
		<div class="inner_wrap">';
393
394
	// There is now a global "Go to top" link at the right.
395
	echo '
396
		<ul>
397
			<li class="floatright"><a href="', $scripturl, '?action=help">', $txt['help'], '</a> ', (!empty($modSettings['requireAgreement'])) ? '| <a href="' . $scripturl . '?action=help;sa=rules">' . $txt['terms_and_rules'] . '</a>' : '', ' | <a href="#top_section">', $txt['go_up'], ' &#9650;</a></li>
398
			<li class="copyright">', theme_copyright(), '</li>
0 ignored issues
show
Are you sure the usage of theme_copyright() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
399
		</ul>';
400
401
	// Show the load time?
402
	if ($context['show_load_time'])
403
		echo '
404
		<p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>';
405
406
	echo '
407
		</div>
408
	</div><!-- #footer -->';
409
410
}
411
412
/**
413
 * This shows any deferred JavaScript and closes out the HTML
414
 */
415
function template_html_below()
416
{
417
	// Load in any javascipt that could be deferred to the end of the page
418
	template_javascript(true);
419
420
	echo '
421
</body>
422
</html>';
423
}
424
425
/**
426
 * Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
427
 *
428
 * @param bool $force_show Whether to force showing it even if settings say otherwise
429
 */
430
function theme_linktree($force_show = false)
431
{
432
	global $context, $shown_linktree, $scripturl, $txt;
433
434
	// If linktree is empty, just return - also allow an override.
435
	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
436
		return;
437
	echo '
438
				<div class="navigate_section">
439
					<ul>';
440
441
	if ($context['user']['is_logged'])
442
		echo '
443
						<li class="unread_links">
444
							<a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a>
445
							<a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a>
446
						</li>';
447
448
	// Each tree item has a URL and name. Some may have extra_before and extra_after.
449
	foreach ($context['linktree'] as $link_num => $tree)
450
	{
451
		echo '
452
						<li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';
453
454
		// Don't show a separator for the first one.
455
		// Better here. Always points to the next level when the linktree breaks to a second line.
456
		// Picked a better looking HTML entity, and added support for RTL plus a span for styling.
457
		if ($link_num != 0)
458
			echo '
459
							<span class="dividers">', $context['right_to_left'] ? ' &#9668; ' : ' &#9658; ', '</span>';
460
461
		// Show something before the link?
462
		if (isset($tree['extra_before']))
463
			echo $tree['extra_before'], ' ';
464
465
		// Show the link, including a URL if it should have one.
466
		if (isset($tree['url']))
467
			echo '
468
							<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>';
469
		else
470
			echo '
471
							<span>' . $tree['name'] . '</span>';
472
473
		// Show something after the link...?
474
		if (isset($tree['extra_after']))
475
			echo ' ', $tree['extra_after'];
476
477
		echo '
478
						</li>';
479
	}
480
481
	echo '
482
					</ul>
483
				</div><!-- .navigate_section -->';
484
485
	$shown_linktree = true;
486
}
487
488
/**
489
 * Show the menu up top. Something like [home] [help] [profile] [logout]...
490
 */
491
function template_menu()
492
{
493
	global $context;
494
495
	echo '
496
					<ul class="dropmenu menu_nav">';
497
498
	// Note: Menu markup has been cleaned up to remove unnecessary spans and classes.
499
	foreach ($context['menu_buttons'] as $act => $button)
500
	{
501
		echo '
502
						<li class="button_', $act, '', !empty($button['sub_buttons']) ? ' subsections"' : '"', '>
503
							<a', $button['active_button'] ? ' class="active"' : '', ' href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
504
								', $button['icon'], '<span class="textmenu">', $button['title'], !empty($button['amt']) ? ' <span class="amt">' . $button['amt'] . '</span>' : '', '</span>
505
							</a>';
506
507
		// 2nd level menus
508
		if (!empty($button['sub_buttons']))
509
		{
510
			echo '
511
							<ul>';
512
513
			foreach ($button['sub_buttons'] as $childbutton)
514
			{
515
				echo '
516
								<li', !empty($childbutton['sub_buttons']) ? ' class="subsections"' : '', '>
517
									<a href="', $childbutton['href'], '"', isset($childbutton['target']) ? ' target="' . $childbutton['target'] . '"' : '', '>
518
										', $childbutton['title'], !empty($childbutton['amt']) ? ' <span class="amt">' . $childbutton['amt'] . '</span>' : '', '
519
									</a>';
520
				// 3rd level menus :)
521
				if (!empty($childbutton['sub_buttons']))
522
				{
523
					echo '
524
									<ul>';
525
526
					foreach ($childbutton['sub_buttons'] as $grandchildbutton)
527
						echo '
528
										<li>
529
											<a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
530
												', $grandchildbutton['title'], !empty($grandchildbutton['amt']) ? ' <span class="amt">' . $grandchildbutton['amt'] . '</span>' : '', '
531
											</a>
532
										</li>';
533
534
					echo '
535
									</ul>';
536
				}
537
538
				echo '
539
								</li>';
540
			}
541
			echo '
542
							</ul>';
543
		}
544
		echo '
545
						</li>';
546
	}
547
548
	echo '
549
					</ul><!-- .menu_nav -->';
550
}
551
552
/**
553
 * Generate a strip of buttons.
554
 *
555
 * @param array $button_strip An array with info for displaying the strip
556
 * @param string $direction The direction
557
 * @param array $strip_options Options for the button strip
558
 */
559
function template_button_strip($button_strip, $direction = '', $strip_options = array())
560
{
561
	global $context, $txt;
562
563
	if (!is_array($strip_options))
0 ignored issues
show
The condition is_array($strip_options) is always true.
Loading history...
564
		$strip_options = array();
565
566
	// Create the buttons...
567
	$buttons = array();
568
	foreach ($button_strip as $key => $value)
569
	{
570
		// As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!)
571
		if (!isset($value['test']) || !empty($context[$value['test']]))
572
		{
573
			if (!isset($value['id']))
574
				$value['id'] = $key;
575
576
			$button = '
577
				<a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>'.(!empty($value['icon']) ? '<span class="main_icons '.$value['icon'].'"></span>' : '').'' . $txt[$value['text']] . '</a>';
578
579
			if (!empty($value['sub_buttons']))
580
			{
581
				$button .= '
582
					<div class="top_menu dropmenu ' . $key . '_dropdown">
583
						<div class="viewport">
584
							<div class="overview">';
585
				foreach ($value['sub_buttons'] as $element)
586
				{
587
					if (isset($element['test']) && empty($context[$element['test']]))
588
						continue;
589
590
					$button .= '
591
								<a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>';
592
					if (isset($txt[$element['text'] . '_desc']))
593
						$button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>';
594
					$button .= '</a>';
595
				}
596
				$button .= '
597
							</div><!-- .overview -->
598
						</div><!-- .viewport -->
599
					</div><!-- .top_menu -->';
600
			}
601
602
			$buttons[] = $button;
603
		}
604
	}
605
606
	// No buttons? No button strip either.
607
	if (empty($buttons))
608
		return;
609
610
	echo '
611
		<div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '>
612
			', implode('', $buttons), '
613
		</div>';
614
}
615
616
/**
617
 * Generate a list of quickbuttons.
618
 *
619
 * @param array $list_items An array with info for displaying the strip
620
 * @param string $list_id unique list id, used for integration hooks
621
 */
622
function template_quickbuttons($list_items, $list_id = null, $output_method = 'echo')
623
{
624
	global $txt;
625
626
	// Enable manipulation with hooks
627
	if(!empty($list_id))
628
		call_integration_hook('integrate_' . $list_id . '_quickbuttons', array(&$list_items));
629
630
	// Make sure the list has at least one shown item
631
	foreach ($list_items as $key => $li)
632
	{
633
		// Is there a sublist, and does it have any shown items
634
		if ($key == 'more')
635
		{
636
			foreach ($li as $subkey => $subli)
637
				if (isset($subli['show']) && !$subli['show'])
638
					unset($list_items[$key][$subkey]);
639
640
			if (empty($list_items[$key]))
641
				unset($list_items[$key]);
642
		}
643
		// A normal list item
644
		elseif (isset($li['show']) && !$li['show'])
645
			unset($list_items[$key]);
646
	}
647
648
	// Now check if there are any items left
649
	if (empty($list_items))
650
		return;
651
652
	// Print the quickbuttons
653
	$output = '
654
		<ul' . (!empty($list_id) ? ' id="quickbuttons_'.$list_id.'"' : '') . ' class="quickbuttons">';
655
656
	// This is used for a list item or a sublist item
657
	$list_item_format = function($li)
658
	{
659
		$html = '
660
			<li' . (!empty($li['class']) ? ' class="'.$li['class'].'"' : '') . (!empty($li['id']) ? ' id="'.$li['id'].'"' : '') . (!empty($li['custom']) ? $li['custom'] : '') . '>';
661
662
		if(isset($li['content']))
663
			$html .= $li['content'];
664
		else
665
			$html .= '
666
				<a' . (!empty($li['href']) ? ' href="'.$li['href'].'"' : '') . (!empty($li['javascript']) ? $li['javascript'] : '') . '>
667
					' . (!empty($li['icon']) ? '<span class="main_icons '.$li['icon'].'"></span>' : '') . (!empty($li['label']) ? $li['label'] : '') . '
668
				</a>';
669
670
		$html .= '
671
			</li>';
672
673
		return $html;
674
	};
675
676
	foreach ($list_items as $key => $li)
677
	{
678
		// Handle the sublist
679
		if($key == 'more')
680
		{
681
			$output .= '
682
			<li class="post_options">' . $txt['post_options'] . '
683
				<ul>';
684
685
			foreach ($li as $subli)
686
				$output .= $list_item_format($subli);
687
688
			$output .= '
689
				</ul>
690
			</li>';
691
		}
692
		// Ordinary list item
693
		else
694
			$output .= $list_item_format($li);
695
	}
696
697
	$output .= '
698
		</ul><!-- .quickbuttons -->';
699
700
	// There are a few spots where the result needs to be returned
701
	if($output_method == 'echo')
702
		echo $output;
703
	else
704
		return $output;
705
}
706
707
/**
708
 * The upper part of the maintenance warning box
709
 */
710
function template_maint_warning_above()
711
{
712
	global $txt, $context, $scripturl;
713
714
	echo '
715
	<div class="errorbox" id="errors">
716
		<dl>
717
			<dt>
718
				<strong id="error_serious">', $txt['forum_in_maintenance'], '</strong>
719
			</dt>
720
			<dd class="error" id="error_list">
721
				', sprintf($txt['maintenance_page'], $scripturl . '?action=admin;area=serversettings;' . $context['session_var'] . '=' . $context['session_id']), '
722
			</dd>
723
		</dl>
724
	</div>';
725
}
726
727
/**
728
 * The lower part of the maintenance warning box.
729
 */
730
function template_maint_warning_below()
731
{
732
733
}
734
735
?>