'. 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 ($path == '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:
'. 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() { $items = array(); $items['admin/settings/geshifilter'] = array( 'title' => 'GeSHi Filter', 'description' => 'Configure the GeSHi filter.', 'file' => 'geshifilter.admin.inc', 'page callback' => 'drupal_get_form', 'page arguments' => array('geshifilter_admin_general_settings'), 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); $items['admin/settings/geshifilter/general'] = array( 'title' => 'General settings', 'description' => 'General GeSHi filter settings.', 'access arguments' => array('administer site configuration'), 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items['admin/settings/geshifilter/filterconflicts'] = array( 'title' => 'Filter conflicts', 'description' => 'Information on possible conflicts with other filters.', 'file' => 'geshifilter.conflicts.inc', 'page callback' => 'geshifilter_admin_filter_conflicts', 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, 'weight' => 10, ); // language settings $items['admin/settings/geshifilter/languages'] = array( 'title' => 'Languages', 'description' => 'Enable the desired languages and configure their settings.', 'file' => 'geshifilter.admin.inc', 'page callback' => 'drupal_get_form', 'page arguments' => array('geshifilter_admin_per_language_settings'), 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, ); $items['admin/settings/geshifilter/languages/enabled'] = array( 'title' => 'Enabled', 'description' => 'Show the enabled languages', 'access arguments' => array('administer site configuration'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 3, ); $items['admin/settings/geshifilter/languages/all'] = array( 'title' => 'All', 'description' => 'Show all the available languages', 'page arguments' => array('geshifilter_admin_per_language_settings', 4), 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); $items['admin/settings/geshifilter/languages/disabled'] = array( 'title' => 'Disabled', 'description' => 'Show the disabled languages', 'page arguments' => array('geshifilter_admin_per_language_settings', 4), 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, 'weight' => 6, ); // Callback for generating CSS rules. $items['admin/settings/geshifilter/generate_css'] = array( 'page callback' => 'geshifilter_generate_language_css_rules', 'access arguments' => array('administer site configuration'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implementation of hook_init(). */ function geshifilter_init() { // 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) { drupal_add_css(file_directory_path() .'/geshifilter-languages.css'); } drupal_add_css(drupal_get_path('module', 'geshifilter') .'/geshifilter.css'); } /** * Implementation of hook_filter_tips(). */ function geshifilter_filter_tips($delta, $format, $long = FALSE) { require_once drupal_get_path('module', 'geshifilter') .'/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 drupal_get_path('module', 'geshifilter') .'/geshifilter.pages.inc'; return _geshifilter_prepare($format, $text); case 'process': require_once drupal_get_path('module', 'geshifilter') .'/geshifilter.pages.inc'; return _geshifilter_process($format, $text); case 'settings': require_once drupal_get_path('module', 'geshifilter') .'/geshifilter.admin.inc'; return _geshifilter_filter_settings($format); case 'no cache': return FALSE; default: return $text; } } /** * Implementation of hook_theme(). */ function geshifilter_theme() { return array( 'geshifilter_per_language_settings' => array( 'arguments' => array('form' => NULL) ) ); } /** * Implementation of hook_requirements(). */ function geshifilter_requirements($phase) { $requirements = array(); if ($phase == 'runtime') { require_once drupal_get_path('module', 'geshifilter') .'/geshifilter.inc'; // 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 require_once drupal_get_path('module', 'geshifilter') .'/geshifilter.conflicts.inc'; 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 generating the CSS rules for the syntax highlighting */ function geshifilter_generate_language_css_rules() { require_once drupal_get_path('module', 'geshifilter') .'/geshifilter.admin.inc'; drupal_set_header("Content-type: text/css"); $output = _geshifilter_generate_languages_css_rules(); print($output); exit(); }