public function afficherPublicationAction()
 {
     $rubriqueModel = new RubriqueModel();
     $categorieModel = new CategorieModel();
     $publicationModel = new PublicationModel();
     $this->layout()->setVariable('listeRubrique', $rubriqueModel->fetchAll());
     $this->layout()->setVariable('langue', $this->getEvent()->getRouteMatch()->getParam('langue'));
     $this->layout()->setVariable('menu_id', 0);
     return new ViewModel(array('listePubli' => $publicationModel->fetchAll(), 'listeCateg' => $categorieModel->fetchAll(), 'langue' => $this->getEvent()->getRouteMatch()->getParam('langue')));
 }
 public function afficherPublicationAction()
 {
     // verification de connexion
     $token = VerifUser::tokenAction();
     // verification des rubriques
     $rubriqueModel = new RubriqueModel();
     $data = null;
     $rubrique = null;
     try {
         $data = $rubriqueModel->fetchAll();
     } catch (\Exception $e) {
         SendLayout::traiteExceptionsAllRubriques($this, $data, 'pbm', $this->getEvent()->getRouteMatch()->getParam('langue'), $token, $e->getMessage());
     }
     //verification des publications
     $publicationModel = new PublicationModel();
     $dataP = null;
     $publication = null;
     try {
         $dataP = $publicationModel->fetchAll();
         $dataP = $publicationModel->fetchAllByDate();
     } catch (\Exception $e) {
         $exceptionP = $e;
     }
     // verification des categories
     $categorieModel = new CategorieModel();
     $dataC = null;
     $categorie = null;
     try {
         $dataC = $categorieModel->fetchAll();
     } catch (\Exception $e) {
         $exceptionC = $e;
     }
     $this->layout()->setVariable('listeRubrique', $data);
     $this->layout()->setVariable('langue', $this->getEvent()->getRouteMatch()->getParam('langue'));
     $this->layout()->setVariable('menu_id', 'pbm');
     $this->layout()->setVariable('token', $token);
     if ($this->getEvent()->getRouteMatch()->getParam('trie') == 'categ') {
         $listeSup = $dataC;
     } elseif ($this->getEvent()->getRouteMatch()->getParam('trie') == 'date') {
         $listeSup = $dataP;
     }
     if (isset($listeSup)) {
         if (isset($exceptionP) && isset($exceptionC)) {
             return new ViewModel(array('trie' => $this->getEvent()->getRouteMatch()->getParam('trie'), 'excC' => $exceptionC, 'excP' => $exceptionP, 'listePubli' => $dataP, 'listeSup' => $listeSup, 'langue' => $this->getEvent()->getRouteMatch()->getParam('langue')));
         } elseif (isset($exceptionC)) {
             return new ViewModel(array('trie' => $this->getEvent()->getRouteMatch()->getParam('trie'), 'excC' => $exceptionC, 'listePubli' => $dataP, 'listeSup' => $listeSup, 'langue' => $this->getEvent()->getRouteMatch()->getParam('langue')));
         } elseif (isset($exceptionP)) {
             return new ViewModel(array('trie' => $this->getEvent()->getRouteMatch()->getParam('trie'), 'excP' => $exceptionP, 'listePubli' => $dataP, 'listeSup' => $listeSup, 'langue' => $this->getEvent()->getRouteMatch()->getParam('langue')));
         } else {
             return new ViewModel(array('trie' => $this->getEvent()->getRouteMatch()->getParam('trie'), 'listePubli' => $dataP, 'listeSup' => $listeSup, 'langue' => $this->getEvent()->getRouteMatch()->getParam('langue')));
         }
     } else {
         return new ViewModel(array('trie' => $this->getEvent()->getRouteMatch()->getParam('trie'), 'listePubli' => $dataP, 'msgError' => 'error', 'langue' => $this->getEvent()->getRouteMatch()->getParam('langue')));
     }
 }
 public function afficherPublicationAction()
 {
     //Vérification token
     $token = VerifUser::tokenAction();
     $langue = $this->getEvent()->getRouteMatch()->getParam('langue');
     $rubriqueModel = new RubriqueModel();
     $categorieModel = new CategorieModel();
     $publicationModel = new PublicationModel();
     //try catch du fetchAll des rubriques
     $listeRubriques = SendLayout::fetchAllRubriques($this, 'pbm', $langue, $token);
     if ($this->getEvent()->getRouteMatch()->getParam('trie') == 'categ') {
         $listeSup = $categorieModel->fetchAll();
     } elseif ($this->getEvent()->getRouteMatch()->getParam('trie') == 'date') {
         $listeSup = $publicationModel->fetchAllByDate();
     }
     SendLayout::sendGeneral($this, $listeRubriques, 'pbm', $langue, $token);
     return new ViewModel(array('trie' => $this->getEvent()->getRouteMatch()->getParam('trie'), 'listePubli' => $publicationModel->fetchAll(), 'listeSup' => $listeSup, 'langue' => $langue));
 }
 public function modifPublicationAction()
 {
     $token = VerifUser::tokenAction();
     if ($token == null) {
         $this->redirect()->toRoute('home');
     }
     $langue = $this->getEvent()->getRouteMatch()->getParam('langue');
     $idPublication = $this->getEvent()->getRouteMatch()->getParam('id_publication');
     //récupère id de la publication correspondante
     $adminModel = new AdminModel();
     $publicationModel = new PublicationModel();
     $form = new PublicationForm();
     //formulaire de modification de rubrique
     $publicationToModif = null;
     $msgSuccess = null;
     $errorExt = null;
     $listeRubriques = SendLayout::fetchAllRubriques($this, 'modifpubli', $langue, $token);
     try {
         $publicationToModif = $publicationModel->findOne($token, $idPublication);
     } catch (\Exception $e) {
         SendLayout::traiteExceptionsOnePublication($this, $listeRubriques, 'modifpubli', $idPublication, $langue, $token, $e->getMessage());
         return new ViewModel(array('form' => $form, 'langue' => $langue, 'publicationToModif' => $publicationToModif, 'listeCategories' => $this->getCategories(), 'pubNotFound' => $e->getMessage()));
     }
     $request = $this->getRequest();
     if ($request->isPost()) {
         $publicationModif = new Publication();
         $form->setInputFilter($publicationModif->getInputFilter());
         $other = $request->getPost()->toArray();
         $file = $this->params()->fromFiles('pdf');
         $data = array_merge($other, array('pdf' => $file['name']));
         $form->setData($data);
         if ($form->isValid()) {
             $publicationModif->exchangeArray($form->getData());
             $publicationModif->id = $idPublication;
             $valid = new ValidationUploadedFile();
             if ($file['name'] != '') {
                 if ($valid->validatorsFile($file, 'pdf') == true) {
                     $valid->moveFile($file);
                     $publicationModif->pdf = 'useruploads/files/' . $file['name'];
                 } else {
                     $publicationModif->pdf = null;
                     $errorExt = 'error extension';
                 }
             } else {
                 $publicationModif->pdf = null;
             }
             try {
                 $adminModel->modifPublication($token, $publicationModif);
             } catch (\Exception $e) {
                 return new ViewModel(array('form' => $form, 'publicationToModif' => $publicationToModif, 'listeCategories' => $this->getCategories(), 'langue' => $langue, 'exModifPublication' => $e->getMessage()));
             }
             if (!isset($errorExt)) {
                 $msgSuccess = 'modifpublication';
                 $this->redirect()->toRoute('admin', array('langue' => $langue), array('query' => array('successMdfP' => $msgSuccess)));
             }
         }
     }
     //Envoi des variables au layout
     SendLayout::sendGeneral($this, $listeRubriques, 'modifpubli', $langue, $token);
     $this->layout()->setVariable('id_publication', $idPublication);
     if (!isset($errorExt)) {
         return new ViewModel(array('form' => $form, 'langue' => $langue, 'publicationToModif' => $publicationToModif, 'listeCategories' => $this->getCategories()));
     }
     return new ViewModel(array('form' => $form, 'publicationToModif' => $publicationToModif, 'listeCategories' => $this->getCategories(), 'errorMsgExtension' => 'L\'extension du fichier doit être pdf.', 'langue' => $langue));
 }
