Issues (1014)

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

1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines https://www.simplemachines.org
7
 * @copyright 2022 Simple Machines and individual contributors
8
 * @license https://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1.2
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
	// Set the following variable to true if this theme wants to display the login and register buttons in the main forum menu.
60
	$settings['login_main_menu'] = false;
61
62
	// This defines the formatting for the page indexes used throughout the forum.
63
	$settings['page_index'] = array(
64
		'extra_before' => '<span class="pages">' . $txt['pages'] . '</span>',
65
		'previous_page' => '<span class="main_icons previous_page"></span>',
66
		'current_page' => '<span class="current_page">%1$d</span> ',
67
		'page' => '<a class="nav_page" href="{URL}">%2$s</a> ',
68
		'expand_pages' => '<span class="expand_pages" onclick="expandPages(this, {LINK}, {FIRST_PAGE}, {LAST_PAGE}, {PER_PAGE});"> ... </span>',
69
		'next_page' => '<span class="main_icons next_page"></span>',
70
		'extra_after' => '',
71
	);
72
73
	// Allow css/js files to be disabled for this specific theme.
74
	// 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.
75
	if (!isset($settings['disable_files']))
76
		$settings['disable_files'] = array();
77
}
78
79
/**
80
 * The main sub template above the content.
81
 */
82
function template_html_above()
83
{
84
	global $context, $scripturl, $txt, $modSettings;
85
86
	// Show right to left, the language code, and the character set for ease of translating.
87
	echo '<!DOCTYPE html>
88
<html', $context['right_to_left'] ? ' dir="rtl"' : '', !empty($txt['lang_locale']) ? ' lang="' . str_replace("_", "-", substr($txt['lang_locale'], 0, strcspn($txt['lang_locale'], "."))) . '"' : '', '>
89
<head>
90
	<meta charset="', $context['character_set'], '">';
91
92
	/*
93
		You don't need to manually load index.css, this will be set up for you.
94
		Note that RTL will also be loaded for you.
95
		To load other CSS and JS files you should use the functions
96
		loadCSSFile() and loadJavaScriptFile() respectively.
97
		This approach will let you take advantage of SMF's automatic CSS
98
		minimization and other benefits. You can, of course, manually add any
99
		other files you want after template_css() has been run.
100
101
	*	Short example:
102
			- CSS: loadCSSFile('filename.css', array('minimize' => true));
103
			- JS:  loadJavaScriptFile('filename.js', array('minimize' => true));
104
			You can also read more detailed usages of the parameters for these
105
			functions on the SMF wiki.
106
107
	*	Themes:
108
			The most efficient way of writing multi themes is to use a master
109
			index.css plus variant.css files. If you've set them up properly
110
			(through $settings['theme_variants']), the variant files will be loaded
111
			for you automatically.
112
			Additionally, tweaking the CSS for the editor requires you to include
113
			a custom 'jquery.sceditor.theme.css' file in the css folder if you need it.
114
115
	*	MODs:
116
			If you want to load CSS or JS files in here, the best way is to use the
117
			'integrate_load_theme' hook for adding multiple files, or using
118
			'integrate_pre_css_output', 'integrate_pre_javascript_output' for a single file.
119
	*/
120
121
	// load in any css from mods or themes so they can overwrite if wanted
122
	template_css();
123
124
	// load in any javascript files from mods and themes
125
	template_javascript();
126
127
	echo '
128
	<title>', $context['page_title_html_safe'], '</title>
129
	<meta name="viewport" content="width=device-width, initial-scale=1">';
130
131
	// Content related meta tags, like description, keywords, Open Graph stuff, etc...
132
	foreach ($context['meta_tags'] as $meta_tag)
133
	{
134
		echo '
135
	<meta';
136
137
		foreach ($meta_tag as $meta_key => $meta_value)
138
			echo ' ', $meta_key, '="', $meta_value, '"';
139
140
		echo '>';
141
	}
142
143
	/*	What is your Lollipop's color?
144
		Theme Authors, you can change the color here to make sure your theme's main color gets visible on tab */
145
	echo '
146
	<meta name="theme-color" content="#557EA0">';
147
148
	// Please don't index these Mr Robot.
149
	if (!empty($context['robot_no_index']))
150
		echo '
151
	<meta name="robots" content="noindex">';
152
153
	// Present a canonical url for search engines to prevent duplicate content in their indices.
154
	if (!empty($context['canonical_url']))
155
		echo '
156
	<link rel="canonical" href="', $context['canonical_url'], '">';
157
158
	// Show all the relative links, such as help, search, contents, and the like.
159
	echo '
160
	<link rel="help" href="', $scripturl, '?action=help">
161
	<link rel="contents" href="', $scripturl, '">', ($context['allow_search'] ? '
162
	<link rel="search" href="' . $scripturl . '?action=search">' : '');
163
164
	// If RSS feeds are enabled, advertise the presence of one.
165
	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
166
		echo '
167
	<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'] : '', '">
168
	<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'] : '', '">';
169
170
	// If we're viewing a topic, these should be the previous and next topics, respectively.
171
	if (!empty($context['links']['next']))
172
		echo '
173
	<link rel="next" href="', $context['links']['next'], '">';
174
175
	if (!empty($context['links']['prev']))
176
		echo '
177
	<link rel="prev" href="', $context['links']['prev'], '">';
178
179
	// If we're in a board, or a topic for that matter, the index will be the board's index.
180
	if (!empty($context['current_board']))
181
		echo '
182
	<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">';
183
184
	// Output any remaining HTML headers. (from mods, maybe?)
185
	echo $context['html_headers'];
186
187
	echo '
188
</head>
189
<body id="', $context['browser_body_id'], '" class="action_', !empty($context['current_action']) ? $context['current_action'] : (!empty($context['current_board']) ?
190
		'messageindex' : (!empty($context['current_topic']) ? 'display' : 'home')), !empty($context['current_board']) ? ' board_' . $context['current_board'] : '', '">
