mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
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:
parent
f96a1728eb
commit
b8c51fee44
1 changed files with 10 additions and 2 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue