Ejemplo n.º 1
1
 /**
  * @param  ArrayHash $values
  * @param  Entities\UserEntity $user
  * @param  Entities\WikiEntity $wiki
  * @param  Entities\WikiDraftEntity $e
  * @throws PossibleUniqueKeyDuplicationException
  * @return Entities\WikiEntity
  */
 public function create(ArrayHash $values, Entities\UserEntity $user, Entities\WikiEntity $wiki, Entities\WikiDraftEntity $e)
 {
     $e->setValues($values);
     $e->text = $this->htmlPurifier->purify($values->text);
     $e->wiki = $wiki;
     $e->user = $user;
     $e->createdAt = new DateTime();
     $this->persistAndFlush($this->em, $e);
     return $e;
 }
Ejemplo n.º 2
0
 public function update(ArrayHash $values, Entities\TagEntity $tag, Entities\UserEntity $user, Entities\ArticleEntity $e)
 {
     if ($e->tag->id !== $tag->id) {
         $this->menuCache->deleteSection(MenuCache::SECTION_ARTICLES);
     }
     $e->setValues($values);
     if ($e->tag->id !== $tag->id && $this->getByTagAndName($tag, $values->name)) {
         throw new PossibleUniqueKeyDuplicationException($this->translator->translate('locale.duplicity.article_tag_and_name'));
     }
     $e->slug = $e->slug ?: Slugger::slugify($e->name);
     if ($e->tag->id !== $tag->id && $this->getByTagAndSlug($tag, $e->slug)) {
         throw new PossibleUniqueKeyDuplicationException($this->translator->translate('locale.duplicity.article_tag_and_slug'));
     }
     $e->text = $this->htmlPurifier->purify($values->text);
     $e->tag = $tag;
     $e->user = $user;
     $this->persistAndFlush($this->em, $e);
     return $e;
 }
Ejemplo n.º 3
0
 /**
  * @param  Entities\WikiEntity      $e
  * @param  Entities\WikiDraftEntity $draft
  * @return Entities\WikiEntity
  */
 public function updateWithDraft(Entities\WikiEntity $e, Entities\WikiDraftEntity $draft)
 {
     $e->perex = $draft->perex;
     $e->text = $this->htmlPurifier->purify($draft->text);
     $e->lastUpdatedBy = $draft->user;
     $e->updatedAt = $draft->createdAt;
     foreach (array_reverse($e->drafts->toArray()) as $d) {
         if ($draft->id < $d->id) {
             break;
         }
         if ($e->contributors->contains($d->user) === false) {
             $e->contributors->add($d->user);
         }
         $e->drafts->removeElement($d);
         $this->em->remove($d);
     }
     $this->persistAndFlush($this->em, $e);
     return $e;
 }
Ejemplo n.º 4
0
 /**
  * Filter
  *
  * @see Zend_Filter_Interface::filter
  * @param string $value
  * @return string
  */
 public function filter($value)
 {
     return $this->_purifier->purify($value);
 }
Ejemplo n.º 5
0
 /**
  * Formats the value as HTML text.
  * The value will be purified using [[HtmlPurifier]] to avoid XSS attacks.
  * Use [[asRaw()]] if you do not want any purification of the value.
  * @param string $value the value to be formatted.
  * @param array|null $config the configuration for the HTMLPurifier class.
  * @return string the formatted result.
  */
 public function asHtml($value, $config = null)
 {
     if ($value === null || $value == '') {
         return null;
     }
     return HtmlPurifier::process($value, $config);
 }