191
<div id="footerfix">';
192
}
193
194
/**
195
 * The upper part of the main template layer. This is the stuff that shows above the main forum content.
196
 */
197
function template_body_above()
198
{
199
	global $context, $settings, $scripturl, $txt, $modSettings, $maintenance;
200
201
	// Wrapper div now echoes permanently for better layout options. h1 a is now target for "Go up" links.
202
	echo '
203
	<div id="top_section">
204
		<div class="inner_wrap">';
205
206
	// If the user is logged in, display some things that might be useful.
207
	if ($context['user']['is_logged'])
208
	{
209
		// Firstly, the user's menu
210
		echo '
211
			<ul class="floatleft" id="top_info">
212
				<li>
213
					<a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">';
214
215
		if (!empty($context['user']['avatar']))
216
			echo $context['user']['avatar']['image'];
217
218
		echo '<span class="textmenu">', $context['user']['name'], '</span></a>
219
					<div id="profile_menu" class="top_menu"></div>
220
				</li>';
221
222
		// Secondly, PMs if we're doing them
223
		if ($context['allow_pm'])
224
			echo '
225
				<li>
226
					<a href="', $scripturl, '?action=pm"', !empty($context['self_pm']) ? ' class="active"' : '', ' id="pm_menu_top">
227
						<span class="main_icons inbox"></span>
228
						<span class="textmenu">', $txt['pm_short'], '</span>', !empty($context['user']['unread_messages']) ? '
229
						<span class="amt">' . $context['user']['unread_messages'] . '</span>' : '', '
230
					</a>
231
					<div id="pm_menu" class="top_menu scrollable"></div>
232
				</li>';
233
234
		// Thirdly, alerts
235
		echo '
236
				<li>
237
					<a href="', $scripturl, '?action=profile;area=showalerts;u=', $context['user']['id'], '"', !empty($context['self_alerts']) ? ' class="active"' : '', ' id="alerts_menu_top">
238
						<span class="main_icons alerts"></span>
239
						<span class="textmenu">', $txt['alerts'], '</span>', !empty($context['user']['alerts']) ? '
240
						<span class="amt">' . $context['user']['alerts'] . '</span>' : '', '
241
					</a>
242
					<div id="alerts_menu" class="top_menu scrollable"></div>
243
				</li>';
244
245
		// A logout button for people without JavaScript.
246
		if (empty($settings['login_main_menu']))
247
			echo '
248
				<li id="nojs_logout">
249
					<a href="', $scripturl, '?action=logout;', $context['session_var'], '=', $context['session_id'], '">', $txt['logout'], '</a>
250
					<script>document.getElementById("nojs_logout").style.display = "none";</script>
251
				</li>';
252
253
		// And now we're done.
254
		echo '
255
			</ul>';
256
	}
257
	// Otherwise they're a guest. Ask them to either register or login.
258
	elseif (empty($maintenance))
259
	{
260
		// Some people like to do things the old-fashioned way.
261
		if (!empty($settings['login_main_menu']))
262
		{
263
			echo '
264
			<ul class="floatleft">
265
				<li class="welcome">', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ', \'login\');', $scripturl . '?action=signup'), '</li>
266
			</ul>';
267
		}
268
		else
269
		{
270
			echo '
271
			<ul class="floatleft" id="top_info">
272
				<li class="welcome">
273
					', sprintf($txt['welcome_to_forum'], $context['forum_name_html_safe']), '
274
				</li>
275
				<li class="button_login">
276
					<a href="', $scripturl, '?action=login" class="', $context['current_action'] == 'login' ? 'active' : 'open','" onclick="return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ', \'login\');">
277
						<span class="main_icons login"></span>
278
						<span class="textmenu">', $txt['login'], '</span>
279
					</a>
280
				</li>';
281
282
			if ($context['can_register'])
283
				echo '
284
				<li class="button_signup">
285
					<a href="', $scripturl, '?action=signup" class="', $context['current_action'] == 'signup' ? 'active' : 'open','">
286
						<span class="main_icons regcenter"></span>
287
						<span class="textmenu">', $txt['register'], '</span>
288
					</a>
289
				</li>';
290
291
			echo '
292
			</ul>';
293
		}
294
	}
