mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge remote branch 'origin/1.3' into 1.3
This commit is contained in:
commit
21f61ee34a
5 changed files with 32 additions and 12 deletions
|
@ -245,7 +245,8 @@ class Helper extends Overloadable {
|
|||
Configure::read('Asset.timestamp') === 'force'
|
||||
);
|
||||
if (strpos($path, '?') === false && $timestampEnabled) {
|
||||
$path .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $path));
|
||||
$filepath = preg_replace('/^' . preg_quote($this->webroot, '/') . '/', '', $path);
|
||||
$path .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $filepath));
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
|
|
@ -358,7 +358,7 @@ class HtmlHelper extends AppHelper {
|
|||
$path .= '.css';
|
||||
}
|
||||
}
|
||||
$url = $this->webroot($this->assetTimestamp($path));
|
||||
$url = $this->assetTimestamp($this->webroot($path));
|
||||
|
||||
if (Configure::read('Asset.filter.css')) {
|
||||
$pos = strpos($url, CSS_URL);
|
||||
|
@ -434,7 +434,7 @@ class HtmlHelper extends AppHelper {
|
|||
if (strpos($url, '?') === false && strpos($url, '.js') === false) {
|
||||
$url .= '.js';
|
||||
}
|
||||
$url = $this->webroot($this->assetTimestamp($url));
|
||||
$url = $this->assetTimestamp($this->webroot($url));
|
||||
|
||||
if (Configure::read('Asset.filter.js')) {
|
||||
$url = str_replace(JS_URL, 'cjs/', $url);
|
||||
|
@ -608,7 +608,7 @@ class HtmlHelper extends AppHelper {
|
|||
if ($path[0] !== '/') {
|
||||
$path = IMAGES_URL . $path;
|
||||
}
|
||||
$path = $this->webroot($this->assetTimestamp($path));
|
||||
$path = $this->assetTimestamp($this->webroot($path));
|
||||
}
|
||||
|
||||
if (!isset($options['alt'])) {
|
||||
|
|
|
@ -265,7 +265,7 @@ class JavascriptHelper extends AppHelper {
|
|||
$url .= '.js';
|
||||
}
|
||||
}
|
||||
$url = $this->webroot($this->assetTimestamp($url));
|
||||
$url = $this->assetTimestamp($this->webroot($url));
|
||||
|
||||
if (Configure::read('Asset.filter.js')) {
|
||||
$pos = strpos($url, JS_URL);
|
||||
|
|
|
@ -467,6 +467,10 @@ class HelperTest extends CakeTestCase {
|
|||
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css?someparam');
|
||||
$this->assertEqual($result, CSS_URL . 'cake.generic.css?someparam');
|
||||
|
||||
$this->Helper->webroot = '/some/dir/';
|
||||
$result = $this->Helper->assetTimestamp('/some/dir/' . CSS_URL . 'cake.generic.css');
|
||||
$this->assertPattern('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result);
|
||||
|
||||
Configure::write('debug', $_debug);
|
||||
Configure::write('Asset.timestamp', $_timestamp);
|
||||
}
|
||||
|
|
|
@ -304,14 +304,15 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
function testImageWithTimestampping() {
|
||||
Configure::write('Asset.timestamp', 'force');
|
||||
|
||||
$this->Html->webroot = '/';
|
||||
$result = $this->Html->image('cake.icon.png');
|
||||
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.png\?\d+/', 'alt' => '')));
|
||||
$this->assertTags($result, array('img' => array('src' => 'preg:/\/img\/cake\.icon\.png\?\d+/', 'alt' => '')));
|
||||
|
||||
Configure::write('debug', 0);
|
||||
Configure::write('Asset.timestamp', 'force');
|
||||
|
||||
$result = $this->Html->image('cake.icon.png');
|
||||
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.png\?\d+/', 'alt' => '')));
|
||||
$this->assertTags($result, array('img' => array('src' => 'preg:/\/img\/cake\.icon\.png\?\d+/', 'alt' => '')));
|
||||
|
||||
$webroot = $this->Html->webroot;
|
||||
$this->Html->webroot = '/testing/longer/';
|
||||
|
@ -331,30 +332,42 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
* @link https://trac.cakephp.org/ticket/6490
|
||||
*/
|
||||
function testImageTagWithTheme() {
|
||||
if ($this->skipIf(!is_writable(WWW_ROOT . 'theme'), 'Cannot write to webroot/theme')) {
|
||||
return;
|
||||
}
|
||||
App::import('Core', 'File');
|
||||
|
||||
$testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'img' . DS . '__cake_test_image.gif';
|
||||
$file =& new File($testfile, true);
|
||||
|
||||
App::build(array(
|
||||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
|
||||
));
|
||||
Configure::write('Asset.timestamp', true);
|
||||
Configure::write('debug', 1);
|
||||
|
||||
$this->Html->webroot = '/';
|
||||
$this->Html->theme = 'test_theme';
|
||||
$result = $this->Html->image('cake.power.gif');
|
||||
$result = $this->Html->image('__cake_test_image.gif');
|
||||
$this->assertTags($result, array(
|
||||
'img' => array(
|
||||
'src' => 'preg:/theme\/test_theme\/img\/cake\.power\.gif\?\d+/',
|
||||
'src' => 'preg:/\/theme\/test_theme\/img\/__cake_test_image\.gif\?\d+/',
|
||||
'alt' => ''
|
||||
)));
|
||||
|
||||
$webroot = $this->Html->webroot;
|
||||
$this->Html->webroot = '/testing/';
|
||||
$result = $this->Html->image('cake.power.gif');
|
||||
$result = $this->Html->image('__cake_test_image.gif');
|
||||
|
||||
$this->assertTags($result, array(
|
||||
'img' => array(
|
||||
'src' => 'preg:/\/testing\/theme\/test_theme\/img\/cake\.power\.gif\?\d+/',
|
||||
'src' => 'preg:/\/testing\/theme\/test_theme\/img\/__cake_test_image\.gif\?\d+/',
|
||||
'alt' => ''
|
||||
)));
|
||||
$this->Html->webroot = $webroot;
|
||||
|
||||
$dir =& new Folder(WWW_ROOT . 'theme' . DS . 'test_theme');
|
||||
$dir->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,6 +377,7 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testThemeAssetsInMainWebrootPath() {
|
||||
Configure::write('Asset.timestamp', false);
|
||||
App::build(array(
|
||||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
|
||||
));
|
||||
|
@ -542,6 +556,7 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testScript() {
|
||||
Configure::write('Asset.timestamp', false);
|
||||
$result = $this->Html->script('foo');
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript', 'src' => 'js/foo.js')
|
||||
|
|
Loading…
Reference in a new issue