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