6 |
jpm |
1 |
<?php
|
|
|
2 |
// declare(encoding='UTF-8');
|
|
|
3 |
/**
|
|
|
4 |
* Classe Controleur du module Test.
|
16 |
jpm |
5 |
*
|
|
|
6 |
* TODO : refactoriser l'ensemble des tests!
|
6 |
jpm |
7 |
*
|
|
|
8 |
* @package Referentiel
|
|
|
9 |
* @category Php5.2
|
|
|
10 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
11 |
* @copyright 2010 Tela-Botanica
|
|
|
12 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
|
|
13 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
|
|
14 |
* @version SVN: $Id$
|
|
|
15 |
*/
|
|
|
16 |
class Test extends AppliControleur {
|
|
|
17 |
|
23 |
jpm |
18 |
private $referentiel = null;
|
|
|
19 |
private $traitementDao = null;
|
|
|
20 |
private $messages = null;
|
6 |
jpm |
21 |
|
|
|
22 |
public function __construct() {
|
|
|
23 |
parent::__construct();
|
|
|
24 |
|
|
|
25 |
// Récupération de paramêtres
|
23 |
jpm |
26 |
if (isset($_GET['ref'])) { // code du projet courrant
|
|
|
27 |
$this->referentiel = strtolower($_GET['ref']);
|
6 |
jpm |
28 |
}
|
|
|
29 |
|
|
|
30 |
// Chargement des DAO nécessaires
|
23 |
jpm |
31 |
$this->traitementDao = new TraitementDao();
|
6 |
jpm |
32 |
}
|
|
|
33 |
|
|
|
34 |
//+----------------------------------------------------------------------------------------------------------------+
|
|
|
35 |
// Méthodes
|
|
|
36 |
/**
|
|
|
37 |
* Fonction d'affichage par défaut, elle appelle la liste des administrateurs
|
|
|
38 |
*/
|
|
|
39 |
public function executerActionParDefaut() {
|
23 |
jpm |
40 |
return $this->afficherInterface();
|
6 |
jpm |
41 |
}
|
|
|
42 |
|
23 |
jpm |
43 |
/**
|
|
|
44 |
* Affiche le formulaire de demande de traitement
|
|
|
45 |
*/
|
|
|
46 |
public function afficherInterface() {
|
|
|
47 |
$donnees = array();
|
|
|
48 |
$this->url->unsetVariablesRequete(array('module', 'action', 'ref'));
|
|
|
49 |
$donnees['url_form'] = $this->url->getUrl();
|
|
|
50 |
$donnees['url_module'] = 'Test';
|
|
|
51 |
$donnees['url_action'] = 'demanderTraitement';
|
|
|
52 |
|
|
|
53 |
// Traitement de l'info sur le code du référentiel
|
|
|
54 |
if (isset($this->referentiel)) {
|
|
|
55 |
$donnees['ref'] = $this->referentiel;
|
24 |
jpm |
56 |
$resultat = $this->traitementDao->getTraitementEnCours($this->referentiel);
|
|
|
57 |
if ($resultat != false) {
|
|
|
58 |
$donnees['traitements'] = $resultat;
|
|
|
59 |
} else {
|
|
|
60 |
$this->messages[] = "Un problème est survenu lors de la tentative de récupération des traitements en cours.";
|
|
|
61 |
}
|
23 |
jpm |
62 |
} else {
|
|
|
63 |
$this->messages[] = "Aucun code de projet de référentiel n'est indiqué (Ex. bdnff).";
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
$donnees['messages'] = $this->messages;
|
|
|
67 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('form_traitement', $donnees), false);
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
/**
|
|
|
71 |
* Lance l'ajout d'un traitement
|
|
|
72 |
*/
|
|
|
73 |
public function demanderTraitement() {
|
|
|
74 |
$this->ajouterTraitement();
|
|
|
75 |
//$this->afficherInterface();
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
/**
|
|
|
79 |
* Lance l'ajout d'un traitement
|
|
|
80 |
*/
|
|
|
81 |
private function ajouterTraitement() {
|
|
|
82 |
if (!isset($this->referentiel)) {
|
|
|
83 |
$this->messages[] = "Aucun code de projet de référentiel n'est indiqué (Ex. bdnff).";
|
|
|
84 |
} else {
|
|
|
85 |
$resultat = $this->traitementDao->ajouterTraitement($this->referentiel);
|
|
|
86 |
Debug::printr($resultat);
|
|
|
87 |
if ($resultat != false) {
|
|
|
88 |
$this->messages[] = "Le traitement #'' a été ajouté.";
|
|
|
89 |
} else {
|
|
|
90 |
$this->messages[] = "Un problème est survenu lors de la tentative d'ajout du traitement.";
|
|
|
91 |
}
|
|
|
92 |
}
|
|
|
93 |
}
|
|
|
94 |
|
6 |
jpm |
95 |
}
|
|
|
96 |
?>
|