You are here

function locale_languages_edit_form_validate in Drupal 6

Same name and namespace in other branches
  1. 7 modules/locale/locale.admin.inc \locale_languages_edit_form_validate()

Validate the language editing form. Reused for custom language addition too.

Related topics

1 call to locale_languages_edit_form_validate()
locale_languages_predefined_form_validate in includes/locale.inc
Validate the language addition form.
1 string reference to 'locale_languages_edit_form_validate'
locale_languages_edit_form in includes/locale.inc
Editing screen for a particular language.

File

includes/locale.inc, line 339
Administration functions for locale.module.

Code

function locale_languages_edit_form_validate($form, &$form_state) {

  // Validate that the name, native, and langcode variables are safe.
  if (preg_match('/["<>\']/', $form_state['values']['langcode'])) {
    form_set_error('langcode', t('The characters &lt;, &gt;, " and \' are not allowed in the language code field.'));
  }
  if (preg_match('/["<>\']/', $form_state['values']['name'])) {
    form_set_error('name', t('The characters &lt;, &gt;, " and \' are not allowed in the language name in English field.'));
  }
  if (preg_match('/["<>\']/', $form_state['values']['native'])) {
    form_set_error('native', t('The characters &lt;, &gt;, " and \' are not allowed in the native language name field.'));
  }
  if (!empty($form_state['values']['domain']) && !empty($form_state['values']['prefix'])) {
    form_set_error('prefix', t('Domain and path prefix values should not be set at the same time.'));
  }
  if (!empty($form_state['values']['domain']) && ($duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE domain = '%s' AND language != '%s'", $form_state['values']['domain'], $form_state['values']['langcode'])))) {
    form_set_error('domain', t('The domain (%domain) is already tied to a language (%language).', array(
      '%domain' => $form_state['values']['domain'],
      '%language' => $duplicate->language,
    )));
  }
  if (empty($form_state['values']['prefix']) && language_default('language') != $form_state['values']['langcode'] && empty($form_state['values']['domain'])) {
    form_set_error('prefix', t('Only the default language can have both the domain and prefix empty.'));
  }
  if (!empty($form_state['values']['prefix']) && ($duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE prefix = '%s' AND language != '%s'", $form_state['values']['prefix'], $form_state['values']['langcode'])))) {
    form_set_error('prefix', t('The prefix (%prefix) is already tied to a language (%language).', array(
      '%prefix' => $form_state['values']['prefix'],
      '%language' => $duplicate->language,
    )));
  }
}