public function processArticleForm(Form $form, $values) { if ($this->article === NULL) { $article = $this->articles->createEntity(); } else { $article = $this->article; } $article->setTitle($values->title); $article->setContent($values->content); $this->articles->persist($article); }
/** * @param int $articleId * @return void Odstranuje propojeni clanku a ankety */ public function handleDeleteArticleVote($articleId) { $em = $this->articleRepository->getEntityManager(); $rArticle = $em->getReference(Model\Entities\Article::class, $articleId); $this->myVote->removeArticle($rArticle); $em->flush(); $this->redirect('this'); }
/** * @param int $articleId */ public function actionEdit($articleId) { $this->myArticle = $this->articleRepository->getById($articleId); if (!$this->myArticle) { $this->flashMessage($this->translator->translate('system.invalidId'), self::MESSAGE_DANGER); $this->redirect('default'); } $this->template->title = $this->translator->translate('system.editPost'); }
/** * @param Form $form * @return void Zpracovani formulare - pridani noveho komentare */ public function formSucceeded(Form $form) { //nacteni a smazani session $values = \Nette\Utils\ArrayHash::from($this->commentSession->content); $this->commentSession->remove(); //ulozit novy prispevek ke clanku $this->article = $this->articleRepository->getById($values->articleId); if (isset($this->myUser)) { $values->user = $this->myUser; $values->name = NULL; } else { $values->user = NULL; } //vytvoreni komentu, prirazeni ke clanku a ulozeni $newComment = new \App\Model\Entities\Comment($this->article, $values->user, $values->name, $values->content); $this->articleRepository->getEntityManager()->persist($newComment); $this->article->addComment($newComment); $this->articleRepository->getEntityManager()->flush(); $this->redirect('this'); }
/** * @param string $id Web title tagu */ public function actionTag($id) { list($webId, $webTitle) = Model\Entities\Tag::parseWebId($id); /** @var Model\Entities\Tag $this->objectWithArticles */ $this->objectWithArticles = $this->tagRepository->getById($webId); if (!is_object($this->objectWithArticles)) { $this->flashMessage($this->translator->translate('system.tagNF'), self::MESSAGE_DANGER); $this->redirect('default'); } $this->template->bgImage = "home-bg.jpg"; $this->template->title = $this->objectWithArticles->getTitle(); $this->template->description = $this->translator->translate('system.tag', 1); //nastaveni zajimavych clanku sekce $this->template->dPosts = $this->articleRepository->getMostDiscussedArticles(); $this->template->rPosts = $this->articleRepository->getMostReadedArticles(); $this->template->nPosts = $this->articleRepository->getRandArticles(); //nastaveni strankovani $this->paginator = new \Nette\Utils\Paginator(); $this->paginator->setItemsPerPage(self::POST_PER_PAGE); $this->paginator->setPage(1); $this->setView('articles'); }
/** * @param Nette\Utils\ArrayHash $values Hodnoty z formulare * @return boolean Editace provedena uspesne? */ protected function editArticle($values) { $result = TRUE; try { /** @var \App\Model\Entities\Article $editArticle */ $editArticle = $this->repository->getById($values->id); if (!$editArticle) { return FALSE; } // nastaveni atributu $editArticle->setPublished($values->published); $editArticle->setTitle($values->title); $editArticle->setUpdateDate(); $editArticle->setPublishDate($values->publishDate); $editArticle->setDescription($values->description); $editArticle->setContent($values->content); $tags = []; foreach ($values->tags as $tagId) { $tag = $this->em->getReference(\App\Model\Entities\Tag::class, $tagId); $tags[$tagId] = $tag; } $editArticle->setTags($tags); if ($values->image->isImage()) { $this->imageStorage->setArticleImage($editArticle, $values->image->toImage(), $values->imageSource); } elseif (!empty($values->imageSource)) { $editImage = $editArticle->getImage(); if ($editImage !== NULL) { $editImage->source = $values->imageSource; } } //ulozeni zmeny $this->em->flush(); } catch (\Exception $e) { \Tracy\Debugger::log($e, \Tracy\Debugger::INFO); $result = FALSE; } return $result; }
public function handleDeleteCategoryFromArticle($articleId, $categoryId) { $this->articles->deleteArticleFromCategory($articleId, $categoryId); $this->redrawControl('categoriesEdit'); }
public function getAllArticlesPair() { return $this->articleRepository->findPairsByLang(Languages::CS); }