Permalink
Browse files

Making conditions easier to read.

Adding additional test for image timestamping.
Refs #108
  • Loading branch information...
1 parent 07a89cd commit 022f8ccaa2501e71393513d774d5e41d4549cc87 @markstory markstory committed Sep 22, 2009
View
7 cake/libs/view/helpers/html.php
@@ -348,9 +348,12 @@ function css($path, $rel = null, $htmlAttributes = array(), $inline = true) {
$path .= '.css';
}
}
-
+ $timestampEnabled = (
+ (Configure::read('Asset.timestamp') === true && Configure::read() > 0) ||
+ Configure::read('Asset.timestamp') === 'force'
+ );
$url = $this->webroot($path);
- if (strpos($path, '?') === false && ((Configure::read('Asset.timestamp') === true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force')) {
+ if (strpos($path, '?') === false && $timestampEnabled) {
$url .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $path));
}
View
6 cake/libs/view/helpers/javascript.php
@@ -253,8 +253,12 @@ function link($url, $inline = true) {
$url .= '.js';
}
}
+ $timestampEnabled = (
+ (Configure::read('Asset.timestamp') === true && Configure::read() > 0) ||
+ Configure::read('Asset.timestamp') === 'force'
+ );
- if (strpos($url, '?') === false && ((Configure::read('Asset.timestamp') === true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force')) {
+ if (strpos($url, '?') === false && $timestampEnabled) {
$url = $this->webroot($url) . '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $url));
} else {
$url = $this->webroot($url);
View
9 cake/tests/cases/libs/view/helpers/html.test.php
@@ -284,6 +284,15 @@ function testImageTag() {
$result = $this->Html->image('cake.icon.gif');
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));
+
+ $webroot = $this->Html->webroot;
+ $this->Html->webroot = '/testing/longer/';
+ $result = $this->Html->image('cake.icon.gif');
+ $expected = array(
+ 'img' => array('src' => 'preg:/\/testing\/longer\/img\/cake\.icon\.gif\?[0-9]+/', 'alt' => '')
+ );
+ $this->assertTags($result, $expected);
+ $this->Html->webroot = $webroot;
}
/**
* Tests creation of an image tag using a theme and asset timestamping

0 comments on commit 022f8cc

Please sign in to comment.