/** * @param $id */ public function actionView($id) { $this->article = $this->articlesRepository->get($id); $this->getTemplate()->article = $this->article; $this->getTemplate()->title = $this->article->title() > '' ? $this->article->title() : $this->article->name(); $this->getTemplate()->description = $this->article->description() > '' ? $this->article->description() : $this->article->text(); $this->getTemplate()->keywords = $this->article->keywords() > '' ? $this->article->keywords() : ''; }
/** * @param $id */ public function handleActive($id) { $this->article = $this->articlesRepository->get($id); $this->article->active(!$this->article->active()); $this->articlesRepository->save($this->article); if (!$this->isAjax()) { $this->redirect('default'); } $this->redrawControl(); }
/** * @param int $id */ public function renderEdit($id = 0) { /** @var Form $form */ $form = $this['editForm']; if (!$form->isSubmitted()) { /** @var CommentsEntity $item */ $item = $this->commentsRepository->get($id); $row = $this->commentsRepository->itemToArray($item); if (!$row) { throw new PDOException('Záznam nenalezen'); } if (is_null($item->pageId())) { $row['pageName'] = ''; } else { /** @var PagesEntity $page */ $page = $this->pagesRepository->get($item->pageId()); $row['pageName'] = $page->name(); } if (is_null($item->articleId())) { $row['articleName'] = ''; } else { /** @var ArticlesEntity $aricle */ $aricle = $this->articlesRepository->get($item->articleId()); $row['articleName'] = $aricle->name(); } $form->setDefaults($row); } }
/** * @param $form */ public function formSubmitted(Form $form) { $values = $form->getValues(); if ($values->theme > '') { $values->idTheme = $this->articlesRepository->newTheme($values->theme); } $this->article = $this->articlesRepository->get($values->id); $this->article->name($values->name); $this->article->text($values->text); $this->article->pictureName($values->pictureName); $this->article->pictureDescription($values->pictureDescription); $this->article->active($values->active); $this->article->title($values->title); $this->article->description($values->description); $this->article->keywords($values->keywords); $this->article->galleryIds(json_encode($values->galleryIds)); $this->article->idTheme($values->idTheme); $this->getUrl($values); }
/** * @return Nette\Application\IRouter */ public function createRouter() { $router = new RouteList(); $router[] = $adminRouter = new RouteList('Admin'); $adminRouter[] = new Route('[<locale=cs cs|en>/]admin/<presenter>/<action>', 'Pages:default'); $router[] = $frontRouter = new RouteList('Front'); $frontRouter[] = new Route("rss.xml", 'Homepage:rss'); $frontRouter[] = new Route("sitemap.xml", 'Homepage:sitemap'); $frontRouter[] = new Route('[<locale=cs cs|en>/]blog', 'Articles:default'); $frontRouter[] = new PageRoute('[<locale=cs cs|en>/][stranky/]<id>', array('id' => array(Route::FILTER_IN => function ($id) { if (is_numeric($id)) { return $id; } else { $page = $this->pagesRepository->getOneWhere(['url' => $id]); if ($page === NULL) { return NULL; } return $page->id(); } }, Route::FILTER_OUT => function ($id) { if (!is_numeric($id)) { return $id; } else { $page = $this->pagesRepository->get($id); return $page->url(); } }), 'presenter' => 'Pages', 'action' => 'view')); $frontRouter[] = new ArticleRoute('[<locale=cs cs|en>/]blog/<id>', array('id' => array(Route::FILTER_IN => function ($id) { if (is_numeric($id)) { return $id; } else { $article = $this->articlesRepository->getOneWhere(['url' => $id]); if ($article === NULL) { return NULL; } return $article->id(); } }, Route::FILTER_OUT => function ($id) { if (!is_numeric($id)) { return $id; } else { $article = $this->articlesRepository->get($id); return $article->url(); } }), 'presenter' => [Route::VALUE => 'Articles', Route::FILTER_TABLE => ['blog' => 'Articles']], 'action' => 'view')); $frontRouter[] = new NewsRoute('[<locale=cs cs|en>/][novinky/]<id>', array('id' => array(Route::FILTER_IN => function ($id) { if (is_numeric($id)) { return $id; } else { $page = $this->newsRepository->getOneWhere(['url' => $id]); if ($page === NULL) { return NULL; } return $page->id(); } }, Route::FILTER_OUT => function ($id) { if (!is_numeric($id)) { return $id; } else { $page = $this->newsRepository->get($id); return $page->url(); } }), 'presenter' => 'News', 'action' => 'view')); $frontRouter[] = new Route('[<locale=cs cs|en>/]<presenter>/<action>[/<id>]', 'Homepage:default'); $frontRouter[] = new Route('[<locale=cs cs|en>/]index.php', 'Homepage:default', Route::ONE_WAY); return $router; }