|
@@ -3,42 +3,42 @@
|
|
|
|
|
|
/**
|
|
|
* @file
|
|
|
- * Creates a menu bar.
|
|
|
+ * Creates a simplemenu.
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
* Implementation of hook_menu().
|
|
|
*/
|
|
|
-function menu_bar_menu($may_cache) {
|
|
|
+function simplemenu_menu($may_cache) {
|
|
|
$items = array();
|
|
|
|
|
|
if ($may_cache) {
|
|
|
$items[] = array(
|
|
|
- 'path' => 'menu_bar/menu',
|
|
|
- 'access' => user_access('view menu bar'),
|
|
|
- 'callback' => 'menu_bar_get_menu',
|
|
|
+ 'path' => 'simplemenu/menu',
|
|
|
+ 'access' => user_access('view simplemenu'),
|
|
|
+ 'callback' => 'simplemenu_get_menu',
|
|
|
'type' => MENU_CALLBACK
|
|
|
);
|
|
|
|
|
|
$items[] = array(
|
|
|
- 'path' => 'admin/settings/menu_bar',
|
|
|
- 'title' => t('Menu bar'),
|
|
|
- 'description' => t('Set which menus should appear in the menu bar.'),
|
|
|
+ 'path' => 'admin/settings/simplemenu',
|
|
|
+ 'title' => t('SimpleMenu'),
|
|
|
+ 'description' => t('Select the menu to display.'),
|
|
|
'callback' => 'drupal_get_form',
|
|
|
- 'callback arguments' => array('menu_bar_admin_settings'),
|
|
|
- 'access' => user_access('administer menu bar')
|
|
|
+ 'callback arguments' => array('simplemenu_admin_settings'),
|
|
|
+ 'access' => user_access('administer simplemenu')
|
|
|
);
|
|
|
}
|
|
|
|
|
|
// We put this in !$may_cache so it's only added once per request
|
|
|
- elseif (user_access('view menu bar')) {
|
|
|
- $path = drupal_get_path('module', 'menu_bar');
|
|
|
- drupal_add_css($path .'/menu_bar.css');
|
|
|
+ elseif (user_access('view simplemenu')) {
|
|
|
+ $path = drupal_get_path('module', 'simplemenu');
|
|
|
+ drupal_add_css($path .'/simplemenu.css');
|
|
|
|
|
|
// 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
|
|
|
- drupal_add_js(array('menu_bar' => array('basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q='))), 'setting');
|
|
|
- drupal_add_js($path .'/menu_bar.js');
|
|
|
+ drupal_add_js(array('simplemenu' => array('basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q='))), 'setting');
|
|
|
+ drupal_add_js($path .'/simplemenu.js');
|
|
|
}
|
|
|
|
|
|
return $items;
|
|
@@ -47,26 +47,26 @@ function menu_bar_menu($may_cache) {
|
|
|
/**
|
|
|
* Implementation of hook_perm().
|
|
|
*/
|
|
|
-function menu_bar_perm() {
|
|
|
- return array('view menu bar', 'administer menu bar');
|
|
|
+function simplemenu_perm() {
|
|
|
+ return array('view simplemenu', 'administer simplemenu');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Menu bar settings page
|
|
|
+ * SimpleMenu settings page.
|
|
|
*/
|
|
|
-function menu_bar_admin_settings() {
|
|
|
- $form['default_menu']['menu_bar_menu'] = array(
|
|
|
+function simplemenu_admin_settings() {
|
|
|
+ $form['default_menu']['simplemenu_menu'] = array(
|
|
|
'#type' => 'select',
|
|
|
'#title' => t('Menu'),
|
|
|
'#options' => menu_get_root_menus(),
|
|
|
- '#default_value' => variable_get('menu_bar_menu', 1),
|
|
|
- '#description' => t('Select the menu to display in the menu bar.')
|
|
|
+ '#default_value' => variable_get('simplemenu_menu', 1),
|
|
|
+ '#description' => t('Select the menu to display.')
|
|
|
);
|
|
|
|
|
|
- $form['default_menu']['menu_bar_devel'] = array(
|
|
|
+ $form['default_menu']['simplemenu_devel'] = array(
|
|
|
'#type' => 'checkbox',
|
|
|
'#title' => t('Add devel module links'),
|
|
|
- '#default_value' => variable_get('menu_bar_devel', 0),
|
|
|
+ '#default_value' => variable_get('simplemenu_devel', 0),
|
|
|
'#description' => t('Add devel module links for those users that can access the devel module.')
|
|
|
);
|
|
|
|
|
@@ -75,12 +75,12 @@ function menu_bar_admin_settings() {
|
|
|
|
|
|
/**
|
|
|
* Return a list of devel module links if the module is enabled
|
|
|
- * and the user has access to this module
|
|
|
+ * and the user has access to this module.
|
|
|
*/
|
|
|
-function menu_bar_get_devel() {
|
|
|
+function simplemenu_get_devel() {
|
|
|
$output = '';
|
|
|
|
|
|
- if (variable_get('menu_bar_devel', 0) && module_exists('devel')) {
|
|
|
+ if (variable_get('simplemenu_devel', 0) && module_exists('devel')) {
|
|
|
if (user_access('access devel information')) {
|
|
|
$links[] = l('module settings', 'admin/settings/devel');
|
|
|
$links[] = l('empty cache', 'devel/cache/clear');
|
|
@@ -105,11 +105,11 @@ function menu_bar_get_devel() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Custom implementation of menu_tree()
|
|
|
+ * 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 menu_bar_menu_tree($pid = 1) {
|
|
|
+function simplemenu_menu_tree($pid = 1) {
|
|
|
$menu = menu_get_menu();
|
|
|
$output = '';
|
|
|
|
|
@@ -117,7 +117,7 @@ function menu_bar_menu_tree($pid = 1) {
|
|
|
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, menu_bar_theme_menu_tree($mid), count($children) == 0);
|
|
|
+ $output .= theme('menu_item', $mid, simplemenu_theme_menu_tree($mid), count($children) == 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -125,25 +125,25 @@ function menu_bar_menu_tree($pid = 1) {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Custom implementation of theme_menu_tree() to call our custom menu above
|
|
|
+ * Custom implementation of theme_menu_tree() to call our custom menu above.
|
|
|
*/
|
|
|
-function menu_bar_theme_menu_tree($pid = 1) {
|
|
|
- if ($tree = menu_bar_menu_tree($pid)) {
|
|
|
+function simplemenu_theme_menu_tree($pid = 1) {
|
|
|
+ if ($tree = simplemenu_menu_tree($pid)) {
|
|
|
return '<ul>'. $tree .'</ul>';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * AJAX menu callback to return an HTML list of links for a given menu
|
|
|
+ * AJAX menu callback to return an HTML list of links for a given menu.
|
|
|
*/
|
|
|
-function menu_bar_get_menu() {
|
|
|
- $menu = menu_bar_menu_tree(variable_get('menu_bar_menu', 1));
|
|
|
+function simplemenu_get_menu() {
|
|
|
+ $menu = simplemenu_menu_tree(variable_get('simplemenu_menu', 1));
|
|
|
|
|
|
if (!$menu) {
|
|
|
- $menu = '<li><a href="'. url('admin/settings/menu_bar') .'">'. t('No menu items found. Try a different menu as the default.') .'</a></li>';
|
|
|
+ $menu = '<li><a href="'. url('admin/settings/simplemenu') .'">'. t('No menu items found. Try a different menu as the default.') .'</a></li>';
|
|
|
}
|
|
|
|
|
|
- print menu_bar_get_devel();
|
|
|
+ print simplemenu_get_devel();
|
|
|
print $menu;
|
|
|
exit;
|
|
|
}
|