You are here

function devel_menu in Devel 5

Same name and namespace in other branches
  1. 6 devel.module \devel_menu()
  2. 7 devel.module \devel_menu()

Implementation of hook_menu().

File

./devel.module, line 46

Code

function devel_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'devel/cache/clear',
      'title' => t('Empty cache'),
      'callback' => 'devel_cache_clear',
      'access' => user_access('access devel information'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'devel/rebuild_node_comment_statistics',
      'title' => t('Rebuild node_comment_statistics table'),
      'callback' => 'devel_rebuild_node_comment_statistics_page',
      'access' => user_access('access devel information'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'devel/queries',
      'title' => t('Database queries'),
      'callback' => 'devel_queries',
      'access' => user_access('access devel information'),
    );
    $items[] = array(
      'path' => 'devel/queries/empty',
      'title' => t('Empty database queries'),
      'callback' => 'devel_queries_empty',
      'access' => user_access('access devel information'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'devel/reference',
      'title' => t('function reference'),
      'callback' => 'devel_function_reference',
      'access' => user_access('access devel information'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'devel/reinstall',
      'title' => t('Reinstall modules'),
      'callback' => 'devel_reinstall',
      'access' => user_access('access devel information'),
      'type' => MENU_CALLBACK,
    );
    if (module_exists('menu')) {
      $items[] = array(
        'path' => 'devel/menu/reset',
        'title' => t('Reset menus'),
        'callback' => 'drupal_get_form',
        'callback arguments' => 'devel_menu_reset_form',
        'access' => user_access('access devel information'),
        'type' => MENU_CALLBACK,
      );
    }
    $items[] = array(
      'path' => 'devel/php',
      'title' => t('Execute PHP Code'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'devel_execute_form',
      ),
      'access' => user_access('execute php code'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'devel/variable',
      'title' => t('Variable editor'),
      'callback' => 'devel_variable_page',
      'access' => user_access('access devel information'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'devel/variable/edit',
      'title' => t('Variable editor'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'devel_variable_edit',
      ),
      'access' => user_access('access devel information'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'devel/variable/delete',
      'title' => t('Variable editor'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'devel_variable_delete',
      ),
      'access' => user_access('access devel information'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'devel/session',
      'title' => t('Session viewer'),
      'callback' => 'devel_session',
      'access' => user_access('access devel information'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'devel/switch',
      'title' => t('Switch user'),
      'callback' => 'devel_switch_user',
      'access' => user_access('switch users'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/settings/devel',
      'title' => t('Devel'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'devel_admin_settings',
      ),
      'access' => user_access('administer site configuration'),
      'type' => MENU_NORMAL_ITEM,
    );
  }
  else {

    // Include the class so calls to krumo() succeed.
    has_krumo();
    if (is_numeric(arg(1))) {
      if (arg(0) == 'node') {
        $items[] = array(
          'path' => 'node/' . arg(1) . '/devel/load',
          'title' => t('Dev load'),
          'callback' => 'devel_load_object',
          'callback arguments' => array(
            'node',
            arg(1),
          ),
          'access' => user_access('access devel information'),
          'type' => MENU_LOCAL_TASK,
        );
        $items[] = array(
          'path' => 'node/' . arg(1) . '/devel/render',
          'title' => t('Dev render'),
          'callback' => 'devel_render_object',
          'callback arguments' => array(
            'node',
            arg(1),
          ),
          'access' => user_access('access devel information'),
          'type' => MENU_LOCAL_TASK,
        );
      }
      elseif (arg(0) == 'user') {
        $items[] = array(
          'path' => 'user/' . arg(1) . '/load',
          'title' => t('Dev load'),
          'callback' => 'devel_load_object',
          'callback arguments' => array(
            'user',
            arg(1),
          ),
          'access' => user_access('access devel information'),
          'type' => MENU_LOCAL_TASK,
        );
      }
    }

    /*
     * TODO: this is very naive. We don't preserve views arguments like other tabs.
     * I tried, but it I started borrowing too much Views menu code. I think
     * we need some refactoring in Views!
     * I concluded that the result and 'render' operations yield no useful info
     * so no tabs exist for those.
     */
    if (module_exists('views_ui')) {
      $urls = views_get_all_urls();
      foreach ($urls as $view_name => $url) {
        $items[] = array(
          'path' => "{$url}/devel/load",
          'title' => t('Dev load'),
          'callback' => 'devel_load_object',
          'callback arguments' => array(
            'view',
            $view_name,
          ),
          'access' => user_access('administer views'),
          'type' => MENU_LOCAL_TASK,
          'weight' => 8,
        );
        $items[] = array(
          'path' => "{$url}/devel/queries",
          'title' => t('Dev queries'),
          'callback' => 'devel_views_object',
          'callback arguments' => array(
            'queries',
            $view_name,
          ),
          'access' => user_access('administer views'),
          'type' => MENU_LOCAL_TASK,
          'weight' => 9,
        );
        $items[] = array(
          'path' => "{$url}/devel/items",
          'title' => t('Dev items'),
          'callback' => 'devel_views_object',
          'callback arguments' => array(
            'items',
            $view_name,
          ),
          'access' => user_access('administer views'),
          'type' => MENU_LOCAL_TASK,
          'weight' => 10,
        );
      }
    }
    if (user_access('access devel information')) {
      drupal_add_css(drupal_get_path('module', 'devel') . '/devel.css');
      drupal_add_js(drupal_get_path('module', 'devel') . '/devel.js');
      $path = './' . drupal_get_path('module', 'devel') . '/FirePHPCore/lib/FirePHPCore/fb.php';
      if (file_exists($path)) {
        include_once $path;
      }
    }
  }
  return $items;
}