function js_requirements in JS Callback Handler 7.2
Same name and namespace in other branches
- 5.2 js.install \js_requirements()
- 6 js.install \js_requirements()
- 7 js.install \js_requirements()
Implements hook_requirements().
File
- ./
js.install, line 11 - Ensures JavaScript callback handler has been setup properly.
Code
function js_requirements($phase) {
$requirements = array();
$t = get_t();
switch ($phase) {
case 'runtime':
$title = $t('JavaScript callback handler');
// Warn about missing js.php in root directory.
if (!file_exists('js.php')) {
$requirements['js'] = array(
'title' => $title,
'description' => $t('In order for JavaScript callbacks to work correctly, please copy the js.php file to the root of your Drupal installation.'),
'severity' => REQUIREMENT_ERROR,
'value' => $t('Please copy js.php'),
);
}
elseif (variable_get('js_server_software', 'apache') == 'apache' && strpos(file_get_contents('.htaccess'), 'js.php') === FALSE) {
$requirements['js'] = array(
'title' => $title,
'description' => $t('Please add the <a href="!url">RewriteRules</a> to the .htaccess file.', array(
'!url' => url('admin/config/system/js'),
)),
'severity' => REQUIREMENT_ERROR,
'value' => $t('Add Apache RewriteRule to .htaccess'),
);
}
else {
$requirements['js'] = array(
'title' => $title,
'description' => $t('The JavaScript callback handler has been installed correctly.', array(
'%core' => 'js.php',
)),
'severity' => REQUIREMENT_OK,
'value' => $t('Installed correctly'),
);
}
}
return $requirements;
}