You are here

function fckeditor_global_profile_validate in FCKeditor - WYSIWYG HTML editor 6

Same name and namespace in other branches
  1. 5.2 fckeditor.module \fckeditor_global_profile_validate()

Global profile validation.

1 call to fckeditor_global_profile_validate()
fckeditor_admin in ./fckeditor.module
Controller for FCKeditor administrative settings.

File

./fckeditor.module, line 480
FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2008 Frederico Caldeira Knabben

Code

function fckeditor_global_profile_validate($edit) {
  $errors = array();

  //include mode and all other fields are empty, invalid
  if ($edit['excl_mode'] == 1 && !$edit['excl_fields'] && !$edit['excl_paths']) {
    $errors['excl_mode'] = t('Include mode selected, but no fields/paths given. Enter at least one path or field where FCKeditor should appear.');
  }

  //validate fields
  $fields = preg_split("/[\\s,]+/", strip_tags($edit['excl_fields']));
  foreach ($fields as $field) {
    if ($field && !preg_match("/^[a-z]+(\\-{1,2}[[:alnum:]]+|\\*|\\-\\*)+\$/i", $field)) {
      $errors['excl_fields'] = t("Invalid field specified: %1", array(
        "%1" => $field,
      ));
      break;
    }
  }
  $fields = preg_split("/[\\s,]+/", strip_tags($edit['simple_incl_fields']));
  foreach ($fields as $field) {
    if ($field && !preg_match("/^[a-z]+(\\-{1,2}[[:alnum:]]+|\\*|\\-\\*)+\$/i", $field)) {
      $errors['simple_incl_fields'] = t("Invalid field specified: %1", array(
        "%1" => $field,
      ));
      break;
    }
  }

  //validate paths
  $paths = preg_split("/[\\s,]+/", strip_tags($edit['excl_paths']));
  foreach ($paths as $path) {
    if ($path && !preg_match("|^[_a-z0-9-\\*/]*\$|i", $path)) {
      $errors['excl_paths'] = t("Invalid path specified: %1", array(
        "%1" => $path,
      ));
      break;
    }
  }
  $paths = preg_split("/[\\s,]+/", strip_tags($edit['simple_incl_paths']));
  foreach ($paths as $path) {
    if ($path && !preg_match("|^[_a-z0-9-\\*/]*\$|i", $path)) {
      $errors['simple_incl_paths'] = t("Invalid path specified: %1", array(
        "%1" => $path,
      ));
      break;
    }
  }
  foreach ($errors as $name => $message) {
    form_set_error($name, $message);
  }
  return count($errors) == 0;
}