| Line 1... |
Line 1... |
| 1 |
<?php
|
1 |
<?php
|
| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
class ControlleurFrontal {
|
3 |
class ControlleurFrontal {
|
| 4 |
|
4 |
|
| 5 |
public function getRegistre()
|
5 |
public function getRegistre()
|
| 6 |
{
|
6 |
{
|
| 7 |
return Registre::getRegistre();
|
7 |
return Registre::getRegistre();
|
| 8 |
}
|
8 |
}
|
| 9 |
|
9 |
|
| 10 |
public function parserAction($url)
|
10 |
public function parserAction($url)
|
| 11 |
{
|
11 |
{
|
| - |
|
12 |
if (preg_match('/^(.+?)(?:_(.+)|)$/', $url, $match)) {
|
| 12 |
if (preg_match('/^(.+?)(?:_(.+)|)$/', $url, $match)) {
|
13 |
$aso_compo_classe = explode('-', $match[1]);
|
| - |
|
14 |
$retour['classe_action'] = 'GttCtrlAction';
|
| - |
|
15 |
foreach ($aso_compo_classe as $mot) {
|
| - |
|
16 |
$retour['classe_action'] .= ucfirst($mot);
|
| 13 |
$retour['classe_action'] = 'GttCtrlAction'.ucfirst($match[1]);
|
17 |
}
|
| 14 |
}
|
18 |
}
|
| 15 |
|
19 |
|
| 16 |
$retour['tab_actions'] = array('');
|
20 |
$retour['tab_actions'] = array('__defaut__');
|
| 17 |
if (isset($match[2])) {
|
21 |
if (isset($match[2])) {
|
| - |
|
22 |
preg_match_all('/(.+)(?:_|$)/', $match[2], $match_actions);
|
| - |
|
23 |
//echo '<pre>'.print_r($match_actions[1], true).'</pre>';
|
| - |
|
24 |
foreach ($match_actions[1] as $action) {
|
| - |
|
25 |
$aso_compo_action = explode('-', $action);
|
| - |
|
26 |
$action = '';
|
| - |
|
27 |
foreach ($aso_compo_action as $mot_action) {
|
| - |
|
28 |
$action .= ucfirst($mot_action);
|
| 18 |
preg_match_all('/(.+)(?:_|$)/', $match[2], $match_actions);
|
29 |
}
|
| - |
|
30 |
$retour['tab_actions'][] = $action;
|
| 19 |
$retour['tab_actions'] = $match_actions[1];
|
31 |
}
|
| 20 |
}
|
32 |
}
|
| 21 |
return $retour;
|
33 |
return $retour;
|
| Line -... |
Line 34... |
| - |
|
34 |
}
|
| - |
|
35 |
|
| - |
|
36 |
private function chargerActionGenerique(&$tab_actions)
|
| - |
|
37 |
{
|
| - |
|
38 |
// Gestion de l'identification
|
| - |
|
39 |
$GttCtrlActionIdentification = new GttCtrlActionIdentification($this->getRegistre());
|
| - |
|
40 |
$GttCtrlActionIdentification->setSuivant('__defaut__');
|
| - |
|
41 |
array_unshift($tab_actions, $GttCtrlActionIdentification);
|
| - |
|
42 |
|
| - |
|
43 |
// Gestion des menus
|
| - |
|
44 |
$GttCtrlActionMenu = new GttCtrlActionMenu($this->getRegistre());
|
| - |
|
45 |
$GttCtrlActionMenu->setSuivant('__defaut__');
|
| - |
|
46 |
$tab_actions[] = $GttCtrlActionMenu;
|
| - |
|
47 |
}
|
| 22 |
}
|
48 |
|
| 23 |
|
49 |
|
| 24 |
public function executer($url_action)
|
50 |
public function executer($url_action)
|
| 25 |
{
|
51 |
{
|
| 26 |
$tab_info_url = $this->parserAction($url_action);
|
52 |
$tab_info_url = $this->parserAction($url_action);
|
| 27 |
//echo '<pre>'.print_r($tab_info_url, true).'</pre>';
|
53 |
//echo '<pre>'.print_r($tab_info_url, true).'</pre>';
|
| 28 |
$classe_action = $tab_info_url['classe_action'];
|
54 |
$classe_action = $tab_info_url['classe_action'];
|
| 29 |
$fichier_action = GTT_CHEMIN_ACTION.$classe_action.'.class.php';
|
55 |
$fichier_action = GTT_CHEMIN_ACTION.$classe_action.'.class.php';
|
| 30 |
if (file_exists($fichier_action)) {
|
56 |
if (file_exists($fichier_action)) {
|
| 31 |
require_once $fichier_action;
|
57 |
require_once $fichier_action;
|
| 32 |
$Action = new $classe_action($this->getRegistre());
|
- |
|
| 33 |
foreach ($tab_info_url['tab_actions'] as $action) {
|
- |
|
| 34 |
// Vérification des données POST ou GET avant l'appel de l'action
|
- |
|
| 35 |
if (isset($_POST) || isset($_GET)) {
|
- |
|
| 36 |
$Action->verifier();
|
- |
|
| 37 |
$methode_verif = 'verifier'.ucfirst($action);
|
- |
|
| 38 |
if (method_exists($Action, $methode_verif)) {
|
- |
|
| 39 |
// Méthode "vérifier" spécifique à une action
|
- |
|
| 40 |
$Action->$methode_verif();
|
- |
|
| 41 |
}
|
- |
|
| 42 |
}
|
58 |
$Action = new $classe_action($this->getRegistre());
|
| 43 |
// Execution de l'action
|
- |
|
| 44 |
$Action->setSuivant(ucfirst($action));
|
59 |
$this->chargerActionGenerique(&$tab_info_url['tab_actions']);
|
| 45 |
}
|
60 |
$Action->setSuivant($tab_info_url['tab_actions']);
|
| 46 |
$Action->demarrer();
|
61 |
$Action->demarrer();
|
| 47 |
$aso_principal['principal'] = $this->rendre();
|
- |
|
| 48 |
//echo '<pre>'.print_r($aso_principal, true).'</pre>';
|
62 |
$aso_principal['principal'] = $this->rendre();
|
| 49 |
$Resultats = $this->getRegistre();
|
63 |
//echo '<pre>'.print_r($aso_principal, true).'</pre>';
|
| 50 |
$aso_principal['principal']['titre'] = $Resultats->getTitre();
|
64 |
$aso_principal['principal']['titre'] = $this->getRegistre()->getTitre();
|
| 51 |
$Resultats->setEspaces(array());
|
65 |
$this->getRegistre()->setEspaces(array());
|
| 52 |
$Resultats->setSquelettes(array());
|
66 |
$this->getRegistre()->setSquelettes(array());
|
| 53 |
$Resultats->setDonnees(array());
|
67 |
$this->getRegistre()->setDonnees(array());
|
| 54 |
$Resultats->ajouterEspace('Principal', 'principal');
|
68 |
$this->getRegistre()->ajouterEspace('Principal', 'principal');
|
| 55 |
$Resultats->ajouterSquelette('principal', 'principal.tpl.html');
|
69 |
$this->getRegistre()->ajouterSquelette('principal', 'principal.tpl.html');
|
| 56 |
$Resultats->ajouterDonnee('principal', $aso_principal['principal']);
|
70 |
$this->getRegistre()->ajouterDonnee('principal', $aso_principal['principal']);
|
| 57 |
return $this->rendre();
|
71 |
return $this->rendre();
|
| 58 |
} else {
|
72 |
} else {
|
| 59 |
$m = "Le fichier $fichier_action contenant l'action est introuvable!";
|
73 |
$m = "Le fichier $fichier_action contenant l'action est introuvable!";
|
| 60 |
trigger_error($m, E_USER_ERROR);
|
74 |
trigger_error($m, E_USER_ERROR);
|
| 61 |
}
|
75 |
}
|
| 62 |
}
|
76 |
}
|
| 63 |
|
77 |
|
| 64 |
public function rendre()
|
78 |
public function rendre()
|
| 65 |
{
|
79 |
{
|
| 66 |
$contenu_principal = null;
|
80 |
$contenu_principal = null;
|
| - |
|
81 |
$aso_contenu = array('zone_contenu' => '', 'zone_menu' => '', 'zone_identification' => '');
|
| - |
|
82 |
foreach ($this->getRegistre()->getEspaces() as $espace_de_nom) {
|
| - |
|
83 |
if (is_array($this->getRegistre()->getDonnees($espace_de_nom))) {
|
| 67 |
$aso_contenu = array('zone_contenu' => '', 'zone_identification' => '');
|
84 |
$fichier_squelette = GTT_CHEMIN_PRESENTATION.$this->getRegistre()->getSquelettes($espace_de_nom);
|
| 68 |
foreach ($this->getRegistre()->getEspaces() as $espace_de_nom) {
|
85 |
if (file_exists($fichier_squelette)) {
|
| 69 |
ob_start();
|
86 |
ob_start();
|
| - |
|
87 |
extract($GLOBALS['_GTT_']['i18n']['general'], EXTR_PREFIX_ALL, 'i18n_general');
|
| 70 |
extract($GLOBALS['_GTT_']['i18n']['general'], EXTR_PREFIX_ALL, 'i18n_general');
|
88 |
extract($this->getRegistre()->getDonnees($espace_de_nom));
|
| 71 |
extract($this->getRegistre()->getDonnees($espace_de_nom));
|
89 |
|
| 72 |
include_once GTT_CHEMIN_PRESENTATION.$this->getRegistre()->getSquelettes($espace_de_nom);
|
90 |
include_once $fichier_squelette;
|
| 73 |
// Répartition dans des zones
|
91 |
// Répartition dans des zones
|
| 74 |
switch($espace_de_nom) {
|
92 |
switch($espace_de_nom) {
|
| 75 |
case 'principal' :
|
93 |
case 'principal' :
|
| 76 |
$contenu_principal .= ob_get_contents();
|
94 |
$contenu_principal .= ob_get_contents();
|
| 77 |
break;
|
95 |
break;
|
| - |
|
96 |
case 'identification' :
|
| - |
|
97 |
$aso_contenu['zone_identification'] .= ob_get_contents();
|
| - |
|
98 |
break;
|
| 78 |
case 'identification' :
|
99 |
case 'zone_menu' :
|
| 79 |
$aso_contenu['zone_identification'] .= ob_get_contents();
|
100 |
$aso_contenu['zone_menu'] .= ob_get_contents();
|
| 80 |
break;
|
101 |
break;
|
| - |
|
102 |
default:
|
| - |
|
103 |
$aso_contenu['zone_contenu'] .= ob_get_contents();
|
| - |
|
104 |
}
|
| - |
|
105 |
ob_end_clean();
|
| - |
|
106 |
} else {
|
| 81 |
default:
|
107 |
trigger_error("Absence du fichier de squelette : $fichier_squelette", E_USER_ERROR);
|
| 82 |
$aso_contenu['zone_contenu'] .= ob_get_contents();
|
- |
|
| 83 |
}
|
108 |
}
|
| 84 |
ob_end_clean();
|
109 |
}
|
| 85 |
}
|
110 |
}
|
| 86 |
if (!is_null($contenu_principal)) {
|
111 |
if (!is_null($contenu_principal)) {
|
| 87 |
return $contenu_principal;
|
112 |
return $contenu_principal;
|