Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Making conditions easier to read.

Adding additional test for image timestamping.
Refs #108
  • Loading branch information...
commit 022f8ccaa2501e71393513d774d5e41d4549cc87 1 parent 07a89cd
Mark Story markstory authored
7 cake/libs/view/helpers/html.php
View
@@ -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));
}
6 cake/libs/view/helpers/javascript.php
View
@@ -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);
9 cake/tests/cases/libs/view/helpers/html.test.php
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.