コード例 #1
0
ファイル: CommentsControl.php プロジェクト: blitzik/CMS
 public function processForm(Form $form, $values)
 {
     if ($this->page->getAllowedComments() === false and !$this->authorizator->isAllowed($this->user, 'page_comment_form', 'comment_on_closed')) {
         $this->flashMessage('page.comments.form.messages.closedComments', FlashMessage::WARNING);
         $this->redirect('this#comments');
     }
     $values['page'] = $this->page;
     try {
         $comment = $this->commentFacade->save((array) $values);
         $this->flashMessage('page.comments.form.messages.success', FlashMessage::SUCCESS);
         $this->redirect('this#comment-' . $comment->getId());
     } catch (ActionFailedException $e) {
         $form->addError($this->translator->translate('page.comments.form.messages.error'));
     }
 }
コード例 #2
0
ファイル: PagePersister.php プロジェクト: blitzik/CMS
 /**
  * @param array $values
  * @param Page|null $page
  * @return Page
  * @throws PagePublicationTimeException
  * @throws PagePublicationTimeMissingException
  * @throws UrlAlreadyExistsException
  * @throws LocaleNotFoundException
  * @throws PageTitleAlreadyExistsException
  * @throws PageIntroHtmlLengthException
  * @throws \Exception
  */
 public function save(array $values, Page $page = null)
 {
     foreach ($values as $k => $v) {
         $values[$k] = $v === '' ? null : $v;
     }
     if ($values['publishedAt'] === null and $values['saveAsDraft'] === false) {
         throw new PagePublicationTimeMissingException();
     }
     $values['author'] = $this->em->find(User::class, $values['author']->getId());
     try {
         if ($page !== null and $page->getId() !== null) {
             $wasDraft = $page->isDraft();
             $hadOpenedComments = $page->getAllowedComments();
             $this->updatePage($page, $values);
             $this->onSuccessPageEditing($page);
         } else {
             $wasDraft = true;
             $hadOpenedComments = true;
             $page = $this->createNewPage($values, $page);
             $this->onSuccessPageCreation($page);
         }
         if ($wasDraft !== $page->isDraft() and $wasDraft === true) {
             $this->onPageRelease($page);
         }
         if ($hadOpenedComments !== $page->getAllowedComments()) {
             if ($hadOpenedComments === true) {
                 $this->onPageCommentsClosure($page);
             } else {
                 $this->onPageCommentsOpening($page);
             }
         }
     } catch (UrlAlreadyExistsException $u) {
         $this->closeEntityManager();
         throw $u;
     } catch (PageTitleAlreadyExistsException $p) {
         $this->closeEntityManager();
         throw $p;
     } catch (\Exception $e) {
         $this->closeEntityManager();
         throw $e;
     }
     return $page;
 }
コード例 #3
0
ファイル: PageFormControl.php プロジェクト: blitzik/CMS
 private function fillFormBy(Page $page)
 {
     $this['pageForm']['url']->setDefaultValue($page->getUrlPath());
     $this['pageForm']['publishedAt']->setDefaultValue($page->getTitle());
     if ($page->getPublishedAt() !== null) {
         $this['pageForm']['publishedAt']->setDefaultValue($page->getPublishedAt()->format('j.n.Y H:i'));
     }
     $this['pageForm']['title']->setDefaultValue($page->getTitle());
     $this['pageForm']['intro']->setDefaultValue($page->getIntro());
     $this['pageForm']['text']->setDefaultValue($page->getText());
     $this['pageForm']['allowedComments']->setDefaultValue($page->getAllowedComments());
     $this['pageForm']['description']->setDefaultValue($page->getMetaDescription());
     $this['pageForm']['keywords']->setDefaultValue($page->getMetaKeywords());
     $this['pageForm']['lang']->setDefaultValue($page->getLocaleName());
 }
コード例 #4
0
ファイル: Comment.php プロジェクト: blitzik/CMS
 /**
  * @return bool
  */
 public function areCommentsClosed()
 {
     return !$this->page->getAllowedComments();
 }