Fixing HtmlHelper::link() to allow passing $escapeTitle and $confirmMessage params as 'escape' and 'confirm' in $options

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4255 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-01-05 21:48:40 +00:00
parent f96a1728eb
commit b8c51fee44

View file

@ -253,12 +253,21 @@ class HtmlHelper extends AppHelper {
$title = $url;
$escapeTitle = false;
}
if(isset($htmlAttributes['escape'])) {
$escapeTitle = $htmlAttributes['escape'];
unset($htmlAttributes['escape']);
}
if($escapeTitle === true) {
$title = htmlspecialchars($title, ENT_QUOTES);
} else if (is_string($escapeTitle)) {
$title = htmlentities($title, $escapeTitle);
}
if(!empty($htmlAttributes['confirm'])) {
$confirmMessage = $htmlAttributes['confirm'];
unset($htmlAttributes['confirm']);
}
if ($confirmMessage) {
$confirmMessage = htmlspecialchars($confirmMessage, ENT_NOQUOTES);
$confirmMessage = str_replace("'", "\'", $confirmMessage);
@ -266,8 +275,7 @@ class HtmlHelper extends AppHelper {
$htmlAttributes['onclick'] = "return confirm('{$confirmMessage}');";
}
$output = sprintf($this->tags['link'], $url, $this->_parseAttributes($htmlAttributes), $title);
return $this->output($output);
return $this->output(sprintf($this->tags['link'], $url, $this->_parseAttributes($htmlAttributes), $title));
}
/**
* Creates a link element for CSS stylesheets.