89 lines
2.2 KiB
PHP
Executable File
89 lines
2.2 KiB
PHP
Executable File
<?php
|
|
require_once 'Configuration.php';
|
|
require_once 'Requete.php';
|
|
require_once 'Vue.php';
|
|
require_once 'Functions.php';
|
|
|
|
abstract class Controleur
|
|
{
|
|
private $action;
|
|
protected $requete;
|
|
private $menuvue;
|
|
|
|
public function setRequete(Requete $requete)
|
|
{
|
|
$this->requete = $requete;
|
|
}
|
|
public function executerAction($action)
|
|
{
|
|
if (method_exists($this, $action)) {
|
|
$this->action = $action;
|
|
$this->{$this->action}();
|
|
}
|
|
else {
|
|
$classeControleur = get_class($this);
|
|
throw new Exception("Action '$action' non définie!");
|
|
}
|
|
}
|
|
public abstract function index();
|
|
|
|
protected function genererVue($donneesVue = array(), $action = null)
|
|
{
|
|
$actionVue = $this->action;
|
|
if ($action != null) {
|
|
$actionVue = $action;
|
|
}
|
|
$classeControleur = get_class($this);
|
|
$controleurVue = str_replace("Controleur", "", $classeControleur);
|
|
$vue = new Vue($actionVue, $controleurVue);
|
|
|
|
$_SESSION['menuActif'] = $controleurVue;
|
|
|
|
if($controleurVue=='Connexion' or $controleurVue=='Connexionassure' or isset($_SESSION['login']))
|
|
{
|
|
|
|
if(isset($_SESSION['passAchanger']) && $_SESSION['passAchanger'] && $controleurVue!='Changermotpass')
|
|
{
|
|
$this->rediriger("Changermotpass");
|
|
}
|
|
else
|
|
{
|
|
$dureeSession = (isset($_SESSION['dureeSession'])) ? $_SESSION['dureeSession'] : 10;
|
|
$session_expiree = session_expiree($dureeSession);
|
|
|
|
|
|
if($session_expiree)
|
|
{
|
|
$this->rediriger("Recconnexion");
|
|
}
|
|
else
|
|
{
|
|
$vue->generer($donneesVue);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$this->rediriger("Connexion");
|
|
}
|
|
}
|
|
|
|
|
|
protected function genererVueAjax($donneesVue = array(), $action = null)
|
|
{
|
|
$actionVue = $this->action;
|
|
if ($action != null) {
|
|
$actionVue = $action;
|
|
}
|
|
$classeControleur = get_class($this);
|
|
$controleurVue = str_replace("Controleur", "", $classeControleur);
|
|
$vue = new Vue($actionVue, $controleurVue);
|
|
$vue->genererAjax($donneesVue);
|
|
}
|
|
|
|
protected function rediriger($controleur, $action = null)
|
|
{
|
|
$racineWeb = Configuration::get("racineWeb", "/");
|
|
header("Location:" . $racineWeb . $controleur . "/" . $action);
|
|
}
|
|
} |