$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'),
);
}
// Warn about missing RewriteRule in .htaccess.
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 RewriteRules to the .htaccess file.', array('!url' => url('admin/config/system/js'))),
'severity' => REQUIREMENT_ERROR,
'value' => $t('Add Apache RewriteRule to .htaccess'),
);
}
// Return positive status message.
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;
}
/**
* Implements hook_install().
*/
function js_install() {
// Move js.php to the root of Drupal.
$js_dir = realpath(dirname(__FILE__));
$destination = DRUPAL_ROOT . DIRECTORY_SEPARATOR . 'js.php';
$source = $js_dir . DIRECTORY_SEPARATOR . 'js.php';
if (!file_exists($destination) && file_exists($source)) {
if (!copy($source, $destination)) {
drupal_set_message(t('Can not copied js.php to installation root folder.'), 'error');
}
else {
drupal_set_message(t('Copied js.php to installation root folder successfully.'));
}
}
// Notify the user that they should add the rewrite rules to their .htaccess
// file.
drupal_set_message(t('To complete the installation: please add the RewriteRules to the .htaccess file.', array('!url' => url('admin/config/system/js'))));
}
/**
* Implements hook_uninstall().
*/
function js_uninstall() {
// Delete js.php to remove any leftovers from the js module.
$file = DRUPAL_ROOT . DIRECTORY_SEPARATOR . 'js.php';
if (file_exists($file)) {
if (!unlink($file)) {
drupal_set_message(t('Can not delete js.php'), 'warning');
}
else {
drupal_set_message(t('Deleted js.php successfully'));
}
}
// If the .htaccess contains references to js.php, notify the user they should
// clean it up.
if (variable_get('js_server_software', 'apache') == 'apache' && strpos(file_get_contents(DRUPAL_ROOT . DIRECTORY_SEPARATOR . '.htaccess'), 'js.php') !== FALSE) {
drupal_set_message(t('The js.php file is still referenced in the .htaccess file. Please make sure to remove the .htaccess handling for js.php for a full uninstall.'));
}
// Delete used variables.
variable_del('js_server_software');
}