GenericMenu.template.php 11 KB

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