diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php
index 913ec5bb3..dd99fe291 100644
--- a/cake/libs/view/helpers/html.php
+++ b/cake/libs/view/helpers/html.php
@@ -184,6 +184,7 @@ class HtmlHelper extends AppHelper {
if (isset($this->__docTypes[$type])) {
return $this->output($this->__docTypes[$type]);
}
+ return null;
}
/**
* Creates a link to an external resource and handles basic meta tags
@@ -210,7 +211,7 @@ class HtmlHelper extends AppHelper {
if (isset($types[$type])) {
$type = $types[$type];
- } elseif (!isset($types['type']) && !isset($attributes['type']) && $url !== null) {
+ } elseif (!isset($attributes['type']) && $url !== null) {
if (is_array($url) && isset($url['ext'])) {
$type = $types[$url['ext']];
} else {
@@ -218,6 +219,7 @@ class HtmlHelper extends AppHelper {
}
} elseif (isset($attributes['type']) && isset($types[$attributes['type']])) {
$type = $types[$attributes['type']];
+ unset($attributes['type']);
}
} elseif ($url !== null) {
$inline = $url;
@@ -297,15 +299,13 @@ class HtmlHelper extends AppHelper {
$confirmMessage = str_replace("'", "\'", $confirmMessage);
$confirmMessage = str_replace('"', '\"', $confirmMessage);
$htmlAttributes['onclick'] = "return confirm('{$confirmMessage}');";
- } elseif (isset($htmlAttributes['default'])) {
- if ($htmlAttributes['default'] == false) {
- if (isset($htmlAttributes['onclick'])) {
- $htmlAttributes['onclick'] .= ' event.returnValue = false; return false;';
- } else {
- $htmlAttributes['onclick'] = 'event.returnValue = false; return false;';
- }
- unset($htmlAttributes['default']);
+ } elseif (isset($htmlAttributes['default']) && $htmlAttributes['default'] == false) {
+ if (isset($htmlAttributes['onclick'])) {
+ $htmlAttributes['onclick'] .= ' event.returnValue = false; return false;';
+ } else {
+ $htmlAttributes['onclick'] = 'event.returnValue = false; return false;';
}
+ unset($htmlAttributes['default']);
}
return $this->output(sprintf($this->tags['link'], $url, $this->_parseAttributes($htmlAttributes), $title));
}
diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php
index 81c707ad6..189c5b4e9 100644
--- a/cake/tests/cases/libs/view/helpers/html.test.php
+++ b/cake/tests/cases/libs/view/helpers/html.test.php
@@ -51,6 +51,8 @@ class HtmlHelperTest extends CakeTestCase {
$result = $this->Html->docType('html4-strict');
$expected = '';
$this->assertEqual($result, $expected);
+
+ $this->assertNull($this->Html->docType('non-existing-doctype'));
}
function testLink() {
@@ -73,9 +75,7 @@ class HtmlHelperTest extends CakeTestCase {
'/a'
);
$this->assertTags($result, $expected);
- }
- function testLinkEscape() {
$result = $this->Html->link('Next >', '#');
$expected = array(
'a' => array('href' => '#'),
@@ -84,6 +84,22 @@ class HtmlHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
+ $result = $this->Html->link('Next >', '#', array('escape' => true));
+ $expected = array(
+ 'a' => array('href' => '#'),
+ 'Next >',
+ '/a'
+ );
+ $this->assertTags($result, $expected);
+
+ $result = $this->Html->link('Next >', '#', array('escape' => 'utf-8'));
+ $expected = array(
+ 'a' => array('href' => '#'),
+ 'Next >',
+ '/a'
+ );
+ $this->assertTags($result, $expected);
+
$result = $this->Html->link('Next >', '#', array('escape' => false));
$expected = array(
'a' => array('href' => '#'),
@@ -91,9 +107,7 @@ class HtmlHelperTest extends CakeTestCase {
'/a'
);
$this->assertTags($result, $expected);
- }
- function testImageLink() {
$result = $this->Html->link($this->Html->image('test.gif'), '#', array(), false, false, false);
$expected = array(
'a' => array('href' => '#'),
@@ -532,12 +546,34 @@ class HtmlHelperTest extends CakeTestCase {
}
function testMeta() {
- $result = $this->Html->meta('this is an rss feed', array('controller'=> 'posts', 'ext' => 'rss'));
+ $result = $this->Html->meta('this is an rss feed', array('controller' => 'posts', 'ext' => 'rss'));
$this->assertTags($result, array('link' => array('href' => 'preg:/.*\/posts\.rss/', 'type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => 'this is an rss feed')));
- $result = $this->Html->meta('rss', array('controller'=> 'posts', 'ext' => 'rss'), array('title' => 'this is an rss feed'));
+ $result = $this->Html->meta('rss', array('controller' => 'posts', 'ext' => 'rss'), array('title' => 'this is an rss feed'));
$this->assertTags($result, array('link' => array('href' => 'preg:/.*\/posts\.rss/', 'type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => 'this is an rss feed')));
+ $result = $this->Html->meta('atom', array('controller' => 'posts', 'ext' => 'xml'));
+ $this->assertTags($result, array('link' => array('href' => 'preg:/.*\/posts\.xml/', 'type' => 'application/atom+xml', 'title' => 'atom')));
+
+ $result = $this->Html->meta('non-existing');
+ $this->assertTags($result, array('Html->meta('non-existing', '/posts.xpp');
+ $this->assertTags($result, array('link' => array('href' => 'preg:/.*\/posts\.xpp/', 'type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => 'non-existing')));
+
+ $result = $this->Html->meta('non-existing', '/posts.xpp', array('type' => 'atom'));
+ $this->assertTags($result, array('link' => array('href' => 'preg:/.*\/posts\.xpp/', 'type' => 'application/atom+xml', 'title' => 'non-existing')));
+
+ $result = $this->Html->meta('atom', array('controller' => 'posts', 'ext' => 'xml'), array('link' => '/articles.rss'));
+ $this->assertTags($result, array('link' => array('href' => 'preg:/.*\/articles\.rss/', 'type' => 'application/atom+xml', 'title' => 'atom')));
+
+ $result = $this->Html->meta(array('link' => 'favicon.ico', 'rel' => 'icon'));
+ $expected = array(
+ 'link' => array('href' => 'preg:/.*favicon\.ico/', 'rel' => 'icon'),
+ array('link' => array('href' => 'preg:/.*favicon\.ico/', 'rel' => 'shortcut icon'))
+ );
+ $this->assertTags($result, $expected);
+
$result = $this->Html->meta('icon', 'favicon.ico');
$expected = array(
'link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'icon'),