'admin/settings/simplemenu', 'title' => t('SimpleMenu'), 'description' => t('Select the menu to display.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('simplemenu_admin_settings'), 'access' => user_access('administer simplemenu') ); } return $items; } /** * Implementation of hook_footer() */ function simplemenu_footer() { global $theme; $exclusions = variable_get('simplemenu_exclusions', array()); if (user_access('view simplemenu') && !$exclusions[$theme]) { global $theme, $custom_theme; $path = drupal_get_path('module', 'simplemenu'); drupal_add_css($path .'/simplemenu.css'); if (variable_get('simplemenu_rtl', 0)) { drupal_add_css($path .'/simplemenu_rtl.css'); } $settings = array( // pass in base path to the JS file // url() handles appending ?q= but in this case, we need to pass in the variable so the menus work when mod_rewrite is off 'basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q='), 'placement' => variable_get('simplemenu_element_method', 'prepend'), 'element' => variable_get('simplemenu_element', 'body') ); drupal_add_js(array('simplemenu' => $settings), 'setting'); drupal_add_js('var simplemenu = '. drupal_to_js(simplemenu_get_menu()) .';', 'inline'); drupal_add_js($path .'/simplemenu.js'); } } /** * Implementation of hook_perm(). */ function simplemenu_perm() { return array('view simplemenu', 'administer simplemenu'); } /** * SimpleMenu settings page. */ function simplemenu_admin_settings() { $form['default_menu']['simplemenu_menu'] = array( '#type' => 'select', '#title' => t('Menu'), '#options' => menu_parent_options(0), '#default_value' => variable_get('simplemenu_menu', 1), '#description' => t('Select the menu to display.') ); $form['default_menu']['simplemenu_devel'] = array( '#type' => 'checkbox', '#title' => t('Add devel module links'), '#default_value' => variable_get('simplemenu_devel', 0), '#description' => t('Add devel module links for those users that can access the devel module.') ); $form['default_menu']['advanced'] = array( '#type' => 'fieldset', '#title' => t('Advanced settings'), '#collapsible' => TRUE, '#collapsed' => TRUE ); $form['default_menu']['advanced']['simplemenu_element'] = array( '#type' => 'textfield', '#title' => t('CSS selector to attach menu to'), '#default_value' => variable_get('simplemenu_element', 'body'), '#description' => t('A valid CSS selector to attach the menu to. Example: body, #primary, div.my-class'), '#required' => TRUE ); $form['default_menu']['advanced']['simplemenu_element_method'] = array( '#type' => 'radios', '#title' => 'Attach method', '#options' => drupal_map_assoc(array('prepend', 'append', 'replace')), '#default_value' => variable_get('simplemenu_element_method', 'prepend'), '#description' => t('Choose how the menu should be attached to the above selector.'), '#required' => TRUE ); $form['default_menu']['advanced']['simplemenu_exclusions'] = array( '#type' => 'checkboxes', '#title' => 'Theme exclusions', '#options' => drupal_map_assoc(array_keys(list_themes())), '#default_value' => variable_get('simplemenu_exclusions', array()), '#description' => t('Select which themes to not display the menu. Use this when you have a theme that displays its own admin navigation.'), ); $form['default_menu']['advanced']['simplemenu_rtl'] = array( '#type' => 'checkbox', '#title' => t('Set menu orientation to RTL'), '#default_value' => variable_get('simplemenu_rtl', 0), '#description' => t('Set the orientation of the menu to RTL for Eastern languages.') ); return system_settings_form($form); } /** * Render an HTML list of links for a given menu. */ function simplemenu_get_menu() { $output = ''; $menu = simplemenu_menu_tree(variable_get('simplemenu_menu', 1)); if (!$menu) { $menu = '
  • '. t('No menu items found. Try a different menu as the default.') .'
  • '; } $output .= simplemenu_get_devel(); $output .= $menu; return $output; } /** * Custom implementation of menu_tree(). * We want to retrieve the entire menu structure for a given menu, * regardless of whether or not the menu item is expanded or not. */ function simplemenu_menu_tree($pid = 1) { $menu = menu_get_menu(); $output = ''; if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) { foreach ($menu['visible'][$pid]['children'] as $mid) { $type = isset($menu['visible'][$mid]['type']) ? $menu['visible'][$mid]['type'] : NULL; $children = isset($menu['visible'][$mid]['children']) ? $menu['visible'][$mid]['children'] : NULL; $output .= theme('menu_item', $mid, simplemenu_theme_menu_tree($mid), count($children) == 0); } } return $output; } /** * Custom implementation of theme_menu_tree() to call our custom menu above. */ function simplemenu_theme_menu_tree($pid = 1) { if ($tree = simplemenu_menu_tree($pid)) { return ''; } } /** * Return a list of devel module links if the module is enabled * and the user has access to this module. */ function simplemenu_get_devel() { $output = ''; if (variable_get('simplemenu_devel', 0) && module_exists('devel')) { if (user_access('access devel information')) { $links[] = l('Devel settings', 'admin/settings/devel', array('title' => t('Adjust module settings for devel module'))); $links[] = l('Empty cache', 'devel/cache/clear', array('title' => t('Clear the database cache tables which store page, menu, node, and variable caches.')), drupal_get_destination()); $links[] = l('Phpinfo()', 'admin/logs/status/php'); $links[] = l('Function reference', 'devel/reference', array('title' => t('View a list of currently defined user functions with documentation links'))); $links[] = l('Reinstall modules', 'devel/reinstall', array('title' => t('Re-run hook_install() for a given module'))); $links[] = l('Reset menus', 'devel/menu/reset', array('title' => t('Resets all menu items to their default settings'))); $links[] = l('Variable editor', 'devel/variable', array('title' => t('Edit and delete site variables'))); $links[] = l('Session viewer', 'devel/session', array('title' => t('List the contents of $_SESSION'))); if (function_exists('devel_node_access_perm') && user_access(DNA_ACCESS_VIEW)) { // True only if devel_node_access enabled. $links[] = l('Node access summary', 'devel/node_access/summary'); } $output = '
  • '. t('Devel module') .'
  • '; } } return $output; }