295
	else
296
		// In maintenance mode, only login is allowed and don't show OverlayDiv
297
		echo '
298
			<ul class="floatleft welcome">
299
				<li>', sprintf($txt['welcome_guest'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return true;'), '</li>
300
			</ul>';
301
302
	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
303
	{
304
		echo '
305
			<form id="languages_form" method="get" class="floatright">
306
				<select id="language_select" name="language" onchange="this.form.submit()">';
307
308
		foreach ($context['languages'] as $language)
309
			echo '
310
					<option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>';
311
312
		echo '
313
				</select>
314
				<noscript>
315
					<input type="submit" value="', $txt['quick_mod_go'], '">
316
				</noscript>
317
			</form>';
318
	}
319
320
	if ($context['allow_search'])
321
	{
322
		echo '
323
			<form id="search_form" class="floatright" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
324
				<input type="search" name="search" value="">&nbsp;';
325
326
		// Using the quick search dropdown?
327
		$selected = !empty($context['current_topic']) ? 'current_topic' : (!empty($context['current_board']) ? 'current_board' : 'all');
328
329
		echo '
330
				<select name="search_selection">
331
					<option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>';
332
333
		// Can't limit it to a specific topic if we are not in one
334
		if (!empty($context['current_topic']))
335
			echo '
336
					<option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>';
337
338
		// Can't limit it to a specific board if we are not in one
339
		if (!empty($context['current_board']))
340
			echo '
341
					<option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisboard'], '</option>';
342
343
		// Can't search for members if we can't see the memberlist
344
		if (!empty($context['allow_memberlist']))
345
			echo '
346
					<option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>';
347
348
		echo '
349
				</select>';
350
351
		// Search within current topic?
352
		if (!empty($context['current_topic']))
353
			echo '
354
				<input type="hidden" name="sd_topic" value="', $context['current_topic'], '">';
355
356
		// If we're on a certain board, limit it to this board ;).
357
		elseif (!empty($context['current_board']))
358
			echo '
359
				<input type="hidden" name="sd_brd" value="', $context['current_board'], '">';
360
361
		echo '
362
				<input type="submit" name="search2" value="', $txt['search'], '" class="button">
363
				<input type="hidden" name="advanced" value="0">
364
			</form>';
365
	}
366
367
	echo '
368
		</div><!-- .inner_wrap -->
369
	</div><!-- #top_section -->';
370
371
	echo '
372
	<div id="header">
373
		<h1 class="forumtitle">
374
			<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>
375
		</h1>';
376
377
	echo '
378
		', 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>', '';
379
380
	echo '
381
	</div>
382
	<div id="wrapper">
383
		<div id="upper_section">
384
			<div id="inner_section">
385
				<div id="inner_wrap"', !$context['user']['is_logged'] ? ' class="hide_720"' : '', '>
386
					<div class="user">
387
						<time datetime="', smf_gmstrftime('%FT%TZ'), '">', $context['current_time'], '</time>';
388
389
	if ($context['user']['is_logged'])
390
		echo '
391
						<ul class="unread_links">
392
							<li>
393
								<a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a>
