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