Navigation Menu

Skip to content

Commit

Permalink
Removing deprecated code in Html::css()
Browse files Browse the repository at this point in the history
Minor refactoring in HtmlHelper methods.
Fixes #268
  • Loading branch information
markstory committed Nov 6, 2009
1 parent e776cf1 commit 4deaf27
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions cake/libs/view/helpers/html.php
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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';
Expand All @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -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";
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4deaf27

Please sign in to comment.