2
0

GenericMenu.template.php 11 KB

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