GenericMenu.template.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2013 Simple Machines and individual contributors
  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_dropdown_above()
  14. {
  15. global $context, $options, $scripturl, $txt, $modSettings;
  16. // Which menu are we rendering?
  17. $context['cur_menu_id'] = isset($context['cur_menu_id']) ? $context['cur_menu_id'] + 1 : 1;
  18. $menu_context = &$context['menu_data_' . $context['cur_menu_id']];
  19. echo '
  20. <div id="admin_menu">';
  21. echo '
  22. <ul class="dropmenu" id="dropdown_menu_', $context['cur_menu_id'], '">';
  23. // Main areas first.
  24. foreach ($menu_context['sections'] as $section)
  25. {
  26. echo '
  27. <li ', !empty($section['areas']) ? 'class="subsections"' : '', '><a class="', !empty($section['selected']) ? 'active ' : '', '" href="', $section['url'], $menu_context['extra_parameters'], '">', $section['title'] , '</a>
  28. <ul>';
  29. // For every area of this section show a link to that area (bold if it's currently selected.)
  30. // @todo Code for additional_items class was deprecated and has been removed. Suggest following up in Sources if required.
  31. foreach ($section['areas'] as $i => $area)
  32. {
  33. // Not supposed to be printed?
  34. if (empty($area['label']))
  35. continue;
  36. echo '
  37. <li', !empty($area['subsections']) ? ' class="subsections"' : '', '>';
  38. echo '
  39. <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>';
  40. // Is this the current area, or just some area?
  41. if (!empty($area['selected']) && empty($context['tabs']))
  42. $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
  43. // Are there any subsections?
  44. if (!empty($area['subsections']))
  45. {
  46. echo '
  47. <ul>';
  48. foreach ($area['subsections'] as $sa => $sub)
  49. {
  50. if (!empty($sub['disabled']))
  51. continue;
  52. $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
  53. echo '
  54. <li ', !empty($area['subsections']) ? ' class="subsections"' : '', '>
  55. <a ', !empty($sub['selected']) ? 'class="chosen" ' : '', ' href="', $url, $menu_context['extra_parameters'], '">', $sub['label'], '</a>
  56. </li>';
  57. }
  58. echo '
  59. </ul>';
  60. }
  61. echo '
  62. </li>';
  63. }
  64. echo '
  65. </ul>
  66. </li>';
  67. }
  68. echo '
  69. </ul>
  70. </div>';
  71. // This is the main table - we need it so we can keep the content to the right of it.
  72. echo '
  73. <div id="admin_content">';
  74. // It's possible that some pages have their own tabs they wanna force...
  75. // if (!empty($context['tabs']))
  76. template_generic_menu_tabs($menu_context);
  77. }
  78. // Part of the admin layer - used with admin_above to close the table started in it.
  79. function template_generic_menu_dropdown_below()
  80. {
  81. global $context, $options;
  82. echo '
  83. </div>';
  84. }
  85. // Some code for showing a tabbed view.
  86. function template_generic_menu_tabs(&$menu_context)
  87. {
  88. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  89. // Handy shortcut.
  90. $tab_context = &$menu_context['tab_data'];
  91. if (!empty($tab_context['title']))
  92. {
  93. echo '
  94. <div class="cat_bar">
  95. <h3 class="catbg">';
  96. // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
  97. if (function_exists('template_admin_quick_search'))
  98. template_admin_quick_search();
  99. // Exactly how many tabs do we have?
  100. if (!empty($context['tabs']))
  101. {
  102. foreach ($context['tabs'] as $id => $tab)
  103. {
  104. // Can this not be accessed?
  105. if (!empty($tab['disabled']))
  106. {
  107. $tab_context['tabs'][$id]['disabled'] = true;
  108. continue;
  109. }
  110. // Did this not even exist - or do we not have a label?
  111. if (!isset($tab_context['tabs'][$id]))
  112. $tab_context['tabs'][$id] = array('label' => $tab['label']);
  113. elseif (!isset($tab_context['tabs'][$id]['label']))
  114. $tab_context['tabs'][$id]['label'] = $tab['label'];
  115. // Has a custom URL defined in the main admin structure?
  116. if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
  117. $tab_context['tabs'][$id]['url'] = $tab['url'];
  118. // Any additional paramaters for the url?
  119. if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
  120. $tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
  121. // Has it been deemed selected?
  122. if (!empty($tab['is_selected']))
  123. $tab_context['tabs'][$id]['is_selected'] = true;
  124. // Does it have its own help?
  125. if (!empty($tab['help']))
  126. $tab_context['tabs'][$id]['help'] = $tab['help'];
  127. // Is this the last one?
  128. if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
  129. $tab_context['tabs'][$id]['is_last'] = true;
  130. }
  131. // Find the selected tab
  132. foreach ($tab_context['tabs'] as $sa => $tab)
  133. {
  134. if (!empty($tab['is_selected']) || (isset($menu_context['current_subsection']) && $menu_context['current_subsection'] == $sa))
  135. {
  136. $selected_tab = $tab;
  137. $tab_context['tabs'][$sa]['is_selected'] = true;
  138. }
  139. }
  140. }
  141. // Show an icon and/or a help item?
  142. if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
  143. {
  144. if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']))
  145. echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
  146. elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
  147. echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon" />';
  148. if (!empty($selected_tab['help']) || !empty($tab_context['help']))
  149. 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>';
  150. echo $tab_context['title'];
  151. }
  152. else
  153. {
  154. echo '
  155. ', $tab_context['title'];
  156. }
  157. echo '
  158. </h3>
  159. </div>';
  160. }
  161. // Shall we use the tabs? Yes, it's the only known way!
  162. if (!empty($selected_tab['description']) || !empty($tab_context['description']))
  163. echo '
  164. <p class="description">
  165. ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
  166. </p>';
  167. // Print out all the items in this tab (if any).
  168. if (!empty($context['tabs']))
  169. {
  170. // The admin tabs.
  171. echo '
  172. <div id="adm_submenus">
  173. <ul class="dropmenu">';
  174. foreach ($tab_context['tabs'] as $sa => $tab)
  175. {
  176. if (!empty($tab['disabled']))
  177. continue;
  178. if (!empty($tab['is_selected']))
  179. {
  180. echo '
  181. <li>
  182. <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>
  183. </li>';
  184. }
  185. else
  186. echo '
  187. <li>
  188. <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>
  189. </li>';
  190. }
  191. // the end of tabs
  192. echo '
  193. </ul>
  194. </div>';
  195. }
  196. }
  197. ?>