You are here

function hierarchical_select_menu in Hierarchical Select 5.3

Same name and namespace in other branches
  1. 5 hierarchical_select.module \hierarchical_select_menu()
  2. 5.2 hierarchical_select.module \hierarchical_select_menu()
  3. 6.3 hierarchical_select.module \hierarchical_select_menu()
  4. 7.3 hierarchical_select.module \hierarchical_select_menu()

Implementation of hook_menu().

File

./hierarchical_select.module, line 20
This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.

Code

function hierarchical_select_menu($may_cache) {
  if ($may_cache) {
    $items[] = array(
      'path' => 'hierarchical_select_json',
      'callback' => 'hierarchical_select_json',
      'type' => MENU_CALLBACK,
      // TODO: Needs improvements. Ideally, this would inherit the permissions
      // of the form the Hierarchical Select was in.
      'access' => TRUE,
    );
    $items[] = array(
      'path' => 'admin/settings/hierarchical_select',
      'title' => t('Hierarchical Select'),
      'description' => t('Configure site-wide settings for the Hierarchical Select form element.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'hierarchical_select_admin_settings',
      ),
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'admin/settings/hierarchical_select/settings',
      'title' => t('Site-wide settings'),
      'weight' => -10,
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/hierarchical_select/configs',
      'title' => t('Configurations'),
      'description' => t('All available Hierarchical Select configurations.'),
      'callback' => 'hierarchical_select_admin_configs',
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/hierarchical_select/implementations',
      'title' => t('Implementations'),
      'description' => t('Features of each Hierarchical Select implementation.'),
      'callback' => 'hierarchical_select_admin_implementations',
      'type' => MENU_LOCAL_TASK,
    );
  }
  else {

    // Work-around for bug in Drupal 5 (fixed in Drupal 5.8).
    // See http://drupal.org/node/109459.
    global $user;
    if (!isset($user->theme)) {
      $user->theme = variable_get('theme_default', 'garland');
    }
    if (arg(0) == 'admin' && arg(1) == 'settings' && arg(2) == 'hierarchical_select') {
      require_once drupal_get_path('module', 'hierarchical_select') . '/hierarchical_select.admin.inc';
      if (in_array(arg(3), array(
        'export',
        'import',
      ))) {
        require_once drupal_get_path('module', 'hierarchical_select') . '/includes/common.inc';
        $items[] = array(
          'path' => 'admin/settings/hierarchical_select/export/' . arg(4),
          'title' => t('Export'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'hierarchical_select_admin_export',
            arg(4),
          ),
          'type' => MENU_LOCAL_TASK,
        );
        $items[] = array(
          'path' => 'admin/settings/hierarchical_select/import/' . arg(4),
          'title' => t('Import'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'hierarchical_select_admin_import',
            arg(4),
          ),
          'type' => MENU_LOCAL_TASK,
        );
      }
    }
  }
  return $items;
}