'Hook Menu', 'page callback' => 'hook_menu_convert', 'access arguments' => TRUE, ); return $items; } function hook_menu_convert() { $output = ''; $modules = module_list(); // unset($modules['hook_menu'], $modules['system'], $modules['user'], $modules['node']); $router = array( 'page callback', 'page arguments', 'access callback', 'access arguments', 'file', 'theme callback', 'type', 'load arguments', 'delivery callback', 'context', 'file path', 'theme arguments', 'title', 'description', ); $link = array( 'position', 'weight', 'menu_name', ); foreach ($modules as $module) { echo $module; $function = $module . '_menu'; if (function_exists($function)) { $menu = $function(); $router_menu = array(); $link_menu = array(); foreach ($menu as $path => $item) { if ((!isset($item['type']) || $item['type'] == MENU_NORMAL_ITEM) && strpos($path, '%') === FALSE) { foreach ($router as $i) { if (isset($item[$i])) { $router_menu[$path][$i] = $item[$i]; } } $router_menu[$path]['type'] = 'MENU_CALLBACK'; $link_menu[$path] = array( 'link_path' => $path, 'link_title' => $item['title'], ); foreach ($link as $i) { if (isset($item[$i])) { $link_menu[$path][$i] = $item[$i]; } } } else { $router_menu[$path] = $item; switch ($router_menu[$path]['type']) { case MENU_LOCAL_TASK: $router_menu[$path]['type'] = 'MENU_LOCAL_TASK'; break; case MENU_DEFAULT_LOCAL_TASK: $router_menu[$path]['type'] = 'MENU_DEFAULT_LOCAL_TASK'; break; case MENU_CALLBACK: $router_menu[$path]['type'] = 'MENU_CALLBACK'; break; } } } $output .= '

' . $module . '

'; $output .= '
';
      $output .= 'function ' . $module . "_menu() {\n  \$items = array();\n";
      foreach ($router_menu as $path => $item) {
         $output .= '  $items[\'' . $path . '\'] = '. str_replace(array("'MENU_LOCAL_TASK'", "'MENU_DEFAULT_LOCAL_TASK'", "'MENU_CALLBACK'"), array('MENU_LOCAL_TASK', 'MENU_DEFAULT_LOCAL_TASK', 'MENU_CALLBACK'), views_var_export($item, '  ')) . ";\n";
      }
      
      $output .= '}
--------------------------'; $output .= '
$links = ' .  views_var_export($link_menu) . ';
foreach ($links as $link) {
  menu_link_save($link);
}
'; } } return $output; } function views_var_export($var, $prefix = '', $init = TRUE) { if (is_array($var)) { if (empty($var)) { $output = 'array()'; } else { $output = "array(\n"; foreach ($var as $key => $value) { $output .= " '$key' => " . views_var_export($value, ' ', FALSE) . ",\n"; } $output .= ')'; } } else if (is_bool($var)) { $output = $var ? 'TRUE' : 'FALSE'; } else if (is_string($var) && strpos($var, "\n") !== FALSE) { // Replace line breaks in strings with a token for replacement // at the very end. This protects multi-line strings from // unintentional indentation. $var = str_replace("\n", "***BREAK***", $var); $output = var_export($var, TRUE); } else { $output = var_export($var, TRUE); } if ($prefix) { $output = str_replace("\n", "\n$prefix", $output); } if ($init) { $output = str_replace("***BREAK***", "\n", $output); } return $output; }