'activemenu/menu', 'title' => t('activemenu'), 'access' => user_access('access content'), 'type' => MENU_CALLBACK, 'callback' => 'activemenu_js' ); } else { activemenu_load(); } $items = array_merge($items, module_invoke_all('activemenu_menu', $may_cache)); return $items; } /** * Load needed files. */ function activemenu_load() { static $loaded = FALSE; if (!$loaded) { $path = drupal_get_path('module', 'activemenu'); jstools_add_js($path . '/activemenu.js'); $activemenu = module_invoke_all('activemenu'); if (count($activemenu)) { drupal_add_js(array('activemenu' => $activemenu), 'setting'); } $loaded = TRUE; } } /** * Load available includes by module. */ function activemenu_init() { jstools_modules_includes('activemenu'); } function activemenu_js() { if ($path = activemenu_get_request_path()) { $menu = menu_get_menu(); $pid = $menu['path index'][$path]; print drupal_to_js(array('status' => TRUE, 'content' => theme('menu_tree', $pid))); } exit(); } function activemenu_footer() { global $theme; $file = drupal_get_path('module', 'activemenu') .'/theme/'. $theme .'.css'; if (file_exists($file)) { drupal_add_css($file); } drupal_add_css($path .'/activemenu.css', 'theme'); } /** * Parse the incoming request, and extract the correct path */ function activemenu_get_request_path(){ if (isset($_POST['path'])) { $path = $_POST['path']; if ($source = drupal_lookup_path('source', $path)) { $path = $source; } return $path; } return FALSE; }