Exemplo n.º 1
0
 /**
  * @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);
     }
 }
Exemplo n.º 2
0
 /**
  * @param Form $form
  * @param $form->values
  */
 private function formSubmitted(Form $form)
 {
     /** @var PagesEntity $pageParent */
     $pageParent = $this->pagesRepository->get($form->values->parent);
     $this->pagesRepository->begin();
     $this->pagesRepository->prepareBeforeAdd($pageParent);
     $this->page = new PagesEntity();
     $this->page->level($pageParent->level() + 1);
     $this->page->lft($pageParent->rgt());
     $this->page->rgt($pageParent->rgt() + 1);
     $this->page->parent($pageParent->id());
     $this->page->date(new DateTime());
     $this->page->upDate(new DateTime());
     $this->page->name($form->values->name);
     $this->page->inMenu(json_encode($form->values->inMenu));
     $this->page->menuTitle($form->values->menuTitle);
     $this->page->perex($form->values->perex);
     $this->page->text($form->values->text);
     $this->page->pictureName($form->values->pictureName);
     $this->page->pictureDescription($form->values->pictureDescription);
     $this->page->active($form->values->active);
     $this->page->onHomepage($form->values->onHomepage);
     $this->page->secret($form->values->secret);
     $this->page->title($form->values->title);
     $this->page->description($form->values->description);
     $this->page->keywords($form->values->keywords);
     $this->page->secretText($form->values->secretText);
     $this->page->galleryIds(json_encode($form->values->galleryIds));
     $this->page->upDate(new DateTime());
     $this->getUrl($form->values);
     $this->pagesRepository->commit();
 }
Exemplo n.º 3
0
 /**
  * @param $id
  */
 public function handleInTopMenu($id)
 {
     $this->page = $this->pagesRepository->get($id);
     $items = json_decode($this->page->inMenu(), true);
     $key = array_search('topMenu', $items);
     if (is_numeric($key)) {
         unset($items[$key]);
     } else {
         array_push($items, 'topMenu');
     }
     $this->page->inMenu(json_encode($items));
     $this->pagesRepository->save($this->page);
     if (!$this->isAjax()) {
         $this->redirect('default');
     }
     $this->redrawControl();
 }
Exemplo n.º 4
0
 /**
  * @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;
 }