本文整理汇总了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);
}
示例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;
}
示例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);
}
示例4: safe_html
function safe_html($html)
{
return Format::html($html, array('safe' => 1, 'balance' => 1));
}
示例5: safe_html
function safe_html($html)
{
$config = array('safe' => 1, 'balance' => 1, 'comment' => 1);
return Format::html($html, $config);
}
示例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;
}