minou
This commit is contained in:
parent
4d834823e7
commit
0918b215d1
2 changed files with 26 additions and 30 deletions
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
use Smarty\Smarty;
|
||||
|
||||
/**
|
||||
* Le controller de la partie accessible uniquement par l'admin
|
||||
* @author Yasser
|
||||
*/
|
||||
|
||||
class MotherCtrl {
|
||||
|
||||
|
|
@ -11,25 +15,19 @@
|
|||
* Méthode d'affichage des pages
|
||||
*/
|
||||
protected function _display($strView, bool $boolDisplay = true){
|
||||
// Création de l'objet Smarty
|
||||
|
||||
$objSmarty = new Smarty();
|
||||
// Ajouter le var_dump au modificateur de smarty : vardump est le nom appelé après le |
|
||||
$objSmarty->registerPlugin('modifier', 'vardump', 'var_dump');
|
||||
// Désactiver la mise en cache
|
||||
$objSmarty->caching = false;
|
||||
|
||||
// Forcer la recompilation des templates
|
||||
|
||||
$objSmarty->force_compile = true;
|
||||
|
||||
// Vérifier si les templates ont été modifiés
|
||||
|
||||
$objSmarty->compile_check = true;
|
||||
|
||||
// Récupérer les variables
|
||||
foreach($this->_arrData as $key=>$value){
|
||||
//$$key = $value;
|
||||
$objSmarty->assign($key, $value);
|
||||
}
|
||||
// Message de succès
|
||||
|
||||
$objSmarty->assign("success_message", $_SESSION['success']??'');
|
||||
unset($_SESSION['success']);
|
||||
|
||||
|
|
@ -43,14 +41,6 @@
|
|||
}else{
|
||||
return $objSmarty->fetch("views/".$strView.".tpl");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// inclusion du header
|
||||
/*include("views/_partial/header.php");
|
||||
include("views/".$strView.".php");
|
||||
include("views/_partial/footer.php");*/
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
/**
|
||||
* Le controler des Project
|
||||
* @author Yasser & Laura
|
||||
* @author Yasser, Laura, Besnik & Guillaume
|
||||
*/
|
||||
class ProjectCtrl extends MotherCtrl{
|
||||
|
||||
|
|
@ -93,10 +93,9 @@
|
|||
|
||||
/**
|
||||
* Fonction d'affichage de la page projet
|
||||
* @author Christel adapter par Guillaume
|
||||
*/
|
||||
public function addedit_project() {
|
||||
if (!isset($_SESSION['user'])){ // Pas d'utilisateur connecté
|
||||
if (!isset($_SESSION['user'])){
|
||||
header("Location:index.php?ctrl=error&action=error_403");
|
||||
exit;
|
||||
}
|
||||
|
|
@ -105,17 +104,15 @@
|
|||
$objProjectModel = new ProjectModel;
|
||||
$objCategoryModel = new CategoryModel;
|
||||
|
||||
// dans la cas de modif
|
||||
if (isset($_GET['id'])){
|
||||
$arrProject = $objProjectModel->findOne($_GET['id']);
|
||||
$objProject->hydrate($arrProject); // BDD
|
||||
}
|
||||
|
||||
// Tester le formulaire
|
||||
$arrError = [];
|
||||
if (count($_POST) > 0) {
|
||||
|
||||
$objProject->hydrate($_POST); // Formulaire
|
||||
$objProject->hydrate($_POST);
|
||||
if ($objProject->getTitle() == ""){
|
||||
$arrError['title'] = "Le titre est obligatoire";
|
||||
}
|
||||
|
|
@ -134,15 +131,11 @@
|
|||
if (!in_array($_FILES['thumbnail']['type'], $arrTypeAllowed)){
|
||||
$arrError['thumbnail'] = "Le type de fichier n'est pas autorisé";
|
||||
}else{
|
||||
// Vérification des codes d'erreur
|
||||
|
||||
switch ($_FILES['thumbnail']['error']){
|
||||
case 0 :
|
||||
// Renommage de l'image
|
||||
$strImageName = uniqid().".webp";
|
||||
|
||||
// Récupère le nom de l'image avant changement
|
||||
$strOldImg = $objProject->getThumbnail();
|
||||
// Mise à jour du nom de l'image dans l'objet
|
||||
$objProject->setThumbnail($strImageName);
|
||||
break;
|
||||
case 1 :
|
||||
|
|
@ -253,6 +246,10 @@
|
|||
$this->_display('addedit_project');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fonction d'affichage d'un projet
|
||||
*/
|
||||
public function display() {
|
||||
$intId = $_GET['id'] ?? null;
|
||||
|
||||
|
|
@ -276,6 +273,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction d'envoi d'email
|
||||
*/
|
||||
public function sendEmail(){
|
||||
if (count($_POST) > 0) {
|
||||
|
||||
|
|
@ -348,6 +348,9 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction d'acceptation d'un projet
|
||||
*/
|
||||
public function accept(){
|
||||
|
||||
//Récupéré l'id dans l'url
|
||||
|
|
@ -375,7 +378,10 @@
|
|||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fonction de suppression d'un projet
|
||||
*/
|
||||
public function delete(){
|
||||
|
||||
//Récupéré l'id dans l'url
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue