当前位置: 首页>>代码示例>>PHP>>正文


PHP Texy::process方法代码示例

本文整理汇总了PHP中Texy::process方法的典型用法代码示例。如果您正苦于以下问题:PHP Texy::process方法的具体用法?PHP Texy::process怎么用?PHP Texy::process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Texy的用法示例。


在下文中一共展示了Texy::process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: commentTexy

 public function commentTexy($text)
 {
     if (!isset($this->commentTexy)) {
         $this->commentTexy = $this->texyFactory->createTexyForComment();
     }
     return $this->commentTexy->process($text);
 }
开发者ID:blitzik,项目名称:CMS,代码行数:7,代码来源:FilterLoader.php

示例2: save

 /**
  * @param array $values
  * @return Comment
  * @throws ActionFailedException
  */
 public function save(array $values)
 {
     $numberOfComments = $this->getNumberOfComments($values['page']);
     $repliesReferences = $this->findRepliesReferences($values['text']);
     try {
         $this->em->beginTransaction();
         // no replies references found
         if (empty($repliesReferences)) {
             $comment = new Comment($values['author'], $this->texy->process($values['text']), $values['page'], $numberOfComments + 1, $this->request->getRemoteAddress());
             $this->em->persist($comment)->flush();
             $this->em->commit();
             return $comment;
         }
         $commentsToReply = $this->findCommentsToReply($values['page'], $repliesReferences);
         $values['text'] = $this->replaceReplyReferencesByAuthors($values['text'], $commentsToReply);
         $comment = new Comment($values['author'], $this->texy->process($values['text']), $values['page'], $numberOfComments + 1);
         $this->em->persist($comment);
         /** @var Comment $comment */
         foreach ($commentsToReply as $commentToReply) {
             $commentToReply->addReaction($comment);
             $this->em->persist($commentToReply);
         }
         $this->em->flush();
         $this->em->commit();
     } catch (\Exception $e) {
         $this->em->rollback();
         $this->em->close();
         throw new ActionFailedException();
     }
     return $comment;
 }
开发者ID:blitzik,项目名称:CMS,代码行数:36,代码来源:CommentPersister.php

示例3: process

 public function process($text, $singleLine = FALSE)
 {
     $key = $this->cacheKey($text);
     if (!($html = $this->cache->load($key))) {
         $html = parent::process($text, $singleLine);
         $this->cache->save($html);
     }
     return $html;
 }
开发者ID:helpfulrobot,项目名称:jnv-silverstripe-texy,代码行数:9,代码来源:SS_Texy.php

示例4: createTemplate

 /**
  * @param null $class
  * @return Nette\Templating\ITemplate
  */
 protected function createTemplate($class = NULL)
 {
     $template = parent::createTemplate($class);
     $template->registerHelper('texy', function ($input) {
         $texy = new \Texy();
         $html = new Nette\Utils\Html();
         return $html::el()->setHtml($texy->process($input));
     });
     $template->registerHelper('vlna', function ($string) {
         $string = preg_replace('<([^a-zA-Z0-9])([ksvzaiou])\\s([a-zA-Z0-9]{1,})>i', "\$1\$2 \$3", $string);
         //&nbsp; === \xc2\xa0
         return $string;
     });
     $template->registerHelper('dateInWords', function ($time) {
         $time = Nette\Utils\DateTime::from($time);
         $months = [1 => 'leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec'];
         return $time->format('j. ') . $months[$time->format('n')] . $time->format(' Y');
     });
     $template->registerHelper('timeAgoInWords', function ($time) {
         $time = Nette\Utils\DateTime::from($time);
         $delta = round((time() - $time->getTimestamp()) / 60);
         if ($delta == 0) {
             return 'před okamžikem';
         }
         if ($delta == 1) {
             return 'před minutou';
         }
         if ($delta < 45) {
             return "před {$delta} minutami";
         }
         if ($delta < 90) {
             return 'před hodinou';
         }
         if ($delta < 1440) {
             return 'před ' . round($delta / 60) . ' hodinami';
         }
         if ($delta < 2880) {
             return 'včera';
         }
         if ($delta < 43200) {
             return 'před ' . round($delta / 1440) . ' dny';
         }
         if ($delta < 86400) {
             return 'před měsícem';
         }
         if ($delta < 525960) {
             return 'před ' . round($delta / 43200) . ' měsíci';
         }
         if ($delta < 1051920) {
             return 'před rokem';
         }
         return 'před ' . round($delta / 525960) . ' lety';
     });
     return $template;
 }
开发者ID:krausv,项目名称:www.zeminem.cz,代码行数:59,代码来源:BasePresenter.php

示例5: prepareTemplate

 public static function prepareTemplate(Template $template)
 {
     $texy = new \Texy();
     $latte = $template->getLatte();
     $latte->addFilter('texy', function ($text) use($texy) {
         return Html::el('')->setHtml($texy->process($text));
     });
     $latte->addFilter('time', function ($text) {
         return date('j.n.Y G:i:s', $text);
     });
 }
开发者ID:greeny,项目名称:sandbox,代码行数:11,代码来源:Helpers.php

