Browse Source

Renaming base url config keys and methods for better uniformity.

ADmad 12 years ago
parent
commit
61bf8df454

+ 4 - 4
app/Config/core.php

@@ -115,25 +115,25 @@
  * will override the automatic detection of full base URL and can be
  * useful when generating links from the CLI (e.g. sending emails)
  */
-	//Configure::write('App.fullBaseURL', 'http://example.com');
+	//Configure::write('App.fullBaseUrl', 'http://example.com');
 
 /**
  * Web path to the public images directory under webroot.
  * If not set defaults to 'img/'
  */
-	//Configure::write('App.imagesURL', 'img/');
+	//Configure::write('App.imageBaseUrl', 'img/');
 
 /**
  * Web path to the CSS files directory under webroot.
  * If not set defaults to 'css/'
  */
-	//Configure::write('App.cssURL', 'css/');
+	//Configure::write('App.cssBaseUrl', 'css/');
 
 /**
  * Web path to the js files directory under webroot.
  * If not set defaults to 'js/'
  */
-	//Configure::write('App.jsURL', 'js/');
+	//Configure::write('App.jsBaseUrl', 'js/');
 
 /**
  * Uncomment the define below to use CakePHP prefix routes.

+ 2 - 2
lib/Cake/Console/ShellDispatcher.php

@@ -137,9 +137,9 @@ class ShellDispatcher {
 		$this->setErrorHandlers();
 
 		if (!defined('FULL_BASE_URL')) {
-			$url = Configure::read('App.fullBaseURL');
+			$url = Configure::read('App.fullBaseUrl');
 			define('FULL_BASE_URL', $url ? $url : 'http://localhost');
-			Configure::write('App.fullBaseURL', FULL_BASE_URL);
+			Configure::write('App.fullBaseUrl', FULL_BASE_URL);
 		}
 
 		return true;

+ 4 - 4
lib/Cake/Console/Templates/skel/Config/core.php

@@ -106,25 +106,25 @@
  * will override the automatic detection of full base URL and can be
  * useful when generating links from the CLI (e.g. sending emails)
  */
-	//Configure::write('App.fullBaseURL', 'http://example.com');
+	//Configure::write('App.fullBaseUrl', 'http://example.com');
 
 /**
  * Web path to the public images directory under webroot.
  * If not set defaults to 'img/'
  */
-	//Configure::write('App.imagesURL', 'img/');
+	//Configure::write('App.imageBaseUrl', 'img/');
 
 /**
  * Web path to the CSS files directory under webroot.
  * If not set defaults to 'css/'
  */
-	//Configure::write('App.cssURL', 'css/');
+	//Configure::write('App.cssBaseUrl', 'css/');
 
 /**
  * Web path to the js files directory under webroot.
  * If not set defaults to 'js/'
  */
-	//Configure::write('App.jsURL', 'js/');
+	//Configure::write('App.jsBaseUrl', 'js/');
 
 /**
  * Uncomment the define below to use CakePHP prefix routes.

+ 2 - 2
lib/Cake/Core/Object.php

@@ -88,8 +88,8 @@ class Object {
 		$data = isset($extra['data']) ? $extra['data'] : null;
 		unset($extra['data']);
 
-		if (is_string($url) && strpos($url, Router::baseURL()) === 0) {
-			$url = Router::normalize(str_replace(Router::baseURL(), '', $url));
+		if (is_string($url) && strpos($url, Router::fullBaseUrl()) === 0) {
+			$url = Router::normalize(str_replace(Router::fullBaseUrl(), '', $url));
 		}
 		if (is_string($url)) {
 			$request = new CakeRequest($url);

+ 2 - 2
lib/Cake/Network/CakeRequest.php

@@ -238,7 +238,7 @@ class CakeRequest implements ArrayAccess {
 			if ($qPosition !== false && strpos($_SERVER['REQUEST_URI'], '://') > $qPosition) {
 				$uri = $_SERVER['REQUEST_URI'];
 			} else {
-				$uri = substr($_SERVER['REQUEST_URI'], strlen(Configure::read('App.fullBaseURL')));
+				$uri = substr($_SERVER['REQUEST_URI'], strlen(Configure::read('App.fullBaseUrl')));
 			}
 		} elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['SCRIPT_NAME'])) {
 			$uri = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['PHP_SELF']);
@@ -424,7 +424,7 @@ class CakeRequest implements ArrayAccess {
 			$ref = $forwarded;
 		}
 
-		$base = Configure::read('App.fullBaseURL') . $this->webroot;
+		$base = Configure::read('App.fullBaseUrl') . $this->webroot;
 		if (!empty($ref) && !empty($base)) {
 			if ($local && strpos($ref, $base) === 0) {
 				$ref = substr($ref, strlen($base));

+ 10 - 10
lib/Cake/Routing/Router.php

@@ -62,7 +62,7 @@ class Router {
  *
  * @var string
  */
