Initial commit for radiantprestation project
This commit is contained in:
85
Framework/Controleur.php
Normal file
85
Framework/Controleur.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
require_once 'Configuration.php';
|
||||
require_once 'Requete.php';
|
||||
require_once 'Vue.php';
|
||||
require_once 'Functions.php';
|
||||
|
||||
// Ajout du 01/07/2019
|
||||
// require_once 'Localisation.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 dans la classe $classeControleur");
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
if($controleurVue=='Connexion' or $controleurVue=='Connexionassure' or isset($_SESSION['p_login']))
|
||||
{
|
||||
// $vue->generer($donneesVue);
|
||||
$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", "/");
|
||||
|
||||
$_SESSION['p_racineWeb'] = $racineWeb;
|
||||
|
||||
header("Location:" . $racineWeb . $controleur . "/" . $action);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user