10 |
jpm |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class Controlleur {
|
|
|
4 |
|
|
|
5 |
public function executer($action)
|
|
|
6 |
{
|
|
|
7 |
if (preg_match('/^(.+?)(?:_(.+)|)$/', $action, $match)) {
|
|
|
8 |
$classe_action = 'GttAction'.ucfirst($match[1]);
|
|
|
9 |
}
|
|
|
10 |
|
|
|
11 |
$tab_actions = array();
|
|
|
12 |
if (isset($match[2])) {
|
|
|
13 |
preg_match_all('/(.+)(?:_|$)/', $match[2], $match_actions);
|
|
|
14 |
$tab_actions = $match_actions[1];
|
|
|
15 |
}
|
|
|
16 |
$fichier_action = GTT_CHEMIN_ACTION.$classe_action.'.class.php';
|
|
|
17 |
if (file_exists($fichier_action)) {
|
|
|
18 |
require_once $fichier_action;
|
|
|
19 |
$Action = new $classe_action;
|
|
|
20 |
|
|
|
21 |
foreach ($tab_actions as $action) {
|
|
|
22 |
// Vérification des données POST ou GET avant l'appel de l'action
|
|
|
23 |
if (isset($_POST) || isset($_GET)) {
|
|
|
24 |
$methode_verif = 'verifier'.ucfirst($action);
|
|
|
25 |
if (method_exists($Action, $methode_verif)) {
|
|
|
26 |
// Méthode "vérifier" spécifique à une action
|
|
|
27 |
$Action->$methode_verif($Action->getResultat());
|
|
|
28 |
}
|
|
|
29 |
}
|
|
|
30 |
// Execution de l'action
|
|
|
31 |
$Action->setSuivant(ucfirst($action));
|
|
|
32 |
}
|
|
|
33 |
$Action->demarrer();
|
|
|
34 |
$aso_principal['principal']['contenu_principal'] = $this->rendre($Action->getResultat());
|
|
|
35 |
$Resultats = $Action->getResultat();
|
|
|
36 |
$aso_principal['principal']['titre'] = $Resultats->getTitre();
|
|
|
37 |
$Resultats->setEspaces(array());
|
|
|
38 |
$Resultats->setSquelettes(array());
|
|
|
39 |
$Resultats->setDonnees(array());
|
|
|
40 |
$Resultats->ajouterEspace('Principal', 'principal');
|
|
|
41 |
$Resultats->ajouterSquelette('principal', 'principal.tpl.html');
|
|
|
42 |
$Resultats->ajouterDonnee('principal', $aso_principal['principal']);
|
|
|
43 |
return $this->rendre($Resultats);
|
|
|
44 |
}
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
public function rendre(Resultat $Resultats)
|
|
|
48 |
{
|
|
|
49 |
$contenu = '';
|
|
|
50 |
foreach ($Resultats->getEspaces() as $espace_de_nom) {
|
|
|
51 |
ob_start();
|
|
|
52 |
extract($GLOBALS['_GTT_']['i18n']['general'], EXTR_PREFIX_ALL, 'i18n_general');
|
|
|
53 |
extract($Resultats->getDonnees($espace_de_nom));
|
|
|
54 |
include_once GTT_CHEMIN_PRESENTATION.$Resultats->getSquelettes($espace_de_nom);
|
|
|
55 |
$contenu .= ob_get_contents();
|
|
|
56 |
ob_end_clean();
|
|
|
57 |
}
|
|
|
58 |
return $contenu;
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
?>
|