Subversion Repositories Applications.gtt

Rev

Rev 62 | Rev 104 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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