function splashify_where_paths_check in Splashify 6
Same name and namespace in other branches
- 7 admin/splashify.admin.where.inc \splashify_where_paths_check()
Validate the where:list:paths field.
We put this in a function so it can handle both the desktop and mobile settings. This assumes that each path in $paths is separated by a new line character.
1 call to splashify_where_paths_check()
- splashify_admin_where_form_validate in admin/
splashify.admin.where.inc - Implements form validation handler.
File
- admin/
splashify.admin.where.inc, line 130 - The admin "Where" tab.
Code
function splashify_where_paths_check($field, $paths) {
if (empty($paths)) {
form_set_error($field, t('You must enter at least one path.'));
return;
}
$what_paths = preg_split('/[\\n\\r]+/', $paths);
$errors = array();
foreach ($what_paths as $path) {
// If this path is a source url, we know this is a valid path.
if (drupal_valid_path($path)) {
continue;
}
// This path is not an alias or the source url.
$errors[] .= t('The path "@path" is not a valid source page. This path cannot be an alias.', array(
'@path' => $path,
));
}
// Since there could be multiple errors for this one field, we want to
// break each error into a separate line.
if (count($errors) > 0) {
form_set_error($field, implode('<br />', $errors));
}
}