2011-12-14 13:55:57 +01:00
|
|
|
<?php
|
|
|
|
class SessionCiblage
|
|
|
|
{
|
2011-12-14 15:40:55 +01:00
|
|
|
protected $valeur;
|
2011-12-29 22:06:17 +01:00
|
|
|
protected $total = null;
|
|
|
|
protected $insee = null;
|
2011-12-14 13:55:57 +01:00
|
|
|
|
2011-12-14 15:40:55 +01:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$session = new Zend_Session_Namespace('ciblage');
|
2012-01-02 17:55:50 +01:00
|
|
|
$this->valeur = empty($session->ciblage) ? array() : $session->ciblage;
|
2011-12-29 22:06:17 +01:00
|
|
|
if (isset($this->valeur['NB']['total'])){ $this->total = $this->valeur['NB']['total']; }
|
|
|
|
if (isset($this->valeur['NB']['insee'])){ $this->insee = $this->valeur['NB']['insee']; }
|
|
|
|
if (isset($this->valeur['NB'])){ unset($this->valeur['NB']); }
|
2011-12-14 15:40:55 +01:00
|
|
|
}
|
2011-12-14 13:55:57 +01:00
|
|
|
|
2011-12-29 22:10:23 +01:00
|
|
|
/**
|
|
|
|
* Enregistre les informations dans la session
|
|
|
|
*/
|
2011-12-14 15:40:55 +01:00
|
|
|
protected function setSession()
|
|
|
|
{
|
2011-12-29 22:06:17 +01:00
|
|
|
$session = new Zend_Session_Namespace('ciblage');
|
|
|
|
$this->valeur['NB']['total'] = $this->total;
|
|
|
|
$this->valeur['NB']['insee'] = $this->insee;
|
|
|
|
$session->ciblage = $this->valeur;
|
2011-12-14 15:40:55 +01:00
|
|
|
}
|
2011-12-29 22:10:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enregistre un critère et sa valeur
|
|
|
|
* @param unknown_type $key
|
|
|
|
* @param unknown_type $value
|
|
|
|
*/
|
2011-12-14 15:40:55 +01:00
|
|
|
public function setCritere($key, $value)
|
|
|
|
{
|
2012-01-06 12:01:01 +01:00
|
|
|
$this->valeur[$key] = $value;
|
|
|
|
$this->setSession();
|
2011-12-14 15:40:55 +01:00
|
|
|
}
|
2011-12-14 13:55:57 +01:00
|
|
|
|
2011-12-29 22:10:23 +01:00
|
|
|
/**
|
|
|
|
* Définir les critères en une fois
|
|
|
|
* @param array $criteres
|
|
|
|
*/
|
2012-01-11 17:06:16 +01:00
|
|
|
public function setCriteres($criteres)
|
|
|
|
{
|
|
|
|
$this->valeur = $criteres;
|
|
|
|
$this->setSession();
|
|
|
|
}
|
2011-12-14 13:55:57 +01:00
|
|
|
|
2011-12-29 22:10:23 +01:00
|
|
|
/**
|
|
|
|
* Désactivation d'un critère
|
|
|
|
* @param unknown_type $key
|
|
|
|
*/
|
2011-12-14 15:40:55 +01:00
|
|
|
public function unsetCritere($key)
|
|
|
|
{
|
|
|
|
if(key_exists($key, $this->valeur)) {
|
|
|
|
unset($this->valeur[$key]);
|
|
|
|
$this->setSession();
|
|
|
|
}
|
|
|
|
}
|
2011-12-29 22:10:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Récupération de la valeur d'un critère
|
|
|
|
* @param unknown_type $key
|
|
|
|
*/
|
2011-12-29 21:33:23 +01:00
|
|
|
public function getCritere($key)
|
2011-12-14 15:40:55 +01:00
|
|
|
{
|
2012-01-06 12:01:01 +01:00
|
|
|
if(array_key_exists($key, $this->valeur)) {
|
2011-12-29 21:33:23 +01:00
|
|
|
return $this->valeur[$key];
|
|
|
|
}
|
|
|
|
return null;
|
2011-12-14 15:40:55 +01:00
|
|
|
}
|
|
|
|
|
2011-12-29 22:10:23 +01:00
|
|
|
/**
|
|
|
|
* Récupération des critères et de leurs valeurs
|
|
|
|
*/
|
2011-12-14 15:40:55 +01:00
|
|
|
public function getCriteres()
|
|
|
|
{
|
2011-12-29 21:33:23 +01:00
|
|
|
return $this->valeur;
|
2011-12-14 15:40:55 +01:00
|
|
|
}
|
2011-12-29 22:06:17 +01:00
|
|
|
|
2011-12-29 22:10:23 +01:00
|
|
|
/**
|
|
|
|
* Définit un élément de comptage
|
|
|
|
* @param unknown_type $element
|
|
|
|
* @param unknown_type $nb
|
|
|
|
*/
|
2011-12-29 22:06:17 +01:00
|
|
|
public function setNb($element, $nb)
|
|
|
|
{
|
|
|
|
$this->{$element} = $nb;
|
|
|
|
$this->setSession();
|
|
|
|
}
|
|
|
|
|
2011-12-29 22:10:23 +01:00
|
|
|
/**
|
|
|
|
* Récupére la valeur d'un élément de comptage
|
|
|
|
* @param unknown_type $element
|
|
|
|
*/
|
2011-12-29 22:06:17 +01:00
|
|
|
public function getNb($element)
|
|
|
|
{
|
|
|
|
return $this->{$element};
|
|
|
|
}
|
|
|
|
|
2012-01-03 11:44:45 +01:00
|
|
|
|
|
|
|
public function clearCiblage()
|
|
|
|
{
|
|
|
|
Zend_Session::namespaceUnset('ciblage');
|
|
|
|
}
|
|
|
|
|
2011-12-14 13:55:57 +01:00
|
|
|
}
|