GenericMenu.template.php 11 KB

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