diff --git a/wysiwyg_filter.admin.inc b/wysiwyg_filter.admin.inc index 38fb424..43a5e36 100644 --- a/wysiwyg_filter.admin.inc +++ b/wysiwyg_filter.admin.inc @@ -16,7 +16,7 @@ * * remove format suffix, will be first array index * * care for pre- and post-processing, or remove it like parsed-elements * * rewrite validate to get correct values like $form['filters']['settings'][$name] / $form_state['values']['filters'][$name]['settings'] - * + * */ function wysiwyg_filter_filter_wysiwyg_settings(&$form, &$form_state, $filter, $format, $defaults, $filters) { global $base_url; @@ -26,10 +26,10 @@ function wysiwyg_filter_filter_wysiwyg_settings(&$form, &$form_state, $filter, $ $settings = $filter->settings; $settings += $defaults; - + // carry over settings for other formats $filterform = array(); - + // *** valid elements *** $valid_elements = $settings['valid_elements']; $valid_elements_rows = min(20, max(5, substr_count($valid_elements, "\n") + 2)); @@ -144,6 +144,13 @@ This option allows you to specify which HTML elements and attributes are allowed '#default_value' => $settings['nofollow_policy'], '#description' => t('If you choose the whitelist option, be sure to add your own domain names to the list!'), ); + $filterform['nofollow_url_validation'] = array( + '#type' => 'checkbox', + '#title' => t('Enable nofollow domain validation'), + '#description' => t('If enabled, domains you enter in the field below will run through a simple, but sometimes too restrictive check.'), + '#default_value' => !empty($settings['nofollow_url_validation']), + ); + $parts = parse_url($base_url); // Note that domains list is stored by our submit handler in array form where // dots have been escaped, so we need here to revert the process to get a clean @@ -163,7 +170,7 @@ This option allows you to specify which HTML elements and attributes are allowed /* * Implements hook_form_FORM_ID_alter - * + * * add validate and submit handlers */ function wysiwyg_filter_form_filter_admin_format_form_alter(&$form, &$form_state, $form_id) { @@ -268,9 +275,11 @@ function wysiwyg_filter_filter_wysiwyg_settings_validate($form, &$form_state) { // *** validate nofollow_domains *** $nofollow_domains = array_filter(explode(',', preg_replace('#\s+#', ',', $values['nofollow_domains']))); // form2db - foreach ($nofollow_domains as $nofollow_domain) { - if (!preg_match('#^([a-z0-9]([-a-z0-9]*)?\.)+([a-z]+)$#i', $nofollow_domain)) { - form_set_error('nofollow_domains', t('Invalid domain %domain. Please, enter a comma separated list of valid domain names.', array('%domain' => $nofollow_domain))); + if ($values['nofollow_url_validation']) { + foreach ($nofollow_domains as $nofollow_domain) { + if (!preg_match('#^([a-z0-9]([-a-z0-9]*)?\.)+([a-z]+)$#i', $nofollow_domain)) { + form_set_error('nofollow_domains', t('Invalid domain %domain. Please, enter a comma separated list of valid domain names.', array('%domain' => $nofollow_domain))); + } } } } @@ -285,10 +294,10 @@ function wysiwyg_filter_filter_wysiwyg_settings_validate($form, &$form_state) { */ function wysiwyg_filter_filter_wysiwyg_settings_submit($form, &$form_state) { $values =& $form_state['values']['filters']['wysiwyg']['settings']; - + // *** prepare valid_elements - just trim *** $values['valid_elements'] = trim($values['valid_elements']); - + // *** prepare rules - csv2array *** foreach (array_keys(wysiwyg_filter_get_advanced_rules()) as $rule_key) { $field_name = "rule_$rule_key"; @@ -301,7 +310,7 @@ function wysiwyg_filter_filter_wysiwyg_settings_submit($form, &$form_state) { /* * CSV to Array - * + * * @param atring $v * @param bool $space2comma - shall we convet whitespace to commas before processing? * @return array @@ -312,7 +321,7 @@ function wysiwyg_filter_csv2array($v, $space2comma = TRUE) { } /* * Array to CSV - * + * * @param array $v * @return string */