public function __construct($content = "") { Object::__construct(); //FIXME: This should be done by TextParser parent::__construct($content); $this->texy = new SS_Texy(); $this->texy->setOutputMode(Texy::HTML5); $this->setAllowedTags($this->config()->get('allowed_tags')); $this->texy->headingModule->top = $this->config()->get('top_heading'); }
protected function createTemplate($class = NULL) { $template = parent::createTemplate($class); $texy = new \Texy(); $texy->encoding = 'utf-8'; $texy->setOutputMode(\Texy::HTML5); // config as in \TexyConfigurator::safeMode($texy); $safeTags = array('a' => array('href', 'title'), 'acronym' => array('title'), 'b' => array(), 'br' => array(), 'cite' => array(), 'code' => array(), 'em' => array(), 'i' => array(), 'strong' => array(), 'sub' => array(), 'sup' => array(), 'q' => array(), 'small' => array()); $texy->allowedClasses = \Texy::NONE; // no class or ID are allowed $texy->allowedStyles = \Texy::NONE; // style modifiers are disabled $texy->allowedTags = $safeTags; // only some "safe" HTML tags and attributes are allowed $texy->urlSchemeFilters[\Texy::FILTER_ANCHOR] = '#https?:|ftp:|mailto:#A'; $texy->urlSchemeFilters[\Texy::FILTER_IMAGE] = '#https?:#A'; $texy->allowed['image'] = FALSE; // disable images $texy->allowed['link/definition'] = FALSE; // disable [ref]: URL reference definitions $texy->allowed['html/comment'] = FALSE; // disable HTML comments # zakázaní nadpisů $texy->allowed['heading/surrounded'] = FALSE; $texy->allowed['heading/underlined'] = FALSE; # zalamování textu v odstavcích po enteru # false => nebude spojovat řádky, vloží místo enteru <br> # true => řádky po jednom enteru spojí $texy->mergeLines = false; $texy->linkModule->forceNoFollow = TRUE; // force rel="nofollow" $template->registerHelper('texy', callback($texy, 'process')); return $template; }
/** * @return \Texy */ public function createTexyForComment() { $texy = new \Texy(); $texy->headingModule->top = 3; $texy->setOutputMode(\Texy::HTML5); // Images $texy->imageModule->root = '.' . $this->imagesRoot; $texy->imageModule->fileRoot = $this->imagesFileRoot; \TexyConfigurator::safeMode($texy); \TexyConfigurator::disableImages($texy); //$texy->allowed['blockquote'] = false; $texy->allowed['emoticon'] = false; $texy->allowed['heading/underlined'] = false; $texy->allowed['heading/surrounded'] = false; $texy->allowed['horizline'] = false; //$texy->allowed['html/tag'] = false; $texy->allowed['html/comment'] = false; //$texy->allowed['list'] = false; //$texy->allowed['list/definition'] = false; $texy->allowed['script'] = false; $texy->allowed['table'] = false; $texy->linkModule->forceNoFollow = true; $texy->addHandler('block', [$this, 'blockHandler']); return $texy; }
protected function createTemplate($class = NULL) { $template = parent::createTemplate($class); $texy = new \Texy(); $texy->encoding = 'utf-8'; $texy->setOutputMode(\Texy::HTML5); // config as in \TexyConfigurator::safeMode($texy); $safeTags = array('a' => array('href', 'title'), 'acronym' => array('title'), 'b' => array(), 'br' => array(), 'cite' => array(), 'code' => array(), 'em' => array(), 'i' => array(), 'strong' => array(), 'sub' => array(), 'sup' => array(), 'q' => array(), 'small' => array()); $texy->allowedClasses = \Texy::NONE; // no class or ID are allowed $texy->allowedStyles = \Texy::NONE; // style modifiers are disabled $texy->allowedTags = $safeTags; // only some "safe" HTML tags and attributes are allowed $texy->urlSchemeFilters[\Texy::FILTER_ANCHOR] = '#https?:|ftp:|mailto:#A'; $texy->urlSchemeFilters[\Texy::FILTER_IMAGE] = '#https?:#A'; $texy->allowed['image'] = FALSE; // disable images $texy->allowed['link/definition'] = FALSE; // disable [ref]: URL reference definitions $texy->allowed['html/comment'] = FALSE; // disable HTML comments $texy->linkModule->forceNoFollow = TRUE; // force rel="nofollow" $template->registerHelper('texy', callback($texy, 'process')); return $template; }
/** * @return Texy */ public static function createTexy() { $texy = new Texy(); $texy->encoding = 'utf-8'; $texy->setOutputMode(\Texy::HTML5); // from https://github.com/nette/web-content/blob/convertor/src/Wiki/Convertor.php $texy->linkModule->root = ''; $texy->alignClasses['left'] = 'left'; $texy->alignClasses['right'] = 'right'; $texy->emoticonModule->class = 'smiley'; $texy->headingModule->top = 1; $texy->headingModule->generateID = TRUE; $texy->tabWidth = 4; $texy->typographyModule->locale = 'cs'; //en ? $texy->tableModule->evenClass = 'alt'; $texy->dtd['body'][1]['style'] = TRUE; $texy->allowed['longwords'] = FALSE; $texy->allowed['block/html'] = FALSE; $texy->phraseModule->tags['phrase/strong'] = 'b'; $texy->phraseModule->tags['phrase/em'] = 'i'; $texy->phraseModule->tags['phrase/em-alt'] = 'i'; $texy->phraseModule->tags['phrase/acronym'] = 'abbr'; $texy->phraseModule->tags['phrase/acronym-alt'] = 'abbr'; $texy->addHandler('block', array('TexyFactory', 'blockHandler')); return $texy; }
protected function createTemplate() { $template = parent::createTemplate(); $template->addFilter('texy', function ($text) { $texy = new \Texy(); $texy->setOutputMode(\Texy::HTML4_TRANSITIONAL); $texy->encoding = 'utf-8'; $texy->allowedTags = array('strong' => \Texy::NONE, 'b' => \Texy::NONE, 'a' => array('href'), 'em' => \Texy::NONE, 'p' => \Texy::NONE); //$texy->allowedTags = \Texy::NONE; return $texy->process($text); }); return $template; }
public function processNewMessageForm(Form $form) { $values = $form->getValues(); $recipients = is_array($values->recipients) ? $values->recipients : [$values->recipients]; if (!$this->authorizator->isAllowed($this->user, 'message', 'sent_to_restricted_recipients')) { $s = $this->messagesFacade->canMessageBeSentTo($values->recipients, $this->restrictedUsers, $this->users); if ($s === false) { $form->addError('Nelze odeslat zprávu vybranému příjemci.'); return; } } if ($values['isSendAsAdmin'] == true and !$this->authorizator->isAllowed($this->user, 'message', 'send_as_admin')) { $form->addError('Nemáte dostatečná oprávnění k akci.'); return; } $texy = new \Texy(); $texy->setOutputMode(\Texy::HTML4_TRANSITIONAL); $texy->encoding = 'utf-8'; $texy->allowedTags = \Texy::ALL; $text = $texy->process($values->text); $message = new SentMessage($values->subject, $text, $this->user); if ($values['isSendAsAdmin']) { $message->sendByAuthorRole(); } try { $this->messagesFacade->sendMessage($message, $recipients); } catch (MessageLengthException $ml) { $form->addError('Zprávu nelze uložit, protože je příliš dlouhá.'); return; } catch (DBALException $e) { $this->flashMessage('Zpráva nemohla být odeslána. Zkuste akci opakovat později.', 'errror'); $this->redirect('this'); } $this->presenter->flashMessage('Zpráva byla úspěšně odeslána', 'success'); $this->presenter->redirect('MailBox:sent'); }
/** * Texy factory * * @return \Texy */ protected function createTexy() { $texy = new \Texy(); $texy->encoding = 'utf-8'; $texy->setOutputMode(\Texy::HTML5); $texy->headingModule->top = 3; $texy->addHandler('image', ['Zax\\Texy\\Youtube', 'imageHandler']); return $texy; }