Changed tags attributes to protected.

This commit is contained in:
Juan Basso 2011-01-23 12:38:36 -02:00
parent 10d3dd5d2b
commit b1f4c6a0c9

View file

@ -29,9 +29,8 @@ class HtmlHelper extends AppHelper {
* html tags used by this helper. * html tags used by this helper.
* *
* @var array * @var array
* @access public
*/ */
public $tags = array( protected $_tags = array(
'meta' => '<meta%s/>', 'meta' => '<meta%s/>',
'metalink' => '<link href="%s"%s/>', 'metalink' => '<link href="%s"%s/>',
'link' => '<a href="%s"%s>%s</a>', 'link' => '<a href="%s"%s>%s</a>',
@ -246,14 +245,14 @@ class HtmlHelper extends AppHelper {
if (isset($options['link'])) { if (isset($options['link'])) {
if (isset($options['rel']) && $options['rel'] === 'icon') { if (isset($options['rel']) && $options['rel'] === 'icon') {
$out = sprintf($this->tags['metalink'], $options['link'], $this->_parseAttributes($options, array('link'), ' ', ' ')); $out = sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('link'), ' ', ' '));
$options['rel'] = 'shortcut icon'; $options['rel'] = 'shortcut icon';
} else { } else {
$options['link'] = $this->url($options['link'], true); $options['link'] = $this->url($options['link'], true);
} }
$out .= sprintf($this->tags['metalink'], $options['link'], $this->_parseAttributes($options, array('link'), ' ', ' ')); $out .= sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('link'), ' ', ' '));
} else { } else {
$out = sprintf($this->tags['meta'], $this->_parseAttributes($options, array('type'), ' ', ' ')); $out = sprintf($this->_tags['meta'], $this->_parseAttributes($options, array('type'), ' ', ' '));
} }
if ($inline) { if ($inline) {
@ -276,7 +275,7 @@ class HtmlHelper extends AppHelper {
if (empty($charset)) { if (empty($charset)) {
$charset = strtolower(Configure::read('App.encoding')); $charset = strtolower(Configure::read('App.encoding'));
} }
return sprintf($this->tags['charset'], (!empty($charset) ? $charset : 'utf-8')); return sprintf($this->_tags['charset'], (!empty($charset) ? $charset : 'utf-8'));
} }
/** /**
@ -336,7 +335,7 @@ class HtmlHelper extends AppHelper {
} }
unset($options['default']); unset($options['default']);
} }
return sprintf($this->tags['link'], $url, $this->_parseAttributes($options), $title); return sprintf($this->_tags['link'], $url, $this->_parseAttributes($options), $title);
} }
/** /**
@ -391,12 +390,12 @@ class HtmlHelper extends AppHelper {
} }
if ($rel == 'import') { if ($rel == 'import') {
$out = sprintf($this->tags['style'], $this->_parseAttributes($options, array('inline'), '', ' '), '@import url(' . $url . ');'); $out = sprintf($this->_tags['style'], $this->_parseAttributes($options, array('inline'), '', ' '), '@import url(' . $url . ');');
} else { } else {
if ($rel == null) { if ($rel == null) {
$rel = 'stylesheet'; $rel = 'stylesheet';
} }
$out = sprintf($this->tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline'), '', ' ')); $out = sprintf($this->_tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline'), '', ' '));
} }
if ($options['inline']) { if ($options['inline']) {
@ -462,7 +461,7 @@ class HtmlHelper extends AppHelper {
} }
} }
$attributes = $this->_parseAttributes($options, array('inline', 'once'), ' '); $attributes = $this->_parseAttributes($options, array('inline', 'once'), ' ');
$out = sprintf($this->tags['javascriptlink'], $url, $attributes); $out = sprintf($this->_tags['javascriptlink'], $url, $attributes);
if ($options['inline']) { if ($options['inline']) {
return $out; return $out;
@ -494,9 +493,9 @@ class HtmlHelper extends AppHelper {
unset($options['inline'], $options['safe']); unset($options['inline'], $options['safe']);
$attributes = $this->_parseAttributes($options, ' ', ' '); $attributes = $this->_parseAttributes($options, ' ', ' ');
if ($inline) { if ($inline) {
return sprintf($this->tags['javascriptblock'], $attributes, $script); return sprintf($this->_tags['javascriptblock'], $attributes, $script);
} else { } else {
$this->_View->addScript(sprintf($this->tags['javascriptblock'], $attributes, $script)); $this->_View->addScript(sprintf($this->_tags['javascriptblock'], $attributes, $script));
return null; return null;
} }
} }
@ -675,10 +674,10 @@ class HtmlHelper extends AppHelper {
unset($options['url']); unset($options['url']);
} }
$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 sprintf($this->tags['link'], $this->url($url), null, $image); return sprintf($this->_tags['link'], $this->url($url), null, $image);
} }
return $image; return $image;
} }
@ -696,9 +695,9 @@ class HtmlHelper extends AppHelper {
public function tableHeaders($names, $trOptions = null, $thOptions = null) { public function tableHeaders($names, $trOptions = null, $thOptions = null) {
$out = array(); $out = array();
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);
} }
return sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out)); return sprintf($this->_tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out));
} }
/** /**
@ -748,10 +747,10 @@ class HtmlHelper extends AppHelper {
} elseif ($useCount) { } elseif ($useCount) {
$cellOptions['class'] = 'column-' . ++$i; $cellOptions['class'] = 'column-' . ++$i;
} }
$cellsOut[] = sprintf($this->tags['tablecell'], $this->_parseAttributes($cellOptions), $cell); $cellsOut[] = sprintf($this->_tags['tablecell'], $this->_parseAttributes($cellOptions), $cell);
} }
$options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions); $options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions);
$out[] = sprintf($this->tags['tablerow'], $options, implode(' ', $cellsOut)); $out[] = sprintf($this->_tags['tablerow'], $options, implode(' ', $cellsOut));
} }
return implode("\n", $out); return implode("\n", $out);
} }
@ -784,7 +783,7 @@ class HtmlHelper extends AppHelper {
} else { } else {
$tag = 'tag'; $tag = 'tag';
} }
return sprintf($this->tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name); return sprintf($this->_tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name);
} }
/** /**
@ -794,7 +793,7 @@ class HtmlHelper extends AppHelper {
* @return string Formatted block * @return string Formatted block
*/ */
public function useTag($tag) { public function useTag($tag) {
if (!isset($this->tags[$tag])) { if (!isset($this->_tags[$tag])) {
return ''; return '';
} }
$args = func_get_args(); $args = func_get_args();
@ -804,7 +803,7 @@ class HtmlHelper extends AppHelper {
$arg = $this->_parseAttributes($arg, null, ' ', ''); $arg = $this->_parseAttributes($arg, null, ' ', '');
} }
} }
return vsprintf($this->tags[$tag], $args); return vsprintf($this->_tags[$tag], $args);
} }
/** /**
@ -855,7 +854,7 @@ class HtmlHelper extends AppHelper {
} else { } else {
$tag = 'para'; $tag = 'para';
} }
return sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text); return sprintf($this->_tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text);
} }
/** /**
@ -873,7 +872,7 @@ class HtmlHelper extends AppHelper {
$options = array(); $options = array();
} }
$items = $this->__nestedListItem($list, $options, $itemOptions, $tag); $items = $this->__nestedListItem($list, $options, $itemOptions, $tag);
return sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $items); return sprintf($this->_tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $items);
} }
/** /**
@ -900,7 +899,7 @@ class HtmlHelper extends AppHelper {
} else if (isset($itemOptions['odd']) && $index % 2 != 0) { } else if (isset($itemOptions['odd']) && $index % 2 != 0) {
$itemOptions['class'] = $itemOptions['odd']; $itemOptions['class'] = $itemOptions['odd'];
} }
$out .= sprintf($this->tags['li'], $this->_parseAttributes($itemOptions, array('even', 'odd'), ' ', ''), $item); $out .= sprintf($this->_tags['li'], $this->_parseAttributes($itemOptions, array('even', 'odd'), ' ', ''), $item);
$index++; $index++;
} }
return $out; return $out;