projet_php/controllers/MotherCtrl.php
2026-02-28 23:24:38 +01:00

48 lines
No EOL
1.1 KiB
PHP

<?php
namespace Controllers;
use Smarty\Smarty;
/**
* Le controller de la partie accessible uniquement par l'admin
* @author Yasser
*/
class MotherCtrl {
protected array $_arrData = array(); // ou = []
/**
* Méthode d'affichage des pages
*/
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");
}
}
}