GenericMenu.template.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines http://www.simplemachines.org
  7. * @copyright 2014 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, $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. echo '
  82. </div>';
  83. }
  84. // Some code for showing a tabbed view.
  85. function template_generic_menu_tabs(&$menu_context)
  86. {
  87. global $context, $settings, $scripturl, $txt, $modSettings;
  88. // Handy shortcut.
  89. $tab_context = &$menu_context['tab_data'];
  90. if (!empty($tab_context['title']))
  91. {
  92. echo '
  93. <div class="cat_bar">
  94. <h3 class="catbg">';
  95. // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
  96. if (function_exists('template_admin_quick_search'))
  97. template_admin_quick_search();
  98. // Exactly how many tabs do we have?
  99. if (!empty($context['tabs']))
  100. {
  101. foreach ($context['tabs'] as $id => $tab)
  102. {
  103. // Can this not be accessed?
  104. if (!empty($tab['disabled']))
  105. {
  106. $tab_context['tabs'][$id]['disabled'] = true;
  107. continue;
  108. }
  109. // Did this not even exist - or do we not have a label?
  110. if (!isset($tab_context['tabs'][$id]))
  111. $tab_context['tabs'][$id] = array('label' => $tab['label']);
  112. elseif (!isset($tab_context['tabs'][$id]['label']))
  113. $tab_context['tabs'][$id]['label'] = $tab['label'];
  114. // Has a custom URL defined in the main admin structure?
  115. if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
  116. $tab_context['tabs'][$id]['url'] = $tab['url'];
  117. // Any additional paramaters for the url?
  118. if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
  119. $tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
  120. // Has it been deemed selected?
  121. if (!empty($tab['is_selected']))
  122. $tab_context['tabs'][$id]['is_selected'] = true;
  123. // Does it have its own help?
  124. if (!empty($tab['help']))
  125. $tab_context['tabs'][$id]['help'] = $tab['help'];
  126. // Is this the last one?
  127. if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
  128. $tab_context['tabs'][$id]['is_last'] = true;
  129. }
  130. // Find the selected tab
  131. foreach ($tab_context['tabs'] as $sa => $tab)
  132. {
  133. if (!empty($tab['is_selected']) || (isset($menu_context['current_subsection']) && $menu_context['current_subsection'] == $sa))
  134. {
  135. $selected_tab = $tab;
  136. $tab_context['tabs'][$sa]['is_selected'] = true;
  137. }
  138. }
  139. }
  140. // Show an icon and/or a help item?
  141. 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']))
  142. {
  143. if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']))
  144. echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
  145. elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
  146. echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
  147. if (!empty($selected_tab['help']) || !empty($tab_context['help']))
  148. 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>';
  149. echo $tab_context['title'];
  150. }
  151. else
  152. {
  153. echo '
  154. ', $tab_context['title'];
  155. }
  156. echo '
  157. </h3>
  158. </div>';
  159. }
  160. // Shall we use the tabs? Yes, it's the only known way!
  161. if (!empty($selected_tab['description']) || !empty($tab_context['description']))
  162. echo '
  163. <p class="description">
  164. ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
  165. </p>';
  166. // Print out all the items in this tab (if any).
  167. if (!empty($context['tabs']))
  168. {
  169. // The admin tabs.
  170. echo '
  171. <div id="adm_submenus">
  172. <ul class="dropmenu">';
  173. foreach ($tab_context['tabs'] as $sa => $tab)
  174. {
  175. if (!empty($tab['disabled']))
  176. continue;
  177. if (!empty($tab['is_selected']))
  178. {
  179. echo '
  180. <li>
  181. <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>
  182. </li>';
  183. }
  184. else
  185. echo '
  186. <li>
  187. <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>
  188. </li>';
  189. }
  190. // the end of tabs
  191. echo '
  192. </ul>
  193. </div>';
  194. }
  195. }
  196. ?>