function ace_editor_requirements in Ace Code Editor 7
Same name and namespace in other branches
- 8 ace_editor.install \ace_editor_requirements()
Implements hook_requirements().
File
- ./
ace_editor.install, line 73 - Install, update and uninstall functions for the module.
Code
function ace_editor_requirements($phase) {
$requirements = array();
$t = get_t();
// Verify that the library is present.
if ($phase == 'runtime') {
// Libraries module is a dependency.
if (!drupal_load('module', 'libraries')) {
$requirements['ace_editor'] = array(
'title' => t('Libraries module missing'),
'severity' => REQUIREMENT_ERROR,
'value' => t('Libraries module required for Ace Editor.'),
'description' => $t('Ace Editor module requires the <a href="@url">Libraries module</a> to be installed.', array(
'@url' => 'http://drupal.org/project/libraries',
)),
);
return $requirements;
}
if (!is_dir(libraries_get_path('ace'))) {
$requirements['ace_editor'] = array(
'title' => $t('Ace Editor'),
'value' => $t('The required Ace library is missing. @eol See README.txt for the installation instructions.', array(
'eol' => PHP_EOL,
)),
'severity' => REQUIREMENT_ERROR,
);
}
else {
$requirements['ace_editor'] = array(
'title' => $t('Ace Editor'),
'severity' => REQUIREMENT_OK,
'value' => $t('Ace library installed (release ' . trim(fgets(fopen(DRUPAL_ROOT . '/' . libraries_get_path('ace') . '/ChangeLog.txt', 'r'))) . ').'),
);
}
}
if ($phase == 'install') {
if (!module_exists('libraries')) {
$requirements['ace_editor'] = array(
'title' => $t('Libraries module is missing'),
'severity' => REQUIREMENT_ERROR,
'value' => $t('Libraries module is required for Ace Editor.'),
'description' => $t('Ace Editor module requires the <a href="@url">Libraries module</a> to be installed.', array(
'@url' => 'http://drupal.org/project/libraries',
)),
);
}
elseif (function_exists('libraries_get_libraries') && !is_dir(libraries_get_path('ace'))) {
drupal_set_message($t('The required Ace library is missing. The library can be found at <a href="@url">@url</a>. You can install it manually following the README.txt instructions or using the "drush dl-ace" command (it will be downloaded to the libraries/ace directory).', array(
'@url' => 'https://github.com/ajaxorg/ace',
)), 'warning');
}
}
return $requirements;
}