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


PHP Gdn_Format::mentions方法代码示例

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


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

示例1: Format

 public function Format($String)
 {
     $String = str_replace(array('"', ''', ':', 'Â'), array('"', "'", ':', ''), $String);
     $String = str_replace('<#EMO_DIR#>', 'default', $String);
     $String = str_replace('<{POST_SNAPBACK}>', '<span class="SnapBack">»</span>', $String);
     // There is an issue with using uppercase code blocks, so they're forced to lowercase here
     $String = str_replace(array('[CODE]', '[/CODE]'), array('[code]', '[/code]'), $String);
     /**
      * IPB inserts line break markup tags at line breaks.  They need to be removed in code blocks.
      * The original newline/line break should be left intact, so whitespace will be preserved in the pre tag.
      */
     $String = preg_replace_callback('/\\[code\\].*?\\[\\/code\\]/is', function ($CodeBlocks) {
         return str_replace(array('<br />'), array(''), $CodeBlocks[0]);
     }, $String);
     /**
      * IPB formats some quotes as HTML.  They're converted here for the sake of uniformity in presentation.
      * Attribute order seems to be standard.  Spacing between the opening of the tag and the first attribute is variable.
      */
     $String = preg_replace_callback('#<blockquote\\s+class="ipsBlockquote" data-author="([^"]+)" data-cid="(\\d+)" data-time="(\\d+)">(.*?)</blockquote>#is', function ($BlockQuotes) {
         $Author = $BlockQuotes[1];
         $Cid = $BlockQuotes[2];
         $Time = $BlockQuotes[3];
         $QuoteContent = $BlockQuotes[4];
         // $Time will over as a timestamp. Convert it to a date string.
         $Date = date('F j Y, g:i A', $Time);
         return "[quote name=\"{$Author}\" url=\"{$Cid}\" date=\"{$Date}\"]{$QuoteContent}[/quote]";
     }, $String);
     // If there is a really long string, it could cause a stack overflow in the bbcode parser.
     // Not much we can do except try and chop the data down a touch.
     // 1. Remove html comments.
     $String = preg_replace('/<!--(.*)-->/Uis', '', $String);
     // 2. Split the string up into chunks.
     $Strings = (array) $String;
     $Result = '';
     foreach ($Strings as $String) {
         $Result .= $this->NBBC()->Parse($String);
     }
     // Linkify URLs in content
     $Result = Gdn_Format::links($Result);
     // Parsing mentions
     $Result = Gdn_Format::mentions($Result);
     // Handling emoji
     $Result = Emoji::instance()->translateToHtml($Result);
     // Make sure to clean filter the html in the end.
     $Config = array('anti_link_spam' => array('`.`', ''), 'comment' => 1, 'cdata' => 3, 'css_expression' => 1, 'deny_attribute' => 'on*', 'elements' => '*-applet-form-input-textarea-iframe-script-style', 'keep_bad' => 0, 'schemes' => 'classid:clsid; href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; style: nil; *:file, http, https', 'valid_xml' => 2);
     $Spec = 'object=-classid-type, -codebase; embed=type(oneof=application/x-shockwave-flash)';
     $Result = htmLawed($Result, $Config, $Spec);
     return $Result;
 }
开发者ID:nilsen,项目名称:addons,代码行数:49,代码来源:class.ipbformatter.plugin.php

示例2: wysiwyg

 /**
  *
  *
  * @param $Mixed
  * @return mixed|string
  */
 public static function wysiwyg($Mixed)
 {
     static $CustomFormatter;
     if (!isset($CustomFormatter)) {
         $CustomFormatter = c('Garden.Format.WysiwygFunction', false);
     }
     if (!is_string($Mixed)) {
         return self::to($Mixed, 'Wysiwyg');
     } elseif (is_callable($CustomFormatter)) {
         return $CustomFormatter($Mixed);
     } else {
         // The text contains html and must be purified.
         $Formatter = Gdn::factory('HtmlFormatter');
         if (is_null($Formatter)) {
             // If there is no HtmlFormatter then make sure that script injections won't work.
             return self::display($Mixed);
         }
         // HTML filter first
         $Mixed = $Formatter->format($Mixed);
         // Links
         $Mixed = Gdn_Format::links($Mixed);
         // Mentions & Hashes
         $Mixed = Gdn_Format::mentions($Mixed);
         $Mixed = Emoji::instance()->translateToHtml($Mixed);
         return $Mixed;
     }
 }
开发者ID:ringoma,项目名称:vanilla,代码行数:33,代码来源:class.format.php

示例3: processHTML

 /**
  * Performs replacing operations on a HTML string. Usually for formatting posts.
  * Runs an HTML string through the links, mentions, emoji and spoilers formatters.
  *
  * @param $html An unparsed HTML string.
  * @return string The formatted HTML string.
  */
 protected static function processHTML($html)
 {
     $html = Gdn_Format::links($html);
     $html = Gdn_Format::mentions($html);
     $html = Emoji::instance()->translateToHtml($html);
     $html = Gdn_Format::legacySpoilers($html);
     return $html;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:15,代码来源:class.format.php


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