form_styler.install in jQuery form styler 7.2
Same filename and directory in other branches
Contains install and update functions for form_styler.
File
form_styler.installView source
<?php
/**
* @file
* Contains install and update functions for form_styler.
*/
/**
* Implements hook_requirements().
*/
function form_styler_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
$t = get_t();
$plugin_min_version = '1.7.6';
$plugin_name = $t('jQuery form styler plugin');
$library = libraries_detect('jquery_form_styler');
if (empty($library['installed'])) {
$error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
$error_message = isset($library['error message']) ? $library['error message'] : '';
$description = '!error You need to download the !form_styler, extract the' . ' archive, rename it to "jquery_form_styler" and place the plugin ' . 'directory in the %path directory on your server.';
$options = array(
'!error' => $error_message,
'!form_styler' => l($plugin_name, $library['download url']),
'%path' => 'sites/all/libraries',
);
$requirements['jquery_form_styler_plugin'] = array(
'title' => $plugin_name,
'value' => $t('@e: At least @a', array(
'@e' => $error_type,
'@a' => $plugin_min_version,
)),
'severity' => REQUIREMENT_ERROR,
'description' => $t($description, $options),
);
}
elseif (version_compare($library['version'], $plugin_min_version, '>=')) {
$requirements['jquery_form_styler_plugin'] = array(
'title' => $plugin_name,
'severity' => REQUIREMENT_OK,
'value' => $library['version'],
);
}
else {
$description = 'You need to download a later version of the !form_styler ' . 'and replace the old version located in the %path directory on your' . ' server.';
$options = array(
'!form_styler' => l($plugin_name, $library['download url']),
'%path' => $library['library path'],
);
$requirements['jquery_form_styler_plugin'] = array(
'title' => $plugin_name,
'value' => $t('At least @a', array(
'@a' => $plugin_min_version,
)),
'severity' => REQUIREMENT_ERROR,
'description' => $t($description, $options),
);
}
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function form_styler_uninstall() {
// Delete variables from db.
$variable_names = db_select('variable', 'v')
->condition('v.name', db_like('form_styler_') . '%', 'LIKE')
->fields('v', array(
'name',
))
->execute()
->fetchCol();
foreach ($variable_names as $variable_name) {
variable_del($variable_name);
}
}
Functions
Name | Description |
---|---|
form_styler_requirements | Implements hook_requirements(). |
form_styler_uninstall | Implements hook_uninstall(). |