394
							</li>
395
							<li>
396
								<a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a>
397
							</li>
398
						</ul>';
399
400
	echo '
401
					</div>';
402
403
	// Show a random news item? (or you could pick one from news_lines...)
404
	if (!empty($settings['enable_news']) && !empty($context['random_news_line']))
405
		echo '
406
					<div class="news">
407
						<h2>', $txt['news'], ': </h2>
408
						<p>', $context['random_news_line'], '</p>
409
					</div>';
410
411
	echo '
412
				</div>';
413
414
	// Show the menu here, according to the menu sub template, followed by the navigation tree.
415
	// Load mobile menu here
416
	echo '
417
				<a class="mobile_user_menu">
418
					<span class="menu_icon"></span>
419
					<span class="text_menu">', $txt['mobile_user_menu'], '</span>
420
				</a>
421
				<div id="main_menu">
422
					<div id="mobile_user_menu" class="popup_container">
423
						<div class="popup_window description">
424
							<div class="popup_heading">', $txt['mobile_user_menu'], '
425
								<a href="javascript:void(0);" class="main_icons hide_popup"></a>
426
							</div>
427
							', 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...
428
						</div>
429
					</div>
430
				</div>';
431
432
	theme_linktree();
433
434
	echo '
435
			</div><!-- #inner_section -->
436
		</div><!-- #upper_section -->';
437
438
	// The main content should go here.
439
	echo '
440
		<div id="content_section">
441
			<div id="main_content_section">';
442
}
443
444
/**
445
 * The stuff shown immediately below the main content, including the footer
446
 */
447
function template_body_below()
448
{
449
	global $context, $txt, $scripturl, $modSettings;
450
451
	echo '
452
			</div><!-- #main_content_section -->
453
		</div><!-- #content_section -->
454
	</div><!-- #wrapper -->
455
</div><!-- #footerfix -->';
456
457
	// Show the footer with copyright, terms and help links.
458
	echo '
459
	<div id="footer">
460
		<div class="inner_wrap">';
461
462
	// There is now a global "Go to top" link at the right.
463
	echo '
464
		<ul>
465
			<li class="floatright"><a href="', $scripturl, '?action=help">', $txt['help'], '</a> ', (!empty($modSettings['requireAgreement'])) ? '| <a href="' . $scripturl . '?action=agreement">' . $txt['terms_and_rules'] . '</a>' : '', ' | <a href="#top_section">', $txt['go_up'], ' &#9650;</a></li>
466
			<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...
467
		</ul>';
468
469
	// Show the load time?
470
	if ($context['show_load_time'])
471
		echo '
472
		<p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>';
473
474
	echo '
475
		</div>
476
	</div><!-- #footer -->';
477
478
}
479
480
/**
481
 * This shows any deferred JavaScript and closes out the HTML
482
 */
483
function template_html_below()
484
{
485
	// Load in any javascipt that could be deferred to the end of the page
486
	template_javascript(true);
487
488
	echo '
489
</body>
490
</html>';
491
}
492
493
/**
494
 * Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
495
 *
496
 * @param bool $force_show Whether to force showing it even if settings say otherwise
497
 */
498
function theme_linktree($force_show = false)
499
{
500
	global $context, $shown_linktree, $scripturl, $txt;
501
502
	// If linktree is empty, just return - also allow an override.
503
	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
504
		return;
505
506
	echo '
507
				<div class="navigate_section">
508
					<ul>';
509
510
	// Each tree item has a URL and name. Some may have extra_before and extra_after.
511
	foreach ($context['linktree'] as $link_num => $tree)
512
	{
513
		echo '
514
						<li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';
515
516
		// Don't show a separator for the first one.
517
		// Better here. Always points to the next level when the linktree breaks to a second line.
518
		// Picked a better looking HTML entity, and added support for RTL plus a span for styling.
519
		if ($link_num != 0)
520
			echo '
521
							<span class="dividers">', $context['right_to_left'] ? ' &#9668; ' : ' &#9658; ', '</span>';
522
523
		// Show something before the link?
524
		if (isset($tree['extra_before']))
525
			echo $tree['extra_before'], ' ';
526
527
		// Show the link, including a URL if it should have one.
528
		if (isset($tree['url']))
529
			echo '
530
							<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>';
531
		else
532
			echo '
533
							<span>' . $tree['name'] . '</span>';
534
535
		// Show something after the link...?
536
		if (isset($tree['extra_after']))
537
			echo ' ', $tree['extra_after'];
538
539
		echo '
540
						</li>';
541
	}
542
543
	echo '
544
					</ul>
545
				</div><!-- .navigate_section -->';
546
547
	$shown_linktree = true;
548
}
549
550
/**
551
 * Show the menu up top. Something like [home] [help] [profile] [logout]...
552
 */
