Skip to content

Commit 7e277e8

Browse files
committed
Restored ability to link PHP files for CSS and JS from view helpers.
1 parent f56e24c commit 7e277e8

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

cake/libs/view/helpers/html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ function css($path, $rel = null, $htmlAttributes = array(), $inline = true) {
343343
}
344344

345345
if (strpos($path, '?') === false) {
346-
if (substr($path, -4) !== '.css') {
346+
if (!preg_match('/.*\.(css|php)$/i', $path)) {
347347
$path .= '.css';
348348
}
349349
}

cake/libs/view/helpers/javascript.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ function link($url, $inline = true) {
248248
$url = JS_URL . $url;
249249
}
250250
if (strpos($url, '?') === false) {
251-
if (substr($url, -3) !== '.js') {
251+
if (!preg_match('/.*\.(js|php)$/i', $url)) {
252252
$url .= '.js';
253253
}
254254
}

cake/tests/cases/libs/view/helpers/html.test.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ function testCssLink() {
365365
$expected['link']['href'] = 'preg:/.*css\/my\.css\.library\.css/';
366366
$this->assertTags($result, $expected);
367367

368+
$result = $this->Html->css('my.css.php');
369+
$expected['link']['href'] = 'preg:/.*css\/my\.css\.php/';
370+
$this->assertTags($result, $expected);
371+
368372
$result = $this->Html->css('screen.css?1234');
369373
$expected['link']['href'] = 'preg:/.*css\/screen\.css\?1234/';
370374
$this->assertTags($result, $expected);

cake/tests/cases/libs/view/helpers/javascript.test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ function testLink() {
173173
$expected = '<script type="text/javascript" src="js/jquery-1.1.2.js"></script>';
174174
$this->assertEqual($result, $expected);
175175

176-
$result = $this->Javascript->link('jquery-1.1.2');
177-
$expected = '<script type="text/javascript" src="js/jquery-1.1.2.js"></script>';
176+
$result = $this->Javascript->link('jquery-1.1.2.php');
177+
$expected = '<script type="text/javascript" src="js/jquery-1.1.2.php"></script>';
178178
$this->assertEqual($result, $expected);
179179

180180
$result = $this->Javascript->link('/plugin/js/jquery-1.1.2');

0 commit comments

Comments
 (0)