mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Deprecate constants IMAGES_URL, CSS_URL, JS_URL and add corresponding config values instead.
This commit is contained in:
parent
48df85d80d
commit
b22b39f158
7 changed files with 63 additions and 23 deletions
|
@ -117,6 +117,24 @@
|
||||||
*/
|
*/
|
||||||
//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/');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web path to the CSS files directory under webroot.
|
||||||
|
* If not set defaults to 'css/'
|
||||||
|
*/
|
||||||
|
//Configure::write('App.cssURL', 'css/');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web path to the js files directory under webroot.
|
||||||
|
* If not set defaults to 'js/'
|
||||||
|
*/
|
||||||
|
//Configure::write('App.jsURL', 'js/');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uncomment the define below to use CakePHP prefix routes.
|
* Uncomment the define below to use CakePHP prefix routes.
|
||||||
*
|
*
|
||||||
|
|
|
@ -108,6 +108,24 @@
|
||||||
*/
|
*/
|
||||||
//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/');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web path to the CSS files directory under webroot.
|
||||||
|
* If not set defaults to 'css/'
|
||||||
|
*/
|
||||||
|
//Configure::write('App.cssURL', 'css/');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web path to the js files directory under webroot.
|
||||||
|
* If not set defaults to 'js/'
|
||||||
|
*/
|
||||||
|
//Configure::write('App.jsURL', 'js/');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uncomment the define below to use CakePHP prefix routes.
|
* Uncomment the define below to use CakePHP prefix routes.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1877,7 +1877,7 @@ class HtmlHelperTest extends CakeTestCase {
|
||||||
array('pathPrefix' => 'videos/', 'poster' => 'poster.jpg', 'text' => 'Your browser does not support the HTML5 Video element.')
|
array('pathPrefix' => 'videos/', 'poster' => 'poster.jpg', 'text' => 'Your browser does not support the HTML5 Video element.')
|
||||||
);
|
);
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'video' => array('poster' => IMAGES_URL . 'poster.jpg'),
|
'video' => array('poster' => Configure::read('App.imagesURL') . 'poster.jpg'),
|
||||||
array('source' => array('src' => 'videos/video.webm', 'type' => 'video/webm')),
|
array('source' => array('src' => 'videos/video.webm', 'type' => 'video/webm')),
|
||||||
array('source' => array('src' => 'videos/video.ogv', 'type' => 'video/ogg; codecs='theora, vorbis'')),
|
array('source' => array('src' => 'videos/video.ogv', 'type' => 'video/ogg; codecs='theora, vorbis'')),
|
||||||
'Your browser does not support the HTML5 Video element.',
|
'Your browser does not support the HTML5 Video element.',
|
||||||
|
|
|
@ -600,8 +600,8 @@ class HelperTest extends CakeTestCase {
|
||||||
public function testAssetTimestamp() {
|
public function testAssetTimestamp() {
|
||||||
Configure::write('Foo.bar', 'test');
|
Configure::write('Foo.bar', 'test');
|
||||||
Configure::write('Asset.timestamp', false);
|
Configure::write('Asset.timestamp', false);
|
||||||
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css');
|
$result = $this->Helper->assetTimestamp(Configure::read('App.cssURL') . 'cake.generic.css');
|
||||||
$this->assertEquals(CSS_URL . 'cake.generic.css', $result);
|
$this->assertEquals(Configure::read('App.cssURL') . 'cake.generic.css', $result);
|
||||||
|
|
||||||
Configure::write('Asset.timestamp', true);
|
Configure::write('Asset.timestamp', true);
|
||||||
Configure::write('debug', 0);
|
Configure::write('debug', 0);
|
||||||
|
@ -609,25 +609,25 @@ class HelperTest extends CakeTestCase {
|
||||||
$result = $this->Helper->assetTimestamp('/%3Cb%3E/cake.generic.css');
|
$result = $this->Helper->assetTimestamp('/%3Cb%3E/cake.generic.css');
|
||||||
$this->assertEquals('/%3Cb%3E/cake.generic.css', $result);
|
$this->assertEquals('/%3Cb%3E/cake.generic.css', $result);
|
||||||
|
|
||||||
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css');
|
$result = $this->Helper->assetTimestamp(Configure::read('App.cssURL') . 'cake.generic.css');
|
||||||
$this->assertEquals(CSS_URL . 'cake.generic.css', $result);
|
$this->assertEquals(Configure::read('App.cssURL') . 'cake.generic.css', $result);
|
||||||
|
|
||||||
Configure::write('Asset.timestamp', true);
|
Configure::write('Asset.timestamp', true);
|
||||||
Configure::write('debug', 2);
|
Configure::write('debug', 2);
|
||||||
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css');
|
$result = $this->Helper->assetTimestamp(Configure::read('App.cssURL') . 'cake.generic.css');
|
||||||
$this->assertRegExp('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result);
|
$this->assertRegExp('/' . preg_quote(Configure::read('App.cssURL') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
|
||||||
|
|
||||||
Configure::write('Asset.timestamp', 'force');
|
Configure::write('Asset.timestamp', 'force');
|
||||||
Configure::write('debug', 0);
|
Configure::write('debug', 0);
|
||||||
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css');
|
$result = $this->Helper->assetTimestamp(Configure::read('App.cssURL') . 'cake.generic.css');
|
||||||
$this->assertRegExp('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result);
|
$this->assertRegExp('/' . preg_quote(Configure::read('App.cssURL') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
|
||||||
|
|
||||||
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css?someparam');
|
$result = $this->Helper->assetTimestamp(Configure::read('App.cssURL') . 'cake.generic.css?someparam');
|
||||||
$this->assertEquals(CSS_URL . 'cake.generic.css?someparam', $result);
|
$this->assertEquals(Configure::read('App.cssURL') . 'cake.generic.css?someparam', $result);
|
||||||
|
|
||||||
$this->Helper->request->webroot = '/some/dir/';
|
$this->Helper->request->webroot = '/some/dir/';
|
||||||
$result = $this->Helper->assetTimestamp('/some/dir/' . CSS_URL . 'cake.generic.css');
|
$result = $this->Helper->assetTimestamp('/some/dir/' . Configure::read('App.cssURL') . 'cake.generic.css');
|
||||||
$this->assertRegExp('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result);
|
$this->assertRegExp('/' . preg_quote(Configure::read('App.cssURL') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -708,8 +708,8 @@ class HelperTest extends CakeTestCase {
|
||||||
$this->Helper->webroot = '';
|
$this->Helper->webroot = '';
|
||||||
Configure::write('Asset.timestamp', 'force');
|
Configure::write('Asset.timestamp', 'force');
|
||||||
|
|
||||||
$result = $this->Helper->assetUrl('cake.generic.css', array('pathPrefix' => CSS_URL));
|
$result = $this->Helper->assetUrl('cake.generic.css', array('pathPrefix' => Configure::read('App.cssURL')));
|
||||||
$this->assertRegExp('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result);
|
$this->assertRegExp('/' . preg_quote(Configure::read('App.cssURL') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1880,7 +1880,7 @@ class FormHelper extends AppHelper {
|
||||||
} elseif ($isImage) {
|
} elseif ($isImage) {
|
||||||
unset($options['type']);
|
unset($options['type']);
|
||||||
if ($caption{0} !== '/') {
|
if ($caption{0} !== '/') {
|
||||||
$url = $this->webroot(IMAGES_URL . $caption);
|
$url = $this->webroot(Configure::read('App.imagesURL') . $caption);
|
||||||
} else {
|
} else {
|
||||||
$url = $this->webroot(trim($caption, '/'));
|
$url = $this->webroot(trim($caption, '/'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -444,13 +444,13 @@ class HtmlHelper extends AppHelper {
|
||||||
if (strpos($path, '//') !== false) {
|
if (strpos($path, '//') !== false) {
|
||||||
$url = $path;
|
$url = $path;
|
||||||
} else {
|
} else {
|
||||||
$url = $this->assetUrl($path, $options + array('pathPrefix' => CSS_URL, 'ext' => '.css'));
|
$url = $this->assetUrl($path, $options + array('pathPrefix' => Configure::read('App.cssURL'), 'ext' => '.css'));
|
||||||
$options = array_diff_key($options, array('fullBase' => null));
|
$options = array_diff_key($options, array('fullBase' => null));
|
||||||
|
|
||||||
if (Configure::read('Asset.filter.css')) {
|
if (Configure::read('Asset.filter.css')) {
|
||||||
$pos = strpos($url, CSS_URL);
|
$pos = strpos($url, Configure::read('App.cssURL'));
|
||||||
if ($pos !== false) {
|
if ($pos !== false) {
|
||||||
$url = substr($url, 0, $pos) . 'ccss/' . substr($url, $pos + strlen(CSS_URL));
|
$url = substr($url, 0, $pos) . 'ccss/' . substr($url, $pos + strlen(Configure::read('App.cssURL')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -545,11 +545,11 @@ class HtmlHelper extends AppHelper {
|
||||||
$this->_includedScripts[$url] = true;
|
$this->_includedScripts[$url] = true;
|
||||||
|
|
||||||
if (strpos($url, '//') === false) {
|
if (strpos($url, '//') === false) {
|
||||||
$url = $this->assetUrl($url, $options + array('pathPrefix' => JS_URL, 'ext' => '.js'));
|
$url = $this->assetUrl($url, $options + array('pathPrefix' => Configure::read('App.jsURL'), 'ext' => '.js'));
|
||||||
$options = array_diff_key($options, array('fullBase' => null));
|
$options = array_diff_key($options, array('fullBase' => null));
|
||||||
|
|
||||||
if (Configure::read('Asset.filter.js')) {
|
if (Configure::read('Asset.filter.js')) {
|
||||||
$url = str_replace(JS_URL, 'cjs/', $url);
|
$url = str_replace(Configure::read('App.jsURL'), 'cjs/', $url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$attributes = $this->_parseAttributes($options, array('block', 'once'), ' ');
|
$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
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::image
|
||||||
*/
|
*/
|
||||||
public function image($path, $options = array()) {
|
public function image($path, $options = array()) {
|
||||||
$path = $this->assetUrl($path, $options + array('pathPrefix' => IMAGES_URL));
|
$path = $this->assetUrl($path, $options + array('pathPrefix' => Configure::read('App.imagesURL')));
|
||||||
$options = array_diff_key($options, array('fullBase' => null, 'pathPrefix' => null));
|
$options = array_diff_key($options, array('fullBase' => null, 'pathPrefix' => null));
|
||||||
|
|
||||||
if (!isset($options['alt'])) {
|
if (!isset($options['alt'])) {
|
||||||
|
@ -1106,7 +1106,7 @@ class HtmlHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['poster'])) {
|
if (isset($options['poster'])) {
|
||||||
$options['poster'] = $this->assetUrl($options['poster'], array('pathPrefix' => IMAGES_URL) + $options);
|
$options['poster'] = $this->assetUrl($options['poster'], array('pathPrefix' => Configure::read('App.imagesURL')) + $options);
|
||||||
}
|
}
|
||||||
$text = $options['text'];
|
$text = $options['text'];
|
||||||
|
|
||||||
|
|
|
@ -168,6 +168,10 @@ if (!defined('FULL_BASE_URL')) {
|
||||||
unset($httpHost, $s);
|
unset($httpHost, $s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Configure::write('App.imagesURL', IMAGES_URL);
|
||||||
|
Configure::write('App.cssURL', CSS_URL);
|
||||||
|
Configure::write('App.jsURL', JS_URL);
|
||||||
|
|
||||||
App::$bootstrapping = true;
|
App::$bootstrapping = true;
|
||||||
|
|
||||||
Configure::bootstrap(isset($boot) ? $boot : true);
|
Configure::bootstrap(isset($boot) ? $boot : true);
|
||||||
|
|
Loading…
Reference in a new issue