function panels_landing_page_basic_validate in Panels 7.3
Same name and namespace in other branches
- 6.3 plugins/page_wizards/landing_page.inc \panels_landing_page_basic_validate()
Submit function to store the form data in our cache.
File
- plugins/
page_wizards/ landing_page.inc, line 171
Code
function panels_landing_page_basic_validate(&$form, &$form_state) {
// Validate that the name is ok.
$test = page_manager_page_load($form_state['values']['name']);
if ($test) {
form_error($form['name'], t('That name is used by another page: @page', array(
'@page' => $test->admin_title,
)));
}
// Ensure name fits the rules:
if (preg_match('/[^a-zA-Z0-9_]/', $form_state['values']['name'])) {
form_error($form['name'], t('Page name must be alphanumeric or underscores only.'));
}
// Validate that the path is ok.
if (preg_match('/[%!\\?#&]/', $form_state['values']['path'])) {
form_error($form['path'], t('%, !, ?, #, or & cannot appear in the path.'));
}
// Check to see if something is already using the path.
$result = db_query("SELECT * FROM {menu_router} WHERE path = :path", array(
':path' => $form_state['values']['path'],
))
->fetch();
if ($result) {
form_error($form['path'], t('That path is already in use. This system cannot override existing paths.'));
return;
}
// Ensure the path is not already an alias to something else.
$alias = db_query('SELECT alias, source FROM {url_alias} WHERE alias = :path', array(
':path' => $form_state['values']['path'],
))
->fetchObject();
if ($alias) {
form_error($form['path'], t('That path is currently assigned to be an alias for @alias. This system cannot override existing aliases.', array(
'@alias' => $alias->src,
)));
}
}