Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
 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]));
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
 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;
             }
         }
     }
 }
Ejemplo n.º 6
0
 public function executeShow(HTTPRequest $request)
 {
     $manager = $this->getManagerOf($this->module(), 'Templates');
     $templateObject = $manager->getUnique($request->getData('id'));
     $this->sendView($templateObject->src(), array());
 }
Ejemplo n.º 7
0
 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());
 }
Ejemplo n.º 8
0
 public function executeDelete(HTTPRequest $request)
 {
     echo $this->getManagerOf($this->module(), 'Menus')->delete($request->postData('id'));
     exit;
 }
Ejemplo n.º 9
0
 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));
 }
Ejemplo n.º 10
0
 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();
 }
Ejemplo n.º 11
0
 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();
 }