You are here

function simplemeta_meta_form_validate_save in Simple Meta 6.2

Same name and namespace in other branches
  1. 7 simplemeta.module \simplemeta_meta_form_validate_save()
1 string reference to 'simplemeta_meta_form_validate_save'
simplemeta_meta_form in ./simplemeta.module

File

./simplemeta.module, line 345

Code

function simplemeta_meta_form_validate_save($form, &$form_state) {
  $values = $form_state['values'];
  $meta = $values['_meta'];
  $path = $values['_path'];
  $normal_path = drupal_get_normal_path($path);
  if ($path != $normal_path) {

    // drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $item['link_path'], '%normal_path' => $normal_path)));
    $path = $normal_path;
  }
  if (!menu_path_is_external($path)) {
    $parsed_link = parse_url($path);
    if ($path != $parsed_link['path']) {
      $path = $parsed_link['path'];
    }

    // @todo do we need to check the access?
    // @see menu_edit_item_validate()
    if (!trim($path)) {
      form_set_error('_path', t('Path is invalid'));
    }
    $form_state['values']['_path'] = $path;
  }
  else {
    form_set_error('_path', t('Path can be only internal'));
  }
  if (isset($meta->sid) && !simplemeta_meta_load($meta->sid)) {
    form_set_error('_meta', t("Meta #%sid doesn't exist anymore", array(
      '%id' => $meta->sid,
    )));
  }
  elseif (!isset($meta->sid) && simplemeta_meta_load_by_path($path, $meta->language)) {
    form_set_error('_meta', t("Meta for this page in this language already exists"));
  }
  $info = simplemeta_get_info();
  foreach ($info as $key => $definition) {
    if (isset($definition['validate']) && function_exists($definition['validate'])) {
      $function = $definition['validate'];
      $function($form, $form_state);
    }
  }
}