本文整理汇总了PHP中XenForo_Helper_String::highlightSearchTerm方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Helper_String::highlightSearchTerm方法的具体用法?PHP XenForo_Helper_String::highlightSearchTerm怎么用?PHP XenForo_Helper_String::highlightSearchTerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Helper_String
的用法示例。
在下文中一共展示了XenForo_Helper_String::highlightSearchTerm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: helperSnippet
/**
* Strips BB Code from a string and word-trims it to a given max length around an optional search term
*
* @param string $string Input text (bb code)
* @param integer $maxLength
* @param array $options Key-value options
*
* @return string HTML
*/
public static function helperSnippet($string, $maxLength = 0, array $options = array())
{
$options = array_merge(array('term' => '', 'emClass' => '', 'stripQuote' => false), $options);
$string = XenForo_Helper_String::bbCodeStrip($string, $options['stripQuote']);
if ($maxLength) {
$string = XenForo_Helper_String::wholeWordTrimAroundSearchTerm($string, $maxLength, $options['term']);
}
$string = trim($string);
$string = XenForo_Helper_String::censorString($string);
if ($options['term'] && $options['emClass']) {
return XenForo_Helper_String::highlightSearchTerm($string, $options['term'], $options['emClass']);
} else {
return htmlspecialchars($string);
}
}
示例2: helperSnippet
/**
* Strips BB Code from a string and word-trims it to a given max length around an optional search term
*
* @param string $string Input text (bb code)
* @param integer $maxLength
* @param array $options Key-value options
*
* @return string HTML
*/
public static function helperSnippet($string, $maxLength = 0, array $options = array())
{
$options = array_merge(array('term' => '', 'fromStart' => 0, 'emClass' => '', 'stripQuote' => false, 'stripHtml' => false, 'stripPlainTag' => false), $options);
if ($options['stripHtml']) {
$string = strip_tags($string);
} else {
if ($options['stripPlainTag']) {
$string = preg_replace('#(?<=^|\\s|[\\](,]|--|@)@\\[(\\d+):(\'|"|"|)(.*)\\2\\]#iU', '\\3', $string);
} else {
$string = XenForo_Helper_String::bbCodeStrip($string, $options['stripQuote']);
}
}
if ($maxLength) {
if ($options['fromStart']) {
$string = XenForo_Helper_String::wholeWordTrim($string, $maxLength);
} else {
$string = XenForo_Helper_String::wholeWordTrimAroundSearchTerm($string, $maxLength, $options['term']);
}
}
$string = trim($string);
$string = XenForo_Helper_String::censorString($string);
if ($options['term'] && $options['emClass']) {
return XenForo_Helper_String::highlightSearchTerm($string, $options['term'], $options['emClass']);
} else {
return htmlspecialchars($string);
}
}