Пример #1
0
 /**
  * Odstranuje obrazek clanku vcetne nahledu
  * @param Entities\Article $article
  */
 public function deleteArticleImage($article)
 {
     if (!$article->hasImage()) {
         return;
     }
     //odstranit puvodni obr vcetne nahledu
     $oldImage = $article->getImage();
     $oldImagePath = $this->wwwDir . $oldImage->image;
     if (file_exists($oldImagePath)) {
         unlink($oldImagePath);
     }
     $oldImagePath = $this->wwwDir . $oldImage->getThumbnail();
     if (file_exists($oldImagePath)) {
         unlink($oldImagePath);
     }
     $article->setImage();
 }
Пример #2
0
 /**
  * @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');
 }
Пример #3
0
 private function articlePictureHandle(Article $incoming, Article $database)
 {
     if ($incoming->getPicture() == '') {
         $incoming->setPicture($database->getPicture());
     } else {
         $oldImageStorage = $database->getPicture();
         $this->imageService->removeResource($oldImageStorage);
         $identifier = $this->imageService->storeNetteFile($incoming->getPicture());
         $incoming->setPicture($identifier);
     }
 }
Пример #4
0
 /**
  * @param \App\Model\Entities\Article $article
  * @return array Vychozi hodnoty pro formular
  */
 protected function getDefaults($article)
 {
     $result = [];
     $result['id'] = $article->getId();
     $result['title'] = $article->getTitle();
     $result['description'] = $article->getDescription();
     $result['published'] = $article->isPublished();
     $publishDate = $article->getPublishDate();
     if ($publishDate) {
         $result['publishDate'] = $publishDate->format('d. m. Y, H:i');
     }
     $result['content'] = $article->getContent();
     foreach ($article->getTags() as $tag) {
         $result['tags'][] = $tag->getId();
     }
     return $result;
 }
Пример #5
0
 /**
  * Grid column render.
  * @param Article $el
  * @return string
  */
 public function commentModeRender($el)
 {
     return $this->tt(CommentMode::getOptions()[$el->getCommentMode()]);
 }
Пример #6
0
 public function renderPost()
 {
     $this->template->article = $this->article;
     $this->template->votes = $this->article->getVotes();
 }