GenericMenu.template.php 11 KB

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