Commit fc79722b authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#90570 by bdragon and chx: GET query and fragment information were not...

#90570 by bdragon and chx: GET query and fragment information were not possible to define in menu links
parent 74def328
......@@ -138,11 +138,18 @@ function menu_edit_item(&$form_state, $type, $item, $menu) {
$form['menu']['customized'] = array('#type' => 'value', '#value' => 1);
$form['menu']['original_item'] = array('#type' => 'value', '#value' => $item);
$path = $item['link_path'];
if (isset($item['options']['query'])) {
$path .= '?'. $item['options']['query'];
}
if (isset($item['options']['fragment'])) {
$path .= '#'. $item['options']['fragment'];
}
if ($item['module'] == 'menu') {
$form['menu']['link_path'] = array(
'#type' => 'textfield',
'#title' => t('Path'),
'#default_value' => $item['link_path'],
'#default_value' => $path,
'#description' => t('The path this menu item links to. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.', array('%front' => '<front>', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org')),
'#required' => TRUE,
);
......@@ -211,7 +218,19 @@ function menu_edit_item(&$form_state, $type, $item, $menu) {
* Validate form values for a menu link being added or edited.
*/
function menu_edit_item_validate($form, &$form_state) {
$item = $form_state['values']['menu'];
$item = &$form_state['values']['menu'];
if (!menu_path_is_external($item['link_path'])) {
$parsed_link = parse_url($item['link_path']);
if (isset($parsed_link['query'])) {
$item['options']['query'] = $parsed_link['query'];
}
if (isset($parsed_link['fragment'])) {
$item['options']['fragment'] = $parsed_link['fragment'];
}
if ($item['link_path'] != $parsed_link['path']) {
$item['link_path'] = $parsed_link['path'];
}
}
if (!trim($item['link_path']) || !menu_valid_path($item)) {
form_set_error('link_path', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $item['link_path'])));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment