You are here

function xmlsitemap_engines_validate_custom_urls in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap_engines/xmlsitemap_engines.admin.inc \xmlsitemap_engines_validate_custom_urls()

Validate the custom submission URL element.

1 string reference to 'xmlsitemap_engines_validate_custom_urls'
xmlsitemap_engines_settings_form in xmlsitemap_engines/xmlsitemap_engines.admin.inc
Form builder; Administration settings form.

File

xmlsitemap_engines/xmlsitemap_engines.admin.inc, line 73
Administrative page callbacks for the xmlsitemap_engines module.

Code

function xmlsitemap_engines_validate_custom_urls($element, &$form_state) {
  $custom_urls = preg_split('/[\\r\\n]+/', $element['#value'], -1, PREG_SPLIT_NO_EMPTY);
  foreach ($custom_urls as $custom_url) {
    $url = xmlsitemap_engines_prepare_url($custom_url, '');
    if (!valid_url($url, TRUE)) {
      form_error($element, t('Invalid URL %url.', array(
        '%url' => $custom_url,
      )));
    }
  }
  $form_state['values']['xmlsitemap_engines_custom_urls'] = implode("\n", $custom_urls);
}