示例6: createTemplate

 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;
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:13,代码来源:MessageDetailControl.php

示例7: fillPageEntity

 /**
  * @param array $values
  * @param Page $page
  * @throws PagePublicationTimeException
  * @throws PageIntroHtmlLengthException
  */
 private function fillPageEntity(array $values, Page $page)
 {
     $page->setTitle($values['title']);
     $page->setMetaDescription($values['description']);
     $page->setMetaKeywords($values['keywords']);
     $page->setIntro($values['intro']);
     $page->setIntroHtml($this->texy->process($values['intro']));
     $page->setText($values['text']);
     if ($values['text'] === null) {
         $page->setTextHtml(null);
     } else {
         $page->setTextHtml($this->texy->process($values['text']));
     }
     $page->setPublishedAt($values['publishedAt']);
     $page->setAllowedComments($values['allowedComments']);
     if ($page->isDraft() and $values['saveAsDraft'] === false) {
         $page->setAsPublished($values['publishedAt']);
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:25,代码来源:PagePersister.php

示例8: texyCb

 /**
  * Callback for self::texyBlocks.
  * @ignore internal
  */
 public static function texyCb($m)
 {
     list(, $mAttrs, $mContent) = $m;
     // parse attributes
     $attrs = array();
     if ($mAttrs) {
         foreach (String::matchAll($mAttrs, '#([a-z0-9:-]+)\\s*(?:=\\s*(\'[^\']*\'|"[^"]*"|[^\'"\\s]+))?()#isu') as $m) {
             $key = strtolower($m[1]);
             $val = $m[2];
             if ($val == NULL) {
                 $attrs[$key] = TRUE;
             } elseif ($val[0] === '\'' || $val[0] === '"') {
                 $attrs[$key] = html_entity_decode(substr($val, 1, -1), ENT_QUOTES, 'UTF-8');
             } else {
                 $attrs[$key] = html_entity_decode($val, ENT_QUOTES, 'UTF-8');
             }
         }
     }
     return self::$texy->process($m[2]);
 }
开发者ID:regiss,项目名称:texyla-s-Nete1-PhP-5.2,代码行数:24,代码来源:TemplateFilters.php

示例9: process

 function process($text, $useCache = TRUE)
 {
     $this->time = -microtime(TRUE);
     if ($useCache) {
         $md5 = md5($text);
         // md5 is key for caching
         // check, if cached file exists
         $cacheFile = $this->cachePath . $md5 . '.html';
         $content = is_file($cacheFile) ? unserialize(file_get_contents($cacheFile)) : NULL;
         if ($content) {
             // read from cache
             list($html, $this->styleSheet, $this->headingModule->title) = $content;
         } else {
             // doesn't exists
             $html = parent::process($text);
             file_put_contents($cacheFile, serialize(array($html, $this->styleSheet, $this->headingModule->title)));
         }
     } else {
         // if caching is disabled
         $html = parent::process($text);
     }
     $this->time += microtime(TRUE);
     return $html;
 }
开发者ID:jiripudil,项目名称:texy,代码行数:24,代码来源:mytexy.php

示例10: processNewMessageForm

 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');
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:36,代码来源:NewMessageControl.php

示例11: imageHandler

 */
function imageHandler($invocation, $image, $link)
{
    $parts = explode(':', $image->URL);
    if (count($parts) !== 2) {
        return $invocation->proceed();
    }
    switch ($parts[0]) {
        case 'youtube':
            $video = htmlSpecialChars($parts[1]);
            $dimensions = 'width="' . ($image->width ? $image->width : 425) . '" height="' . ($image->height ? $image->height : 350) . '"';
            $code = '<div><object ' . $dimensions . '>' . '<param name="movie" value="http://www.youtube.com/v/' . $video . '" /><param name="wmode" value="transparent" />' . '<embed src="http://www.youtube.com/v/' . $video . '" type="application/x-shockwave-flash" wmode="transparent" ' . $dimensions . ' /></object></div>';
            $texy = $invocation->getTexy();
            return $texy->protect($code, Texy::CONTENT_BLOCK);
    }
    return $invocation->proceed();
}
$texy = new Texy();
$texy->addHandler('image', 'imageHandler');
// processing
$text = file_get_contents('sample.texy');
$html = $texy->process($text);
// that's all folks!
// echo formated output
header('Content-type: text/html; charset=utf-8');
echo $html;
// echo generated HTML code
echo '<hr />';
echo '<pre>';
echo htmlSpecialChars($html);
echo '</pre>';
开发者ID:jiripudil,项目名称:texy,代码行数:31,代码来源:demo.php

示例12: formattingByTexy

 static function formattingByTexy($source)
 {
     static $texy;
     if (is_null($texy)) {
         if (!class_exists('Texy', false)) {
             $dir = Q::ini('vendor_dir');
             require_once "{$dir}/geshi/geshi.php";
             require_once "{$dir}/texy/texy.php";
         }
         Texy::$advertisingNotice = false;
         $texy = new Texy();
         $options = self::$_texy_options;
         foreach ($options as $module => $config) {
             foreach ($config as $key => $value) {
                 $m = $module . 'Module';
                 $texy->{$m}->{$key} = $value;
             }
         }
         $texy->addHandler('block', array(__CLASS__, 'texyBlockHandler'));
     }
     return $texy->process($source);
 }
开发者ID:xtgss,项目名称:qeephp2_x,代码行数:22,代码来源:abstract.php

示例13: actionDefault

 public function actionDefault()
 {
     $texy = new Texy();
     $this->template->text = $texy->process(dibi::query('SELECT text FROM [options] WHERE [name]=%s', 'home')->fetchSingle());
 }
开发者ID:xixixao,项目名称:chytrapalice,代码行数:5,代码来源:DefaultPresenter.php

示例14: process

 function process($text)
 {
     $texy = new Texy();
     return $texy->process($text);
 }
开发者ID:uuking,项目名称:wildflower,代码行数:5,代码来源:texy.php

示例15: beforeRender

 public function beforeRender()
 {
     parent::beforeRender();
     $nastaveni = $this->database->table('nastaveni');
     $this->template->nastaveni = $nastaveni;
     $this->template->basicMenu = $this->getBasicMenu();
     $zmeneneStranky = $this->database->table('stranka')->where('editor_zmeneno != ?', 'ne')->where('redirect IS NULL');
     //\Tracy\Debugger::barDump($zmeneneStranky->count());
     if ($zmeneneStranky->count() > 0) {
         $texy = new \Texy();
         $texy->headingModule->top = (int) $nastaveni->get('texy_heading_top')->hodnota;
         $texy->imageModule->root = '/images/main-content/';
         $texy->imageModule->leftClass = 'tifl';
         $texy->imageModule->rightClass = 'tifr';
         $now = new Nette\DateTime();
         $menuTable = $this->getBasicMenu(TRUE);
         foreach ($zmeneneStranky as $stranka) {
             $obsahujeGalerii = 'ne';
             $tempTemplate = NULL;
             $fragmentHtml = array();
             $castiStranky = $stranka->related('editor_obsahu_stranky')->order('poradi, id');
             if ($castiStranky->count() > 0) {
                 foreach ($castiStranky as $fragment) {
                     $zaloha = array();
                     $posledniZalohaTexy = NULL;
                     if ($fragment->galerie_skupina_fotek_id == NULL) {
                         $posledniZaloha = $this->database->table('zaloha_obsah')->where('editor_obsahu_stranky_id = ?', $fragment->id)->order('id DESC')->limit(1)->fetch();
                         if ($posledniZaloha) {
                             $posledniZalohaTexy = $posledniZaloha->texy;
                         } else {
                             $posledniZalohaTexy = NULL;
                         }
                         $posledniZaloha = NULL;
                         if ($posledniZalohaTexy != $fragment->obsah_texy) {
                             $zaloha = array('editor_obsahu_stranky_id' => $fragment->id, 'stranka_id' => $fragment->stranka_id, 'poradi' => $fragment->poradi, 'pocet_sloupcu' => $fragment->pocet_sloupcu, 'texy' => $fragment->obsah_texy, 'datum' => $now);
                             $this->database->table('zaloha_obsah')->insert($zaloha);
                         }
                         $posledniZalohaTexy = NULL;
                         $zaloha = array();
                         $fragmentHtml[$fragment->id] = $texy->process($fragment->obsah_texy);
                     } else {
                         $obsahujeGalerii = 'ano';
                     }
                 }
                 $tempTemplate = NULL;
                 $tempTemplate = $this->createTemplate()->setFile(__DIR__ . '/templates/components/renderMainContent.latte')->setParameters(array('casti' => $castiStranky, 'htmlFragmenty' => $fragmentHtml));
                 $tempTemplate = (string) $tempTemplate;
             }
             $bigTemplate = NULL;
             $bigTemplate = $this->createTemplate()->setFile(__DIR__ . '/templates/components/renderStandardPage.latte')->setParameters(array('stranka' => $stranka, 'sGalerii' => $obsahujeGalerii, 'upperContent' => $tempTemplate, 'basicMenu' => $menuTable, 'noflashes' => 'noflashes', 'nastaveni' => $nastaveni));
             $bigTemplate = (string) $bigTemplate;
             $tempTemplate = NULL;
             $proVlozeni = array();
             $proVlozeni = array('html' => $bigTemplate, 'stranka_id' => $stranka->id);
             $bigTemplate = NULL;
             if ($stranka->related('stranka_html_celek')->count() > 0) {
                 $stranka->related('stranka_html_celek')->order('id')->limit(1)->fetch()->update($proVlozeni);
             } else {
                 $this->database->table('stranka_html_celek')->insert($proVlozeni);
             }
             $proVlozeni = NULL;
             $stranka->update(array('obsahuje_galerii' => $obsahujeGalerii, 'editor_zmeneno' => 'ne'));
             $this->flashMessage('Upravena stránka id ' . $stranka->id);
         }
     }
 }
开发者ID:kuvava,项目名称:kuvava,代码行数:66,代码来源:NastrojePresenter.php


注:本文中的Texy::process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。