You are here

function evoc_import_form_validate in RDF Extensions 7.2

File

evoc/evoc.pages.inc, line 71
Page callbacks for importing a vocabulary.

Code

function evoc_import_form_validate($form, &$form_state) {

  // Load the XML Namespace regular expression patterns.
  module_load_include('inc', 'rdfx');
  $prefix = $form_state['values']['prefix'];
  $ns_uri = $form_state['values']['ns_uri'];

  // Ensure the that namespace is a valid URI.
  if (!valid_url($ns_uri, $absolute = TRUE)) {
    form_set_error('ns_uri', t('The Vocabulary URI must be a valid URI.'));
  }

  // Ensure the namespace URI ends in either a / or a #.
  if (!preg_match('/(\\/|\\#)$/', $ns_uri)) {
    form_set_error('ns_uri', t('The Vocabulary URI must end in either a / or a #.'));
  }

  // Ensure the prefix is well formed according to the specification.
  if (!preg_match('/^' . PREFIX . '$/', $prefix)) {
    form_set_error('prefix', t('The prefix must follow the !link.', array(
      '!link' => '<a href="http://www.w3.org/TR/xml-names11/#NT-NCName">XML Namespace Specification</a>',
    )));
  }
}