From fc79722b392f436622b95d7178a1a05e1d27d814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Thu, 27 Sep 2007 16:59:54 +0000 Subject: #90570 by bdragon and chx: GET query and fragment information were not possible to define in menu links --- modules/menu/menu.admin.inc | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/menu/menu.admin.inc b/modules/menu/menu.admin.inc index 4a7147060..d697c08b3 100644 --- a/modules/menu/menu.admin.inc +++ b/modules/menu/menu.admin.inc @@ -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' => '', '%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']))); } -- cgit v1.2.3