function panels_landing_page_basic_validate in Panels 6.3
Same name and namespace in other branches
- 7.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 162
Code
function panels_landing_page_basic_validate(&$form, &$form_state) {
// Ensure all 'page' features are loaded.
$page_task = page_manager_get_task('page');
// 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 = '%s'", $form_state['values']['path']);
while ($router = db_fetch_object($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.
$result = db_query("SELECT src, dst FROM {url_alias} WHERE dst = '%s'", $form_state['values']['path']);
if ($alias = db_fetch_object($result)) {
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,
)));
}
}