You are here

function geshifilter_requirements in GeSHi Filter for syntax highlighting 6

Same name and namespace in other branches
  1. 8.2 geshifilter.install \geshifilter_requirements()
  2. 8 geshifilter.install \geshifilter_requirements()
  3. 5.2 geshifilter.module \geshifilter_requirements()
  4. 7 geshifilter.module \geshifilter_requirements()

Implementation of hook_requirements().

File

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

Code

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 <a href="!geshisettings">GeSHi settings</a>.', 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 <a href="!geshi">GeSHi filter</a> or change the <a href="!filesystem">download mode</a> 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;
}