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


PHP Format::html方法代码示例

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


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

示例1: clickableurls

 function clickableurls($text, $target = '_blank')
 {
     global $ost;
     // Find all text between tags
     $text = preg_replace_callback(':^[^<]+|>[^<]+:', function ($match) {
         // Scan for things that look like URLs
         return preg_replace_callback('`(?<!>)(((f|ht)tp(s?)://|(?<!//)www\\.)([-+~%/.\\w]+)(?:[-?#+=&;%@.\\w]*)?)' . '|(\\b[_\\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,4})`', function ($match) {
             if ($match[1]) {
                 while (in_array(substr($match[1], -1), array('.', '?', '-', ':', ';'))) {
                     $match[9] = substr($match[1], -1) . $match[9];
                     $match[1] = substr($match[1], 0, strlen($match[1]) - 1);
                 }
                 if (strpos($match[2], '//') === false) {
                     $match[1] = 'http://' . $match[1];
                 }
                 return sprintf('<a href="%s">%s</a>%s', $match[1], $match[1], $match[9]);
             } elseif ($match[6]) {
                 return sprintf('<a href="mailto:%1$s" target="_blank">%1$s</a>', $match[6]);
             }
         }, $match[0]);
     }, $text);
     // Now change @href and @src attributes to come back through our
     // system as well
     $config = array('hook_tag' => function ($e, $a = 0) use($target) {
         static $eE = array('area' => 1, 'br' => 1, 'col' => 1, 'embed' => 1, 'hr' => 1, 'img' => 1, 'input' => 1, 'isindex' => 1, 'param' => 1);
         if ($e == 'a' && $a) {
             $a['target'] = $target;
             $a['class'] = 'no-pjax';
         }
         $at = '';
         if (is_array($a)) {
             foreach ($a as $k => $v) {
                 $at .= " {$k}=\"{$v}\"";
             }
             return "<{$e}{$at}" . (isset($eE[$e]) ? " /" : "") . ">";
         } else {
             return "</{$e}>";
         }
     }, 'schemes' => 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; *:file, http, https; src: cid, http, https, data', 'elements' => '*+iframe', 'balance' => 0, 'spec' => 'span=data-src,width,height');
     return Format::html($text, $config);
 }
开发者ID:gizur,项目名称:osticket,代码行数:41,代码来源:class.format.php

示例2: getBody

 function getBody($mid)
 {
     $body = '';
     if (!($body = $this->getPart($mid, 'TEXT/PLAIN', $this->charset))) {
         if ($body = $this->getPart($mid, 'TEXT/HTML', $this->charset)) {
             //Convert tags of interest before we striptags
             $body = str_replace("</DIV><DIV>", "\n", $body);
             $body = str_replace(array("<br>", "<br />", "<BR>", "<BR />"), "\n", $body);
             $body = Format::html($body);
             //Balance html tags before stripping.
             $body = Format::striptags($body);
             //Strip tags??
         }
     }
     return $body;
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:16,代码来源:class.mailfetch.php

示例3: getSearchable

 function getSearchable()
 {
     // Replace tag chars with spaces (to ensure words are separated)
     $body = Format::html($this->body, array('hook_tag' => function ($el, $attributes = 0) {
         static $non_ws = array('wbr' => 1);
         return isset($non_ws[$el]) ? '' : ' ';
     }));
     // Collapse multiple white-spaces
     $body = html_entity_decode($body, ENT_QUOTES);
     $body = preg_replace('`\\s+`u', ' ', $body);
     return Format::searchable($body);
 }
开发者ID:jmangarret,项目名称:ostickets,代码行数:12,代码来源:class.thread.php

示例4: safe_html

 function safe_html($html)
 {
     return Format::html($html, array('safe' => 1, 'balance' => 1));
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:4,代码来源:class.format.php

示例5: safe_html

 function safe_html($html)
 {
     $config = array('safe' => 1, 'balance' => 1, 'comment' => 1);
     return Format::html($html, $config);
 }
开发者ID:pkdevboxy,项目名称:osTicket-1.7,代码行数:5,代码来源:class.format.php

示例6: getBody

 function getBody()
 {
     $body = '';
     if (!($body = $this->getPart($this->struct, 'text/plain'))) {
         if ($body = $this->getPart($this->struct, 'text/html')) {
             //Cleanup the html.
             $body = str_replace("</DIV><DIV>", "\n", $body);
             $body = str_replace(array("<br>", "<br />", "<BR>", "<BR />"), "\n", $body);
             $body = Format::striptags(Format::html($body));
         }
     }
     return $body;
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:13,代码来源:class.mailparse.php


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