-	protected static $_baseURL;
+	protected static $_fullBaseUrl;
 
 /**
  * List of action prefixes used in connected routes.
@@ -767,7 +767,7 @@ class Router {
  *   cake relative URLs are required when using requestAction.
  * - `?` - Takes an array of query string parameters
  * - `#` - Allows you to set URL hash fragments.
- * - `full_base` - If true the `Router::baseURL()` value will be prepended to generated URLs.
+ * - `full_base` - If true the `Router::fullBaseUrl()` value will be prepended to generated URLs.
  *
  * @param string|array $url Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4"
  *   or an array specifying any of the following: 'controller', 'action',
@@ -805,7 +805,7 @@ class Router {
 		if (empty($url)) {
 			$output = isset($path['here']) ? $path['here'] : '/';
 			if ($full) {
-				$output = self::baseURL() . $output;
+				$output = self::fullBaseUrl() . $output;
 			}
 			return $output;
 		} elseif (is_array($url)) {
@@ -893,7 +893,7 @@ class Router {
 			$output = str_replace('//', '/', $base . '/' . $output);
 
 			if ($full) {
-				$output = self::baseURL() . $output;
+				$output = self::fullBaseUrl() . $output;
 			}
 			if (!empty($extension)) {
 				$output = rtrim($output, '/');
@@ -917,15 +917,15 @@ class Router {
  * For example: ``http://example.com``
  * @return string
  */