553
function template_menu()
554
{
555
	global $context;
556
557
	echo '
558
					<ul class="dropmenu menu_nav">';
559
560
	// Note: Menu markup has been cleaned up to remove unnecessary spans and classes.
561
	foreach ($context['menu_buttons'] as $act => $button)
562
	{
563
		echo '
564
						<li class="button_', $act, '', !empty($button['sub_buttons']) ? ' subsections"' : '"', '>
565
							<a', $button['active_button'] ? ' class="active"' : '', ' href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', isset($button['onclick']) ? ' onclick="' . $button['onclick'] . '"' : '', '>
566
								', $button['icon'], '<span class="textmenu">', $button['title'], !empty($button['amt']) ? ' <span class="amt">' . $button['amt'] . '</span>' : '', '</span>
567
							</a>';
568
569
		// 2nd level menus
570
		if (!empty($button['sub_buttons']))
571
		{
572
			echo '
573
							<ul>';
574
575
			foreach ($button['sub_buttons'] as $childbutton)
576
			{
577
				echo '
578
								<li', !empty($childbutton['sub_buttons']) ? ' class="subsections"' : '', '>
579
									<a href="', $childbutton['href'], '"', isset($childbutton['target']) ? ' target="' . $childbutton['target'] . '"' : '', isset($childbutton['onclick']) ? ' onclick="' . $childbutton['onclick'] . '"' : '', '>
580
										', $childbutton['title'], !empty($childbutton['amt']) ? ' <span class="amt">' . $childbutton['amt'] . '</span>' : '', '
581
									</a>';
582
				// 3rd level menus :)
583
				if (!empty($childbutton['sub_buttons']))
584
				{
585
					echo '
586
									<ul>';
587
588
					foreach ($childbutton['sub_buttons'] as $grandchildbutton)
589
						echo '
590
										<li>
591
											<a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', isset($grandchildbutton['onclick']) ? ' onclick="' . $grandchildbutton['onclick'] . '"' : '', '>
592
												', $grandchildbutton['title'], !empty($grandchildbutton['amt']) ? ' <span class="amt">' . $grandchildbutton['amt'] . '</span>' : '', '
593
											</a>
594
										</li>';
595
596
					echo '
597
									</ul>';
598
				}
599
600
				echo '
601
								</li>';
602
			}
603
			echo '
604
							</ul>';
605
		}
606
		echo '
607
						</li>';
608
	}
609
610
	echo '
611
					</ul><!-- .menu_nav -->';
612
}
613
614
/**
615
 * Generate a strip of buttons.
616
 *
617
 * @param array $button_strip An array with info for displaying the strip
618
 * @param string $direction The direction
619
 * @param array $strip_options Options for the button strip
620
 */
621
function template_button_strip($button_strip, $direction = '', $strip_options = array())
622
{
623
	global $context, $txt;
624
625
	if (!is_array($strip_options))
0 ignored issues
show
The condition is_array($strip_options) is always true.
Loading history...
626
		$strip_options = array();
627
628
	// Create the buttons...
629
	$buttons = array();
630
	foreach ($button_strip as $key => $value)
631
	{
632
		// 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!)
633
		if (!isset($value['test']) || !empty($context[$value['test']]))
634
		{
635
			if (!isset($value['id']))
636
				$value['id'] = $key;
637
638
			$button = '
639
				<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>';
640
641
			if (!empty($value['sub_buttons']))
642
			{
643
				$button .= '
644
					<div class="top_menu dropmenu ' . $key . '_dropdown">
645
						<div class="viewport">
646
							<div class="overview">';
647
				foreach ($value['sub_buttons'] as $element)
648
				{
649
					if (isset($element['test']) && empty($context[$element['test']]))
650
						continue;
651
652
					$button .= '
653
								<a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>';
654
					if (isset($txt[$element['text'] . '_desc']))
655
						$button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>';
656
					$button .= '</a>';
657
				}
658
				$button .= '
659
							</div><!-- .overview -->
660
						</div><!-- .viewport -->
661
					</div><!-- .top_menu -->';
662
			}
663
664
			$buttons[] = $button;
665
		}
666
	}
667
668
	// No buttons? No button strip either.
669
	if (empty($buttons))
670
		return;
671
672
	echo '
673
		<div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '>
674
			', implode('', $buttons), '
675
		</div>';
676
}
677
678
/**
679
 * Generate a list of quickbuttons.
680
 *
681
 * @param array $list_items An array with info for displaying the strip
682
 * @param string $list_class Used for integration hooks and as a class name
683
 * @param string $output_method The output method. If 'echo', simply displays the buttons, otherwise returns the HTML for them
684
 * @return void|string Returns nothing unless output_method is something other than 'echo'
685
 */
