Skip to content
Snippets Groups Projects
Commit 917f478a authored by pairprog's avatar pairprog
Browse files

render domain browser with list

parent d7070f5c
Branches
Tags
2 merge requests!258Dev/13872 Orphee Allow Hold Available Items,!4dev#12091 Moulins portail jeunesse
......@@ -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();
}
......
<?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
......@@ -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);
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment