nice_menus.module 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <?php
  2. /**
  3. * @file
  4. * Module to enable CSS dropdown and flyout menus.
  5. *
  6. * Maintainer: Addison Berry (add1sun)
  7. * Originally written by Jake Gordon (jakeg)
  8. */
  9. /**
  10. * Implements hook_help().
  11. */
  12. function nice_menus_help($path, $arg) {
  13. $output = '';
  14. switch ($path) {
  15. case 'admin/config/modules#description':
  16. $output .= t('Make drop down/flyout CSS menus for site and admin menus.');
  17. break;
  18. case 'admin/config/nice_menus':
  19. $output .= t('<p>This is a simple module that enables the site to have drop down/flyout CSS menus for site and admin navigation.</p><p>Remember to activate and configure the menu blocks in !link</p>', array('!link' => l('admin/structure/block', 'admin/structure/block')));
  20. break;
  21. }
  22. return $output;
  23. }
  24. /**
  25. * Implements hook_form_alter().
  26. */
  27. function nice_menus_form_alter(&$form, $form_state, $form_id) {
  28. switch ($form_id) {
  29. case 'system_theme_settings':
  30. // This is a global setting, so only insert the field
  31. // on the global settings page.
  32. if (arg(4) && arg(4) != 'global') {
  33. return;
  34. }
  35. // Have to add a custom submit handler since this form doesn't use
  36. // the standard system submit handler.
  37. $form['#submit'][] = 'nice_menus_system_theme_settings_submit';
  38. // Add global theme setting for a custom CSS file.
  39. $form['nice_menus_custom_css'] = array(
  40. '#type' => 'textfield',
  41. '#title' => t('Path to custom Nice menus CSS file'),
  42. '#description' => t('To override the default Nice menus CSS layout, enter the path to your custom CSS file. It should be a relative path from the root of your Drupal install (e.g. sites/all/themes/example/mymenu.css).'),
  43. '#default_value' => variable_get('nice_menus_custom_css', ''),
  44. // Field appears below submit buttons without this -- yucky.
  45. '#weight' => 0,
  46. );
  47. break;
  48. }
  49. }
  50. /**
  51. * Records the Nice menu custom CSS file per theme.
  52. */
  53. function nice_menus_system_theme_settings_submit($form, &$form_state) {
  54. variable_set('nice_menus_custom_css', $form_state['values']['nice_menus_custom_css']);
  55. }
  56. /**
  57. * Implements hook_menu().
  58. */
  59. function nice_menus_menu() {
  60. $items['admin/config/user-interface/nice_menus'] = array(
  61. 'title' => 'Nice menus',
  62. 'description' => 'Configure Nice menus.',
  63. 'page callback' => 'drupal_get_form',
  64. 'page arguments' => array('nice_menus_admin_settings'),
  65. 'access arguments' => array('administer site configuration'),
  66. 'type' => MENU_NORMAL_ITEM,
  67. );
  68. return $items;
  69. }
  70. /**
  71. * Settings form as implemented by hook_menu
  72. */
  73. function nice_menus_admin_settings($form, &$form_state) {
  74. $form['nice_menus_number'] = array(
  75. '#type' => 'textfield',
  76. '#description' => t('The total number of independent Nice menus blocks you want. Enter a number between 0 and 99. If you set this to 0, you will have no blocks created but you can still use the Nice menus theme functions directly in your theme.'),
  77. '#default_value' => variable_get('nice_menus_number', '2'),
  78. '#size' => 2,
  79. );
  80. $form['nice_menus_js'] = array(
  81. '#type' => 'checkbox',
  82. '#title' => t('Use JavaScript'),
  83. '#description' => t('This will add Superfish Jquery to Nice menus. This is required for Nice menus to work properly in Internet Explorer.'),
  84. '#default_value' => variable_get('nice_menus_js', 1),
  85. );
  86. $form['nice_menus_sf_options'] = array(
  87. '#type' => 'fieldset',
  88. '#title' => t('Advanced: Superfish options'),
  89. '#description' => t('You can change the default Superfish options by filling out the desired values here. These only take effect if the Use JavaScript box above is checked.'),
  90. '#collapsible' => TRUE,
  91. '#collapsed' => TRUE,
  92. );
  93. $form['nice_menus_sf_options']['nice_menus_sf_delay'] = array(
  94. '#type' => 'textfield',
  95. '#title' => t('Mouse delay'),
  96. '#description' => t('The delay in milliseconds that the mouse can remain outside a submenu without it closing.'),
  97. '#default_value' => variable_get('nice_menus_sf_delay', 800),
  98. '#size' => 5,
  99. );
  100. $form['nice_menus_sf_options']['nice_menus_sf_speed'] = array(
  101. '#type' => 'select',
  102. '#title' => t('Animation speed'),
  103. '#multiple' => FALSE,
  104. '#description' => t('Speed of the menu open/close animation.'),
  105. '#options' => array(
  106. 'slow' => t('slow'),
  107. 'normal' => t('normal'),
  108. 'fast' => t('fast'),
  109. ),
  110. '#default_value' => variable_get('nice_menus_sf_speed', 1),
  111. );
  112. // Custom validation to make sure the user is entering numbers.
  113. $form['#validate'][] = 'nice_menus_settings_validate';
  114. return system_settings_form($form);
  115. }
  116. /**
  117. * Custom validation for the settings form.
  118. */
  119. function nice_menus_settings_validate($form, &$form_state) {
  120. $number = $form_state['values']['nice_menus_number'];
  121. // Check to make sure it is a number and that is a maximum of 2 digits.
  122. if (!is_numeric($number) || strlen($number) > 2) {
  123. form_set_error('nice_menus_number', t('You must enter a number from 0 to 99.'));
  124. }
  125. }
  126. /**
  127. * Implements hook_init().
  128. *
  129. * We are adding the JavaScript and CSS here rather than theme_nice_menu
  130. * because when block caching is enabled none of it would get fired
  131. * and the menus are unstyled.
  132. */
  133. function nice_menus_init() {
  134. // Add Superfish JavaScript, if enabled.
  135. if (variable_get('nice_menus_js', 1) == 1) {
  136. // The script, from http://users.tpg.com.au/j_birch/plugins/superfish.
  137. drupal_add_js(drupal_get_path('module', 'nice_menus') . '/superfish/js/superfish.js');
  138. // Add the Superfish options variables.
  139. drupal_add_js(array(
  140. 'nice_menus_options' => array(
  141. 'delay' => variable_get('nice_menus_sf_delay', 800),
  142. 'speed' => variable_get('nice_menus_sf_speed', 1),
  143. ),
  144. ), array('type' => 'setting', 'scope' => JS_DEFAULT));
  145. // Add the bgIframe plugin.
  146. drupal_add_js(drupal_get_path('module', 'nice_menus') . '/superfish/js/jquery.bgiframe.min.js');
  147. // Add the HoverIntent plugin.
  148. drupal_add_js(drupal_get_path('module', 'nice_menus') . '/superfish/js/jquery.hoverIntent.minified.js');
  149. // The Nice menus implementation.
  150. drupal_add_js(drupal_get_path('module', 'nice_menus') . '/nice_menus.js');
  151. }
  152. // Add main CSS functionality.
  153. drupal_add_css(drupal_get_path('module', 'nice_menus') . '/nice_menus.css', array('group' => CSS_DEFAULT, 'basename' => 'nice_menus.css'));
  154. // Add custom CSS layout if specified.
  155. if ($custom = variable_get('nice_menus_custom_css', '')) {
  156. drupal_add_css($custom, array('group' => CSS_DEFAULT, 'basename' => 'nice_menus_custom.css'));
  157. }
  158. // Fall back to default layout.
  159. else {
  160. drupal_add_css(drupal_get_path('module', 'nice_menus') . '/nice_menus_default.css', array('group' => CSS_DEFAULT, 'basename' => 'nice_menus_default.css'));
  161. }
  162. }
  163. /**
  164. * Implements hook_block_info().
  165. */
  166. function nice_menus_block_info() {
  167. $blocks = array();
  168. for ($i = 1; $i <= variable_get('nice_menus_number', '2'); $i++) {
  169. $blocks[$i]['info'] = variable_get('nice_menus_name_' . $i, 'Nice menu ' . $i) . ' (Nice menu)';
  170. // We have too many things changing per user, per page to cache.
  171. $blocks[$i]['cache'] = DRUPAL_NO_CACHE;
  172. }
  173. return $blocks;
  174. }
  175. /**
  176. * Implements hook_block_configure().
  177. */
  178. function nice_menus_block_configure($delta) {
  179. $form['nice_menus_name_' . $delta] = array(
  180. '#type' => 'textfield',
  181. '#title' => t('Menu Name'),
  182. '#default_value' => variable_get('nice_menus_name_' . $delta, 'Nice menu ' . $delta),
  183. );
  184. $form['nice_menus_menu_' . $delta] = array(
  185. '#type' => 'select',
  186. '#title' => t('Menu Parent'),
  187. '#description' => t('The menu parent from which to show a Nice menu.'),
  188. '#default_value' => variable_get('nice_menus_menu_' . $delta, 'navigation:0'),
  189. '#options' => menu_get_menus(),
  190. );
  191. $form['nice_menus_depth_' . $delta] = array(
  192. '#type' => 'select',
  193. '#title' => t('Menu Depth'),
  194. '#description' => t('The depth of the menu, i.e. the number of child levels starting with the parent selected above. Leave set to -1 to display all children and use 0 to display no children.'),
  195. '#default_value' => variable_get('nice_menus_depth_' . $delta, -1),
  196. '#options' => drupal_map_assoc(range(-1, 5)),
  197. );
  198. $form['nice_menus_type_' . $delta] = array(
  199. '#type' => 'select',
  200. '#title' => t('Menu Style'),
  201. '#description' => t('right: menu items are listed on top of each other and expand to the right') . '<br />' . t('left: menu items are listed on top of each other and expand to the left') . '<br />' . t('down: menu items are listed side by side and expand down'),
  202. '#default_value' => variable_get('nice_menus_type_' . $delta, 'right'),
  203. '#options' => drupal_map_assoc(array('right', 'left', 'down')),
  204. );
  205. return $form;
  206. }
  207. /**
  208. * Implements hook_block_save().
  209. */
  210. function nice_menus_block_save($delta, $edit) {
  211. variable_set('nice_menus_name_' . $delta, $edit['nice_menus_name_' . $delta]);
  212. variable_set('nice_menus_menu_' . $delta, $edit['nice_menus_menu_' . $delta]);
  213. variable_set('nice_menus_depth_' . $delta, $edit['nice_menus_depth_' . $delta]);
  214. variable_set('nice_menus_type_' . $delta, $edit['nice_menus_type_' . $delta]);
  215. }
  216. /**
  217. * Implements hook_block_view().
  218. */
  219. function nice_menus_block_view($delta) {
  220. // Build the Nice menu for the block.
  221. list($menu_name) = explode(':', variable_get('nice_menus_menu_' . $delta, 'navigation:0'));
  222. $direction = variable_get('nice_menus_type_' . $delta, 'right');
  223. $depth = variable_get('nice_menus_depth_' . $delta, '-1');
  224. if ($output = theme('nice_menus', array('id' => $delta, 'menu_name' => $menu_name, 'direction' => $direction, 'depth' => $depth))) {
  225. $block['content'] = $output['content'];
  226. if (variable_get('nice_menus_type_' . $delta, 'right') == 'down') {
  227. $class = 'nice-menu-hide-title';
  228. }
  229. else {
  230. $class = 'nice-menu-show-title';
  231. }
  232. // If we're building the navigation block
  233. // use the same block title logic as menu module.
  234. global $user;
  235. if ($output['subject'] == t('navigation') && $user->uid) {
  236. $subject = $user->name;
  237. }
  238. else {
  239. $subject = $output['subject'];
  240. }
  241. $block['subject'] = '<span class="' . $class . '">' . check_plain($subject) . '</span>';
  242. }
  243. else {
  244. $block['content'] = FALSE;
  245. }
  246. return $block;
  247. }
  248. /**
  249. * Implements hook_theme().
  250. */
  251. function nice_menus_theme() {
  252. return array(
  253. 'nice_menus_tree' => array(
  254. 'variables' => array('menu_name' => NULL, 'mlid' => NULL, 'depth' => -1, 'menu' => NULL),
  255. ),
  256. 'nice_menus_build' => array(
  257. 'variables' => array('menu' => NULL, 'depth' => -1, 'trail' => NULL),
  258. ),
  259. 'nice_menus' => array(
  260. 'variables' => array('id' => NULL, 'menu_name' => NULL, 'mlid' => NULL, 'direction' => 'right', 'depth' => -1, 'menu' => NULL),
  261. ),
  262. 'nice_menus_main_menu' => array(
  263. 'variables' => array('direction' => 'down', 'depth' => -1),
  264. ),
  265. 'nice_menus_secondary_menu' => array(
  266. 'variables' => array('direction' => 'down', 'depth' => -1),
  267. ),
  268. );
  269. }
  270. /**
  271. * Builds the active trail from the page's menu data.
  272. *
  273. * @param $page_menu
  274. * The menu data for a page.
  275. *
  276. * @return
  277. * An array of parent menu item ids.
  278. */
  279. function nice_menus_build_page_trail($page_menu) {
  280. $trail = array();
  281. foreach ($page_menu as $item) {
  282. if ($item['link']['in_active_trail']) {
  283. $trail[] = $item['link']['mlid'];
  284. }
  285. if ($item['below']) {
  286. $trail = array_merge($trail, nice_menus_build_page_trail($item['below']));
  287. }
  288. }
  289. return $trail;
  290. }
  291. /**
  292. * Builds the final Nice menu.
  293. *
  294. * @param $menu_name
  295. * The top-level menu name that contains the menu to use (e.g. navigation
  296. * or main-menu) for Drupal menus. For custom $menus this is just the
  297. * name for menu display.
  298. * @param $mlid
  299. * The menu ID from which to start building the items, i.e. the parent
  300. * of the displayed menu.
  301. * @param $depth
  302. * The number of children levels to display. Use -1 to display all children
  303. * and use 0 to display no children.
  304. * @param $menu
  305. * Optional. A custom menu array to use for theming -- it should have
  306. * the same structure as that returned by menu_tree_all_data().
  307. *
  308. * @return
  309. * An HTML string of properly nested Nice menu lists.
  310. */
  311. function theme_nice_menus_tree($variables) {
  312. $menu_name = $variables['menu_name'];
  313. $mlid = $variables['mlid'];
  314. $depth = $variables['depth'];
  315. $menu = $variables['menu'];
  316. // Load the full menu array.
  317. $menu = isset($menu) ? $menu : menu_tree_all_data($menu_name);
  318. if (isset($menu)) {
  319. $page_menu = menu_tree_page_data($menu_name);
  320. $trail = nice_menus_build_page_trail($page_menu);
  321. unset($page_menu);
  322. }
  323. // Allow i18n module to translate strings where available.
  324. if (module_exists('i18n_menu')) {
  325. $menu = i18n_menu_localize_tree($menu);
  326. }
  327. // Assume depth == 0 by default, overriden if mlid is specified.
  328. $parent_depth = 0;
  329. // For custom $menus and menus built all the way from the top-level we
  330. // don't need to "create" the specific sub-menu and we need to get the title
  331. // from the $menu_name since there is no "parent item" array.
  332. // Create the specific menu if we have a mlid.
  333. if (!empty($mlid)) {
  334. // Load the parent menu item.
  335. $item = menu_link_load($mlid);
  336. $title = check_plain($item['title']);
  337. // The depth for our parent item, if it exists.
  338. $parent_depth = ($item['depth']) ? $item['depth'] : 0;
  339. // Narrow down the full menu to the specific sub-tree we need.
  340. for ($p = 1; $p < 10; $p++) {
  341. if ($sub_mlid = $item["p$p"]) {
  342. $subitem = menu_link_load($sub_mlid);
  343. // Menu sets these ghetto-ass keys in _menu_tree_check_access().
  344. $menu = $menu[(50000 + $subitem['weight']) . ' ' . $subitem['title'] . ' ' . $subitem['mlid']]['below'];
  345. }
  346. }
  347. }
  348. // Otherwise just set a title and move on.
  349. else {
  350. // Get the title from the DB since we don't have it in the $menu.
  351. $result = db_query("SELECT title FROM {menu_custom} WHERE menu_name = :menu_name", array(':menu_name' => $menu_name))->fetchField();
  352. $title = check_plain($result);
  353. }
  354. $output['content'] = '';
  355. $output['subject'] = $title;
  356. if ($menu) {
  357. // Set the total menu depth counting from this parent if we need it.
  358. $depth = ($depth > 0) ? ($parent_depth + $depth) : $depth;
  359. $output['content'] .= theme('nice_menus_build', array('menu' => $menu, 'depth' => $depth, 'trail' => $trail));
  360. }
  361. return $output;
  362. }
  363. /**
  364. * Helper function that builds the nested lists of a Nice menu.
  365. *
  366. * @param $menu
  367. * Menu array from which to build the nested lists.
  368. * @param $depth
  369. * The number of children levels to display. Use -1 to display all children
  370. * and use 0 to display no children.
  371. * @param $trail
  372. * An array of parent menu items.
  373. */
  374. function theme_nice_menus_build($variables) {
  375. $menu = $variables['menu'];
  376. $depth = $variables['depth'];
  377. $trail = $variables['trail'];
  378. $output = '';
  379. // Prepare to count the links so we can mark first, last, odd and even.
  380. $index = 0;
  381. $count = 0;
  382. foreach ($menu as $menu_count) {
  383. if ($menu_count['link']['hidden'] == 0) {
  384. $count++;
  385. }
  386. }
  387. // Get to building the menu.
  388. foreach ($menu as $menu_item) {
  389. $mlid = $menu_item['link']['mlid'];
  390. // Check to see if it is a visible menu item.
  391. if (!isset($menu_item['link']['hidden']) || $menu_item['link']['hidden'] == 0) {
  392. // Check our count and build first, last, odd/even classes.
  393. $index++;
  394. $first_class = $index == 1 ? ' first ' : '';
  395. $oddeven_class = $index % 2 == 0 ? ' even ' : ' odd ';
  396. $last_class = $index == $count ? ' last ' : '';
  397. // Build class name based on menu path
  398. // e.g. to give each menu item individual style.
  399. // Strip funny symbols.
  400. $clean_path = str_replace(array('http://', 'www', '<', '>', '&', '=', '?', ':', '.'), '', $menu_item['link']['href']);
  401. // Convert slashes to dashes.
  402. $clean_path = str_replace('/', '-', $clean_path);
  403. $class = 'menu-path-' . $clean_path;
  404. if ($trail && in_array($mlid, $trail)) {
  405. $class .= ' active-trail';
  406. }
  407. // If it has children build a nice little tree under it.
  408. if ((!empty($menu_item['link']['has_children'])) && (!empty($menu_item['below'])) && $depth != 0) {
  409. // Keep passing children into the function 'til we get them all.
  410. if ($menu_item['link']['depth'] <= $depth || $depth == -1) {
  411. $children = array(
  412. '#theme' => 'nice_menus_build',
  413. '#prefix' => '<ul>',
  414. '#suffix' => '</ul>',
  415. '#menu' => $menu_item['below'],
  416. '#depth' => $depth,
  417. '#trail' => $trail,
  418. );
  419. }
  420. else {
  421. $children = '';
  422. }
  423. // Set the class to parent only of children are displayed.
  424. $parent_class = ($children && ($menu_item['link']['depth'] <= $depth || $depth == -1)) ? 'menuparent ' : '';
  425. $element = array(
  426. '#below' => $children,
  427. '#title' => $menu_item['link']['link_title'],
  428. '#href' => $menu_item['link']['href'],
  429. '#localized_options' => $menu_item['link']['localized_options'],
  430. '#attributes' => array(
  431. 'class' => array('menu-' . $mlid, $parent_class, $class, $first_class, $oddeven_class, $last_class),
  432. ),
  433. );
  434. $variables['element'] = $element;
  435. $output .= theme('menu_link', $variables);
  436. }
  437. else {
  438. $element = array(
  439. '#below' => '',
  440. '#title' => $menu_item['link']['link_title'],
  441. '#href' => $menu_item['link']['href'],
  442. '#localized_options' => $menu_item['link']['localized_options'],
  443. '#attributes' => array(
  444. 'class' => array('menu-' . $mlid, $class, $first_class, $oddeven_class, $last_class),
  445. ),
  446. );
  447. $variables['element'] = $element;
  448. $output .= theme('menu_link', $variables);
  449. }
  450. }
  451. }
  452. return $output;
  453. }
  454. /**
  455. * Theme function to allow any menu tree to be themed as a Nice menu.
  456. *
  457. * @param $id
  458. * The Nice menu ID.
  459. * @param $menu_name
  460. * The top parent menu name from which to build the full menu.
  461. * @param $mlid
  462. * The menu ID from which to build the displayed menu.
  463. * @param $direction
  464. * Optional. The direction the menu expands. Default is 'right'.
  465. * @param $depth
  466. * The number of children levels to display. Use -1 to display all children
  467. * and use 0 to display no children.
  468. * @param $menu
  469. * Optional. A custom menu array to use for theming --
  470. * it should have the same structure as that returned
  471. * by menu_tree_all_data(). Default is the standard menu tree.
  472. *
  473. * @return
  474. * An HTML string of Nice menu links.
  475. */
  476. function theme_nice_menus($variables) {
  477. $output = array(
  478. 'content' => '',
  479. 'subject' => '',
  480. );
  481. $id = $variables['id'];
  482. $menu_name = $variables['menu_name'];
  483. $mlid = $variables['mlid'];
  484. $direction = $variables['direction'];
  485. $depth = $variables['depth'];
  486. $menu = $variables['menu'];
  487. if ($menu_tree = theme('nice_menus_tree', array('menu_name' => $menu_name, 'mlid' => $mlid, 'depth' => $depth, 'menu' => $menu))) {
  488. if ($menu_tree['content']) {
  489. $output['content'] = '<ul class="nice-menu nice-menu-' . $direction . '" id="nice-menu-' . $id . '">' . $menu_tree['content'] . '</ul>' . "\n";
  490. $output['subject'] = $menu_tree['subject'];
  491. }
  492. }
  493. return $output;
  494. }
  495. /**
  496. * Theme the main menu as a Nice menu.
  497. *
  498. * @param $direction
  499. * Optional. The direction the menu expands. Default is 'down'.
  500. * @param $depth
  501. * The number of children levels to display. Use -1 to display all children
  502. * and use 0 to display no children.
  503. *
  504. * @return
  505. * An HTML string of Nice main menu links.
  506. */
  507. function theme_nice_menus_main_menu($variables) {
  508. $direction = $variables['direction'];
  509. $depth = $variables['depth'];
  510. $menu_name = variable_get('menu_main_links_source', 'main-menu');
  511. $output = theme('nice_menus', array('id' => 0, 'menu_name' => $menu_name, 'mlid' => 0, 'direction' => $direction, 'depth' => $depth));
  512. return $output['content'];
  513. }
  514. /**
  515. * Theme the secondary menu as a Nice menu.
  516. *
  517. * @param $direction
  518. * Optional. The direction the menu expands. Default is 'down'.
  519. * @param $depth
  520. * The number of children levels to display. Use -1 to display all children
  521. * and use 0 to display no children.
  522. *
  523. * @return
  524. * An HTML string of Nice secondary menu links.
  525. */
  526. function theme_nice_menus_secondary_menu($variables) {
  527. $direction = $variables['direction'];
  528. $depth = $variables['depth'];
  529. $menu_name = variable_get('menu_secondary_links_source', 'user-menu');
  530. $output = theme('nice_menus', array('id' => 0, 'menu_name' => $menu_name, 'mlid' => 0, 'direction' => $direction, 'depth' => $depth));
  531. return $output['content'];
  532. }