Permalink
Browse files

Removing $inline parameter from HtmlHelper::meta() inline is now an o…

…ption.
  • Loading branch information...
markstory committed Oct 17, 2009
1 parent b021461 commit 7344c0ce7d0cd57cee50f35e95c79e79342851f0
Showing with 22 additions and 16 deletions.
  1. +21 −15 cake/libs/view/helpers/html.php
  2. +1 −1 cake/tests/cases/libs/view/helpers/html.test.php
@@ -209,15 +209,21 @@ function docType($type = 'xhtml-strict') {
/**
* Creates a link to an external resource and handles basic meta tags
*
+ * #### Options
+ *
+ * - `inline` Whether or not the link element should be output inline, or in scripts_for_layout.
+ *
* @param string $type The title of the external resource
* @param mixed $url The address of the external resource or string for content attribute
- * @param array $attributes Other attributes for the generated tag. If the type attribute is html,
+ * @param array $options Other attributes for the generated tag. If the type attribute is html,
* rss, atom, or icon, the mime-type is returned.
- * @param boolean $inline If set to false, the generated tag appears in the head tag of the layout.
* @return string A completed <link /> element.
* @access public
*/
- function meta($type, $url = null, $attributes = array(), $inline = true) {
+ function meta($type, $url = null, $options = array()) {
+ $inline = isset($options['inline']) ? $options['inline'] : true;
+ unset($options['inline']);
+
if (!is_array($type)) {
$types = array(
'rss' => array('type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => $type, 'link' => $url),
@@ -233,34 +239,34 @@ function meta($type, $url = null, $attributes = array(), $inline = true) {
if (isset($types[$type])) {
$type = $types[$type];
- } elseif (!isset($attributes['type']) && $url !== null) {
+ } elseif (!isset($options['type']) && $url !== null) {
if (is_array($url) && isset($url['ext'])) {
$type = $types[$url['ext']];
} else {
$type = $types['rss'];
}
- } elseif (isset($attributes['type']) && isset($types[$attributes['type']])) {
- $type = $types[$attributes['type']];
- unset($attributes['type']);
+ } elseif (isset($options['type']) && isset($types[$options['type']])) {
+ $type = $types[$options['type']];
+ unset($options['type']);
} else {
$type = array();
}
} elseif ($url !== null) {
$inline = $url;
}
- $attributes = array_merge($type, $attributes);
+ $options = array_merge($type, $options);
$out = null;
- if (isset($attributes['link'])) {
- if (isset($attributes['rel']) && $attributes['rel'] === 'icon') {
- $out = sprintf($this->tags['metalink'], $attributes['link'], $this->_parseAttributes($attributes, array('link'), ' ', ' '));
- $attributes['rel'] = 'shortcut icon';
+ if (isset($options['link'])) {
+ if (isset($options['rel']) && $options['rel'] === 'icon') {
+ $out = sprintf($this->tags['metalink'], $options['link'], $this->_parseAttributes($options, array('link'), ' ', ' '));
+ $options['rel'] = 'shortcut icon';
} else {
- $attributes['link'] = $this->url($attributes['link'], true);
+ $options['link'] = $this->url($options['link'], true);
}
- $out .= sprintf($this->tags['metalink'], $attributes['link'], $this->_parseAttributes($attributes, array('link'), ' ', ' '));
+ $out .= sprintf($this->tags['metalink'], $options['link'], $this->_parseAttributes($options, array('link'), ' ', ' '));
} else {
- $out = sprintf($this->tags['meta'], $this->_parseAttributes($attributes, array('type')));
+ $out = sprintf($this->tags['meta'], $this->_parseAttributes($options, array('type')));
}
if ($inline) {
@@ -1049,7 +1049,7 @@ function testMeta() {
$result = $this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'));
$this->assertTags($result, array('meta' => array('name' => 'ROBOTS', 'content' => 'ALL')));
- $this->assertNull($this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'), null, array(), false));
+ $this->assertNull($this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'), null, array('inline' => false)));
$view =& ClassRegistry::getObject('view');
$result = $view->__scripts[0];
$this->assertTags($result, array('meta' => array('name' => 'ROBOTS', 'content' => 'ALL')));

0 comments on commit 7344c0c

Please sign in to comment.