コード例 #1
0
ファイル: TagPresenter.php プロジェクト: krupaj/my-blog
 /**
  * Vraci vsechny pouzite tagy
  * @return Model\Entities\Tag[]
  */
 public function getTags()
 {
     if (!isset($this->tags)) {
         $this->tags = $this->tagRepository->getAllTags();
     }
     return $this->tags;
 }
コード例 #2
0
ファイル: TagsPresenter.php プロジェクト: krupaj/my-blog
 /**
  * @param int $tagId
  * @return void Odstraneni sekce
  */
 public function handleDeleteTag($tagId)
 {
     $this->myTag = $this->tagRepository->getById($tagId);
     if (!$this->myTag) {
         $this->flashMessage($this->translator->translate('system.invalidId'));
         return;
     }
     $result = $this->tagRepository->deleteTag($this->myTag);
     if ($result) {
         $this->flashMessage($this->translator->translate('system.requestS'), self::MESSAGE_SUCCESS);
     } else {
         $this->flashMessage($this->translator->translate('system.requestN'), self::MESSAGE_DANGER);
     }
     $this->redirect('this');
 }
コード例 #3
0
ファイル: TagFormFactory.php プロジェクト: krupaj/my-blog
 /**
  * @param Nette\Utils\ArrayHash $values Hodnoty z formulare
  * @return boolean Editace provedena uspesne?
  */
 protected function editTag($values)
 {
     $result = TRUE;
     try {
         /** @var \App\Model\Entities\Tag */
         $editTag = $this->repository->getById($values->id);
         if (!$editTag) {
             return FALSE;
         }
         // nastaveni atributu a ulozeni zmeny
         $editTag->setTitle($values->title);
         $this->em->flush();
     } catch (\Exception $e) {
         \Tracy\Debugger::log($e, \Tracy\Debugger::INFO);
         $result = FALSE;
     }
     return $result;
 }
コード例 #4
0
ファイル: ArticlesPresenter.php プロジェクト: krupaj/my-blog
 /**
  * Vraci dostupne tagy
  * @return array
  */
 protected function getTags()
 {
     $result = [];
     $tags = $this->tagRepository->getAllTags();
     foreach ($tags as $tag) {
         /** @var $tag Model\Entities\Tag */
         $result[$tag->getId()] = $tag->getTitle();
     }
     return $result;
 }
コード例 #5
0
ファイル: HomepagePresenter.php プロジェクト: krupaj/my-blog
 /**
  * @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');
 }