Removing use of Helper::output from core helpers.

Removing duplicated test caused by merge in form helper test.
This commit is contained in:
mark_story 2009-11-21 16:43:54 -05:00
parent 94c0ec1699
commit c11509483c
9 changed files with 55 additions and 79 deletions

View file

@ -528,7 +528,7 @@ class AjaxHelper extends AppHelper {
} }
} }
$attr = $this->_parseAttributes(array_merge($options, array('id' => $id))); $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 '';
} }
} }
return $this->output($this->Html->tags['blockend']); return $this->Html->tags['blockend'];
} }
/** /**

View file

@ -294,7 +294,7 @@ class FormHelper extends AppHelper {
$this->setEntity($model . '.', true); $this->setEntity($model . '.', true);
$attributes = $this->_parseAttributes($htmlAttributes, null, ''); $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 =& ClassRegistry::getObject('view');
$view->modelScope = false; $view->modelScope = false;
return $this->output($out); return $out;
} }
/** /**
@ -528,11 +528,11 @@ class FormHelper extends AppHelper {
$labelFor = $this->domId($fieldName); $labelFor = $this->domId($fieldName);
} }
return $this->output(sprintf( return sprintf(
$this->Html->tags['label'], $this->Html->tags['label'],
$labelFor, $labelFor,
$this->_parseAttributes($options), $text $this->_parseAttributes($options), $text
)); );
} }
/** /**
@ -940,11 +940,11 @@ class FormHelper extends AppHelper {
} }
unset($options['hiddenField']); unset($options['hiddenField']);
return $this->output($output . sprintf( return $output . sprintf(
$this->Html->tags['checkbox'], $this->Html->tags['checkbox'],
$options['name'], $options['name'],
$this->_parseAttributes($options, array('name'), null, ' ') $this->_parseAttributes($options, array('name'), null, ' ')
)); );
} }
/** /**
@ -1036,7 +1036,7 @@ class FormHelper extends AppHelper {
sprintf($this->Html->tags['legend'], $legend) . $out 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( $options = $this->_initInputField($fieldName, array_merge(
array('type' => 'text'), $options array('type' => 'text'), $options
)); ));
return $this->output(sprintf( return sprintf(
$this->Html->tags['input'], $this->Html->tags['input'],
$options['name'], $options['name'],
$this->_parseAttributes($options, array('name'), null, ' ') $this->_parseAttributes($options, array('name'), null, ' ')
)); );
} }
/** /**
@ -1066,11 +1066,11 @@ class FormHelper extends AppHelper {
*/ */
function password($fieldName, $options = array()) { function password($fieldName, $options = array()) {
$options = $this->_initInputField($fieldName, $options); $options = $this->_initInputField($fieldName, $options);
return $this->output(sprintf( return sprintf(
$this->Html->tags['password'], $this->Html->tags['password'],
$options['name'], $options['name'],
$this->_parseAttributes($options, array('name'), null, ' ') $this->_parseAttributes($options, array('name'), null, ' ')
)); );
} }
/** /**
@ -1091,12 +1091,12 @@ class FormHelper extends AppHelper {
} }
unset($options['value']); unset($options['value']);
} }
return $this->output(sprintf( return sprintf(
$this->Html->tags['textarea'], $this->Html->tags['textarea'],
$options['name'], $options['name'],
$this->_parseAttributes($options, array('type', 'name'), null, ' '), $this->_parseAttributes($options, array('type', 'name'), null, ' '),
$value $value
)); );
} }
/** /**
@ -1123,11 +1123,11 @@ class FormHelper extends AppHelper {
$this->__secure(null, '' . $options['value']); $this->__secure(null, '' . $options['value']);
} }
return $this->output(sprintf( return sprintf(
$this->Html->tags['hidden'], $this->Html->tags['hidden'],
$options['name'], $options['name'],
$this->_parseAttributes($options, array('name', 'class'), '', ' ') $this->_parseAttributes($options, array('name', 'class'), '', ' ')
)); );
} }
/** /**
@ -1149,7 +1149,7 @@ class FormHelper extends AppHelper {
} }
$attributes = $this->_parseAttributes($options, array('name'), '', ' '); $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']) { if ($options['escape']) {
$title = h($title); $title = h($title);
} }
return $this->output(sprintf( return sprintf(
$this->Html->tags['button'], $this->Html->tags['button'],
$options['type'], $options['type'],
$this->_parseAttributes($options, array('type'), '', ' '), $this->_parseAttributes($options, array('type'), '', ' '),
$title $title
)); );
} }
/** /**
@ -1217,11 +1217,11 @@ class FormHelper extends AppHelper {
if (strpos($caption, '://') !== false) { if (strpos($caption, '://') !== false) {
unset($options['type']); unset($options['type']);
$out .= $this->output($before . sprintf( $out .= $before . sprintf(
$this->Html->tags['submitimage'], $this->Html->tags['submitimage'],
$caption, $caption,
$this->_parseAttributes($options, null, '', ' ') $this->_parseAttributes($options, null, '', ' ')
) . $after); ) . $after;
} elseif (preg_match('/\.(jpg|jpe|jpeg|gif|png|ico)$/', $caption)) { } elseif (preg_match('/\.(jpg|jpe|jpeg|gif|png|ico)$/', $caption)) {
unset($options['type']); unset($options['type']);
if ($caption{0} !== '/') { if ($caption{0} !== '/') {
@ -1230,17 +1230,17 @@ class FormHelper extends AppHelper {
$caption = trim($caption, '/'); $caption = trim($caption, '/');
$url = $this->webroot($caption); $url = $this->webroot($caption);
} }
$out .= $this->output($before . sprintf( $out .= $before . sprintf(
$this->Html->tags['submitimage'], $this->Html->tags['submitimage'],
$url, $url,
$this->_parseAttributes($options, null, '', ' ') $this->_parseAttributes($options, null, '', ' ')
) . $after); ) . $after;
} else { } else {
$options['value'] = $caption; $options['value'] = $caption;
$out .= $this->output($before . sprintf( $out .= $before . sprintf(
$this->Html->tags['submit'], $this->Html->tags['submit'],
$this->_parseAttributes($options, null, '', ' ') $this->_parseAttributes($options, null, '', ' ')
). $after); ). $after;
} }
if (isset($divOptions)) { if (isset($divOptions)) {
@ -1347,7 +1347,7 @@ class FormHelper extends AppHelper {
$template = ($style == 'checkbox') ? 'checkboxmultipleend' : 'selectend'; $template = ($style == 'checkbox') ? 'checkboxmultipleend' : 'selectend';
$select[] = $this->Html->tags[$template]; $select[] = $this->Html->tags[$template];
return $this->output(implode("\n", $select)); return implode("\n", $select);
} }
/** /**

View file

@ -201,7 +201,7 @@ class HtmlHelper extends AppHelper {
*/ */
function docType($type = 'xhtml-strict') { function docType($type = 'xhtml-strict') {
if (isset($this->__docTypes[$type])) { if (isset($this->__docTypes[$type])) {
return $this->output($this->__docTypes[$type]); return $this->__docTypes[$type];
} }
return null; return null;
} }
@ -270,7 +270,7 @@ class HtmlHelper extends AppHelper {
} }
if ($inline) { if ($inline) {
return $this->output($out); return $out;
} else { } else {
$view =& ClassRegistry::getObject('view'); $view =& ClassRegistry::getObject('view');
$view->addScript($out); $view->addScript($out);
@ -288,7 +288,7 @@ class HtmlHelper extends AppHelper {
if (empty($charset)) { if (empty($charset)) {
$charset = strtolower(Configure::read('App.encoding')); $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']); 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 = sprintf($this->tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline'), '', ' '));
} }
$out = $this->output($out);
if ($options['inline']) { if ($options['inline']) {
return $out; return $out;
@ -472,7 +471,7 @@ class HtmlHelper extends AppHelper {
} }
} }
$attributes = $this->_parseAttributes($options, array('inline', 'once'), ' '); $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']) { if ($options['inline']) {
return $out; return $out;
@ -585,7 +584,7 @@ class HtmlHelper extends AppHelper {
$out[] = $crumb[0]; $out[] = $crumb[0];
} }
} }
return $this->output(join($separator, $out)); return join($separator, $out);
} else { } else {
return null; return null;
} }
@ -624,9 +623,9 @@ class HtmlHelper extends AppHelper {
$image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' ')); $image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' '));
if ($url) { 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) { foreach ($names as $arg) {
$out[] = sprintf($this->tags['tableheader'], $this->_parseAttributes($thOptions), $arg); $out[] = sprintf($this->tags['tableheader'], $this->_parseAttributes($thOptions), $arg);
} }
$data = sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out)); return sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out));
return $this->output($data);
} }
/** /**
@ -698,7 +696,7 @@ class HtmlHelper extends AppHelper {
$options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions); $options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions);
$out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cellsOut)); $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 { } else {
$tag = 'tag'; $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 { } else {
$tag = 'para'; $tag = 'para';
} }
return $this->output(sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text)); return sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text);
} }
/** /**

View file

@ -273,7 +273,7 @@ class JavascriptHelper extends AppHelper {
} }
} }
} }
$out = $this->output(sprintf($this->tags['javascriptlink'], $url)); $out = sprintf($this->tags['javascriptlink'], $url);
if ($inline) { if ($inline) {
return $out; return $out;

View file

@ -557,7 +557,7 @@ class PaginatorHelper extends AppHelper {
$out = str_replace($newKeys, array_values($map), $out); $out = str_replace($newKeys, array_values($map), $out);
break; break;
} }
return $this->output($out); return $out;
} }
/** /**
@ -678,7 +678,7 @@ class PaginatorHelper extends AppHelper {
$out .= $after; $out .= $after;
} }
return $this->output($out); return $out;
} }
/** /**

View file

@ -269,7 +269,7 @@ class RssHelper extends XmlHelper {
if (!empty($elements)) { if (!empty($elements)) {
$content = join('', $elements); $content = join('', $elements);
} }
return $this->output($this->elem('item', $att, $content, !($content === null))); return $this->elem('item', $att, $content, !($content === null));
} }
/** /**

View file

@ -87,8 +87,7 @@ class TimeHelper extends AppHelper {
$date = time(); $date = time();
} }
$ret = date("D, M jS Y, H:i", $date); return date("D, M jS Y, H:i", $date);
return $this->output($ret);
} }
/** /**
@ -115,8 +114,7 @@ class TimeHelper extends AppHelper {
} else { } else {
$ret = date("M jS{$y}, H:i", $date); $ret = date("M jS{$y}, H:i", $date);
} }
return $ret;
return $this->output($ret);
} }
/** /**
@ -134,8 +132,7 @@ class TimeHelper extends AppHelper {
$begin = date('Y-m-d', $begin) . ' 00:00:00'; $begin = date('Y-m-d', $begin) . ' 00:00:00';
$end = date('Y-m-d', $end) . ' 23:59:59'; $end = date('Y-m-d', $end) . ' 23:59:59';
$ret ="($fieldName >= '$begin') AND ($fieldName <= '$end')"; return "($fieldName >= '$begin') AND ($fieldName <= '$end')";
return $this->output($ret);
} }
/** /**
@ -149,8 +146,7 @@ class TimeHelper extends AppHelper {
*/ */
function dayAsSql($dateString, $fieldName, $userOffset = null) { function dayAsSql($dateString, $fieldName, $userOffset = null) {
$date = $this->fromString($dateString, $userOffset); $date = $this->fromString($dateString, $userOffset);
$ret = $this->daysAsSql($dateString, $dateString, $fieldName); return $this->daysAsSql($dateString, $dateString, $fieldName);
return $this->output($ret);
} }
/** /**
@ -254,7 +250,7 @@ class TimeHelper extends AppHelper {
break; break;
} }
} }
return $this->output($date); return $date;
} }
/** /**
@ -265,8 +261,7 @@ class TimeHelper extends AppHelper {
* @return integer Unix timestamp * @return integer Unix timestamp
*/ */
function toUnix($dateString, $userOffset = null) { function toUnix($dateString, $userOffset = null) {
$ret = $this->fromString($dateString, $userOffset); return $this->fromString($dateString, $userOffset);
return $this->output($ret);
} }
/** /**
@ -278,8 +273,7 @@ class TimeHelper extends AppHelper {
*/ */
function toAtom($dateString, $userOffset = null) { function toAtom($dateString, $userOffset = null) {
$date = $this->fromString($dateString, $userOffset); $date = $this->fromString($dateString, $userOffset);
$ret = date('Y-m-d\TH:i:s\Z', $date); return date('Y-m-d\TH:i:s\Z', $date);
return $this->output($ret);
} }
/** /**
@ -291,8 +285,7 @@ class TimeHelper extends AppHelper {
*/ */
function toRSS($dateString, $userOffset = null) { function toRSS($dateString, $userOffset = null) {
$date = $this->fromString($dateString, $userOffset); $date = $this->fromString($dateString, $userOffset);
$ret = date("r", $date); return date("r", $date);
return $this->output($ret);
} }
/** /**
@ -472,7 +465,7 @@ class TimeHelper extends AppHelper {
$relativeDate = sprintf(__('%s ago', true), $relativeDate); $relativeDate = sprintf(__('%s ago', true), $relativeDate);
} }
} }
return $this->output($relativeDate); return $relativeDate;
} }
/** /**

View file

@ -65,7 +65,7 @@ class XmlHelper extends AppHelper {
$attrib = 'xml ' . $attrib; $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) { if (!$endTag) {
$this->Xml =& $elem; $this->Xml =& $elem;
} }
return $this->output($out); return $out;
} }
/** /**
@ -144,7 +144,7 @@ class XmlHelper extends AppHelper {
if ($parent =& $this->Xml->parent()) { if ($parent =& $this->Xml->parent()) {
$this->Xml =& $parent; $this->Xml =& $parent;
} }
return $this->output('</' . $name . '>'); return '</' . $name . '>';
} }
/** /**

View file

@ -5064,21 +5064,6 @@ class FormHelperTest extends CakeTestCase {
'/fieldset' '/fieldset'
); );
$this->assertTags($result, $expected); $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);
} }
/** /**