You are here

function glossary_menu in Glossary 5

Same name and namespace in other branches
  1. 5.2 glossary.module \glossary_menu()
  2. 6 glossary.module \glossary_menu()
  3. 7 glossary.module \glossary_menu()

Implementation of hook_menu().

File

./glossary.module, line 58

Code

function glossary_menu($may_cache) {
  if ($may_cache) {
    $items[] = array(
      'path' => 'glossary/search',
      'title' => t('Glossary Search'),
      'callback' => 'glossary_search_results',
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'glossary/clearcache',
      'title' => t('Glossary'),
      'callback' => 'glossary_clearcache',
      'access' => user_access('administer filters'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'glossary',
      'title' => t('Glossary'),
      'callback' => 'glossary_page',
      'access' => user_access('access content'),
      'type' => MENU_SUGGESTED_ITEM,
    );
    $items[] = array(
      'path' => 'admin/settings/glossary',
      'title' => t('Glossary Settings'),
      'callback' => 'glossary_settings_page',
      'description' => t('Select how you want the Glossary module to behave.'),
      'access' => user_access('administer filters'),
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'admin/settings/glossary/general',
      'title' => t('General'),
      'description' => t('General settings'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'glossary_general_settings_form',
      ),
      'access' => user_access('administer filters'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -3,
    );
    $items[] = array(
      'path' => 'admin/settings/glossary/alphabet',
      'title' => t('Alphabet'),
      'access' => user_access('administer filters'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'glossary_alphabet_form',
      ),
      'description' => t('Alphabet settings.'),
      'type' => MENU_LOCAL_TASK,
      'weight' => 0,
    );
    $items[] = array(
      'path' => 'admin/settings/glossary/clearcache',
      'title' => t('Clear cache'),
      'access' => user_access('administer filters'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'glossary_clearcache_form',
      ),
      'description' => t('Clear the filter cache.'),
      'type' => MENU_LOCAL_TASK,
      'weight' => 0,
    );
  }
  else {
    drupal_add_css(drupal_get_path('module', 'glossary') . '/glossary.css');
    $result = db_query('SELECT format, name FROM {filter_formats}');
    while ($filter = db_fetch_array($result)) {
      $enabled = db_result(db_query("SELECT COUNT(delta) FROM {filters} WHERE format=%d AND module='glossary'", $filter['format']));
      if ($enabled || !variable_get('glossary_hide_menus', false)) {
        $items[] = array(
          'path' => 'admin/settings/glossary/filter/' . $filter['format'],
          'title' => $filter['name'],
          'access' => user_access('administer filters'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'glossary_filter_form',
            $filter['format'],
          ),
          'description' => t('Settings for the !name input format.', array(
            '!name' => $filter['name'],
          )),
          'weight' => 2,
          'type' => MENU_LOCAL_TASK,
        );
      }
    }
    if (arg(2)) {
      $items[] = array(
        'path' => 'glossary/term/' . arg(2),
        'title' => t('Glossary'),
        'callback' => 'glossary_term',
        'callback arguments' => array(
          arg(2),
        ),
        'access' => user_access('access content'),
        'type' => MENU_CALLBACK,
      );
    }
  }
  return $items;
}