From 34a5d46022b47be3ef30f32ce1187081918c7ab0 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 27 Dec 2005 10:36:16 +0000 Subject: [PATCH] - Patch #36465 by chx / Richard: made it possible to link to the front page. --- includes/common.inc | 36 ++++++++++++++++-------------------- includes/menu.inc | 2 +- modules/menu.module | 2 +- modules/menu/menu.module | 2 +- modules/system.module | 3 +++ modules/system/system.module | 3 +++ 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/includes/common.inc b/includes/common.inc index cf194cbc53e..5af1f5be21e 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -954,6 +954,7 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { global $base_url; static $script; + static $clean_url; if (empty($script)) { // On some web servers, such as IIS, we can't omit "index.php". So, we @@ -962,8 +963,10 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) ? 'index.php' : ''; } - $path = drupal_get_path_alias($path); - $path = drupal_urlencode($path); + // Cache the clean_url variable to improve performance. + if ($clean_url === NULL) { + $clean_url = (variable_get('clean_url', '0') == '0') ? false : true; + } if (isset($fragment)) { $fragment = '#'. $fragment; @@ -971,8 +974,11 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { $base = ($absolute ? $base_url .'/' : ''); - if (variable_get('clean_url', '0') == '0') { - if (isset($path)) { + // The special path '' links to the default front page. + if (isset($path) && $path != '') { + $path = drupal_get_path_alias($path); + $path = drupal_urlencode($path); + if (!$clean_url) { if (isset($query)) { return $base . $script .'?q='. $path .'&'. $query . $fragment; } @@ -981,16 +987,6 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { } } else { - if (isset($query)) { - return $base . $script .'?'. $query . $fragment; - } - else { - return $base . $fragment; - } - } - } - else { - if (isset($path)) { if (isset($query)) { return $base . $path .'?'. $query . $fragment; } @@ -998,13 +994,13 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { return $base . $path . $fragment; } } + } + else { + if (isset($query)) { + return $base . $script .'?'. $query . $fragment; + } else { - if (isset($query)) { - return $base . $script .'?'. $query . $fragment; - } - else { - return $base . $fragment; - } + return $base . $fragment; } } } diff --git a/includes/menu.inc b/includes/menu.inc index aecc7fcc661..e511ec6bdbc 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -464,7 +464,7 @@ function menu_get_active_help() { function menu_get_active_breadcrumb() { $menu = menu_get_menu(); - $links[] = l(t('Home'), ''); + $links[] = l(t('Home'), ''); $trail = _menu_get_active_trail(); foreach ($trail as $mid) { diff --git a/modules/menu.module b/modules/menu.module index 37cf137b779..ef22582cf80 100644 --- a/modules/menu.module +++ b/modules/menu.module @@ -400,7 +400,7 @@ function menu_edit_item_form($edit) { else { $form['description'] = array('#type' => 'textfield', '#title' => t('Description'), '#default_value' => $edit['description'], '#description' => t('The description displayed when hovering over a menu item.')); - $path_description = t('The Drupal path this menu item links to.'); + $path_description = t('The Drupal path this menu item links to. Enter %front to link to the front page.', array('%front' => theme('placeholder', ''))); if ($edit['type'] & MENU_CREATED_BY_ADMIN) { $form['path'] = array('#type' => 'textfield', '#title' => t('Path'), '#default_value' => $edit['path'], '#description' => $path_description, '#required' => TRUE); diff --git a/modules/menu/menu.module b/modules/menu/menu.module index 37cf137b779..ef22582cf80 100644 --- a/modules/menu/menu.module +++ b/modules/menu/menu.module @@ -400,7 +400,7 @@ function menu_edit_item_form($edit) { else { $form['description'] = array('#type' => 'textfield', '#title' => t('Description'), '#default_value' => $edit['description'], '#description' => t('The description displayed when hovering over a menu item.')); - $path_description = t('The Drupal path this menu item links to.'); + $path_description = t('The Drupal path this menu item links to. Enter %front to link to the front page.', array('%front' => theme('placeholder', ''))); if ($edit['type'] & MENU_CREATED_BY_ADMIN) { $form['path'] = array('#type' => 'textfield', '#title' => t('Path'), '#default_value' => $edit['path'], '#description' => $path_description, '#required' => TRUE); diff --git a/modules/system.module b/modules/system.module index f98ae7c24b5..b634a232e36 100644 --- a/modules/system.module +++ b/modules/system.module @@ -752,6 +752,9 @@ function system_settings_form_submit($form_id, $values) { else { drupal_set_message(t('The configuration options have been saved.')); } + if ($form_id == 'system_settings_form') { + menu_rebuild(); + } } /** diff --git a/modules/system/system.module b/modules/system/system.module index f98ae7c24b5..b634a232e36 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -752,6 +752,9 @@ function system_settings_form_submit($form_id, $values) { else { drupal_set_message(t('The configuration options have been saved.')); } + if ($form_id == 'system_settings_form') { + menu_rebuild(); + } } /**