From 917f478aeaa1d5549ebd44ae3bb401e81abeec57 Mon Sep 17 00:00:00 2001 From: pairprog <pairprog@afi-sa.fr> Date: Fri, 28 Feb 2014 17:44:20 +0100 Subject: [PATCH] render domain browser with list --- .../View/Helper/Accueil/DomainBrowser.php | 2 +- .../ZendAfi/View/Helper/DomainsBrowsing.php | 86 ------------------- .../View/Helper/Accueil/DomainBrowserTest.php | 6 +- 3 files changed, 4 insertions(+), 90 deletions(-) delete mode 100644 library/ZendAfi/View/Helper/DomainsBrowsing.php diff --git a/library/ZendAfi/View/Helper/Accueil/DomainBrowser.php b/library/ZendAfi/View/Helper/Accueil/DomainBrowser.php index 0a447dcae73..032cb4ab35b 100644 --- a/library/ZendAfi/View/Helper/Accueil/DomainBrowser.php +++ b/library/ZendAfi/View/Helper/Accueil/DomainBrowser.php @@ -24,7 +24,7 @@ class ZendAfi_View_Helper_Accueil_DomainBrowser extends ZendAfi_View_Helper_Accu $this->titre = $this->preferences['titre']; $current_domain = Class_Catalogue::find($this->preferences['root_domain_id']); - $this->contenu = $this->view->domainsBrowsing($current_domain, ''); + $this->contenu = $this->view->domainBrowser($current_domain, ''); return $this->getHtmlArray(); } diff --git a/library/ZendAfi/View/Helper/DomainsBrowsing.php b/library/ZendAfi/View/Helper/DomainsBrowsing.php deleted file mode 100644 index c3877e01488..00000000000 --- a/library/ZendAfi/View/Helper/DomainsBrowsing.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php -/** - * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. - * - * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * AFI-OPAC 2.0 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with AFI-OPAC 2.0; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -class ZendAfi_View_Helper_DomainsBrowsing extends ZendAfi_View_Helper_BaseHelper { - public function domainsBrowsing($current_domain,$current_breadcrumb) { - if (null == $current_domain) - $current_domain = Class_Catalogue::getRoot(); - - return - $this->displayParentsDomains($current_breadcrumb). - $this->displayDomain($current_domain,$current_breadcrumb). - $this->displayChildrenDomains($current_domain->getChildren(), - $this->constructBreadcrumb($current_domain,$current_breadcrumb)); - } - - protected function displayChildrenDomains($children_domains,$parents_domains) { - $html=''; - foreach($children_domains as $child) { - $html.=$this->displayDomain($child,$parents_domains); - } - return $html; - } - - protected function constructBreadcrumb($current_domain,$current_breadcrumb) { - return - $current_breadcrumb - ? $current_breadcrumb.';'.$current_domain->getId() - : $current_domain->getId(); - } - - public function displayParentsDomains($breadcrumb) { - if (!$breadcrumb) - return ''; - - $html="<div class='domains_breadcrumb'>"; - $parents_domains=Class_Catalogue::getDomainsForBreadcrumb($breadcrumb); - $new_breadcrumb=''; - foreach($parents_domains as $domain) { - $html.=$this->displayDomain($domain,$new_breadcrumb); - $new_breadcrumb=$this->constructBreadcrumb($domain,$new_breadcrumb); - } - return $html."</div>"; - } - - protected function displayDomain($domain,$breadcrumb) { - return - $this->view - ->tagAnchor($this->getBrowsingDomainUrl($domain,$breadcrumb), - ($url_img=$domain->getUrlImg()) ? $this->view->tagImg($url_img, ['alt' => $domain->getLibelle(), 'title' => $domain->getLibelle()]): $domain->getLibelle()); - } - - - protected function getBrowsingDomainUrl($domain, $parents) { - return - $domain->hasSousDomaines() - ? $this->view->url(array_filter(['controller' =>'domains', - 'action' => 'browse', - 'id'=> $domain->getId(), - 'parents' => $parents]),null,true) - : $this->view->url(array_filter(['controller' =>'recherche', - 'action' => 'simple', - 'id_catalogue'=> $domain->getId(), - 'parents' => $parents]),null,true); - } - -} - -?> \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php b/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php index b328776598c..bc5b87d215c 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php @@ -48,7 +48,7 @@ abstract class ZendAfi_View_Helper_Accueil_DomainBrowserTestCase extends ViewHel -class ZendAfi_View_Helper_Accueil_DomainBrowserTest extends ZendAfi_View_Helper_Accueil_DomainBrowserTestCase { +class ZendAfi_View_Helper_Accueil_DomainBrowserWithDomainTest extends ZendAfi_View_Helper_Accueil_DomainBrowserTestCase { public function setUp() { parent::setUp(); @@ -101,13 +101,13 @@ class ZendAfi_View_Helper_Accueil_DomainBrowserWithoutConfigTest extends ZendAfi /** @test */ public function linkForDomainMetalShouldBePresent() { - $this->assertXPath($this->_html, '//a[contains(@href, "/recherche/simple/id_catalogue/1")]', $this->_html); + $this->assertXPath($this->_html, '//div//ul//li//a[contains(@href, "/recherche/simple/id_catalogue/1")]', $this->_html); } /** @test */ public function linkForDomainJazzShouldBePresent() { - $this->assertXPath($this->_html, '//a[contains(@href, "/recherche/simple/id_catalogue/2")]', $this->_html); + $this->assertXPath($this->_html, '//div//ul//a[contains(@href, "/recherche/simple/id_catalogue/2")]', $this->_html); } } -- GitLab