示例#1
0
 public function renderTag($internal_id)
 {
     $this->template->pages = $this->pages;
     $tag = null;
     if ($internal_id !== null) {
         $tag = $this->tagFacade->getById($internal_id);
     }
     $this->template->tag = $tag;
 }
示例#2
0
 public function render()
 {
     $template = $this->getTemplate();
     $template->setFile(__DIR__ . '/pageTagsPicking.latte');
     $tags = $this->tagFacade->fetchTags((new TagQuery())->indexedByTagId())->toArray();
     $template->tags = $tags;
     $template->pageTags = isset($this->page) ? $this->page->getTags() : [];
     $template->render();
 }
示例#3
0
 public function handleRemoveTag()
 {
     if (!$this->authorizator->isAllowed($this->user, 'page_tag', 'remove')) {
         $this->flashMessage('authorization.noPermission', FlashMessage::WARNING);
         if ($this->presenter->isAjax()) {
             $this->presenter->payload->errorEl = 'no permission';
             $this->redrawControl('tag');
             return;
         } else {
             $this->redirect('this');
         }
     }
     try {
         $this->tagFacade->removeTag($this->tag->getId());
         if ($this->presenter->isAjax()) {
             $this->redrawControl('tag');
         } else {
             $this->redirect('this');
         }
     } catch (DBALException $e) {
         $this->flashMessage('tags.overview.actions.remove.messages.removeError', FlashMessage::ERROR);
         if ($this->presenter->isAjax()) {
             // value does not matter, in JS we just check existence of this variable
             $this->presenter->payload->errorEl = true;
             $this->redrawControl('flashes');
         } else {
             $this->redirect('this');
         }
     }
 }
示例#4
0
 public function processNewTag(Form $form, $values)
 {
     if (!$this->authorizator->isAllowed($this->user, 'page_tag', 'create')) {
         $this->flashMessage('authorization.noPermission', FlashMessage::WARNING);
         return;
     }
     try {
         $tag = $this->tagFacade->saveTag((array) $values);
         $this->onSuccessTagSaving($tag, $this);
     } catch (TagNameAlreadyExistsException $t) {
         $form->addError($this->translator->translate('tags.tagForm.messages.nameExists', ['name' => $values['name']]));
     } catch (UrlAlreadyExistsException $url) {
         $form->addError($this->translator->translate('tags.tagForm.messages.tagUrlExists'));
     } catch (DBALException $e) {
         $form->addError($this->translator->translate('tags.tagForm.messages.savingError'));
     }
 }
示例#5
0
 /**
  * @param int $tagId
  * @return Tag
  */
 private function getTag($tagId)
 {
     if (empty($this->tags)) {
         // if processing "handle" method, $this->tags is always empty array
         // because this factory is invoked before render method
         $tag = $this->tagFacade->getById($tagId);
         if ($tag === null) {
             // trying to request non-existing tag
             $this->onMissingTag($this);
             // there is happening redirect
         }
         $this->tags[$tagId] = $tag;
     } else {
         // common request
         $tag = $this->tags[$tagId];
     }
     return $tag;
 }