From ba45698e2058d6463f2553bd16968130f97625d8 Mon Sep 17 00:00:00 2001 From: lbrun <leo@sandbox.pergame.net> Date: Mon, 8 Feb 2016 15:02:09 +0100 Subject: [PATCH] hotline#37341 : fix search result type doc display --- VERSIONS_HOTLINE/37341 | 1 + .../View/Helper/Notice/FacettesTypeDoc.php | 12 ++++++------ .../View/Helper/Notice/FacettesTypeDocTest.php | 17 +++++------------ 3 files changed, 12 insertions(+), 18 deletions(-) create mode 100644 VERSIONS_HOTLINE/37341 diff --git a/VERSIONS_HOTLINE/37341 b/VERSIONS_HOTLINE/37341 new file mode 100644 index 00000000000..64ee4bc8e0e --- /dev/null +++ b/VERSIONS_HOTLINE/37341 @@ -0,0 +1 @@ + - ticket #37341 : CASQY : Correction de l'affichage des types docs en résultat de recherche \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/FacettesTypeDoc.php b/library/ZendAfi/View/Helper/Notice/FacettesTypeDoc.php index fa3580a29fa..90207bbe38d 100644 --- a/library/ZendAfi/View/Helper/Notice/FacettesTypeDoc.php +++ b/library/ZendAfi/View/Helper/Notice/FacettesTypeDoc.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_Notice_FacettesTypeDoc extends Zend_View_Helper_HtmlElement { public function notice_FacettesTypeDoc($facettes) { @@ -26,10 +26,10 @@ class ZendAfi_View_Helper_Notice_FacettesTypeDoc extends Zend_View_Helper_HtmlEl if (!isset($facettes['T'])) $facettes['T'] = []; - foreach($facettes['T'] as $facette) { - if (!is_array($facette)) - continue; - $html .= $this->renderFacette($facette['id'], $facette['libelle'], $facette['nombre']); + foreach($facettes['T'] as $code => $value) { + $label = Class_Codification::getInstance()->getLibelleFacette($code); + + $html .= $this->renderFacette($code, $label, $value); } return $html.'</div>'; @@ -37,7 +37,7 @@ class ZendAfi_View_Helper_Notice_FacettesTypeDoc extends Zend_View_Helper_HtmlEl public function renderFacette($id, $libelle, $nombre) { - return $this->view->tagAnchor(['facette' => $id], $nombre, + return $this->view->tagAnchor(['facette' => $id], $nombre, ['class' => 'type_doc_'.substr($id, 1 ), 'libelle' => $libelle]); } diff --git a/tests/library/ZendAfi/View/Helper/Notice/FacettesTypeDocTest.php b/tests/library/ZendAfi/View/Helper/Notice/FacettesTypeDocTest.php index 4383f1fea08..cf14bfb1c88 100644 --- a/tests/library/ZendAfi/View/Helper/Notice/FacettesTypeDocTest.php +++ b/tests/library/ZendAfi/View/Helper/Notice/FacettesTypeDocTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_Notice_FacettesTypeDocTest extends ViewHelperTestCase { @@ -26,29 +26,22 @@ class ZendAfi_View_Helper_Notice_FacettesTypeDocTest extends ViewHelperTestCase parent::setUp(); $this->_helper = new ZendAfi_View_Helper_Notice_FacettesTypeDoc(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); - $this->_html = $this->_helper->notice_FacettesTypeDoc(['T' => [ 'titre' => 'Type de document', - 1 => ['id' => 'T1', - 'libelle' => 'Livres', - 'nombre' => 22], - 2 => ['id' => 'T3', - 'libelle' => 'DVD', - 'nombre' => 34]]]); + $this->_html = $this->_helper->notice_FacettesTypeDoc(['T' => ['T1' => 22, + 'T3' => 34]]); } /** @test */ public function linkForTypeDocLivreShouldContains22() { $this->assertXPathContentContains($this->_html, - '//div[@class="facettes_type_doc"]//a[@class="type_doc_1"][contains(@href, "facette/T1")]', - '22'); + '//div[@class="facettes_type_doc"]//a[@class="type_doc_1"][contains(@href, "facette/T1")]', '22'); } /** @test */ public function linkForTypeDVDShouldContains34() { $this->assertXPathContentContains($this->_html, - '//div[@class="facettes_type_doc"]//a[@class="type_doc_3"][contains(@href, "facette/T3")]', - '34'); + '//div[@class="facettes_type_doc"]//a[@class="type_doc_3"][contains(@href, "facette/T3")]', '34'); } } ?> \ No newline at end of file -- GitLab