686
function template_quickbuttons($list_items, $list_class = null, $output_method = 'echo')
687
{
688
	global $txt;
689
690
	// Enable manipulation with hooks
691
	if (!empty($list_class))
692
		call_integration_hook('integrate_' . $list_class . '_quickbuttons', array(&$list_items));
693
694
	// Make sure the list has at least one shown item
695
	foreach ($list_items as $key => $li)
696
	{
697
		// Is there a sublist, and does it have any shown items
698
		if ($key == 'more')
699
		{
700
			foreach ($li as $subkey => $subli)
701
				if (isset($subli['show']) && !$subli['show'])
702
					unset($list_items[$key][$subkey]);
703
704
			if (empty($list_items[$key]))
705
				unset($list_items[$key]);
706
		}
707
		// A normal list item
708
		elseif (isset($li['show']) && !$li['show'])
709
			unset($list_items[$key]);
710
	}
711
712
	// Now check if there are any items left
713
	if (empty($list_items))
714
		return;
715
716
	// Print the quickbuttons
717
	$output = '
718
		<ul class="quickbuttons' . (!empty($list_class) ? ' quickbuttons_' . $list_class : '') . '">';
719
720
	// This is used for a list item or a sublist item
721
	$list_item_format = function($li)
722
	{
723
		$html = '
724
			<li' . (!empty($li['class']) ? ' class="' . $li['class'] . '"' : '') . (!empty($li['id']) ? ' id="' . $li['id'] . '"' : '') . (!empty($li['custom']) ? ' ' . $li['custom'] : '') . '>';
725
726
		if (isset($li['content']))
727
			$html .= $li['content'];
728
		else
729
			$html .= '
730
				<a href="' . (!empty($li['href']) ? $li['href'] : 'javascript:void(0);') . '"' . (!empty($li['javascript']) ? ' ' . $li['javascript'] : '') . '>
731
					' . (!empty($li['icon']) ? '<span class="main_icons ' . $li['icon'] . '"></span>' : '') . (!empty($li['label']) ? $li['label'] : '') . '
732
				</a>';
733
734
		$html .= '
735
			</li>';
736
737
		return $html;
738
	};
739
740
	foreach ($list_items as $key => $li)
741
	{
742
		// Handle the sublist
743
		if ($key == 'more')
744
		{
745
			$output .= '
746
			<li class="post_options">
747
				<a href="javascript:void(0);">' . $txt['post_options'] . '</a>
748
				<ul>';
749
750
			foreach ($li as $subli)
751
				$output .= $list_item_format($subli);
752
753
			$output .= '
754
				</ul>
755
			</li>';
756
		}
757
		// Ordinary list item
758
		else
759
			$output .= $list_item_format($li);
760
	}
761
762
	$output .= '
763
		</ul><!-- .quickbuttons -->';
764
765
	// There are a few spots where the result needs to be returned
766
	if ($output_method == 'echo')
767
		echo $output;
768
	else
769
		return $output;
770
}
771
772
/**
773
 * The upper part of the maintenance warning box
774
 */
775
function template_maint_warning_above()
776
{
777
	global $txt, $context, $scripturl;
778
779
	echo '
780
	<div class="errorbox" id="errors">
781
		<dl>
782
			<dt>
783
				<strong id="error_serious">', $txt['forum_in_maintenance'], '</strong>
784
			</dt>
785
			<dd class="error" id="error_list">
786
				', sprintf($txt['maintenance_page'], $scripturl . '?action=admin;area=serversettings;' . $context['session_var'] . '=' . $context['session_id']), '
787
			</dd>
788
		</dl>
789
	</div>';
790
}
791
792
/**
793
 * The lower part of the maintenance warning box.
794
 */
795
function template_maint_warning_below()
796
{
797
798
}
799
800
?>