function _geshifilter_check_geshi_library in GeSHi Filter for syntax highlighting 5.2
Same name and namespace in other branches
- 6 geshifilter.inc \_geshifilter_check_geshi_library()
Helper function for loading/checking the GeSHi library v 1.0.x (if not already) Returns an array with keys 'success', 'loaded' and 'message'
9 calls to _geshifilter_check_geshi_library()
- geshifilter_admin_general_settings_validate in ./
geshifilter.admin.inc - Validation function for admin settings
- geshifilter_geshi_process in ./
geshifilter.pages.inc - geshifilter wrapper for GeSHi processing.
- geshifilter_requirements in ./
geshifilter.module - Implementation of hook_requirements()
- _geshifilter_admin_filter_conflicts in ./
geshifilter.conflicts.inc - Menu callback for filter conflicts page
- _geshifilter_admin_general_settings in ./
geshifilter.admin.inc - Menu callback for admin settings
File
- ./
geshifilter.inc, line 11
Code
function _geshifilter_check_geshi_library($use_cache = TRUE, $geshi_dir = NULL, $load_when_found = TRUE) {
static $geshi_library_cache = NULL;
if ($use_cache && $geshi_library_cache !== NULL) {
// get from cache
$geshi_library = $geshi_library_cache;
}
else {
// initialisation
$geshi_library = array(
'success' => NULL,
'loaded' => FALSE,
'message' => NULL,
);
// no cache
if (!$geshi_dir) {
$geshi_dir = _geshifilter_get_geshi_dir();
}
if (!is_dir($geshi_dir)) {
$geshi_library['success'] = FALSE;
$geshi_library['message'] = t('GeSHi library error: %dir is not a directory.', array(
'%dir' => $geshi_dir,
));
}
elseif (is_file($geshi_dir . '/geshi.php')) {
// GeSHi 1.0.x found (probably, we can only be sure by loading it)
$geshi_library['success'] = TRUE;
if ($load_when_found) {
require_once $geshi_dir . '/geshi.php';
// check version
$geshi_library_version = explode('.', GESHI_VERSION);
if (!($geshi_library_version[0] == '1' && $geshi_library_version[1] == '0')) {
$geshi_library['success'] = FALSE;
$geshi_library['loaded'] = FALSE;
$geshi_library['message'] = t('GeSHi library error: The detected version of GeSHi library (%version) is not supported. A version from the 1.0.x branch is required.', array(
'%version' => GESHI_VERSION,
));
}
else {
$geshi_library['loaded'] = TRUE;
}
}
}
else {
$geshi_library['success'] = FALSE;
$geshi_library['message'] = t('GeSHi library error: Could not find a known version of the GeSHi library at directory %dir.', array(
'%dir' => $geshi_dir,
));
}
// store in cache if needed
if ($use_cache) {
$geshi_library_cache = $geshi_library;
}
}
return $geshi_library;
}