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