Commit e5b9eacb authored by Jelle Sebreghts's avatar Jelle Sebreghts
Browse files

inform admin of deprecated files

parent ea2530dd
......@@ -4,9 +4,17 @@
* Admin settings for Clientside Validation
*/
function _clientside_validation_deprecated_admin_message() {
$warning = t('The jquery.validate files that are included in the module are deprecated and will be removed in the next version. Please download and enable the libraries module and download the !link and place them under sites/all/libraries/jquery.validate.',
array('!link' => l(t('latest version of jQuery validate'), 'http://bassistance.de/jquery-plugins/jquery-plugin-validation/')));
drupal_set_message($warning, 'warning');
}
function clientside_validation_general_settings_form($form_id, $form_state) {
drupal_set_title(t('Edit general settings'));
if (!module_exists('libraries') || ($library = libraries_detect('jquery.validate') && !empty($library['installed']))) {
_clientside_validation_deprecated_admin_message();
}
//jquery.validate.js settings
$form['clientside_validation_min'] = array(
'#type' => 'fieldset',
......@@ -160,6 +168,9 @@ function clientside_validation_general_settings_form($form_id, $form_state) {
}
function clientside_validation_settings_form($form, $form_state, $cvs_formid = NULL, $cvs_type = 'default') {
if (!module_exists('libraries') || ($library = libraries_detect('jquery.validate') && !empty($library['installed']))) {
_clientside_validation_deprecated_admin_message();
}
$settings = clientside_validation_settings_load($cvs_type, $cvs_formid, TRUE);
$form['new'] = array(
'#type' => 'value',
......@@ -550,6 +561,9 @@ function _cv_setting_status($status) {
}
function clientside_validation_settings_overview($form, $form_state, $cvs_type) {
if (!module_exists('libraries') || ($library = libraries_detect('jquery.validate') && !empty($library['installed']))) {
_clientside_validation_deprecated_admin_message();
}
$form = array();
$settings = clientside_validation_settings_load($cvs_type, NULL, TRUE);
$definedforms = array();
......
......@@ -88,6 +88,8 @@ function clientside_validation_libraries_info() {
function clientside_validation_requirements() {
// make sure we don't crash the site. Previous versions did not have libraries
// as dependency. They will need to run update.php first.
$warning = t('The jquery.validate files that are included in the module are deprecated and will be removed in the next version. Please download and enable the libraries module and download the !link and place them under sites/all/libraries/jquery.validate.',
array('!link' => l(t('latest version of jQuery validate'), 'http://bassistance.de/jquery-plugins/jquery-plugin-validation/')));
if (module_exists('libraries')) {
$library = libraries_detect('jquery.validate');
if ($library && !empty($library['installed'])) {
......@@ -103,12 +105,19 @@ function clientside_validation_requirements() {
return array(
'clientside_validation' => array(
'title' => t('jquery.validate.js'),
'value' => $library ? $library['error message'] : t('Could not detect jquery.validate library'),
'severity' => REQUIREMENT_ERROR,
'value' => ($library ? $library['error message'] : t('Could not detect jquery.validate library')) . $warning,
'severity' => REQUIREMENT_WARNING,
),
);
}
}
return array(
'clientside_validation' => array(
'title' => t('jquery.validate.js'),
'value' => $warning,
'severity' => REQUIREMENT_WARNING,
),
);
}
/**
......@@ -400,11 +409,17 @@ function clientside_validation_webform_after_build(&$form, &$form_state) {
function clientside_validation_add_js_settings($settings) {
$clientside_validation_settings = &drupal_static('clientside_validation_settings', array());
if (variable_get('clientside_validation_use_minified', 0) == 0) {
libraries_load('jquery.validate');
if (!module_exists('libraries') || ($library = libraries_detect('jquery.validate') && !empty($library['installed']))) {
if (variable_get('clientside_validation_use_minified', 0) == 0) {
libraries_load('jquery.validate');
}
else {
libraries_load('jquery.validate', 'minified');
}
}
else {
libraries_load('jquery.validate', 'minified');
// @todo: deprecated.
_clientside_validation_add_js_deprecated();
}
if (variable_get('clientside_validation_add_js_timing', 0)) {
......@@ -414,6 +429,23 @@ function clientside_validation_add_js_settings($settings) {
$clientside_validation_settings = drupal_array_merge_deep($clientside_validation_settings, $settings);
}
function _clientside_validation_add_js_deprecated() {
if (variable_get('clientside_validation_use_minified', 0) == 0) {
drupal_add_js(drupal_get_path('module', 'clientside_validation') . '/jquery-validate/jquery.validate.js');
}
else {
drupal_add_js(drupal_get_path('module', 'clientside_validation') . '/jquery-validate/jquery.validate.min.js');
}
//add our js file to the footer to support vertical_tabs
drupal_add_js(drupal_get_path('module', 'clientside_validation') . '/clientside_validation.ie8.js', array(
'scope' => 'footer',
'weight' => 19,
'browsers' => array('IE' => 'lt IE 9', '!IE' => FALSE),
));
drupal_add_js(drupal_get_path('module', 'clientside_validation') . '/clientside_validation.js', array('scope' => 'footer', 'weight' => 20));
}
function _clientside_validation_add_special_rules(&$js_rules, &$settings, $form) {
$form_id = $form['#id'];
$matches = array();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment