public function executeShow(HTTPRequest $request)
 {
     $news = $this->getManagerOf($this->module(), 'News')->getUnique($request->getData('id'));
     if (empty($news)) {
         $this->app->httpResponse()->redirect404();
     }
     $this->sendView('news:front:show', array('comments' => $this->getManagerOf($this->module(), 'Comments')->getListOf($news->id()), 'news' => $news));
 }
 public function executeUpdate(HTTPRequest $request)
 {
     $categoriesManager = $this->getManagerOf($this->module(), 'Categories');
     $category = $navbarManager->getUnique($request->getData('id'));
     $category->setName($request->postData('name'));
     $category->setParentId($request->postData('parentId'));
     $categoriesManager->save($category);
     $this->app->httpResponse()->previous();
 }
 public function executeShow(HTTPRequest $request)
 {
     $page = $this->getManagerOf($this->module(), 'Pages')->getUnique($request->getData('slug'));
     if (empty($page)) {
         $this->app->httpResponse()->redirect404();
     }
     //get template name
     preg_match_all('#template:([a-zA-Z0-9]+)#i', $page->template(), $matches);
     $this->sendView('pages:pagesFront:show', array('page' => $page, 'templateName' => $matches[1][0]));
 }
 public function executeSave(HTTPRequest $request)
 {
     if ($this->user()->authLevel() <= 1) {
         echo 'false';
         exit;
     }
     $comment = new Comment();
     $comment->setContent($request->postData('content'));
     $comment->setAutor($this->user()->nickName());
     $comment->setNews($request->postData('news'));
     $manager = $this->getManagerOf($this->module, 'Comments');
     $id = $manager->save($comment);
     echo 'true';
     exit;
 }
 public function executeTryLogUp(HTTPRequest $request)
 {
     //On récupère le manager de Users
     $manager = $this->getManagerOf($this->module(), 'Users');
     //Verify if this nickname already exists
     if ($manager->exists($request->postData('nickname'))) {
         echo 'nickname';
         exit;
     } else {
         if ($manager->exists($request->postData('mail'))) {
             echo 'mail';
             exit;
         } else {
             //Create a new user
             $newUser = new User(['nickname' => $request->postData('nickname'), 'pass' => Secure::passHash($request->postData('pass')), 'mail' => $request->postData('mail'), 'authLevel' => User::MEMBER]);
             //Save into dataBase
             $manager->save($newUser);
             if ($GLOBALS['userManager']->set($request->postData('nickname'), $request->postData('pass'))) {
                 echo 'ok';
                 exit;
             }
         }
     }
 }
 public function executeShow(HTTPRequest $request)
 {
     $manager = $this->getManagerOf($this->module(), 'Templates');
     $templateObject = $manager->getUnique($request->getData('id'));
     $this->sendView($templateObject->src(), array());
 }
 protected function processForm(HTTPRequest $request)
 {
     if ($request->method() == 'POST') {
         $news = new News(['auteur' => $request->postData('auteur'), 'titre' => $request->postData('titre'), 'contenu' => $request->postData('contenu')]);
         if ($request->getExists('id')) {
             $news->setId($request->getData('id'));
         }
     } else {
         // L'identifiant de la news est transmis si on veut la modifier
         if ($request->getExists('id')) {
             $news = $this->getManagerOf($this->module(), 'News')->getUnique($request->getData('id'));
         } else {
             $news = new News();
         }
     }
     $formBuilder = new NewsFormBuilder($news);
     $formBuilder->build();
     $form = $formBuilder->form();
     $formHandler = new FormHandler($form, $this->getManagerOf($this->module(), 'News'), $request);
     if ($formHandler->process()) {
         $this->app->session()->setFlash($news->isNew() ? 'La news a bien été ajoutée !' : 'La news a bien été modifiée !');
         $this->app->httpResponse()->redirect('/admin/');
     }
     $this->page->addVar('form', $form->createView());
 }
 public function executeDelete(HTTPRequest $request)
 {
     echo $this->getManagerOf($this->module(), 'Menus')->delete($request->postData('id'));
     exit;
 }
 public function updateModaleAction(HTTPRequest $request, $vars = array())
 {
     $manager = $this->getManagerOf($this->module(), 'Items');
     $item = $manager->getUnique($vars['itemId']);
     $form = $this->formBuilder->create(new ItemSchema($request->postData('navbarId')), $item);
     if ($form->handleRequest($request)->isValid()) {
         $id = $manager->save($item);
         $this->session()->setFlash('L\'item ' . $item->name() . ' a bien été modifié.');
         $this->response()->redirect('/admin/nav/');
     }
     $this->render('DDMenu:back:items:updateModale', array('form' => $form, 'item' => $item));
 }
 public function executeDelete(HTTPRequest $request)
 {
     $this->getManagerOf($this->module(), 'Comments')->delete($request->getData('id'));
     $this->app->session()->setFlash('Le commentaire a bien été supprimé !');
     $this->app->httpResponse()->previous();
 }
 public function executeDelete(HTTPRequest $request)
 {
     $this->getManagerOf($this->module(), 'Images')->delete($request->getData('id'));
     $this->session()->setFlash('L\'image a bien été supprimée');
     $this->response()->previous();
 }