-	public static function baseURL($base = null) {
+	public static function fullBaseUrl($base = null) {
 		if ($base !== null) {
-			self::$_baseURL = $base;
-			Configure::write('App.fullBaseURL', $base);
+			self::$_fullBaseUrl = $base;
+			Configure::write('App.fullBaseUrl', $base);
 		}
-		if (empty(self::$_baseURL)) {
-			self::$_baseURL = Configure::read('App.fullBaseURL');
+		if (empty(self::$_fullBaseUrl)) {
+			self::$_fullBaseUrl = Configure::read('App.fullBaseUrl');
 		}
-		return self::$_baseURL;
+		return self::$_fullBaseUrl;
 	}
 
 /**

+ 1 - 1
lib/Cake/Test/Case/Core/ObjectTest.php

@@ -456,7 +456,7 @@ class ObjectTest extends CakeTestCase {
 		$this->assertEquals($expected, $result);
 
 		$result = $this->object->requestAction(
-			Configure::read('App.fullBaseURL') . '/request_action/test_request_action'
+			Configure::read('App.fullBaseUrl') . '/request_action/test_request_action'
 		);
 		$expected = 'This is a test';
 		$this->assertEquals($expected, $result);

+ 6 - 6
lib/Cake/Test/Case/Network/CakeRequestTest.php

@@ -157,7 +157,7 @@ class CakeRequestTest extends CakeTestCase {
 		$request = new CakeRequest();
 		$this->assertEquals('some/path', $request->url);
 
-		$_SERVER['REQUEST_URI'] = Configure::read('App.fullBaseURL') . '/other/path?url=http://cakephp.org';
+		$_SERVER['REQUEST_URI'] = Configure::read('App.fullBaseUrl') . '/other/path?url=http://cakephp.org';
 		$request = new CakeRequest();
 		$this->assertEquals('other/path', $request->url);
 	}
@@ -689,19 +689,19 @@ class CakeRequestTest extends CakeTestCase {
 		$result = $request->referer();
 		$this->assertSame($result, '/');
 
-		$_SERVER['HTTP_REFERER'] = Configure::read('App.fullBaseURL') . '/some/path';
+		$_SERVER['HTTP_REFERER'] = Configure::read('App.fullBaseUrl') . '/some/path';
 		$result = $request->referer(true);
 		$this->assertSame($result, '/some/path');
 
-		$_SERVER['HTTP_REFERER'] = Configure::read('App.fullBaseURL') . '/some/path';
+		$_SERVER['HTTP_REFERER'] = Configure::read('App.fullBaseUrl') . '/some/path';
 		$result = $request->referer(false);
-		$this->assertSame($result, Configure::read('App.fullBaseURL') . '/some/path');
+		$this->assertSame($result, Configure::read('App.fullBaseUrl') . '/some/path');
 
-		$_SERVER['HTTP_REFERER'] = Configure::read('App.fullBaseURL') . '/some/path';
+		$_SERVER['HTTP_REFERER'] = Configure::read('App.fullBaseUrl') . '/some/path';
 		$result = $request->referer(true);
 		$this->assertSame($result, '/some/path');
 
-		$_SERVER['HTTP_REFERER'] = Configure::read('App.fullBaseURL') . '/recipes/add';
+		$_SERVER['HTTP_REFERER'] = Configure::read('App.fullBaseUrl') . '/recipes/add';
 		$result = $request->referer(true);
 		$this->assertSame($result, '/recipes/add');
 

+ 7 - 7
lib/Cake/Test/Case/Routing/RouterTest.php

@@ -49,8 +49,8 @@ class RouterTest extends CakeTestCase {
 	public function tearDown() {
 		parent::tearDown();
 		CakePlugin::unload();
-		Router::baseURL('');
-		Configure::write('App.fullBaseURL', 'http://localhost');
+		Router::fullbaseURL('');
+		Configure::write('App.fullBaseUrl', 'http://localhost');
 	}
 
 /**
@@ -71,13 +71,13 @@ class RouterTest extends CakeTestCase {
  * @return void
  */
 	public function testBaseURL() {
-		$this->assertEquals(FULL_BASE_URL, Router::baseUrl());
-		Router::baseURL('http://example.com');
+		$this->assertEquals(FULL_BASE_URL, Router::fullBaseUrl());
+		Router::fullbaseURL('http://example.com');
 		$this->assertEquals('http://example.com/', Router::url('/', true));
-		$this->assertEquals('http://example.com', Configure::read('App.fullBaseURL'));
-		Router::baseURL('https://example.com');
+		$this->assertEquals('http://example.com', Configure::read('App.fullBaseUrl'));
+		Router::fullbaseURL('https://example.com');
 		$this->assertEquals('https://example.com/', Router::url('/', true));
-		$this->assertEquals('https://example.com', Configure::read('App.fullBaseURL'));
+		$this->assertEquals('https://example.com', Configure::read('App.fullBaseUrl'));
 	}
 
 /**

+ 2 - 2
lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php

@@ -210,7 +210,7 @@ class HtmlHelperTest extends CakeTestCase {
 		Router::reload();
 
 		$result = $this->Html->link('Posts', array('controller' => 'posts', 'action' => 'index', 'full_base' => true));
-		$expected = array('a' => array('href' => Router::baseURL() . '/posts'), 'Posts', '/a');
+		$expected = array('a' => array('href' => Router::fullBaseUrl() . '/posts'), 'Posts', '/a');
 		$this->assertTags($result, $expected);
 
 		$result = $this->Html->link('Home', '/home', array('confirm' => 'Are you sure you want to do this?'));
@@ -1877,7 +1877,7 @@ class HtmlHelperTest extends CakeTestCase {
 			array('pathPrefix' => 'videos/', 'poster' => 'poster.jpg', 'text' => 'Your browser does not support the HTML5 Video element.')
 		);
 		$expected = array(
-			'video' => array('poster' => Configure::read('App.imagesURL') . 'poster.jpg'),
+			'video' => array('poster' => Configure::read('App.imageBaseUrl') . 'poster.jpg'),
 				array('source' => array('src' => 'videos/video.webm', 'type' => 'video/webm')),
 				array('source' => array('src' => 'videos/video.ogv', 'type' => 'video/ogg; codecs='theora, vorbis'')),
 				'Your browser does not support the HTML5 Video element.',

+ 16 - 16
lib/Cake/Test/Case/View/HelperTest.php

@@ -600,8 +600,8 @@ class HelperTest extends CakeTestCase {
 	public function testAssetTimestamp() {
 		Configure::write('Foo.bar', 'test');
 		Configure::write('Asset.timestamp', false);
-		$result = $this->Helper->assetTimestamp(Configure::read('App.cssURL') . 'cake.generic.css');
-		$this->assertEquals(Configure::read('App.cssURL') . 'cake.generic.css', $result);
+		$result = $this->Helper->assetTimestamp(Configure::read('App.cssBaseUrl') . 'cake.generic.css');
+		$this->assertEquals(Configure::read('App.cssBaseUrl') . 'cake.generic.css', $result);
 
 		Configure::write('Asset.timestamp', true);
 		Configure::write('debug', 0);
@@ -609,25 +609,25 @@ class HelperTest extends CakeTestCase {
 		$result = $this->Helper->assetTimestamp('/%3Cb%3E/cake.generic.css');
 		$this->assertEquals('/%3Cb%3E/cake.generic.css', $result);
 
-		$result = $this->Helper->assetTimestamp(Configure::read('App.cssURL') . 'cake.generic.css');
-		$this->assertEquals(Configure::read('App.cssURL') . 'cake.generic.css', $result);
+		$result = $this->Helper->assetTimestamp(Configure::read('App.cssBaseUrl') . 'cake.generic.css');
+		$this->assertEquals(Configure::read('App.cssBaseUrl') . 'cake.generic.css', $result);
 
 		Configure::write('Asset.timestamp', true);
 		Configure::write('debug', 2);
-		$result = $this->Helper->assetTimestamp(Configure::read('App.cssURL') . 'cake.generic.css');
-		$this->assertRegExp('/' . preg_quote(Configure::read('App.cssURL') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
+		$result = $this->Helper->assetTimestamp(Configure::read('App.cssBaseUrl') . 'cake.generic.css');
+		$this->assertRegExp('/' . preg_quote(Configure::read('App.cssBaseUrl') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
 
 		Configure::write('Asset.timestamp', 'force');
 		Configure::write('debug', 0);
-		$result = $this->Helper->assetTimestamp(Configure::read('App.cssURL') . 'cake.generic.css');
-		$this->assertRegExp('/' . preg_quote(Configure::read('App.cssURL') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
+		$result = $this->Helper->assetTimestamp(Configure::read('App.cssBaseUrl') . 'cake.generic.css');
+		$this->assertRegExp('/' . preg_quote(Configure::read('App.cssBaseUrl') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
 
-		$result = $this->Helper->assetTimestamp(Configure::read('App.cssURL') . 'cake.generic.css?someparam');
-		$this->assertEquals(Configure::read('App.cssURL') . 'cake.generic.css?someparam', $result);
+		$result = $this->Helper->assetTimestamp(Configure::read('App.cssBaseUrl') . 'cake.generic.css?someparam');
+		$this->assertEquals(Configure::read('App.cssBaseUrl') . 'cake.generic.css?someparam', $result);
 
 		$this->Helper->request->webroot = '/some/dir/';
-		$result = $this->Helper->assetTimestamp('/some/dir/' . Configure::read('App.cssURL') . 'cake.generic.css');
-		$this->assertRegExp('/' . preg_quote(Configure::read('App.cssURL') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
+		$result = $this->Helper->assetTimestamp('/some/dir/' . Configure::read('App.cssBaseUrl') . 'cake.generic.css');
+		$this->assertRegExp('/' . preg_quote(Configure::read('App.cssBaseUrl') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
 	}
 
 /**
@@ -644,13 +644,13 @@ class HelperTest extends CakeTestCase {
 			),
 			array('fullBase' => true)
 		);
-		$this->assertEquals(Router::baseURL() . '/js/post.js', $result);
+		$this->assertEquals(Router::fullBaseUrl() . '/js/post.js', $result);
 
 		$result = $this->Helper->assetUrl('foo.jpg', array('pathPrefix' => 'img/'));
 		$this->assertEquals('img/foo.jpg', $result);
 
 		$result = $this->Helper->assetUrl('foo.jpg', array('fullBase' => true));
-		$this->assertEquals(Router::baseURL() . '/foo.jpg', $result);
+		$this->assertEquals(Router::fullBaseUrl() . '/foo.jpg', $result);
 
 		$result = $this->Helper->assetUrl('style', array('ext' => '.css'));
 		$this->assertEquals('style.css', $result);
@@ -708,8 +708,8 @@ class HelperTest extends CakeTestCase {
 		$this->Helper->webroot = '';
 		Configure::write('Asset.timestamp', 'force');
 
-		$result = $this->Helper->assetUrl('cake.generic.css', array('pathPrefix' => Configure::read('App.cssURL')));
-		$this->assertRegExp('/' . preg_quote(Configure::read('App.cssURL') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
+		$result = $this->Helper->assetUrl('cake.generic.css', array('pathPrefix' => Configure::read('App.cssBaseUrl')));
+		$this->assertRegExp('/' . preg_quote(Configure::read('App.cssBaseUrl') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
 	}
 
 /**

+ 1 - 1
lib/Cake/View/Helper.php

@@ -328,7 +328,7 @@ class Helper extends Object {
 		$path = $this->_encodeUrl($this->assetTimestamp($this->webroot($path)));
 
 		if (!empty($options['fullBase'])) {
-			$path = rtrim(Router::baseURL(), '/') . '/' . ltrim($path, '/');
+			$path = rtrim(Router::fullBaseUrl(), '/') . '/' . ltrim($path, '/');
 		}
 		return $path;
 	}

+ 1 - 1
lib/Cake/View/Helper/FormHelper.php

@@ -1880,7 +1880,7 @@ class FormHelper extends AppHelper {
 		} elseif ($isImage) {
 			unset($options['type']);
 			if ($caption{0} !== '/') {
-				$url = $this->webroot(Configure::read('App.imagesURL') . $caption);
+				$url = $this->webroot(Configure::read('App.imageBaseUrl') . $caption);
 			} else {
 				$url = $this->webroot(trim($caption, '/'));
 			}

+ 7 - 7
lib/Cake/View/Helper/HtmlHelper.php

@@ -444,13 +444,13 @@ class HtmlHelper extends AppHelper {
 		if (strpos($path, '//') !== false) {
 			$url = $path;
 		} else {
-			$url = $this->assetUrl($path, $options + array('pathPrefix' => Configure::read('App.cssURL'), 'ext' => '.css'));
+			$url = $this->assetUrl($path, $options + array('pathPrefix' => Configure::read('App.cssBaseUrl'), 'ext' => '.css'));
 			$options = array_diff_key($options, array('fullBase' => null));
 
 			if (Configure::read('Asset.filter.css')) {
-				$pos = strpos($url, Configure::read('App.cssURL'));
+				$pos = strpos($url, Configure::read('App.cssBaseUrl'));
 				if ($pos !== false) {
-					$url = substr($url, 0, $pos) . 'ccss/' . substr($url, $pos + strlen(Configure::read('App.cssURL')));
+					$url = substr($url, 0, $pos) . 'ccss/' . substr($url, $pos + strlen(Configure::read('App.cssBaseUrl')));
 				}
 			}
 		}
@@ -545,11 +545,11 @@ class HtmlHelper extends AppHelper {
 		$this->_includedScripts[$url] = true;
 
 		if (strpos($url, '//') === false) {
-			$url = $this->assetUrl($url, $options + array('pathPrefix' => Configure::read('App.jsURL'), 'ext' => '.js'));
+			$url = $this->assetUrl($url, $options + array('pathPrefix' => Configure::read('App.jsBaseUrl'), 'ext' => '.js'));
 			$options = array_diff_key($options, array('fullBase' => null));
 
 			if (Configure::read('Asset.filter.js')) {
-				$url = str_replace(Configure::read('App.jsURL'), 'cjs/', $url);
+				$url = str_replace(Configure::read('App.jsBaseUrl'), 'cjs/', $url);
 			}
 		}
 		$attributes = $this->_parseAttributes($options, array('block', 'once'), ' ');
@@ -803,7 +803,7 @@ class HtmlHelper extends AppHelper {
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::image
  */
 	public function image($path, $options = array()) {
-		$path = $this->assetUrl($path, $options + array('pathPrefix' => Configure::read('App.imagesURL')));
+		$path = $this->assetUrl($path, $options + array('pathPrefix' => Configure::read('App.imageBaseUrl')));
 		$options = array_diff_key($options, array('fullBase' => null, 'pathPrefix' => null));
 
 		if (!isset($options['alt'])) {
@@ -1106,7 +1106,7 @@ class HtmlHelper extends AppHelper {
 		}
 
 		if (isset($options['poster'])) {
-			$options['poster'] = $this->assetUrl($options['poster'], array('pathPrefix' => Configure::read('App.imagesURL')) + $options);
+			$options['poster'] = $this->assetUrl($options['poster'], array('pathPrefix' => Configure::read('App.imageBaseUrl')) + $options);
 		}
 		$text = $options['text'];
 

+ 4 - 4
lib/Cake/bootstrap.php

@@ -163,14 +163,14 @@ if (!defined('FULL_BASE_URL')) {
 
 	if (isset($httpHost)) {
 		define('FULL_BASE_URL', 'http' . $s . '://' . $httpHost);
-		Configure::write('App.fullBaseURL', FULL_BASE_URL);
+		Configure::write('App.fullBaseUrl', FULL_BASE_URL);
 	}
 	unset($httpHost, $s);
 }
 
-Configure::write('App.imagesURL', IMAGES_URL);
-Configure::write('App.cssURL', CSS_URL);
-Configure::write('App.jsURL', JS_URL);
+Configure::write('App.imageBaseUrl', IMAGES_URL);
+Configure::write('App.cssBaseUrl', CSS_URL);
+Configure::write('App.jsBaseUrl', JS_URL);
 
 App::$bootstrapping = true;