-
Notifications
You must be signed in to change notification settings - Fork 0
/
GenericMenu.template.php
360 lines (301 loc) · 11.3 KB
/
GenericMenu.template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<?php
/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines
* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
*/
// This contains the html for the side bar of the admin center, which is used for all admin pages.
function template_generic_menu_sidebar_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
// This is the main table - we need it so we can keep the content to the right of it.
echo '
<div id="main_container">
<div id="left_admsection"><span id="admin_menu"></span>';
// What one are we rendering?
$context['cur_menu_id'] = isset($context['cur_menu_id']) ? $context['cur_menu_id'] + 1 : 1;
$menu_context = &$context['menu_data_' . $context['cur_menu_id']];
// For every section that appears on the sidebar...
$firstSection = true;
foreach ($menu_context['sections'] as $section)
{
// Show the section header - and pump up the line spacing for readability.
echo '
<div class="adm_section">
<div class="cat_bar">
<h4 class="catbg">';
if ($firstSection && !empty($menu_context['can_toggle_drop_down']))
{
echo '
<span class="ie6_header floatleft">
<a href="', $menu_context['toggle_url'], '">', $section['title'],'<img style="margin: 0 5px; vertical-align: middle;" src="', $context['menu_image_path'], '/change_menu', $context['right_to_left'] ? '' : '2', '.png" alt="!" /></a>
</span>';
}
else
{
echo '
', $section['title'];
}
echo '
</h4>
</div>
<ul class="smalltext left_admmenu">';
// For every area of this section show a link to that area (bold if it's currently selected.)
foreach ($section['areas'] as $i => $area)
{
// Not supposed to be printed?
if (empty($area['label']))
continue;
echo '
<li>';
// Is this the current area, or just some area?
if ($i == $menu_context['current_area'])
{
echo '
<strong><a href="', isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i, $menu_context['extra_parameters'], '">', $area['label'], '</a></strong>';
if (empty($context['tabs']))
$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
}
else
echo '
<a href="', isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i, $menu_context['extra_parameters'], '">', $area['label'], '</a>';
echo '
</li>';
}
echo '
</ul>
</div>';
$firstSection = false;
}
// This is where the actual "main content" area for the admin section starts.
echo '
</div>
<div id="main_admsection">';
// If there are any "tabs" setup, this is the place to shown them.
if (!empty($context['tabs']) && empty($context['force_disable_tabs']))
template_generic_menu_tabs($menu_context);
}
// Part of the sidebar layer - closes off the main bit.
function template_generic_menu_sidebar_below()
{
global $context, $settings, $options;
echo '
</div>
</div><br class="clear" />';
}
// This contains the html for the side bar of the admin center, which is used for all admin pages.
function template_generic_menu_dropdown_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
// Which menu are we rendering?
$context['cur_menu_id'] = isset($context['cur_menu_id']) ? $context['cur_menu_id'] + 1 : 1;
$menu_context = &$context['menu_data_' . $context['cur_menu_id']];
if (!empty($menu_context['can_toggle_drop_down']))
echo '
<a href="', $menu_context['toggle_url'], '"><img id="menu_toggle" src="', $context['menu_image_path'], '/change_menu', $context['right_to_left'] ? '2' : '', '.png" alt="*" /></a>';
echo '
<div id="admin_menu">
<ul class="nav nav-pills" id="dropdown_menu_', $context['cur_menu_id'], '">';
// Main areas first.
foreach ($menu_context['sections'] as $section)
{
echo '
<li role="presentation" class="dropdown"><a class="dropdown-toggle', ($section['id'] == $menu_context['current_section'] ? ' active' : ''), '" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">', $section['title'] , '</a>
<ul class="dropdown-menu">';
// For every area of this section show a link to that area (bold if it's currently selected.)
$additional_items = 0;
foreach ($section['areas'] as $i => $area)
{
// Not supposed to be printed?
if (empty($area['label']))
continue;
echo '
<li', !empty($area['subsections']) ? ' class="additional_items dropdown-submenu"' : '' ,'>';
// Is this the current area, or just some area?
if ($i == $menu_context['current_area'])
{
echo '
<a class="chosen" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '"><span>', $area['icon'], $area['label'], '</span></a>';
if (empty($context['tabs']))
$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
}
else
echo '
<a href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '"><span>', $area['icon'], $area['label'], '</span></a>';
// Is there any subsections?
$additional_items_sub = 0;
if (!empty($area['subsections']))
{
echo '
<ul class="dropdown-menu">';
foreach ($area['subsections'] as $sa => $sub)
{
if (!empty($sub['disabled']))
continue;
$url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
echo '
<li', (++$additional_items_sub > 6) ? ' class="additional_items"' : '' ,'>
<a ', !empty($sub['selected']) ? 'class="active" ' : '', 'href="', $url, $menu_context['extra_parameters'], '"><span>', $sub['label'], '</span></a>
</li>';
}
echo '
</ul>';
}
echo '
</li>';
}
echo '
</ul>
</li>';
}
echo '
</ul>
</div>';
// This is the main table - we need it so we can keep the content to the right of it.
echo '
<div id="admin_content">';
// It's possible that some pages have their own tabs they wanna force...
if (!empty($context['tabs']))
template_generic_menu_tabs($menu_context);
}
// Part of the admin layer - used with admin_above to close the table started in it.
function template_generic_menu_dropdown_below()
{
global $context, $settings, $options;
echo '
</div>';
}
// Some code for showing a tabbed view.
function template_generic_menu_tabs(&$menu_context)
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
// Handy shortcut.
$tab_context = &$menu_context['tab_data'];
echo '
<div class="cat_bar">
<h3 class="catbg">';
// Exactly how many tabs do we have?
foreach ($context['tabs'] as $id => $tab)
{
// Can this not be accessed?
if (!empty($tab['disabled']))
{
$tab_context['tabs'][$id]['disabled'] = true;
continue;
}
// Did this not even exist - or do we not have a label?
if (!isset($tab_context['tabs'][$id]))
$tab_context['tabs'][$id] = array('label' => $tab['label']);
elseif (!isset($tab_context['tabs'][$id]['label']))
$tab_context['tabs'][$id]['label'] = $tab['label'];
// Has a custom URL defined in the main admin structure?
if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
$tab_context['tabs'][$id]['url'] = $tab['url'];
// Any additional paramaters for the url?
if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
// Has it been deemed selected?
if (!empty($tab['is_selected']))
$tab_context['tabs'][$id]['is_selected'] = true;
// Does it have its own help?
if (!empty($tab['help']))
$tab_context['tabs'][$id]['help'] = $tab['help'];
// Is this the last one?
if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
$tab_context['tabs'][$id]['is_last'] = true;
}
// Find the selected tab
foreach ($tab_context['tabs'] as $sa => $tab)
{
if (!empty($tab['is_selected']) || (isset($menu_context['current_subsection']) && $menu_context['current_subsection'] == $sa))
{
$selected_tab = $tab;
$tab_context['tabs'][$sa]['is_selected'] = true;
}
}
// Show an icon and/or a help item?
if (!empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
{
echo '
<span class="ie6_header floatleft">';
if (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon" />';
if (!empty($selected_tab['help']) || !empty($tab_context['help']))
echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" class="icon" /></a>';
echo $tab_context['title'], '
</span>';
}
else
{
echo '
', $tab_context['title'];
}
echo '
</h3>
</div>';
// Shall we use the tabs?
if (!empty($settings['use_tabs']))
{
echo '
<p class="windowbg description">
', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
</p>';
// The admin tabs.
echo '
<div id="adm_submenus" class="buttonlist">
<ul class="nav nav-pills">';
// Print out all the items in this tab.
foreach ($tab_context['tabs'] as $sa => $tab)
{
if (!empty($tab['disabled']))
continue;
if (!empty($tab['is_selected']))
{
echo '
<li role="presentation">
<a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '"><span class="firstlevel">', $tab['label'], '</span></a>
</li>';
}
else
echo '
<li role="presentation">
<a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '"><span class="firstlevel">', $tab['label'], '</span></a>
</li>';
}
// the end of tabs
echo '
</ul>
</div><br class="clear" />';
}
// ...if not use the old style
else
{
echo '
<p class="tabs">';
// Print out all the items in this tab.
foreach ($tab_context['tabs'] as $sa => $tab)
{
if (!empty($tab['disabled']))
continue;
if (!empty($tab['is_selected']))
{
echo '
<img src="', $settings['images_url'], '/selected.gif" alt="*" /> <strong><a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], '">', $tab['label'], '</a></strong>';
}
else
echo '
<a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], '">', $tab['label'], '</a>';
if (empty($tab['is_last']))
echo ' | ';
}
echo '
</p>
<p class="windowbg description">', isset($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '</p>';
}
}
?>