Example #1
0
 protected function getPage($page, $xray = false)
 {
     $source = $this->pages->getPage($page, $xray);
     if (!$source) {
         throw new Nette\Application\BadRequestException("Page '{$page}' not found");
     }
     if ($source->data) {
         $data = \Nette\Utils\Json::decode($source->data);
     } else {
         $data = null;
     }
     $template = $this->createTemplate("\\Nette\\Templating\\Template");
     $template->heading = $source->heading;
     $template->data = $data;
     $template->setSource($source->body);
     return $template;
 }
Example #2
0
 public function handleDelete($id)
 {
     try {
         $page = $this->pages->find($id);
         if (!$page) {
             throw new \PDOException("Row #{$id} not exists!");
         }
         $page->delete();
         $this->logger->log('CMS', 'delete', "%user% smazala(a) stránku {$page->name}");
         $msg = $this->flashMessage("Stránka smazána", 'success');
         $msg->title = 'A je venku!';
         $msg->icon = 'trash-o';
     } catch (\PDOException $e) {
         $msg = $this->flashMessage("Někde nastala chyba.", 'danger');
         $msg->title = 'Oh shit!';
         $msg->icon = 'exclamation-triangle';
         \Nette\Diagnostics\Debugger::log($e, \Nette\Diagnostics\Debugger::ERROR);
     }
     $this->redirect('this');
 }