From 709649594369d050d37af35ef89a6005e41ae544 Mon Sep 17 00:00:00 2001 From: Lucas Freitas Date: Mon, 3 Mar 2014 05:01:49 -0300 Subject: [PATCH 1/4] Allow the passing parameter escape of the getCrumbList method and reflecting that into the outputted link too --- lib/Cake/View/Helper/HtmlHelper.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 6ce3cfafa..7bfc51878 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -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']; + $escape = $options['escape']; unset($options['firstClass'], $options['lastClass'], $options['separator']); - $crumbs = $this->_prepareCrumbs($startText); + $crumbs = $this->_prepareCrumbs($startText, $escape); if (empty($crumbs)) { return null; } @@ -754,7 +755,7 @@ class HtmlHelper extends AppHelper { * @param string $startText Text to prepend * @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 +767,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; } From d4b91166bc7d8c4a4f5f51f0f1d83eff170525d6 Mon Sep 17 00:00:00 2001 From: Lucas Freitas Date: Mon, 3 Mar 2014 05:10:21 -0300 Subject: [PATCH 2/4] Fixing stupidity and adding the PHPDoc param --- lib/Cake/View/Helper/HtmlHelper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 7bfc51878..219345371 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -753,6 +753,7 @@ 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, $escape = true) { @@ -767,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('escape' => $escape)); + array_unshift($crumbs, array($text, $url, $startText + array('escape' => $escape))); } return $crumbs; } From b522b1e7241750e513e6f30d487d2a737775c58d Mon Sep 17 00:00:00 2001 From: Lucas Freitas Date: Mon, 3 Mar 2014 05:28:59 -0300 Subject: [PATCH 3/4] Entire UL element was being outputted directly (escaped), added to the unset list and fixed --- lib/Cake/View/Helper/HtmlHelper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 219345371..949ace545 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -719,7 +719,7 @@ class HtmlHelper extends AppHelper { $lastClass = $options['lastClass']; $separator = $options['separator']; $escape = $options['escape']; - unset($options['firstClass'], $options['lastClass'], $options['separator']); + unset($options['firstClass'], $options['lastClass'], $options['separator'], $options['escape']); $crumbs = $this->_prepareCrumbs($startText, $escape); if (empty($crumbs)) { @@ -764,11 +764,11 @@ class HtmlHelper extends AppHelper { 'url' => '/', 'text' => $startText ); - } + } $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('escape' => $escape))); + array_unshift($crumbs, array($text, $url, $startText + array('escape' => $escape))); } return $crumbs; } From 4cd6ac2f15ab313ccaca76a87b25d37721edbaef Mon Sep 17 00:00:00 2001 From: Lucas Freitas Date: Thu, 13 Mar 2014 00:24:16 -0300 Subject: [PATCH 4/4] Fix break of the CS on Travis --- lib/Cake/View/Helper/HtmlHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 949ace545..d26ba64f3 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -764,7 +764,7 @@ class HtmlHelper extends AppHelper { 'url' => '/', 'text' => $startText ); - } + } $startText += array('url' => '/', 'text' => __d('cake', 'Home')); list($url, $text) = array($startText['url'], $startText['text']); unset($startText['url'], $startText['text']);