--- bootstrap.inc.1 2005-02-03 15:42:39.000000000 +0100 +++ bootstrap.inc 2005-02-03 15:43:38.000000000 +0100 @@ -628,6 +628,134 @@ function drupal_get_messages() { return $messages; } +/** + * Send the user to a different Drupal page. + * + * This issues an on-site HTTP redirect. The function makes sure the redirected + * URL is formatted correctly. + * + * It is advised to use drupal_goto() instead of PHP's header(), because + * drupal_goto() will append the user's session ID to the URI when PHP is + * compiled with "--enable-trans-sid". + * + * This function ends the request; use it rather than a print theme('page') + * statement in your menu callback. + * + * @param $path + * A Drupal path. + * @param $query + * The query string component, if any. + * @param $fragment + * The destination fragment identifier (named anchor). + */ +function drupal_goto($path = '', $query = NULL, $fragment = NULL) { + // Translate & to simply & in the absolute URL. + $url = str_replace('&', '&', url($path, $query, $fragment, TRUE)); + + if (ini_get('session.use_trans_sid') && session_id() && !strstr($url, session_id())) { + $sid = session_name() . '=' . session_id(); + + if (strstr($url, '?') && !strstr($url, $sid)) { + $url = $url .'&'. $sid; + } + else { + $url = $url .'?'. $sid; + } + } + + // Before the redirect, allow modules to react to the end of the page request. + module_invoke_all('exit', $url); + + header('Location: '. $url); + + // The "Location" header sends a REDIRECT status code to the http + // daemon. In some cases this can go wrong, so we make sure none + // of the code below the drupal_goto() call gets executed when we redirect. + exit(); +} + +/** + * Generate an internal Drupal URL. + * + * @param $path + * The Drupal path being linked to, such as "admin/node". + * @param $query + * A query string to append to the link. + * @param $fragment + * A fragment identifier (named anchor) to append to the link. + * @param $absolute + * Whether to force the output to be an absolute link (beginning with http:). + * Useful for links that will be displayed outside the site, such as in an RSS feed. + * @return + * an HTML string containing a link to the given path. + * + * When creating links in modules, consider whether l() could be a better + * alternative than url(). + */ +function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { + global $base_url; + + static $script; + + if (empty($script)) { + // On some web servers, such as IIS, we can't omit "index.php". So, we + // generate "index.php?q=foo" instead of "?q=foo" on anything that is not + // Apache. + $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) ? 'index.php' : ''; + } + + if (function_exists('drupal_get_path_alias')) { + $path = drupal_get_path_alias($path); + } + + if (function_exists('i18n_url_rewrite')) { + $path = i18n_url_rewrite($path); + } + + if (isset($fragment)) { + $fragment = '#'. $fragment; + } + + $base = ($absolute ? $base_url . '/' : ''); + + if (variable_get('clean_url', '0') == '0') { + if (isset($path)) { + if (isset($query)) { + return $base . $script .'?q='. $path .'&'. $query . $fragment; + } + else { + return $base . $script .'?q='. $path . $fragment; + } + } + 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; + } + else { + return $base . $path . $fragment; + } + } + else { + if (isset($query)) { + return $base . $script .'?'. $query . $fragment; + } + else { + return $base . $fragment; + } + } + } +} + unset($conf); $config = conf_init(); --- common.inc.1 2005-02-03 15:42:33.000000000 +0100 +++ common.inc 2005-02-03 15:43:31.000000000 +0100 @@ -134,71 +134,6 @@ function drupal_get_destination() { } /** - * Send the user to a different Drupal page. - * - * This issues an on-site HTTP redirect. The function makes sure the redirected - * URL is formatted correctly. - * - * Usually the redirected URL is constructed from this function's input - * parameters. However you may override that behavior by setting a - * destination in either the $_REQUEST-array (i.e. by using - * the query string of an URI) or the $_REQUEST['edit']-array (i.e. by - * using a hidden form field). This is used to direct the user back to - * the proper page after completing a form. For example, after editing - * a post on the 'admin/node'-page or after having logged on using the - * 'user login'-block in a sidebar. The function drupal_get_destination() - * can be used to help set the destination URL. - * - * It is advised to use drupal_goto() instead of PHP's header(), because - * drupal_goto() will append the user's session ID to the URI when PHP is - * compiled with "--enable-trans-sid". - * - * This function ends the request; use it rather than a print theme('page') - * statement in your menu callback. - * - * @param $path - * A Drupal path. - * @param $query - * The query string component, if any. - * @param $fragment - * The destination fragment identifier (named anchor). - * - * @see drupal_get_destination() - */ -function drupal_goto($path = '', $query = NULL, $fragment = NULL) { - if ($_REQUEST['destination']) { - extract(parse_url($_REQUEST['destination'])); - } - else if ($_REQUEST['edit']['destination']) { - extract(parse_url($_REQUEST['edit']['destination'])); - } - - // Translate & to simply & in the absolute URL. - $url = str_replace('&', '&', url($path, $query, $fragment, TRUE)); - - if (ini_get('session.use_trans_sid') && session_id() && !strstr($url, session_id())) { - $sid = session_name() . '=' . session_id(); - - if (strstr($url, '?') && !strstr($url, $sid)) { - $url = $url .'&'. $sid; - } - else { - $url = $url .'?'. $sid; - } - } - - // Before the redirect, allow modules to react to the end of the page request. - module_invoke_all('exit', $url); - - header('Location: '. $url); - - // The "Location" header sends a REDIRECT status code to the http - // daemon. In some cases this can go wrong, so we make sure none - // of the code below the drupal_goto() call gets executed when we redirect. - exit(); -} - -/** * Generates a 404 error if the request can not be handled. */ function drupal_not_found() { @@ -1440,82 +1375,6 @@ function form_weight($title = NULL, $nam */ /** - * Generate an internal Drupal URL. - * - * @param $path - * The Drupal path being linked to, such as "admin/node". - * @param $query - * A query string to append to the link. - * @param $fragment - * A fragment identifier (named anchor) to append to the link. - * @param $absolute - * Whether to force the output to be an absolute link (beginning with http:). - * Useful for links that will be displayed outside the site, such as in an RSS feed. - * @return - * an HTML string containing a link to the given path. - * - * When creating links in modules, consider whether l() could be a better - * alternative than url(). - */ -function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { - global $base_url; - - static $script; - - if (empty($script)) { - // On some web servers, such as IIS, we can't omit "index.php". So, we - // generate "index.php?q=foo" instead of "?q=foo" on anything that is not - // Apache. - $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) ? 'index.php' : ''; - } - - $path = drupal_get_path_alias($path); - - if (isset($fragment)) { - $fragment = '#'. $fragment; - } - - $base = ($absolute ? $base_url . '/' : ''); - - if (variable_get('clean_url', '0') == '0') { - if (isset($path)) { - if (isset($query)) { - return $base . $script .'?q='. $path .'&'. $query . $fragment; - } - else { - return $base . $script .'?q='. $path . $fragment; - } - } - 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; - } - else { - return $base . $path . $fragment; - } - } - else { - if (isset($query)) { - return $base . $script .'?'. $query . $fragment; - } - else { - return $base . $fragment; - } - } - } -} - -/** * Format an attribute string to insert in a tag. * * @param $attributes