/**
  * @param null $data
  * @return TagControl
  */
 public function create($data = null)
 {
     $this->initCountOfItems();
     $control = new TagControl();
     $control->setItems($this->tagFacade->getLastTags($this->countOfItems));
     return $control;
 }
Example #2
0
 /**
  * @param $id
  */
 public function actionPosts($id)
 {
     if ($tag = $this->tagFacade->getOne($id)) {
         $this->template->tag = $tag;
         $this->posts = $tag->getPosts()->toArray();
         if (!count($this->posts)) {
             $this->setView('none');
         }
     } else {
         $this->setView('notFound');
     }
 }
Example #3
0
 /**
  * @param PostForm $form
  */
 public function formSubmitted(PostForm $form)
 {
     $values = $form->getValues();
     $values->category = $this->categoryFacade->getOne($values->category);
     $tags = array();
     if (count($values->tags)) {
         foreach ($values->tags as $tagId) {
             $tags[] = $this->tagFacade->getOne($tagId);
         }
     }
     $values->tags = $tags;
     try {
         $this->postManager->update($values);
         $form->presenter->flashMessage('Post management was successful', 'success');
     } catch (\Nette\InvalidArgumentException $ex) {
         $form->addError($ex->getMessage());
     }
 }
Example #4
0
 /**
  * @param \Flame\CMS\PostBundle\Forms\IPostFormFactory $postFormFactory
  * @return \Flame\CMS\PostBundle\Forms\PostForm
  */
 protected function createComponentPostForm(\Flame\CMS\PostBundle\Forms\IPostFormFactory $postFormFactory)
 {
     $default = array();
     if ($this->post instanceof \Flame\CMS\PostBundle\Model\Post) {
         $default = $this->post->toArray();
     }
     $form = $postFormFactory->create($default);
     $form->setCategories($this->categoryFacade->getLastCategories());
     $form->setTags($this->tagFacade->getLastTags());
     if ($this->post) {
         $form->onSuccess[] = $this->lazyLink('this');
     } else {
         $form->onSuccess[] = $this->lazyLink('default');
     }
     return $form;
 }
Example #5
0
 /**
  * @param null $id
  */
 public function actionUpdate($id = null)
 {
     $this->tag = $this->tagFacade->getOne($id);
     $this->template->tag = $this->tag;
 }