Skip to content

Commit

Permalink
Making conditions easier to read.
Browse files Browse the repository at this point in the history
Adding additional test for image timestamping.
Refs #108
  • Loading branch information
markstory committed Sep 24, 2009
1 parent de47373 commit 26d2237
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
7 changes: 5 additions & 2 deletions cake/libs/view/helpers/html.php
Expand Up @@ -373,9 +373,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));
}

Expand Down
6 changes: 5 additions & 1 deletion cake/libs/view/helpers/javascript.php
Expand Up @@ -270,8 +270,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);
Expand Down
9 changes: 9 additions & 0 deletions cake/tests/cases/libs/view/helpers/html.test.php
Expand Up @@ -308,6 +308,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;
}

/**
Expand Down

0 comments on commit 26d2237

Please sign in to comment.