51 lines
No EOL
1.3 KiB
PHP
51 lines
No EOL
1.3 KiB
PHP
<?php
|
|
namespace Controllers;
|
|
|
|
use Smarty\Smarty;
|
|
|
|
/**
|
|
* Controller Mère qui permet de gèrer l'affichage des pages
|
|
* @author Yasser
|
|
*/
|
|
|
|
class MotherCtrl {
|
|
|
|
protected array $_arrData = array(); // ou = []
|
|
|
|
/**
|
|
* Méthode d'affichage des pages
|
|
* @param string $strView Le fichier a afficher
|
|
* @param bool $boolDisplay Booléen pour afficher web ou mail
|
|
* @return page|object affiche la page ou retourne l'objet pour le mail
|
|
*/
|
|
protected function _display($strView, bool $boolDisplay = true){
|
|
|
|
$objSmarty = new Smarty();
|
|
$objSmarty->registerPlugin('modifier', 'vardump', 'var_dump');
|
|
$objSmarty->registerPlugin('modifier', 'file_exists', 'file_exists');
|
|
$objSmarty->caching = false;
|
|
|
|
$objSmarty->force_compile = true;
|
|
|
|
$objSmarty->compile_check = true;
|
|
|
|
foreach($this->_arrData as $key=>$value){
|
|
$objSmarty->assign($key, $value);
|
|
}
|
|
|
|
$objSmarty->assign("success_message", $_SESSION['success']??'');
|
|
unset($_SESSION['success']);
|
|
|
|
if (isset($_SESSION['error'])){
|
|
$objSmarty->assign("arrError", array($_SESSION['error']));
|
|
unset($_SESSION['error']);
|
|
}
|
|
|
|
if ($boolDisplay){
|
|
$objSmarty->display("views/".$strView.".tpl");
|
|
}else{
|
|
return $objSmarty->fetch("views/".$strView.".tpl");
|
|
}
|
|
}
|
|
|
|
} |