2
0

GenericMenu.template.php 10 KB

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