You are here

function geshifilter_menu in GeSHi Filter for syntax highlighting 5.2

Same name and namespace in other branches
  1. 5 geshifilter.module \geshifilter_menu()
  2. 6 geshifilter.module \geshifilter_menu()
  3. 7 geshifilter.module \geshifilter_menu()

Implementation of hook_menu().

File

./geshifilter.module, line 73
An input filter for syntax highlighting using the GeSHi library.

Code

function geshifilter_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/settings/geshifilter',
      'title' => t('GeSHi Filter'),
      'description' => t('Configure the GeSHi filter.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'geshifilter_admin_general_settings',
      ),
      'access' => user_access('administer site configuration'),
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'admin/settings/geshifilter/general',
      'title' => t('General settings'),
      'description' => t('General GeSHi filter settings.'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/geshifilter/filterconflicts',
      'title' => t('Filter conflicts'),
      'description' => t('Information on possible conflicts with other filters.'),
      'callback' => 'geshifilter_admin_filter_conflicts',
      'type' => MENU_LOCAL_TASK,
      'weight' => 10,
    );

    // language settings
    $items[] = array(
      'path' => 'admin/settings/geshifilter/languages',
      'title' => t('Languages'),
      'description' => t('Enable the desired languages and configure their settings.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'geshifilter_admin_per_language_settings',
      ),
      'access' => user_access('administer site configuration'),
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/geshifilter/languages/enabled',
      'title' => t('Enabled'),
      'description' => t('Show the enabled languages'),
      'weight' => 3,
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/geshifilter/languages/all',
      'title' => t('All'),
      'description' => t('Show all the available languages'),
      'weight' => 1,
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/geshifilter/languages/disabled',
      'title' => t('Disabled'),
      'description' => t('Show the disabled languages'),
      'weight' => 6,
      'type' => MENU_LOCAL_TASK,
    );

    // clear available languages cache
    $items[] = array(
      'path' => 'geshifilter/clearavailablelanguagescache',
      'title' => t('Clear available languages cache'),
      'callback' => 'geshifilter_clear_available_languages_cache',
      'type' => MENU_CALLBACK,
      'access' => user_access('administer site configuration'),
    );

    // callback for generating CSS rules
    $items[] = array(
      'path' => 'admin/settings/geshifilter/generate_css',
      'callback' => 'geshifilter_generate_language_css_rules',
      'type' => MENU_CALLBACK,
      'access' => user_access('administer site configuration'),
    );
  }
  else {

    // Since the filtered content is cached, it is not possible to know on which
    // pages the css file is actually needed. Thus it is included on all pages.
    if (variable_get('geshifilter_css_mode', GESHIFILTER_CSS_INLINE) == GESHIFILTER_CSS_CLASSES_AUTOMATIC) {
      if ($stylesheet_file = variable_get('geshifilter_languages_css', NULL)) {
        drupal_add_css($stylesheet_file);
      }
    }
    drupal_add_css(drupal_get_path('module', 'geshifilter') . '/geshifilter.css');
  }
  return $items;
}