Same name and namespace in other branches
- 2.0.x colorbox.install \colorbox_requirements() 1 comment
- 7.x-1.x colorbox.install \colorbox_requirements() 1 comment
- 8.x-1.x colorbox.install \colorbox_requirements() 1 comment
Implements hook_requirements().
File
-
./
colorbox.install, line 21
Code
function colorbox_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
$t = get_t();
// The colorbox library is required.
$library = libraries_detect('colorbox');
$error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
$error_message = isset($library['error message']) ? $library['error message'] : '';
if (empty($library['installed'])) {
$requirements['colorbox_plugin'] = array(
'title' => $t('Colorbox plugin'),
'value' => $t('@e: At least @a', array(
'@e' => $error_type,
'@a' => COLORBOX_MIN_PLUGIN_VERSION,
)),
'severity' => REQUIREMENT_ERROR,
'description' => $t('!error You need to download the !colorbox, extract the archive and place the colorbox directory in the %path directory on your server.', array(
'!error' => $error_message,
'!colorbox' => l($t('Colorbox plugin'), $library['download url']),
'%path' => 'sites/all/libraries',
)),
);
}
elseif (version_compare($library['version'], COLORBOX_MIN_PLUGIN_VERSION, '>=')) {
$requirements['colorbox_plugin'] = array(
'title' => $t('Colorbox plugin'),
'severity' => REQUIREMENT_OK,
'value' => $library['version'],
);
}
else {
$requirements['colorbox_plugin'] = array(
'title' => $t('Colorbox plugin'),
'value' => $t('At least @a', array(
'@a' => COLORBOX_MIN_PLUGIN_VERSION,
)),
'severity' => REQUIREMENT_ERROR,
'description' => $t('You need to download a later version of the !colorbox and replace the old version located in the %path directory on your server.', array(
'!colorbox' => l($t('Colorbox plugin'), $library['download url']),
'%path' => $library['library path'],
)),
);
}
// The DOMPurify library is recommended.
$library = libraries_detect('DOMPurify');
$error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
$error_message = isset($library['error message']) ? $library['error message'] : '';
if (empty($library['installed'])) {
if (empty(variable_get('colorbox_dompurify_hide_warning', 0))) {
$requirements['dompurify'] = array(
'title' => $t('DOMPurify library'),
'value' => $t('@e: At least @a', array(
'@e' => $error_type,
'@a' => COLORBOX_DOMPURIFY_MIN_PLUGIN_VERSION,
)),
'severity' => REQUIREMENT_WARNING,
'description' => $t('!error The Colorbox module uses this library to sanitize HTML captions. ' . 'Without this library, all captions will be treated as plain text. ' . 'If you intend to have HTML captions in Colorbox content, ' . 'download the !library, extract the archive, and place the ' . 'purify.min.js file in the %path directory on your server. ' . 'To avoid potential security issues, please only install purify.min.js and not ' . 'any other files from the archive.<br /><br />' . 'If you do not intend to use HTML captions, you can suppress this warning on the ' . '!colorbox_config_page .', array(
'!error' => $error_message,
'!library' => l($t('DOMPurify library'), $library['download url']),
'!colorbox_config_page' => l($t('Colorbox configuration page'), '/admin/config/media/colorbox'),
'%path' => 'sites/all/libraries/DOMPurify',
)),
);
}
}
elseif (version_compare($library['version'], COLORBOX_DOMPURIFY_MIN_PLUGIN_VERSION, '>=')) {
$requirements['dompurify'] = array(
'title' => $t('DOMPurify library'),
'severity' => REQUIREMENT_OK,
'value' => $library['version'],
);
}
else {
$requirements['dompurify'] = array(
'title' => $t('DOMPurify library'),
'value' => $t('At least @a', array(
'@a' => COLORBOX_DOMPURIFY_MIN_PLUGIN_VERSION,
)),
'severity' => REQUIREMENT_ERROR,
'description' => $t('The Colorbox module uses this library to sanitize HTML captions. ' . 'Without this library, all captions will be treated as plain text. ' . 'You need to download a later version of the !library and replace the old version ' . 'located in the %path directory on your server.', array(
'!library' => l($t('DOMPurify library'), $library['download url']),
'%path' => $library['library path'],
)),
);
}
}
return $requirements;
}