'. t('We love the Drupal 6 menu system!.') .'

'; return $output; } } /** * Implementation of hook_perm(). */ function adminpw_perm() { return array('adminpw superuser'); } /** * Implementation of hook_menu(). */ function adminpw_menu() { $items['admin/settings/adminpw'] = array( 'access arguments' => array('administer site configuration'), 'page callback' => 'drupal_get_form', 'page arguments' => array('adminpw_settings'), 'title' => 'Nothing to see here', ); return $items; } /** * Implementation of hook_menu_alter(). */ function adminpw_menu_alter($menu) { // Run as part of the shutdown, otherwise the router is not fully built. register_shutdown_function('_adminpw_rebuild_links'); } function _adminpw_rebuild_links() { // Get the newly rebuilt menu $menu = menu_router_build(); // Add normal and suggested items as links. $menu_links = array(); foreach ($menu as $path => $item) { if (($item['type'] != MENU_CALLBACK) && ($item['_parts'][0] == 'admin') && (count($item['_parts']) > 1)) { // TODO: handle local tasks with wildcards if (!strpos($path, '%')) { $item = _adminpw_link_build($item); $menu_links[$path] = $item; $sort[$path] = $item['_number_parts']; } } } if ($menu_links) { // Make sure no child comes before its parent. array_multisort($sort, SORT_NUMERIC, $menu_links); foreach ($menu_links as $item) { $existing_item = db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", $item['link_path'], 'admin_menu')); // TODO handle the case when something changes - e.g. router item title. if (!$existing_item) { menu_link_save($item); } } } } function _adminpw_link_build($item) { $item['module'] = 'admin_menu'; $item += array( 'menu_name' => 'admin_menu', 'link_title' => $item['title'], 'link_path' => $item['path'], 'hidden' => 0, 'options' => array('alter' => TRUE), ); $item['options'] += empty($item['description']) ? array() : array('attributes' => array('title' => $item['description'])); return $item; } /** * Implementation of hook_translated_menu_link_alter(). */ function adminpw_translated_menu_link_alter(&$item, $map) { static $acccess_all; if (!isset($acccess_all)) { // Please, put some real check here. $acccess_all = module_exists('devel'); } if (!$acccess_all) { return; } if ($item['menu_name'] == 'admin_menu' && !$item['access']) { $item['access'] = TRUE; // Prepare for http://drupal.org/node/266596 if (!isset($item['localized_options'])) { _menu_item_localize($item, $map, TRUE); } } } /** * Menu callback to configure module settings. */ function adminpw_settings() { $form['basic'] = array( '#type' => 'fieldset', '#title' => t('General settings'), ); return system_settings_form($form); } function adminpw_block($op = 'list', $delta = 0) { if ($op == 'list') { $blocks = array(); $blocks['adminpw']['info'] = t('Admin menu demo block'); // Menu blocks can't be cached because each menu item can have // a custom access callback. menu.inc manages its own caching. $blocks['adminpw']['cache'] = BLOCK_NO_CACHE; return $blocks; } elseif ($op == 'view' && user_access('adminpw superuser')) { $data['subject'] = ''; $data['content'] = menu_tree_output(menu_tree_all_data('admin_menu')); return $data; } }