'. t('The GeSHi filter module provides a filter for syntax highlighting of inline source code or blocks of source code based on the PHP library !GeSHi.', array('!GeSHi' => l('GeSHi (Generic Syntax Highlighter)', 'http://qbnz.com/highlighter/'))) .'

'; if ($section == 'admin/help#geshifilter') { $output .= '

'. t('The GeSHi filter module for Drupal requires the GeSHi library (version 1.0.x) to work. The GeSHi filter is actually just a Drupal wrapper module around the GeSHi library. Because of drupal.org repository policies however, the GeSHi library is not included in the GeSHi filter package, so you should download and install the GeSHi library separately.', array( '!repositorypolicies' => url('http://drupal.org/node/66113'), '!geshi' => url('http://qbnz.com/highlighter/'), )) .'

'; $output .= t('

Quick overview of how to set up and use the GeSHi filter:

', array( '!geshifilter_settings' => url('admin/settings/geshifilter'), '!geshifilter_languages' => url('admin/settings/geshifilter/languages/all'), '!inputformats' => l(t('input formats'), 'admin/settings/filters'), '!filterconflicts' => l(t('filter conflicts'), 'admin/settings/geshifilter/filterconflicts'), '!filtertips' => l(t('filter tips'), 'filter/tips'), )); } return $output; break; case 'admin/settings/geshifilter/languages': case 'admin/settings/geshifilter/languages/enabled': case 'admin/settings/geshifilter/languages/all': case 'admin/settings/geshifilter/languages/disabled': $output = '

'. t('Here you can enable/disable the desired languages to use. It is suggested to disable languages that are not relevant for you site not only to avoid unnecessary cluttering of the GeSHi filter configuration pages and the !filtertips, but also to make the GeSHi filter processing lighter.', array('!filtertips' => l(t('filter tips'), 'filter/tips'))) .'

'; if (!geshifilter_use_format_specific_options()) { $output .= '

'. t('You can also define the language specific tags here.') .'

'; } return $output; break; } } /** * Implementation of hook_menu(). */ 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; } /** * Implementation of hook_filter_tips(). */ function geshifilter_filter_tips($delta, $format, $long = false) { require_once('geshifilter.filtertips.inc'); return _geshifilter_filter_tips($delta, $format, $long); } /** * Implementation of hook_filter(). */ function geshifilter_filter($op, $delta = 0, $format = -1, $text = '') { switch ($op) { case 'list': return array('GeSHi filter'); case 'description': return t('Enables syntax highlighting of inline/block source code using the GeSHi engine'); case 'prepare': require_once('geshifilter.pages.inc'); return _geshifilter_prepare($format, $text); case 'process': require_once('geshifilter.pages.inc'); return _geshifilter_process($format, $text); case 'settings': require_once('geshifilter.admin.inc'); return _geshifilter_filter_settings($format); case 'no cache': return false; default: return $text; } } /** * Menu callback for admin settings */ function geshifilter_admin_general_settings() { require_once('geshifilter.admin.inc'); return _geshifilter_admin_general_settings(); } /** * Menu callback for per language settings */ function geshifilter_admin_per_language_settings($view = 'enabled') { require_once('geshifilter.admin.inc'); return _geshifilter_admin_per_language_settings($view); } /** * Menu callback for filter conflicts page */ function geshifilter_admin_filter_conflicts($check_only=FALSE) { require_once('geshifilter.conflicts.inc'); return _geshifilter_admin_filter_conflicts($check_only); } /** * Implementation of hook_requirements() */ function geshifilter_requirements($phase) { require_once('geshifilter.inc'); $requirements = array(); if ($phase == 'runtime') { // check if GeSHi library is available $geshi_library = _geshifilter_check_geshi_library(); if (!$geshi_library['loaded']) { $requirements[] = array( 'title' => 'GeSHi filter', 'value' => t('GeSHi library not found.'), 'description' => t('You should install the GeSHi library and set its path in the GeSHi settings.', array('!geshisettings' => url('admin/settings/geshifilter'))), 'severity' => REQUIREMENT_ERROR, ); } else { $requirements[] = array( 'title' => 'GeSHi filter', 'value' => t('Found GeSHi library version %version', array('%version' => GESHI_VERSION)), // GESHI_VERSION is defined in GeSHi library 'severity' => REQUIREMENT_OK, ); } // Warn if GeSHi filter is configured to automatically managed external stylesheet when it's not possible if (variable_get('geshifilter_css_mode', GESHIFILTER_CSS_INLINE) == GESHIFILTER_CSS_CLASSES_AUTOMATIC && !_geshifilter_managed_external_stylesheet_possible()) { $requirements[] = array( 'title' => 'GeSHi filter CSS mode', 'value' => t('GeSHi filter can not automatically manage an external style sheet when the download method is private.'), 'severity' => REQUIREMENT_ERROR, 'description' => t('Change the CSS mode of the GeSHi filter or change the download mode to public.', array('!geshi' => url('admin/settings/geshifilter'), '!filesystem' => url('admin/settings/file-system'))), ); } // check for filter conflicts if (geshifilter_admin_filter_conflicts(TRUE) > 0) { $requirements[] = array( 'title' => 'GeSHi filter', 'value' => t('Some filter conflicts were detected.'), 'description' => l(t('View and resolve the detected filter conflicts'), 'admin/settings/geshifilter/filterconflicts'), 'severity' => REQUIREMENT_ERROR, ); } } return $requirements; } /** * Helper function for checking if an automatically managed style sheet is possible * * @return boolean indicating if an automatically managed style sheet is possible */ function _geshifilter_managed_external_stylesheet_possible() { $directory = file_directory_path(); return is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC); } /** * Callback function for clearing the available languages cache */ function geshifilter_clear_available_languages_cache() { variable_del('geshifilter_available_languages_cache'); drupal_set_message('Flushed cache of available languages.'); drupal_goto(); } /** * Callback function for generating the CSS rules for the syntax highlighting */ function geshifilter_generate_language_css_rules() { require_once('geshifilter.admin.inc'); drupal_set_header("Content-type: text/css"); $output = _geshifilter_generate_languages_css_rules(); print($output); exit(); }