mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #2941 from lucasff/master
Allow the passing parameter escape of the getCrumbList method
This commit is contained in:
commit
90ca41d436
1 changed files with 7 additions and 5 deletions
|
@ -713,14 +713,15 @@ class HtmlHelper extends AppHelper {
|
|||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#creating-breadcrumb-trails-with-htmlhelper
|
||||
*/
|
||||
public function getCrumbList($options = array(), $startText = false) {
|
||||
$defaults = array('firstClass' => 'first', 'lastClass' => 'last', 'separator' => '');
|
||||
$defaults = array('firstClass' => 'first', 'lastClass' => 'last', 'separator' => '', 'escape' => true);
|
||||
$options = array_merge($defaults, (array)$options);
|
||||
$firstClass = $options['firstClass'];
|
||||
$lastClass = $options['lastClass'];
|
||||
$separator = $options['separator'];
|
||||
unset($options['firstClass'], $options['lastClass'], $options['separator']);
|
||||
$escape = $options['escape'];
|
||||
unset($options['firstClass'], $options['lastClass'], $options['separator'], $options['escape']);
|
||||
|
||||
$crumbs = $this->_prepareCrumbs($startText);
|
||||
$crumbs = $this->_prepareCrumbs($startText, $escape);
|
||||
if (empty($crumbs)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -752,9 +753,10 @@ class HtmlHelper extends AppHelper {
|
|||
* Prepends startText to crumbs array if set
|
||||
*
|
||||
* @param string $startText Text to prepend
|
||||
* @param boolean $escape If the output should be escaped or not
|
||||
* @return array Crumb list including startText (if provided)
|
||||
*/
|
||||
protected function _prepareCrumbs($startText) {
|
||||
protected function _prepareCrumbs($startText, $escape = true) {
|
||||
$crumbs = $this->_crumbs;
|
||||
if ($startText) {
|
||||
if (!is_array($startText)) {
|
||||
|
@ -766,7 +768,7 @@ class HtmlHelper extends AppHelper {
|
|||
$startText += array('url' => '/', 'text' => __d('cake', 'Home'));
|
||||
list($url, $text) = array($startText['url'], $startText['text']);
|
||||
unset($startText['url'], $startText['text']);
|
||||
array_unshift($crumbs, array($text, $url, $startText));
|
||||
array_unshift($crumbs, array($text, $url, $startText + array('escape' => $escape)));
|
||||
}
|
||||
return $crumbs;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue