當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。