Passed
Push — myDevel ( d43be7...574062 )
by Spuds
05:08
created

template_format_xml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 6
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
/**
4
 * @package SimplePortal ElkArte
5
 *
6
 * @author SimplePortal Team
7
 * @copyright 2015-2021 SimplePortal Team
8
 * @license BSD 3-clause
9
 * @version 1.0.0 RC2
10
 */
11
function template_information()
12
{
13
	global $context, $txt;
14
15
	if ($context['in_admin'])
16
	{
17
		echo '
18
	<div id="sp_admin_main">
19
		<div id="admin_main_section">
20
			<div id="sp_live_info" class="floatleft">
21
				<h3 class="category_header hdicon cat_img_talk">
22
					', $txt['sp-info_live'], '
23
				</h3>
24
				<div class="content">
25
					<div id="spAnnouncements">', $txt['sp-info_no_live'], '</div>
26
				</div>
27
			</div>
28
			<div id="sp_general_info" class="floatright">
29
				<h3 class="category_header hdicon cat_img_config">
30
					', $txt['sp-info_general'], '
31
				</h3>
32
				<div class="content">
33
					<strong>', $txt['sp-info_versions'], ':</strong><br />
34
					', $txt['sp-info_your_version'], ':
35
					<em id="spYourVersion" style="white-space: nowrap;">', $context['sp_version'], '</em><br />
36
					', $txt['sp-info_current_version'], ':
37
					<em id="spCurrentVersion" style="white-space: nowrap;">???</em><br />
38
					<strong>', $txt['sp-info_managers'], ':</strong>
39
					', implode(', ', $context['sp_managers']), '
40
				</div>
41
			</div>
42
		</div>
43
		<script>
44
			var func = function ()
45
			{
46
				sp_currentVersion();
47
			}
48
			addLoadEvent(func);
49
		</script>';
50
	}
51
52
	echo '
53
		<div class="quick_tasks" id="sp_credits">';
54
55
	foreach ($context['sp_credits'] as $section)
56
	{
57
		if (isset($section['pretext']))
58
			echo '
59
			<p>', $section['pretext'], '</p>';
60
61
		foreach ($section['groups'] as $group)
62
		{
63
			if (empty($group['members']))
64
				continue;
65
66
			echo '
67
			<p>';
68
69
			if (isset($group['title']))
70
				echo '
71
				<strong>', $group['title'], ':</strong> ';
72
73
			echo implode(', ', $group['members']), '
74
			</p>';
75
		}
76
77
78
		if (isset($section['posttext']))
79
			echo '
80
			<p>', $section['posttext'], '</p>';
81
	}
82
83
	echo '
84
			<hr />
85
			<p>', sprintf($txt['sp-info_contribute'], 'https://simpleportal.net/index.php?page=contribute'), '</p>
86
		</div>
87
	</div>';
88
}
89
90
/**
91
 * Provide an xml response to an active on/off toggle
92
 */
93
function template_change_status()
94
{
95
	global $context, $txt;
96
97
	echo '<', '?xml version="1.0" encoding="UTF-8" ?', '>
98
<elk>
99
	<id>', $context['item_id'], '</id>
100
	<status>', $context['status'], '</status>
101
	<label>', $txt['sp-blocks' . ($context['status'] === 'active' ? 'Deactivate' : 'Activate')] . '</label>
102
</elk>';
103
}
104
105
/**
106
 * Return an xml response to a format swap/change request
107
 */
108
function template_format_xml()
109
{
110
	global $context;
111
112
	// Cleanup the conversion
113
	$text = trim($context['SPortal']['text']);
114
	$text = preg_replace("~(\s*[\n]\s*){2,}~", "\n\n", $text);
115
	$text = str_replace("\n\x00", '', $text);
116
117
	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
118
<elk>
119
	<format>', $text, '</format>
120
</elk>';
121
}
122