function fckeditor_profile_validate in FCKeditor - WYSIWYG HTML editor 6
Same name and namespace in other branches
- 5.2 fckeditor.module \fckeditor_profile_validate()
Profile validation.
1 call to fckeditor_profile_validate()
- fckeditor_admin in ./
fckeditor.module - Controller for FCKeditor administrative settings.
File
- ./
fckeditor.module, line 369 - FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2008 Frederico Caldeira Knabben
Code
function fckeditor_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.');
}
if (!preg_match("/^\\d+\$/", trim($edit['min_rows']))) {
$errors['min_rows'] = t('Minimum rows must be a valid number');
}
if ($edit['default'] == 't' && $edit['popup'] == 't') {
$errors['popup'] = t('If FCKeditor is enabled by default, popup window must be disabled.');
}
if ($edit['show_toggle'] == 't' && $edit['popup'] == 't') {
$errors['popup'] = t('If toggle is enabled, popup window must be disabled.');
}
if (!$edit['name']) {
$errors['name'] = t('You must give a profile name.');
}
if (!preg_match("/^\\d+%?\$/", $edit['width'])) {
$errors['width'] = t('Enter valid width. Ex: 400 or 100%');
}
if (!empty($edit['css_path'])) {
if ($edit['css_mode'] != 'self') {
$errors['css_path'] = t('CSS path is not empty. Please set the "Editor CSS" option to "define css" mode.');
}
elseif (false !== strpos($edit['css_path'], '"')) {
$errors['css_path'] = t('Double quotes are not allowed in CSS path.');
}
elseif (substr($edit['css_path'], 0, 1) == "'" && substr($edit['css_path'], -1) == "'") {
$errors['css_path'] = t('Enter valid path, do not surround it with quotes.');
}
}
if (!empty($edit['styles_path'])) {
if ($edit['css_style'] != 'self') {
$errors['styles_path'] = t('Path to predefined styles is not empty. Please set the "Predefined styles" option to "define path to fckstyles.xml" mode.');
}
elseif (false !== strpos($edit['styles_path'], '"')) {
$errors['styles_path'] = t('Double quotes are not allowed in path.');
}
elseif (substr($edit['styles_path'], 0, 1) == "'" && substr($edit['styles_path'], -1) == "'") {
$errors['styles_path'] = t('Enter valid path, do not surround it with quotes.');
}
}
if (!empty($edit['font_format'])) {
if (!preg_match("/^((p|div|pre|address|h1|h2|h3|h4|h5|h6);)*(p|div|pre|address|h1|h2|h3|h4|h5|h6)\$/", $edit['font_format'])) {
$errors['font_format'] = t('Enter valid, semicolon separated, list of HTML font formats (no semicolon at the end of list expected).');
}
}
//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;
}
}
if (variable_get('file_downloads', '') !== FILE_DOWNLOADS_PRIVATE) {
if (!empty($edit['UserFilesAbsolutePath']) && empty($edit['UserFilesPath'])) {
$errors['UserFilesPath'] = t("Path to uploaded files is required.");
}
if (!empty($edit['UserFilesPath']) && empty($edit['UserFilesAbsolutePath'])) {
$errors['UserFilesPath'] = t("Absolute path to uploaded files is required.");
}
}
foreach ($errors as $name => $message) {
form_set_error($name, $message);
}
return count($errors) == 0;
}