From c11509483ce837e276584bd8f73a5598191bd847 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Nov 2009 16:43:54 -0500 Subject: [PATCH] Removing use of Helper::output from core helpers. Removing duplicated test caused by merge in form helper test. --- cake/libs/view/helpers/ajax.php | 4 +- cake/libs/view/helpers/form.php | 50 +++++++++---------- cake/libs/view/helpers/html.php | 26 +++++----- cake/libs/view/helpers/javascript.php | 2 +- cake/libs/view/helpers/paginator.php | 4 +- cake/libs/view/helpers/rss.php | 2 +- cake/libs/view/helpers/time.php | 25 ++++------ cake/libs/view/helpers/xml.php | 6 +-- .../cases/libs/view/helpers/form.test.php | 15 ------ 9 files changed, 55 insertions(+), 79 deletions(-) diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index 494e6fc40..0a69b5f21 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -528,7 +528,7 @@ class AjaxHelper extends AppHelper { } } $attr = $this->_parseAttributes(array_merge($options, array('id' => $id))); - return $this->output(sprintf($this->Html->tags['blockstart'], $attr)); + return sprintf($this->Html->tags['blockstart'], $attr); } /** @@ -547,7 +547,7 @@ class AjaxHelper extends AppHelper { return ''; } } - return $this->output($this->Html->tags['blockend']); + return $this->Html->tags['blockend']; } /** diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 9cb39b5b2..c88337f22 100755 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -294,7 +294,7 @@ class FormHelper extends AppHelper { $this->setEntity($model . '.', true); $attributes = $this->_parseAttributes($htmlAttributes, null, ''); - return $this->output(sprintf($this->Html->tags['form'], $attributes)) . $append; + return sprintf($this->Html->tags['form'], $attributes) . $append; } /** @@ -349,7 +349,7 @@ class FormHelper extends AppHelper { $view =& ClassRegistry::getObject('view'); $view->modelScope = false; - return $this->output($out); + return $out; } /** @@ -528,11 +528,11 @@ class FormHelper extends AppHelper { $labelFor = $this->domId($fieldName); } - return $this->output(sprintf( + return sprintf( $this->Html->tags['label'], $labelFor, $this->_parseAttributes($options), $text - )); + ); } /** @@ -940,11 +940,11 @@ class FormHelper extends AppHelper { } unset($options['hiddenField']); - return $this->output($output . sprintf( + return $output . sprintf( $this->Html->tags['checkbox'], $options['name'], $this->_parseAttributes($options, array('name'), null, ' ') - )); + ); } /** @@ -1036,7 +1036,7 @@ class FormHelper extends AppHelper { sprintf($this->Html->tags['legend'], $legend) . $out ); } - return $this->output($out); + return $out; } /** @@ -1050,11 +1050,11 @@ class FormHelper extends AppHelper { $options = $this->_initInputField($fieldName, array_merge( array('type' => 'text'), $options )); - return $this->output(sprintf( + return sprintf( $this->Html->tags['input'], $options['name'], $this->_parseAttributes($options, array('name'), null, ' ') - )); + ); } /** @@ -1066,11 +1066,11 @@ class FormHelper extends AppHelper { */ function password($fieldName, $options = array()) { $options = $this->_initInputField($fieldName, $options); - return $this->output(sprintf( + return sprintf( $this->Html->tags['password'], $options['name'], $this->_parseAttributes($options, array('name'), null, ' ') - )); + ); } /** @@ -1091,12 +1091,12 @@ class FormHelper extends AppHelper { } unset($options['value']); } - return $this->output(sprintf( + return sprintf( $this->Html->tags['textarea'], $options['name'], $this->_parseAttributes($options, array('type', 'name'), null, ' '), $value - )); + ); } /** @@ -1123,11 +1123,11 @@ class FormHelper extends AppHelper { $this->__secure(null, '' . $options['value']); } - return $this->output(sprintf( + return sprintf( $this->Html->tags['hidden'], $options['name'], $this->_parseAttributes($options, array('name', 'class'), '', ' ') - )); + ); } /** @@ -1149,7 +1149,7 @@ class FormHelper extends AppHelper { } $attributes = $this->_parseAttributes($options, array('name'), '', ' '); - return $this->output(sprintf($this->Html->tags['file'], $options['name'], $attributes)); + return sprintf($this->Html->tags['file'], $options['name'], $attributes); } /** @@ -1169,12 +1169,12 @@ class FormHelper extends AppHelper { if ($options['escape']) { $title = h($title); } - return $this->output(sprintf( + return sprintf( $this->Html->tags['button'], $options['type'], $this->_parseAttributes($options, array('type'), '', ' '), $title - )); + ); } /** @@ -1217,11 +1217,11 @@ class FormHelper extends AppHelper { if (strpos($caption, '://') !== false) { unset($options['type']); - $out .= $this->output($before . sprintf( + $out .= $before . sprintf( $this->Html->tags['submitimage'], $caption, $this->_parseAttributes($options, null, '', ' ') - ) . $after); + ) . $after; } elseif (preg_match('/\.(jpg|jpe|jpeg|gif|png|ico)$/', $caption)) { unset($options['type']); if ($caption{0} !== '/') { @@ -1230,17 +1230,17 @@ class FormHelper extends AppHelper { $caption = trim($caption, '/'); $url = $this->webroot($caption); } - $out .= $this->output($before . sprintf( + $out .= $before . sprintf( $this->Html->tags['submitimage'], $url, $this->_parseAttributes($options, null, '', ' ') - ) . $after); + ) . $after; } else { $options['value'] = $caption; - $out .= $this->output($before . sprintf( + $out .= $before . sprintf( $this->Html->tags['submit'], $this->_parseAttributes($options, null, '', ' ') - ). $after); + ). $after; } if (isset($divOptions)) { @@ -1347,7 +1347,7 @@ class FormHelper extends AppHelper { $template = ($style == 'checkbox') ? 'checkboxmultipleend' : 'selectend'; $select[] = $this->Html->tags[$template]; - return $this->output(implode("\n", $select)); + return implode("\n", $select); } /** diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index f86c84087..b4039e0e5 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -201,7 +201,7 @@ class HtmlHelper extends AppHelper { */ function docType($type = 'xhtml-strict') { if (isset($this->__docTypes[$type])) { - return $this->output($this->__docTypes[$type]); + return $this->__docTypes[$type]; } return null; } @@ -270,7 +270,7 @@ class HtmlHelper extends AppHelper { } if ($inline) { - return $this->output($out); + return $out; } else { $view =& ClassRegistry::getObject('view'); $view->addScript($out); @@ -288,7 +288,7 @@ class HtmlHelper extends AppHelper { if (empty($charset)) { $charset = strtolower(Configure::read('App.encoding')); } - return $this->output(sprintf($this->tags['charset'], (!empty($charset) ? $charset : 'utf-8'))); + return sprintf($this->tags['charset'], (!empty($charset) ? $charset : 'utf-8')); } /** @@ -347,7 +347,7 @@ class HtmlHelper extends AppHelper { } unset($options['default']); } - return $this->output(sprintf($this->tags['link'], $url, $this->_parseAttributes($options), $title)); + return sprintf($this->tags['link'], $url, $this->_parseAttributes($options), $title); } /** @@ -408,7 +408,6 @@ class HtmlHelper extends AppHelper { } $out = sprintf($this->tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline'), '', ' ')); } - $out = $this->output($out); if ($options['inline']) { return $out; @@ -472,7 +471,7 @@ class HtmlHelper extends AppHelper { } } $attributes = $this->_parseAttributes($options, array('inline', 'once'), ' '); - $out = $this->output(sprintf($this->tags['javascriptlink'], $url, $attributes)); + $out = sprintf($this->tags['javascriptlink'], $url, $attributes); if ($options['inline']) { return $out; @@ -585,7 +584,7 @@ class HtmlHelper extends AppHelper { $out[] = $crumb[0]; } } - return $this->output(join($separator, $out)); + return join($separator, $out); } else { return null; } @@ -624,9 +623,9 @@ class HtmlHelper extends AppHelper { $image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' ')); if ($url) { - return $this->output(sprintf($this->tags['link'], $this->url($url), null, $image)); + return sprintf($this->tags['link'], $this->url($url), null, $image); } - return $this->output($image); + return $image; } /** @@ -643,8 +642,7 @@ class HtmlHelper extends AppHelper { foreach ($names as $arg) { $out[] = sprintf($this->tags['tableheader'], $this->_parseAttributes($thOptions), $arg); } - $data = sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out)); - return $this->output($data); + return sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out)); } /** @@ -698,7 +696,7 @@ class HtmlHelper extends AppHelper { $options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions); $out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cellsOut)); } - return $this->output(join("\n", $out)); + return implode("\n", $out); } /** @@ -729,7 +727,7 @@ class HtmlHelper extends AppHelper { } else { $tag = 'tag'; } - return $this->output(sprintf($this->tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name)); + return sprintf($this->tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name); } /** @@ -778,7 +776,7 @@ class HtmlHelper extends AppHelper { } else { $tag = 'para'; } - return $this->output(sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text)); + return sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text); } /** diff --git a/cake/libs/view/helpers/javascript.php b/cake/libs/view/helpers/javascript.php index c4732a5ca..c7c44c898 100644 --- a/cake/libs/view/helpers/javascript.php +++ b/cake/libs/view/helpers/javascript.php @@ -273,7 +273,7 @@ class JavascriptHelper extends AppHelper { } } } - $out = $this->output(sprintf($this->tags['javascriptlink'], $url)); + $out = sprintf($this->tags['javascriptlink'], $url); if ($inline) { return $out; diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 45ffb488d..38625b57a 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -557,7 +557,7 @@ class PaginatorHelper extends AppHelper { $out = str_replace($newKeys, array_values($map), $out); break; } - return $this->output($out); + return $out; } /** @@ -678,7 +678,7 @@ class PaginatorHelper extends AppHelper { $out .= $after; } - return $this->output($out); + return $out; } /** diff --git a/cake/libs/view/helpers/rss.php b/cake/libs/view/helpers/rss.php index c0bc776c2..a05b85b6a 100644 --- a/cake/libs/view/helpers/rss.php +++ b/cake/libs/view/helpers/rss.php @@ -269,7 +269,7 @@ class RssHelper extends XmlHelper { if (!empty($elements)) { $content = join('', $elements); } - return $this->output($this->elem('item', $att, $content, !($content === null))); + return $this->elem('item', $att, $content, !($content === null)); } /** diff --git a/cake/libs/view/helpers/time.php b/cake/libs/view/helpers/time.php index ac14484b0..54eefe05e 100644 --- a/cake/libs/view/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -87,8 +87,7 @@ class TimeHelper extends AppHelper { $date = time(); } - $ret = date("D, M jS Y, H:i", $date); - return $this->output($ret); + return date("D, M jS Y, H:i", $date); } /** @@ -115,8 +114,7 @@ class TimeHelper extends AppHelper { } else { $ret = date("M jS{$y}, H:i", $date); } - - return $this->output($ret); + return $ret; } /** @@ -134,8 +132,7 @@ class TimeHelper extends AppHelper { $begin = date('Y-m-d', $begin) . ' 00:00:00'; $end = date('Y-m-d', $end) . ' 23:59:59'; - $ret ="($fieldName >= '$begin') AND ($fieldName <= '$end')"; - return $this->output($ret); + return "($fieldName >= '$begin') AND ($fieldName <= '$end')"; } /** @@ -149,8 +146,7 @@ class TimeHelper extends AppHelper { */ function dayAsSql($dateString, $fieldName, $userOffset = null) { $date = $this->fromString($dateString, $userOffset); - $ret = $this->daysAsSql($dateString, $dateString, $fieldName); - return $this->output($ret); + return $this->daysAsSql($dateString, $dateString, $fieldName); } /** @@ -254,7 +250,7 @@ class TimeHelper extends AppHelper { break; } } - return $this->output($date); + return $date; } /** @@ -265,8 +261,7 @@ class TimeHelper extends AppHelper { * @return integer Unix timestamp */ function toUnix($dateString, $userOffset = null) { - $ret = $this->fromString($dateString, $userOffset); - return $this->output($ret); + return $this->fromString($dateString, $userOffset); } /** @@ -278,8 +273,7 @@ class TimeHelper extends AppHelper { */ function toAtom($dateString, $userOffset = null) { $date = $this->fromString($dateString, $userOffset); - $ret = date('Y-m-d\TH:i:s\Z', $date); - return $this->output($ret); + return date('Y-m-d\TH:i:s\Z', $date); } /** @@ -291,8 +285,7 @@ class TimeHelper extends AppHelper { */ function toRSS($dateString, $userOffset = null) { $date = $this->fromString($dateString, $userOffset); - $ret = date("r", $date); - return $this->output($ret); + return date("r", $date); } /** @@ -472,7 +465,7 @@ class TimeHelper extends AppHelper { $relativeDate = sprintf(__('%s ago', true), $relativeDate); } } - return $this->output($relativeDate); + return $relativeDate; } /** diff --git a/cake/libs/view/helpers/xml.php b/cake/libs/view/helpers/xml.php index f6a03321b..ac7b9775b 100644 --- a/cake/libs/view/helpers/xml.php +++ b/cake/libs/view/helpers/xml.php @@ -65,7 +65,7 @@ class XmlHelper extends AppHelper { $attrib = 'xml ' . $attrib; } - return $this->output($this->Xml->header($attrib)); + return $this->Xml->header($attrib); } /** @@ -131,7 +131,7 @@ class XmlHelper extends AppHelper { if (!$endTag) { $this->Xml =& $elem; } - return $this->output($out); + return $out; } /** @@ -144,7 +144,7 @@ class XmlHelper extends AppHelper { if ($parent =& $this->Xml->parent()) { $this->Xml =& $parent; } - return $this->output(''); + return ''; } /** diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 316cd8a0c..f19c16f85 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -5064,21 +5064,6 @@ class FormHelperTest extends CakeTestCase { '/fieldset' ); $this->assertTags($result, $expected); - - $this->Form->data = array(); - $this->Form->params['controller'] = 'contacts'; - $this->Form->params['models'] = array('Contact'); - $result = $this->Form->create(array('url' => array('action' => 'index', 'param'))); - $expected = array( - 'form' => array( - 'id' => 'ContactAddForm', 'method' => 'post', 'action' => '/contacts/index/param' - ), - 'fieldset' => array('style' => 'preg:/display\s*\:\s*none;\s*/'), - 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'), - '/fieldset' - ); - $this->assertTags($result, $expected); - } /**