function gplib_version_check in Grammar Parser Library 7.2
Same name and namespace in other branches
- 7 gplib.module \gplib_version_check()
Indicates whether the installed library code is of the correct version.
Parameters
boolean $display_message: Whether to display a message.
Return value
boolean Whether a valid version was found.
File
- ./
gplib.module, line 72 - Provides primary Drupal hook implementations.
Code
function gplib_version_check($display_message = TRUE) {
$version_state = variable_get('gplib_grammar_parser_version_state', GPLIB_VERSION_UNKNOWN);
if ($version_state == GPLIB_VERSION_VALID) {
return TRUE;
}
$info = gplib_libraries_info();
$info = $info['grammar_parser'];
$keys = array_keys($info['versions']);
$version = reset($keys);
$url = l('here', $info['download url']);
$message = t('Install version @version of the Grammar Parser library code (from !url) in a libraries directory such as "sites/all/libraries." For easy installation, use the drush make file in the Grammar Parser Library project.', array(
'@version' => $version,
'!url' => $url,
));
if ($version_state == GPLIB_VERSION_INVALID) {
if ($display_message) {
drupal_set_message($message, 'error');
}
return FALSE;
}
$info = libraries_detect('grammar_parser');
if ($info === FALSE || empty($info['version']) || !version_compare($info['version'], $version, '>=')) {
if ($display_message) {
drupal_set_message($message, 'error');
}
variable_set('gplib_grammar_parser_version_state', $info === FALSE ? GPLIB_VERSION_UNKNOWN : GPLIB_VERSION_INVALID);
return FALSE;
}
variable_set('gplib_grammar_parser_version_state', GPLIB_VERSION_VALID);
return TRUE;
}