BUGFIX Reverted Director class using BASE_PATH instead of dirname(dirname(['SCRIPT_FILENAME'])), originally committed in r63154

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63157 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-09-27 17:02:46 +00:00
parent c4a47f1def
commit 0da97be4f9

View File

@ -272,9 +272,7 @@ class Director {
* @todo Document how relativeToSiteBase works
*/
static function absoluteURL($url, $relativeToSiteBase = false) {
if(strpos($url,'/') === false && !$relativeToSiteBase && !self::$alternateBaseURL) {
$url = dirname($_SERVER['REQUEST_URI'] . 'x') . '/' . $url;
}
if(strpos($url,'/') === false && !$relativeToSiteBase) $url = dirname($_SERVER['REQUEST_URI'] . 'x') . '/' . $url;
if(substr($url,0,4) != "http") {
if($url[0] != "/") $url = Director::baseURL() . $url;
@ -376,14 +374,12 @@ class Director {
/**
* Returns the root URL for the site.
* It will be automatically determined from the current script URL
* unless it is overridden with {@link setBaseURL()}.
* It will be automatically calculated unless it is overridden with {@link setBaseURL()}.
*/
static function baseURL() {
if(self::$alternateBaseURL) {
return self::$alternateBaseURL;
} else {
$base = BASE_URL;
if(self::$alternateBaseURL) return self::$alternateBaseURL;
else {
$base = dirname(dirname($_SERVER['SCRIPT_NAME']));
if($base == '/' || $base == '/.' || $base == '\\') return '/';
else return $base . '/';
}
@ -392,7 +388,6 @@ class Director {
/**
* Sets the root URL for the website.
* If the site isn't accessible from the URL you provide, weird things will happen.
* Set to false if you want to undo the base url override.
*/
static function setBaseURL($baseURL) {
self::$alternateBaseURL = $baseURL;
@ -404,7 +399,7 @@ class Director {
*/
static function baseFolder() {
if(self::$alternateBaseFolder) return self::$alternateBaseFolder;
else return BASE_PATH;
else return dirname(dirname($_SERVER['SCRIPT_FILENAME']));
}
/**
@ -471,8 +466,6 @@ class Director {
/**
* Returns the Absolute URL of the site root, embedding the current basic-auth credentials into the URL.
*
* @todo allow override by self::$alternateBaseURL
*/
static function absoluteBaseURLWithAuth() {
$s = "";
@ -491,8 +484,6 @@ class Director {
* <code>
* if(Director::isLive()) Director::forceSSL();
* </code>
*
* @todo allow override by self::$alternateBaseURL
*/
static function forceSSL() {
if(!isset($_SERVER['HTTPS']) && !Director::isDev()) {
@ -505,8 +496,6 @@ class Director {
/**
* Force a redirect to a domain starting with "www."
*
* @todo allow override by self::$alternateBaseURL
*/
static function forceWWW() {
if(!Director::isDev() && !Director::isTest() && strpos( $_SERVER['SERVER_NAME'], 'www') !== 0 ){