function menu_editor_validate_item in Menu Editor 6
Same name and namespace in other branches
- 6.3 menu_editor.admin.inc \menu_editor_validate_item()
- 6.2 menu_editor.admin.inc \menu_editor_validate_item()
- 7 menu_editor.admin.inc \menu_editor_validate_item()
Validate form values for a menu link being added or edited.
1 call to menu_editor_validate_item()
File
- ./
menu_editor.admin.inc, line 213
Code
function menu_editor_validate_item(&$element, $link_path, $error_key_prefix) {
$placeholders = menu_editor_get_placeholders();
if (isset($placeholders[$link_path])) {
// it would be hard to check access,
// because we don't necessarily know the mlid.
// Thus, we simply grant access for all placeholders.
return;
}
if ($element['link_path']['#default_value'] == $link_path) {
// link_path is the only field that we check,
// and we don't complain about existing link paths.
return;
}
$item = $element['#item'];
$normal_path = drupal_get_normal_path($link_path);
$item['link_path'] = $normal_path;
if (!menu_path_is_external($normal_path)) {
$parsed_link = parse_url($normal_path);
if (isset($parsed_link['query'])) {
$item['options']['query'] = $parsed_link['query'];
}
if (isset($parsed_link['fragment'])) {
$item['options']['fragment'] = $parsed_link['fragment'];
}
$item['link_path'] = $parsed_link['path'];
}
if (!trim($item['link_path']) || !menu_valid_path($item)) {
form_set_error($error_key_prefix . 'link_path', t("The path '@link_path' is either invalid or you do not have access to it.", array(
'@link_path' => $item['link_path'],
)));
}
}