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