Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removing deprecated code in Html::css()

Minor refactoring in HtmlHelper methods.
Fixes #268
  • Loading branch information...
commit 4deaf27cc02ed29766f6d6d5aca3b1f4220741b0 1 parent e776cf1
@markstory markstory authored
Showing with 10 additions and 14 deletions.
  1. +10 −14 cake/libs/view/helpers/html.php
View
24 cake/libs/view/helpers/html.php
@@ -356,7 +356,7 @@ function link($title, $url = null, $options = array(), $confirmMessage = false)
*
* #### Options
*
- * - `inline` If set to false, the generated tag appears in the head tag of the layout.
+ * - `inline` If set to false, the generated tag appears in the head tag of the layout. Defaults to true
*
* @param mixed $path The name of a CSS style sheet or an array containing names of
* CSS stylesheets. If `$path` is prefixed with '/', the path will be relative to the webroot
@@ -367,13 +367,13 @@ function link($title, $url = null, $options = array(), $confirmMessage = false)
* @access public
*/
function css($path, $rel = null, $options = array()) {
- $inline = isset($options['inline']) ? $options['inline'] : true;
+ $options += array('inline' => true);
if (is_array($path)) {
$out = '';
foreach ($path as $i) {
- $out .= "\n\t" . $this->css($i, $rel, $options, $inline);
+ $out .= "\n\t" . $this->css($i, $rel, $options);
}
- if ($inline) {
+ if ($options['inline']) {
return $out . "\n";
}
return;
@@ -402,7 +402,7 @@ function css($path, $rel = null, $options = array()) {
}
if ($rel == 'import') {
- $out = sprintf($this->tags['style'], $this->_parseAttributes($options, null, '', ' '), '@import url(' . $url . ');');
+ $out = sprintf($this->tags['style'], $this->_parseAttributes($options, array('inline'), '', ' '), '@import url(' . $url . ');');
} else {
if ($rel == null) {
$rel = 'stylesheet';
@@ -411,7 +411,7 @@ function css($path, $rel = null, $options = array()) {
}
$out = $this->output($out);
- if ($inline) {
+ if ($options['inline']) {
return $out;
} else {
$view =& ClassRegistry::getObject('view');
@@ -472,12 +472,10 @@ function script($url, $options = array()) {
$url = str_replace(JS_URL, 'cjs/', $url);
}
}
- $inline = $options['inline'];
- unset($options['inline'], $options['once']);
- $attributes = $this->_parseAttributes($options, ' ', ' ');
+ $attributes = $this->_parseAttributes($options, array('inline', 'once'), ' ');
$out = $this->output(sprintf($this->tags['javascriptlink'], $url, $attributes));
- if ($inline) {
+ if ($options['inline']) {
return $out;
} else {
$view =& ClassRegistry::getObject('view');
@@ -497,8 +495,7 @@ function script($url, $options = array()) {
* @return mixed string or null depending on the value of `$options['inline']`
**/
function scriptBlock($script, $options = array()) {
- $defaultOptions = array('safe' => true, 'inline' => true);
- $options = array_merge($defaultOptions, $options);
+ $options += array('safe' => true, 'inline' => true);
if ($options['safe']) {
$script = "\n" . '//<![CDATA[' . "\n" . $script . "\n" . '//]]>' . "\n";
}
@@ -527,8 +524,7 @@ function scriptBlock($script, $options = array()) {
* @return void
**/
function scriptStart($options = array()) {
- $defaultOptions = array('safe' => true, 'inline' => true);
- $options = array_merge($defaultOptions, $options);
+ $options += array('safe' => true, 'inline' => true);
$this->_scriptBlockOptions = $options;
ob_start();
return null;
Please sign in to comment.
Something went wrong with that request. Please try again.