Skip to content
Snippets Groups Projects
Commit b83c729f authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

rel #12091: Domain browsing display a default image when a domain does not have one

parent f4ea9550
Branches
Tags
2 merge requests!258Dev/13872 Orphee Allow Hold Available Items,!4dev#12091 Moulins portail jeunesse
......@@ -30,60 +30,69 @@ class ZendAfi_View_Helper_RenderDomainBrowser extends ZendAfi_View_Helper_BaseHe
$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 '<div class="children_domains"><ul>'.$html.'</ul></div>';
protected function displayChildrenDomains($children, $parents) {
$html = '';
foreach($children as $child)
$html .= $this->displayDomain($child, $parents);
$view = $this->view;
return $view->tag('div', $view->tag('ul', $html),
['class' => 'children_domains']);
}
protected function constructBreadcrumb($current_domain,$current_breadcrumb) {
return
$current_breadcrumb
? $current_breadcrumb.';'.$current_domain->getId()
: $current_domain->getId();
protected function constructBreadcrumb($domain, $breadcrumb) {
if (!$breadcrumb)
return $domain->getId();
return $breadcrumb . ';' . $domain->getId();
}
public function displayDomains($current_domain, $breadcrumb) {
public function displayDomains($current, $breadcrumb) {
if (!$breadcrumb)
return '';
$parents_domain_html='';
$parents_domains=Class_Catalogue::getDomainsForBreadcrumb($breadcrumb);
$new_breadcrumb='';
foreach($parents_domains as $domain) {
$parents_domain_html.=$this->displayDomain($domain,$new_breadcrumb);
$new_breadcrumb=$this->constructBreadcrumb($domain,$new_breadcrumb);
$parents_html = '';
$parents = Class_Catalogue::getDomainsForBreadcrumb($breadcrumb);
$new_breadcrumb = '';
foreach($parents as $domain) {
$parents_html .= $this->displayDomain($domain, $new_breadcrumb);
$new_breadcrumb = $this->constructBreadcrumb($domain, $new_breadcrumb);
}
return
'<div class="breadcrumb_domains">'.
'<ul>'.$parents_domain_html.$this->displayDomain($current_domain, $breadcrumb).'</ul>'.
'</div>';
$view = $this->view;
return $view->tag('div',
$view->tag('ul',
$parents_html . $this->displayDomain($current, $breadcrumb)),
['class' => 'breadcrumb_domains']);
}
protected function displayDomain($domain,$breadcrumb) {
return '<li>'.
$this->view
->tagAnchor($this->getBrowsingDomainUrl($domain,$breadcrumb),
($url_img=$domain->getUrlImg())
? $this->view->tagImg($url_img, ['alt' => $domain->getLibelle(), 'title' => $domain->getLibelle()])
: $domain->getLibelle())
.'</li>';
protected function displayDomain($domain, $breadcrumb) {
$view = $this->view;
$url_img = $domain->getUrlImg();
$img = $view->tagImg($url_img ? $url_img : $view->skinImageUrl('filetypes.png'),
['alt' => $domain->getLibelle(),
'title' => $domain->getLibelle()]);
$url = $this->getBrowsingDomainUrl($domain, $breadcrumb);
return
$view->tag('li', $view->tagAnchor($url, $img . $view->tag('span', $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);
$params = $domain->hasSousDomaines()
? array_filter(['controller' =>'domains',
'action' => 'browse',
'id'=> $domain->getId(),
'parents' => $parents])
: array_filter(['controller' =>'recherche',
'action' => 'simple',
'id_catalogue'=> $domain->getId(),
'parents' => $parents]);
return $this->view->url($params, null, true);
}
}
......
public/opac/images/filetypes.png

16.2 KiB

......@@ -80,30 +80,43 @@ class DomainsControllerBrowseALetterDomainTest extends DomainsControllerBrowseTe
}
/** @test */
public function browsingADomainShouldDisplayLinkAnimalsDomainAsRechercheSimple() {
public function shouldDisplayLinkAnimalsDomainAsRechercheSimple() {
$this->assertXPath('//div[@class="children_domains"]/ul/li/a[@href="/recherche/simple/id_catalogue/10/parents/3%3B4"]');
}
/** @test */
public function browsingADomainShouldDisplayLinkADomain() {
public function shouldDisplayLinkADomain() {
$this->assertXPath('//div[@class="breadcrumb_domains"]/ul/li/a[@href="/domains/browse/id/4/parents/3"]');
}
/** @test */
public function browsingADomainShouldDisplayLinkToYouthDomain() {
$this->assertXPath('//div[@class="breadcrumb_domains"]/ul/li/a[@href="/domains/browse/id/3"]/img[@src="http://imgs/youth.png"]');
public function shouldDisplayLinkToYouthDomain() {
$this->assertXPath('//div[@class="breadcrumb_domains"]/ul/li/'
. 'a[@href="/domains/browse/id/3"]/img[@src="http://imgs/youth.png"]'
. '[following-sibling::span]');
}
}
class DomainsControllerBrowseCLetterDomainTest extends DomainsControllerBrowseTestCase {
/** @test **/
public function browsingCLetterDomainShouldDisplayLinkToCarAndLinkToCinema() {
public function setUp() {
parent::setUp();
$this->dispatch('/domains/browse/id/6/parents/3', true);
}
/** @test **/
public function shouldDisplayLinkToCarAndLinkToCinema() {
$this->assertXPathCount('//div[@class="children_domains"]/ul/li/a[contains(@href,"/recherche/simple/id")]', 2);
}
/** @test */
public function shouldDisplayGeneratedImage() {
$this->assertXPath('//div[@class="breadcrumb_domains"]//a[@href="/domains/browse/id/6/parents/3"]/img');
}
}
......
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