New file |
0,0 → 1,182 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Classe de test des Controleurs. |
* |
* @package Collection |
* @category Php 5.2 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright 2010 Tela-Botanica |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL |
* @version SVN: $Id: Fiche.php 152 2010-09-06 16:19:12Z jpm $ |
*/ |
class Station extends aControleur { |
|
private $id_station_en_cours = null; |
|
public function __construct() { |
|
parent::__construct(); |
$this->initialiser(); |
} |
|
public function initialiser() { |
|
$this->id_station_en_cours = $_GET['id_station']; |
$this->setNavigation(); |
|
} |
|
public function executerActionParDefaut() { |
return $this->afficherFormulaireSaisieStation(); |
} |
|
// +---------------------------------------------------------------------------------------------------------------+ |
// METHODES D'AFFICHAGE DE FORMULAIRE |
public function afficherFormulaireSaisieStation() { |
|
$donnees = array(); |
$formulaire = $this->getVue('formulaires/station_saisie',$donnees); |
$this->setSortie(self::RENDU_CORPS, $formulaire); |
} |
|
public function afficherFormulaireModificationStation() { |
|
$donnees = array(); |
|
$id_station = $this->id_station_en_cours; |
$donnees['infos_station'] = $this->getInformationsStation($id_station); |
$formulaire = $this->getVue('formulaires/station_modification',$donnees); |
$this->setSortie(self::RENDU_CORPS, $formulaire); |
} |
|
// +---------------------------------------------------------------------------------------------------------------+ |
// METHODES APPELEES LORS DE LA VALIDATION D'UN FORMULAIRE |
public function validerFormulaireSaisieStation() { |
|
$valeurs_formulaires = $_POST['form_saisie_station']; |
|
$valeurs_verifiees = $this->collecterValeursFormulaireSaisieStation(); |
|
$station_dao = new StationDao(); |
$station_dao->ajouterStation($valeurs_verifiees); |
} |
|
private function collecterValeursFormulaireSaisieStation() { |
|
$valeurs_verifiees['station_commune'] = $_POST['station_commune']; |
$valeurs_verifiees['station_milieu'] = $_POST['station_milieu']; |
$valeurs_verifiees['station_nom'] = $_POST['station_nom']; |
$valeurs_verifiees['station_lat'] = $_POST['station_lat']; |
$valeurs_verifiees['station_lon'] = $_POST['station_lon']; |
|
//TODO: verifier valeurs plus complètement |
|
return $valeurs_verifiees; |
|
} |
|
public function validerFormulaireModificationStation() { |
|
$valeurs_formulaires = $_POST['form_modif_station']; |
|
$valeurs_verifiees = array(); |
|
$station_dao = new StationDao(); |
$station_dao->modifierStation($valeurs_verifiees); |
|
} |
|
// +---------------------------------------------------------------------------------------------------------------+ |
// METHODES D'AFFICHAGES D'INFORMATION |
public function afficherlisteStation($param = null) { |
|
$id_utilisateur = AppControleur::getIdUtilisateur(); |
|
$donnees['stations'] = $this->getListeStations($id_utilisateur); |
$this->setSortie(self::RENDU_CORPS, $this->getVue('listes/station_liste', $donnees)); |
} |
|
public function afficherInformationsStation() { |
|
$id_station = $this->id_station_en_cours; |
|
$donnees['id_station'] = $id_station; |
$donnees['infos_station'] = $this->getInformationsStation($id_station); |
$this->setSortie(self::RENDU_CORPS, $this->getVue('fiches/station_fiche', $donnees)); |
|
} |
|
// +---------------------------------------------------------------------------------------------------------------+ |
// METHODES POUR FABRIQUER LE MENU |
public function construireMenuNavigation($espece_en_cours = null) { |
|
$id_station_en_cours = $this->id_station_en_cours; |
|
$stations = $this->getListeStations(); |
|
foreach($stations as &$station) { |
$station['url'] = aControleur::getUrlConsultationFicheStation($station['id']); |
} |
|
if($id_station_en_cours != null) { |
$especes_station_en_cours = $this->getEspecesStation($id_station_en_cours); |
|
foreach($especes_station_en_cours as &$espece) { |
$espece['url'] = aControleur::getUrlConsultationEspeceStation($id_station_en_cours, $espece['id']); |
} |
$stations[$id_station_en_cours]['especes'] = $especes_station_en_cours; |
} |
|
$donnees['stations'] = $stations; |
$donnees['id_station_en_cours'] = $id_station_en_cours; |
|
if($id_espece_en_cours != null) { |
$donnees['id_espece_en_cours'] = $id_espece; |
} |
|
$menu_navigation = $this->getVue('navigation/menu', $donnees); |
|
return $menu_navigation; |
|
} |
|
public function setNavigation() { |
$this->setSortie(self::RENDU_NAVIGATION, $this->construireMenuNavigation()); |
} |
|
// +---------------------------------------------------------------------------------------------------------------+ |
// METHODE D'APPELS AUX DAOS |
protected function getListeStations() { |
|
$station_dao = new StationDao(); |
return $station_dao->getListeStations(); |
} |
|
private function getInformationsStation($id_station) { |
|
$station_dao = new StationDao(); |
$infos_station = $station_dao->getInformationsStation($id_station); |
|
$infos_station['individus'] = $this->getIndividusStation($id_station); |
|
return $infos_station; |
} |
|
private function getEspecesStation($id_station) { |
|
$espece_dao = new EspeceDao(); |
$liste_especes = $espece_dao->getListeEspecesPourStation($id_station); |
|
return $liste_especes; |
} |
|
public function getIndividusStation($id_station) { |
|
$individu_dao = new IndividuDao(); |
$liste_individus = $individu_dao->getListeIndividusPourStation($id_station); |
|
return $liste_individus; |
} |
} |