mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +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;
|
$title = $url;
|
||||||
$escapeTitle = false;
|
$escapeTitle = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($htmlAttributes['escape'])) {
|
||||||
|
$escapeTitle = $htmlAttributes['escape'];
|
||||||
|
unset($htmlAttributes['escape']);
|
||||||
|
}
|
||||||
if($escapeTitle === true) {
|
if($escapeTitle === true) {
|
||||||
$title = htmlspecialchars($title, ENT_QUOTES);
|
$title = htmlspecialchars($title, ENT_QUOTES);
|
||||||
} else if (is_string($escapeTitle)) {
|
} else if (is_string($escapeTitle)) {
|
||||||
$title = htmlentities($title, $escapeTitle);
|
$title = htmlentities($title, $escapeTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!empty($htmlAttributes['confirm'])) {
|
||||||
|
$confirmMessage = $htmlAttributes['confirm'];
|
||||||
|
unset($htmlAttributes['confirm']);
|
||||||
|
}
|
||||||
if ($confirmMessage) {
|
if ($confirmMessage) {
|
||||||
$confirmMessage = htmlspecialchars($confirmMessage, ENT_NOQUOTES);
|
$confirmMessage = htmlspecialchars($confirmMessage, ENT_NOQUOTES);
|
||||||
$confirmMessage = str_replace("'", "\'", $confirmMessage);
|
$confirmMessage = str_replace("'", "\'", $confirmMessage);
|
||||||
|
@ -266,8 +275,7 @@ class HtmlHelper extends AppHelper {
|
||||||
$htmlAttributes['onclick'] = "return confirm('{$confirmMessage}');";
|
$htmlAttributes['onclick'] = "return confirm('{$confirmMessage}');";
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = sprintf($this->tags['link'], $url, $this->_parseAttributes($htmlAttributes), $title);
|
return $this->output(sprintf($this->tags['link'], $url, $this->_parseAttributes($htmlAttributes), $title));
|
||||||
return $this->output($output);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Creates a link element for CSS stylesheets.
|
* Creates a link element for CSS stylesheets.
|
||||||
|
|
Loading…
Add table
Reference in a new issue