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

rename domainsbrowsing

parent 56415143
Branches
Tags
2 merge requests!258Dev/13872 Orphee Allow Hold Available Items,!4dev#12091 Moulins portail jeunesse
<?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_DomainBrowser extends ZendAfi_View_Helper_BaseHelper {
public function domainBrowser($current_domain,$current_breadcrumb) {
if (null == $current_domain)
$current_domain = Class_Catalogue::getRoot();
return
$this->displayParentsDomains($current_breadcrumb).
'<ul>'.$this->displayDomain($current_domain,$current_breadcrumb).'</ul>'.
$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 '<div class="domains_children"><ul>'.$html.'</ul></div>';
}
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'><ul>";
$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."</ul></div>";
}
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 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
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