function patterns_requirements in Patterns 7
Same name and namespace in other branches
- 6.2 patterns.module \patterns_requirements()
- 6 patterns.module \patterns_requirements()
- 7.2 patterns.install \patterns_requirements()
Implements hook_requirements().
Parameters
string $phase The phase in which hook_requirements is run (install|runtime).:
File
- ./
patterns.install, line 142
Code
function patterns_requirements($phase) {
$requirements = array();
// Checking if patterns directory is writable
// Must be done at installation and runtime
if (!_patterns_io_is_patterns_dir_ready(NULL, FILE_CREATE_DIRECTORY)) {
$requirements['pdir'] = array(
'title' => t('Patterns files dir writable'),
'description' => t("Patterns folder doesn't exist or is not writable: !path", array(
'!path' => patterns_path_get_files_dir(),
)),
'severity' => REQUIREMENT_WARNING,
'value' => t('Not writable'),
);
}
else {
$requirements['pdir'] = array(
'title' => t('Patterns files dir'),
'severity' => REQUIREMENT_OK,
'value' => t('Writable'),
);
}
switch ($phase) {
case 'runtime':
if (!ini_get('allow_url_fopen')) {
$requirements['allow_url_fopen'] = array(
'title' => t('Patterns import files from remote URL'),
'description' => t('To import patterns directly from remote URL \'allow_url_fopen\' must be enabled in your PHP configuration.'),
'severity' => REQUIREMENT_WARNING,
'value' => t('Disabled'),
);
}
//Trying to detect CodeMirror library
$library = libraries_detect('codemirror');
if (empty($library['installed'])) {
$requirements['codemirror'] = array(
'title' => t('CodeMirror (JavaScript based code editor)'),
'description' => t('Patterns editor can be better visualized with CodeMirror. To enable CodeMirror support, download the !codemirror and copy it into the libraries folder (e.g. sites/all/libraries/codemirror/). Error: !error', array(
'!codemirror' => l(t('library'), 'https://github.com/marijnh/CodeMirror/', array(
'absolute' => TRUE,
)),
'!error' => $library['error message'],
)),
'severity' => REQUIREMENT_WARNING,
'value' => t($library['error']),
);
}
else {
$requirements['codemirror'] = array(
'title' => t('CodeMirror Library (JavaScript based code editor)'),
'severity' => REQUIREMENT_OK,
'value' => $library['version'],
);
}
break;
}
return $requirements;
}