Exemplo n.º 1
0
 public function executeSave(HTTPRequest $request)
 {
     $response = false;
     $manager = $this->getManagerOf($this->module(), 'Pages');
     if (!$request->postExists('id')) {
         $userManager = $this->getManagerOf('users', 'Users');
         $page = new Page();
         $page->setAutor($userManager->getUnique($this->user()->id()));
         $page->setTitle($request->postData('title'));
         $page->setTemplate(trim($request->postData('template')));
         $response = $manager->save($page);
     } else {
         $page = $manager->getUnique($request->postData('id'));
         $page->setTitle($request->postData('title'));
         $page->setSlug($this->to_permalink($request->postData('title')));
         $page->setContent(trim($request->postData('content')));
         if ($request->postExists('template')) {
             $page->setTemplate(trim($request->postData('template')));
         } else {
             $page->setTemplate($page->template());
         }
         $manager->save($page);
         $response = true;
     }
     echo json_encode($response);
     exit;
 }
Exemplo n.º 2
0
 public function executeSave(HTTPRequest $request)
 {
     $response = false;
     $manager = $this->getManagerOf($this->module(), 'News');
     if (!$request->postExists('id')) {
         $userManager = $this->getManagerOf('users', 'Users');
         $news = new News();
         $news->setAutor($this->user()->nickName());
         if ($request->postExists('title')) {
             $news->setTitle($request->postData('title'));
         }
         if ($request->postExists('content')) {
             $news->setContent($request->postData('content'));
         }
         $response = $manager->save($news);
     } else {
         $news = $manager->getUnique($request->postData('id'));
         $news->setTitle($request->postData('title'));
         $news->setContent(trim($request->postData('content')));
         $manager->save($news);
         $response = true;
     }
     echo json_encode($response);
     exit;
 }