2
0

GenericMenu.template.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2012 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">';
  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. ', $section['title'], '
  33. </h4>
  34. </div>
  35. <ul class="dropmenu left_admmenu">';
  36. // For every area of this section show a link to that area (bold if it's currently selected.)
  37. foreach ($section['areas'] as $i => $area)
  38. {
  39. // Not supposed to be printed?
  40. if (empty($area['label']))
  41. continue;
  42. echo '
  43. <li ', !empty($area['subsections']) ?'class="subsections"':'', ' ', ($i == $menu_context['current_area']) ?'id="menu_current_area"':'', '>';
  44. // Is this the current area, or just some area?
  45. if ($i == $menu_context['current_area'])
  46. {
  47. echo '
  48. <strong><a href="', isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i, $menu_context['extra_parameters'], '">', $area['label'], '</a></strong>';
  49. if (empty($context['tabs']))
  50. $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
  51. }
  52. else
  53. echo '
  54. <a href="', isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i, $menu_context['extra_parameters'], '">', $area['label'], '</a>';
  55. // Is there any subsections?
  56. if (!empty($area['subsections']))
  57. {
  58. echo '
  59. <ul>';
  60. foreach ($area['subsections'] as $sa => $sub)
  61. {
  62. if (!empty($sub['disabled']))
  63. continue;
  64. $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
  65. echo '
  66. <li>
  67. <a ', !empty($sub['selected']) ? 'class="chosen" ' : '', 'href="', $url, $menu_context['extra_parameters'], '">', $sub['label'], '</a>
  68. </li>';
  69. }
  70. echo '
  71. </ul>';
  72. }
  73. echo '
  74. </li>';
  75. }
  76. echo '
  77. </ul>
  78. </div>';
  79. $firstSection = false;
  80. }
  81. // This is where the actual "main content" area for the admin section starts.
  82. echo '
  83. </div>
  84. <div id="main_admsection">';
  85. // If there are any "tabs" setup, this is the place to shown them.
  86. if (!empty($context['tabs']) && empty($context['force_disable_tabs']))
  87. template_generic_menu_tabs($menu_context);
  88. }
  89. // Part of the sidebar layer - closes off the main bit.
  90. function template_generic_menu_sidebar_below()
  91. {
  92. global $context, $settings, $options;
  93. echo '
  94. </div>
  95. </div>';
  96. }
  97. // This contains the html for the side bar of the admin center, which is used for all admin pages.
  98. function template_generic_menu_dropdown_above()
  99. {
  100. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  101. // Which menu are we rendering?
  102. $context['cur_menu_id'] = isset($context['cur_menu_id']) ? $context['cur_menu_id'] + 1 : 1;
  103. $menu_context = &$context['menu_data_' . $context['cur_menu_id']];
  104. echo '
  105. <div id="admin_menu">';
  106. echo '
  107. <ul class="dropmenu" id="dropdown_menu_', $context['cur_menu_id'], '">';
  108. // Main areas first.
  109. foreach ($menu_context['sections'] as $section)
  110. {
  111. echo '
  112. <li ', !empty($section['areas']) ? 'class="subsections"' : '', '><a class="', !empty($section['selected']) ? 'active ' : '', '" href="', $section['url'], $menu_context['extra_parameters'], '">', $section['title'] , '</a>
  113. <ul>';
  114. // For every area of this section show a link to that area (bold if it's currently selected.)
  115. // @todo Code for additional_items class was deprecated and has been removed. Suggest following up in Sources if required.
  116. foreach ($section['areas'] as $i => $area)
  117. {
  118. // Not supposed to be printed?
  119. if (empty($area['label']))
  120. continue;
  121. echo '
  122. <li', !empty($area['subsections']) ? ' class="subsections"' : '', '>';
  123. echo '
  124. <a ', !empty($area['selected']) ? 'class="chosen" ' : '', 'href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], '</a>';
  125. // Is this the current area, or just some area?
  126. if (!empty($area['selected']) && empty($context['tabs']))
  127. $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
  128. // Are there any subsections?
  129. if (!empty($area['subsections']))
  130. {
  131. echo '
  132. <ul>';
  133. foreach ($area['subsections'] as $sa => $sub)
  134. {
  135. if (!empty($sub['disabled']))
  136. continue;
  137. $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
  138. echo '
  139. <li ', !empty($area['subsections']) ? ' class="subsections"' : '', '>
  140. <a ', !empty($sub['selected']) ? 'class="chosen" ' : '', ' href="', $url, $menu_context['extra_parameters'], '">', $sub['label'], '</a>
  141. </li>';
  142. }
  143. echo '
  144. </ul>';
  145. }
  146. echo '
  147. </li>';
  148. }
  149. echo '
  150. </ul>
  151. </li>';
  152. }
  153. echo '
  154. </ul>
  155. </div>';
  156. // This is the main table - we need it so we can keep the content to the right of it.
  157. echo '
  158. <div id="admin_content">';
  159. // It's possible that some pages have their own tabs they wanna force...
  160. // if (!empty($context['tabs']))
  161. template_generic_menu_tabs($menu_context);
  162. }
  163. // Part of the admin layer - used with admin_above to close the table started in it.
  164. function template_generic_menu_dropdown_below()
  165. {
  166. global $context, $settings, $options;
  167. echo '
  168. </div>';
  169. }
  170. // Some code for showing a tabbed view.
  171. function template_generic_menu_tabs(&$menu_context)
  172. {
  173. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  174. // Handy shortcut.
  175. $tab_context = &$menu_context['tab_data'];
  176. if (!empty($tab_context['title']))
  177. {
  178. echo '
  179. <div class="cat_bar">
  180. <h3 class="catbg">';
  181. // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
  182. if (function_exists('template_admin_quick_search'))
  183. template_admin_quick_search();
  184. // Exactly how many tabs do we have?
  185. if (!empty($context['tabs']))
  186. {
  187. foreach ($context['tabs'] as $id => $tab)
  188. {
  189. // Can this not be accessed?
  190. if (!empty($tab['disabled']))
  191. {
  192. $tab_context['tabs'][$id]['disabled'] = true;
  193. continue;
  194. }
  195. // Did this not even exist - or do we not have a label?
  196. if (!isset($tab_context['tabs'][$id]))
  197. $tab_context['tabs'][$id] = array('label' => $tab['label']);
  198. elseif (!isset($tab_context['tabs'][$id]['label']))
  199. $tab_context['tabs'][$id]['label'] = $tab['label'];
  200. // Has a custom URL defined in the main admin structure?
  201. if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
  202. $tab_context['tabs'][$id]['url'] = $tab['url'];
  203. // Any additional paramaters for the url?
  204. if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
  205. $tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
  206. // Has it been deemed selected?
  207. if (!empty($tab['is_selected']))
  208. $tab_context['tabs'][$id]['is_selected'] = true;
  209. // Does it have its own help?
  210. if (!empty($tab['help']))
  211. $tab_context['tabs'][$id]['help'] = $tab['help'];
  212. // Is this the last one?
  213. if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
  214. $tab_context['tabs'][$id]['is_last'] = true;
  215. }
  216. // Find the selected tab
  217. foreach ($tab_context['tabs'] as $sa => $tab)
  218. {
  219. if (!empty($tab['is_selected']) || (isset($menu_context['current_subsection']) && $menu_context['current_subsection'] == $sa))
  220. {
  221. $selected_tab = $tab;
  222. $tab_context['tabs'][$sa]['is_selected'] = true;
  223. }
  224. }
  225. }
  226. // Show an icon and/or a help item?
  227. if (!empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
  228. {
  229. if (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
  230. echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon" />';
  231. if (!empty($selected_tab['help']) || !empty($tab_context['help']))
  232. echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics_hd.png" alt="', $txt['help'], '" class="icon" /></a>';
  233. echo $tab_context['title'];
  234. }
  235. else
  236. {
  237. echo '
  238. ', $tab_context['title'];
  239. }
  240. echo '
  241. </h3>
  242. </div>';
  243. }
  244. // Shall we use the tabs? Yes, it's the only known way!
  245. if (!empty($selected_tab['description']) || !empty($tab_context['description']))
  246. echo '
  247. <p class="description">
  248. ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
  249. </p>';
  250. // Print out all the items in this tab (if any).
  251. if (!empty($context['tabs']))
  252. {
  253. // The admin tabs.
  254. echo '
  255. <div id="adm_submenus">
  256. <ul class="dropmenu">';
  257. foreach ($tab_context['tabs'] as $sa => $tab)
  258. {
  259. if (!empty($tab['disabled']))
  260. continue;
  261. if (!empty($tab['is_selected']))
  262. {
  263. echo '
  264. <li>
  265. <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'] : '', '">', $tab['label'], '</a>
  266. </li>';
  267. }
  268. else
  269. echo '
  270. <li>
  271. <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'] : '', '">', $tab['label'], '</a>
  272. </li>';
  273. }
  274. // the end of tabs
  275. echo '
  276. </ul>
  277. </div>
  278. <br class="clear" />';
  279. }
  280. }
  281. ?>