Example #5
0
 public function indexAction()
 {
     $token = VerifUser::tokenAction();
     if ($token == null) {
         $this->redirect()->toRoute('home');
     }
     $successTab = $this->getSuccessAndErrors();
     $langue = $this->getEvent()->getRouteMatch()->getParam('langue');
     $rubriqueModel = new RubriqueModel();
     $publicationModel = new PublicationModel();
     $listeRubrique = null;
     $listePublications = null;
     try {
         $listeRubrique = $rubriqueModel->fetchAll();
     } catch (\Exception $e) {
         SendLayout::traiteExceptionsAllRubriques($this, $listeRubrique, 'admin', $langue, $token, $e->getMessage());
     }
     try {
         $listePublications = $publicationModel->fetchAll();
     } catch (\Exception $e) {
     }
     SendLayout::sendGeneral($this, $listeRubrique, 'admin', $langue, $token);
     return new ViewModel(array('listeRubrique' => $listeRubrique, 'listePublications' => $listePublications, 'langue' => $langue, 'successTab' => $successTab));
 }
Example #6
0
 public function indexAction()
 {
     $token = VerifUser::tokenAction();
     if ($token == null) {
         $this->redirect()->toRoute('home');
     }
     $successTab = array();
     if (!empty($this->getRequest()->getQuery('successCrR', false))) {
         $successCrRub = $this->getRequest()->getQuery('successCrR', false);
     } else {
         $successCrRub = null;
     }
     if (!empty($this->getRequest()->getQuery('successCrP', false))) {
         $successCrPubli = $this->getRequest()->getQuery('successCrP', false);
     } else {
         $successCrPubli = null;
     }
     if (!empty($this->getRequest()->getQuery('successMdfR', false))) {
         $successModifRub = $this->getRequest()->getQuery('successMdfR', false);
     } else {
         $successModifRub = null;
     }
     if (!empty($this->getRequest()->getQuery('successMdfP', false))) {
         $successModifPubli = $this->getRequest()->getQuery('successMdfP', false);
     } else {
         $successModifPubli = null;
     }
     if (!empty($this->getRequest()->getQuery('successDltR', false))) {
         $successDeleteRub = $this->getRequest()->getQuery('successDltR', false);
     } else {
         $successDeleteRub = null;
     }
     if (!empty($this->getRequest()->getQuery('successDltP', false))) {
         $successDeletePubli = $this->getRequest()->getQuery('successDltP', false);
     } else {
         $successDeletePubli = null;
     }
     array_push($successTab, $successCrRub, $successCrPubli, $successModifRub, $successModifPubli, $successDeleteRub, $successDeletePubli);
     $langue = $this->getEvent()->getRouteMatch()->getParam('langue');
     $rubriqueModel = new RubriqueModel();
     $publicationModel = new PublicationModel();
     $listeRubrique = null;
     $listePublications = null;
     try {
         $listeRubrique = $rubriqueModel->fetchAll();
     } catch (\Exception $e) {
         LayoutExceptions::traiteExceptionsAllRubriques($this, $listeRubrique, 'admin', $langue, $token, $e->getMessage());
         return new ViewModel(array('listeRubrique' => $listeRubrique, 'listePublications' => $listePublications, 'langue' => $langue, 'exRubriques' => $e->getMessage()));
     }
     try {
         $listePublications = $publicationModel->fetchAll();
     } catch (\Exception $e) {
         return new ViewModel(array('listeRubrique' => $listeRubrique, 'listePublications' => $listePublications, 'langue' => $langue, 'exPublications' => $e->getMessage()));
     }
     SendLayout::sendGeneral($this, $listeRubrique, 'admin', $langue, $token);
     return new ViewModel(array('listeRubrique' => $listeRubrique, 'listePublications' => $listePublications, 'langue' => $langue, 'successTab' => $successTab));
 }