'activemenu/menu', 'title' => t('activemenu'), 'access' => user_access('access content'), 'type' => MENU_CALLBACK, 'callback' => 'activemenu_js' ); } else { jstools_modules_includes('activemenu'); 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; } } /** * Menu callback. Output a themed menu tree for a requested menu item. */ 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(); } /** * Implementation of hook_footer(). * * Add a theme-specific css file if needed. Pass Javascript data to the browser. */ function activemenu_footer() { global $theme; $file = drupal_get_path('module', 'activemenu') .'/theme/'. $theme .'.css'; if (file_exists($file)) { drupal_add_css($file); } else { drupal_add_css(drupal_get_path('module', 'activemenu') .'/activemenu.css', 'theme'); } } /** * Read the incoming request and return the correct path. */ function activemenu_get_request_path(){ return isset($_POST['path']) ? drupal_get_normal_path($_POST['path']) : FALSE; }