Skip to content

Commit

Permalink
Updating HtmlHelper and JavascriptHelper to use Helper::assetTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Sep 24, 2009
1 parent ee514f3 commit 7f49f7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 38 deletions.
33 changes: 5 additions & 28 deletions cake/libs/view/helpers/html.php
Expand Up @@ -373,14 +373,7 @@ 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 && $timestampEnabled) {
$url .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $path));
}
$url = $this->webroot($this->assetTimestamp($path));

if (Configure::read('Asset.filter.css')) {
$url = str_replace(CSS_URL, 'ccss/', $url);
Expand Down Expand Up @@ -449,21 +442,10 @@ function script($url, $options = array()) {
if ($url[0] !== '/') {
$url = JS_URL . $url;
}
$url = $this->webroot($url);
if (strpos($url, '?') === false) {
if (strpos($url, '.js') === false) {
$url .= '.js';
}
}

$timestampEnabled = (
(Configure::read('Asset.timestamp') === true && Configure::read('debug') > 0) ||
Configure::read('Asset.timestamp') === 'force'
);

if (strpos($url, '?') === false && $timestampEnabled) {
$url .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $url));
if (strpos($url, '?') === false && strpos($url, '.js') === false) {
$url .= '.js';
}
$url = $this->webroot($this->assetTimestamp($url));

if (Configure::read('Asset.filter.js')) {
$url = str_replace(JS_URL, 'cjs/', $url);
Expand Down Expand Up @@ -608,12 +590,7 @@ function image($path, $options = array()) {
if ($path[0] !== '/') {
$path = IMAGES_URL . $path;
}

if ((Configure::read('Asset.timestamp') == true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force') {
$path = $this->webroot($path) . '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $path));
} else {
$path = $this->webroot($path);
}
$path = $this->webroot($this->assetTimestamp($path));
}

if (!isset($options['alt'])) {
Expand Down
11 changes: 1 addition & 10 deletions cake/libs/view/helpers/javascript.php
Expand Up @@ -270,16 +270,7 @@ 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 && $timestampEnabled) {
$url = $this->webroot($url) . '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $url));
} else {
$url = $this->webroot($url);
}
$url = $this->webroot($this->assetTimestamp($url));

if (Configure::read('Asset.filter.js')) {
$url = str_replace(JS_URL, 'cjs/', $url);
Expand Down

0 comments on commit 7f49f7f

Please sign in to comment.