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 executeUpdate(HTTPRequest $request)
 {
     $manager = $this->getManagerOf($this->module(), 'Items');
     $item = $manager->getUnique($request->getData('id'));
     $item->setName($request->postData('name'));
     $item->setHref($request->postData('href'));
     $item->setClassName($request->postData('className'));
     $item->setMinAuth($request->postData('minAuth'));
     $item->setMaxAuth($request->postData('maxAuth'));
     $manager->save($item);
     $id = $manager->save($item);
     echo $id;
     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)
 {
     $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();
 }