Skip to content
Snippets Groups Projects
Commit cc3f6123 authored by llaffont's avatar llaffont
Browse files

Refactoring selecteur de profils pour réutilisation dans la config de la boite recherche

parent 151ac71e
Branches
Tags
No related merge requests found
......@@ -369,7 +369,6 @@ class Class_Profil extends Storm_Model_Abstract {
* @return string
*/
public function getPathTemplates() {
xdebug_break();
if($this->isTelephone())
return './public/opac/mobile/templates/';
return '.'.$this->getPathTheme().'templates/';
......
......@@ -22,18 +22,42 @@
// OPAC3 - Combo des menu paramétrés
//////////////////////////////////////////////////////////////////////////////////////////////////////
class ZendAfi_View_Helper_ComboProfils extends ZendAfi_View_Helper_BaseHelper
{
class ZendAfi_View_Helper_ComboProfils extends ZendAfi_View_Helper_BaseHelper {
protected
$_select_profil_id;
//------------------------------------------------------------------------------------------------------
// Main routine
//------------------------------------------------------------------------------------------------------
function comboProfils($id_zone='ALL',$id_bib='ALL',$id_profil=1,$autoload=false)
{
function comboProfils($id_zone='ALL', $id_bib='ALL', $id_profil=1, $autoload=false) {
$this->_select_profil_id = $id_profil;
return $this->renderSelect('select_clef_profil',
'clef_profil',
$autoload,
$this->renderProfilsByBibGroups());
}
public function renderProfilsByBibGroups() {
$html = '';
$profils_by_bib = $this->getProfilsByBib();
foreach ($profils_by_bib as $bib => $profils)
$html .= $this->renderBibProfils($bib, $profils);
return $html;
}
public function renderSelect($id, $name, $autoload ,$content) {
$onchange='';
if($autoload==true)
$onchange=' onchange="window.location=\''.BASE_URL.'?id_profil=\' + this.value"';
else
$onchange="";
return '<select id="select_clef_profil" name="clef_profil"'.$onchange.'>'.$content.'</select>';
}
public function getProfilsByBib() {
$profils = Class_Profil::getLoader()->findAllByZoneAndBib($id_zone,$id_bib);
$profils_by_bib = array();
foreach ($profils as $profil) {
......@@ -52,28 +76,27 @@ class ZendAfi_View_Helper_ComboProfils extends ZendAfi_View_Helper_BaseHelper
}
ksort($profils_by_bib);
$html = '<select id="select_clef_profil" name="clef_profil"'.$onchange.'>';
$rupture="";
foreach ($profils_by_bib as $bib => $profils) {
$html.='<optgroup label="'.htmlentities($bib).'">';
return $profils_by_bib;
}
public function renderBibProfils($bib, $profils) {
$html = '';
foreach($profils as $profil) {
$libelle = $profil->getLibelle();
if ($id_profil == $profil->getId()) $selected='selected="selected"'; else $selected='';
$html.='<option value="'.$profil->getId().'" '.$selected.'>'.$libelle.': '.$this->translate()->_('Accueil').'</option>';
foreach ($profil->getSubProfils() as $page) {
if ($id_profil == $page->getId()) $selected='selected="selected"'; else $selected='';
$html.='<option value="'.$page->getId().'" '.$selected.'>'.$libelle.': '.$page->getLibelle().'</option>';
$html .= $this->renderProfilOption($profil, $libelle.': '.$this->translate()->_('Accueil'));
}
foreach ($profil->getSubProfils() as $page)
$html .= $this->renderProfilOption($page, $libelle.': '.$page->getLibelle());
}
$html.='</optgroup>';
}
$html.='</select>';
return $html;
return '<optgroup label="'.htmlentities($bib).'">'.$html.'</optgroup>';
}
public function renderProfilOption($profil, $libelle) {
$selected = ($this->_select_profil_id == $profil->getId()) ? 'selected="selected"' : '';
return '<option value="'.$profil->getId().'" '.$selected.'>'.$libelle.'</option>';
}
}
\ 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