1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @package Ultimate Menu mod |
7
|
|
|
* @version 2.0.2 |
8
|
|
|
* @author John Rayes <[email protected]> |
9
|
|
|
* @copyright Copyright (c) 2014, John Rayes |
10
|
|
|
* @license http://opensource.org/licenses/MIT MIT |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
function template_form_above(): void |
14
|
|
|
{ |
15
|
|
|
global $context, $scripturl; |
16
|
|
|
|
17
|
|
|
echo ' |
18
|
|
|
<form action="', $scripturl, '?action=admin;area=umen;sa=savebutton" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify"> |
19
|
|
|
<div class="cat_bar"> |
20
|
|
|
<h3 class="catbg"> |
21
|
|
|
', $context['page_title'], ' |
22
|
|
|
</h3> |
23
|
|
|
</div> |
24
|
|
|
<div class="roundframe noup">'; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
function template_errors_above(): void |
28
|
|
|
{ |
29
|
|
|
global $context, $txt; |
30
|
|
|
|
31
|
|
|
if (!empty($context['post_error'])) |
32
|
|
|
{ |
33
|
|
|
echo ' |
34
|
|
|
<div class="errorbox" id="errors"> |
35
|
|
|
<strong>', $txt[$context['error_title']], '</strong> |
36
|
|
|
<ul>'; |
37
|
|
|
|
38
|
|
|
foreach ($context['post_error'] as $error) |
39
|
|
|
echo ' |
40
|
|
|
<li>', $txt[$error], '</li>'; |
41
|
|
|
|
42
|
|
|
echo ' |
43
|
|
|
</ul> |
44
|
|
|
</div>'; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
function template_errors_below(): void |
49
|
|
|
{ |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
function template_main(): void |
53
|
|
|
{ |
54
|
|
|
global $context, $txt, $scripturl; |
55
|
|
|
|
56
|
|
|
$sel = fn(bool $x, string $str): string => $x ? ' ' . $str : ''; |
57
|
|
|
|
58
|
|
|
echo ' |
59
|
|
|
<dl class="settings"> |
60
|
|
|
<dt> |
61
|
|
|
<strong>', $txt['um_menu_button_name'], ':</strong> |
62
|
|
|
</dt> |
63
|
|
|
<dd> |
64
|
|
|
<input type="text" name="name" value="', $context['button_data']['name'], '" style="width: 100%;" /> |
65
|
|
|
</dd> |
66
|
|
|
<dt> |
67
|
|
|
<strong>', $txt['um_menu_button_position'], ':</strong> |
68
|
|
|
</dt> |
69
|
|
|
<dd> |
70
|
|
|
<select name="position" size="10" style="width: 22%;">'; |
71
|
|
|
|
72
|
|
|
foreach (['after', 'child_of', 'before'] as $v) |
73
|
|
|
printf( |
74
|
|
|
' |
75
|
|
|
<option value="%s"%s>%s...</option>', |
76
|
|
|
$v, |
77
|
|
|
$sel($context['button_data']['position'] == $v, 'selected'), |
78
|
|
|
$txt['um_menu_' . $v] |
79
|
|
|
); |
80
|
|
|
|
81
|
|
|
echo ' |
82
|
|
|
</select> |
83
|
|
|
<select name="parent" size="10" style="width: 75%;">'; |
84
|
|
|
|
85
|
|
|
foreach ($context['button_names'] as $idx => $title) |
86
|
|
|
printf( |
87
|
|
|
' |
88
|
|
|
<option value="%s"%s>%s</option>', |
89
|
|
|
$idx, |
90
|
|
|
$sel($context['button_data']['parent'] == $idx, 'selected'), |
91
|
|
|
str_repeat(' ', $title[0] * 2) . $title[1] |
92
|
|
|
); |
93
|
|
|
|
94
|
|
|
echo ' |
95
|
|
|
</select> |
96
|
|
|
</dd> |
97
|
|
|
<dt> |
98
|
|
|
<strong>', $txt['um_menu_button_type'], ':</strong> |
99
|
|
|
</dt> |
100
|
|
|
<dd> |
101
|
|
|
<input type="radio" name="type" value="forum"', $sel($context['button_data']['type'] == 'forum', 'checked'), '/>', $txt['um_menu_forum'], '<br /> |
102
|
|
|
<input type="radio" name="type" value="external"', $sel($context['button_data']['type'] == 'external', 'checked'), '/>', $txt['um_menu_external'], ' |
103
|
|
|
</dd> |
104
|
|
|
<dt> |
105
|
|
|
<strong>', $txt['um_menu_link_type'], ':</strong> |
106
|
|
|
</dt> |
107
|
|
|
<dd> |
108
|
|
|
<input type="radio" name="target" value="_self"', $sel($context['button_data']['target'] == '_self', 'checked'), '/>', $txt['um_menu_same_window'], '<br /> |
109
|
|
|
<input type="radio" name="target" value="_blank"', $sel($context['button_data']['target'] == '_blank', 'checked'), '/>', $txt['um_menu_new_tab'], ' |
110
|
|
|
</dd> |
111
|
|
|
<dt> |
112
|
|
|
<strong>', $txt['um_menu_button_link'], ':</strong><br /> |
113
|
|
|
</dt> |
114
|
|
|
<dd> |
115
|
|
|
<input type="text" name="link" value="', $context['button_data']['link'], '" style="width: 100%;" /> |
116
|
|
|
<span class="smalltext">', $txt['um_menu_button_link_desc'], '</span> |
117
|
|
|
</dd> |
118
|
|
|
<dt> |
119
|
|
|
<strong>', $txt['um_menu_button_perms'], ':</strong> |
120
|
|
|
</dt> |
121
|
|
|
<dd> |
122
|
|
|
<fieldset id="group_perms"> |
123
|
|
|
<legend>', $txt['avatar_select_permission'], '</legend>'; |
124
|
|
|
|
125
|
|
|
foreach ($context['button_data']['permissions'] as $id => $permission) |
126
|
|
|
{ |
127
|
|
|
echo ' |
128
|
|
|
<label> |
129
|
|
|
<input type="checkbox" name="permissions[]" value="', $id, '"', $sel($permission['checked'], 'checked'), ' /> |
130
|
|
|
<span'; |
131
|
|
|
|
132
|
|
|
if ($permission['is_post_group']) |
133
|
|
|
echo ' title="' . $txt['mboards_groups_post_group'] . '"'; |
134
|
|
|
|
135
|
|
|
echo '>', $permission['name'], '</span> |
136
|
|
|
</label> |
137
|
|
|
<br>'; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
echo ' |
141
|
|
|
<label> |
142
|
|
|
<input type="checkbox"', $sel($context['all_groups_checked'], 'checked'), ' /> |
143
|
|
|
<em>', $txt['check_all'], '</em> |
144
|
|
|
</label> |
145
|
|
|
</fieldset> |
146
|
|
|
</dd> |
147
|
|
|
<dt> |
148
|
|
|
<strong>', $txt['um_menu_button_status'], ':</strong> |
149
|
|
|
</dt> |
150
|
|
|
<dd> |
151
|
|
|
<input type="radio" name="status" value="active"', $sel($context['button_data']['status'] == 'active', 'checked'), ' />', $txt['um_menu_button_active'], ' <br /> |
152
|
|
|
<input type="radio" name="status" value="inactive"', $sel($context['button_data']['status'] == 'inactive', 'checked'), ' />', $txt['um_menu_button_inactive'], ' |
153
|
|
|
</dd> |
154
|
|
|
</dl>'; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
function template_form_below(): void |
158
|
|
|
{ |
159
|
|
|
global $context, $txt; |
160
|
|
|
|
161
|
|
|
echo ' |
162
|
|
|
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> |
163
|
|
|
<input name="in" value="', $context['button_data']['id'], '" type="hidden" /> |
164
|
|
|
<div class="righttext padding"> |
165
|
|
|
<input name="submit" value="', $txt['admin_manage_menu_submit'], '" class="button" type="submit" /> |
166
|
|
|
</div> |
167
|
|
|
</div> |
168
|
|
|
</form> |
169
|
|
|
<script> |
170
|
|
|
var |
171
|
|
|
el = document.createElement("a"), |
172
|
|
|
div = document.getElementById("group_perms"), |
173
|
|
|
l = div.firstElementChild, |
174
|
|
|
a = document.createElement("a"); |
175
|
|
|
el.textContent = l.textContent; |
176
|
|
|
el.className = "toggle_down"; |
177
|
|
|
el.href = "#"; |
178
|
|
|
el.style.display = ""; |
179
|
|
|
el.addEventListener("click", function(event) |
180
|
|
|
{ |
181
|
|
|
div.classList.remove("hidden"); |
182
|
|
|
this.style.display = "none"; |
183
|
|
|
event.stopPropagation(); |
184
|
|
|
event.preventDefault(); |
185
|
|
|
}); |
186
|
|
|
div.classList.add("hidden"); |
187
|
|
|
div.parentNode.appendChild(el); |
188
|
|
|
a.className = "toggle_up"; |
189
|
|
|
a.textContent = l.textContent; |
190
|
|
|
a.href = "#"; |
191
|
|
|
a.style.display = ""; |
192
|
|
|
a.addEventListener("click", function(event) |
193
|
|
|
{ |
194
|
|
|
div.classList.add("hidden"); |
195
|
|
|
el.style.display = ""; |
196
|
|
|
event.stopPropagation(); |
197
|
|
|
event.preventDefault(); |
198
|
|
|
}); |
199
|
|
|
l.textContent = ""; |
200
|
|
|
l.appendChild(a); |
201
|
|
|
div.lastElementChild.firstElementChild.addEventListener("click", function() |
202
|
|
|
{ |
203
|
|
|
invertAll(this, this.form, "permissions[]"); |
204
|
|
|
}); |
205
|
|
|
</script>'; |
206
|
|
|
} |
207
|
|
|
|