本文整理汇总了PHP中MyTextSanitizer::undoHtmlSpecialChars方法的典型用法代码示例。如果您正苦于以下问题:PHP MyTextSanitizer::undoHtmlSpecialChars方法的具体用法?PHP MyTextSanitizer::undoHtmlSpecialChars怎么用?PHP MyTextSanitizer::undoHtmlSpecialChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyTextSanitizer
的用法示例。
在下文中一共展示了MyTextSanitizer::undoHtmlSpecialChars方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: purifyText
/**
* @param string $text
* @param boolean $keyword
*
* @return string
*/
public function purifyText($text, $keyword = false)
{
$text = str_replace(' ', ' ', $text);
$text = str_replace('<br />', ' ', $text);
$text = strip_tags($text);
$text = html_entity_decode($text);
$text = $this->_myts->undoHtmlSpecialChars($text);
$text = str_replace(')', ' ', $text);
$text = str_replace('(', ' ', $text);
$text = str_replace(':', ' ', $text);
$text = str_replace('&euro', ' euro ', $text);
$text = str_replace('&hellip', '...', $text);
$text = str_replace('&rsquo', ' ', $text);
$text = str_replace('!', ' ', $text);
$text = str_replace('?', ' ', $text);
$text = str_replace('"', ' ', $text);
$text = str_replace('-', ' ', $text);
$text = str_replace('\\n', ' ', $text);
if ($keyword) {
$text = str_replace('.', ' ', $text);
$text = str_replace(',', ' ', $text);
$text = str_replace('\'', ' ', $text);
}
$text = str_replace(';', ' ', $text);
return $text;
}
示例2: purifyText
/**
* @param $text
* @param bool $keyword
*
* @return mixed
*/
public function purifyText($text, $keyword = false)
{
// $text = str_replace([' ', ' '], ['<br />', ' '], $text); //for php 5.4
$text = str_replace(' ', ' ', $text);
$text = str_replace('<br />', ' ', $text);
$text = strip_tags($text);
$text = html_entity_decode($text);
$text = $this->myts->undoHtmlSpecialChars($text);
$text = str_replace(')', ' ', $text);
$text = str_replace('(', ' ', $text);
$text = str_replace(':', ' ', $text);
$text = str_replace('&euro', ' euro ', $text);
$text = str_replace('&hellip', '...', $text);
$text = str_replace('&rsquo', ' ', $text);
$text = str_replace('!', ' ', $text);
$text = str_replace('?', ' ', $text);
$text = str_replace('"', ' ', $text);
$text = str_replace('-', ' ', $text);
$text = str_replace('\\n', ' ', $text);
// $text = str_replace([')','(',':','&euro','&hellip','&rsquo','!','?','"','-','\n'], [' ' , ' ', ' ', ' euro ', '...', ' ', ' ', ' ', ' ', ' ', ' '], $text); //for PHP 5.4
if ($keyword) {
$text = str_replace('.', ' ', $text);
$text = str_replace(',', ' ', $text);
$text = str_replace('\'', ' ', $text);
// $text = str_replace(['.', ' '], [',', ' '], ['\'', ' '], $text); //for PHP 5.4
}
$text = str_replace(';', ' ', $text);
return $text;
}
示例3: load
/**
* @param MyTextSanitizer $ts
* @param string $source
* @param string $language
* @return bool|mixed|string
*/
public function load(MyTextSanitizer &$ts, $source, $language)
{
$config = parent::loadConfig(__DIR__);
if (empty($config['highlight'])) {
return "<pre>{$source}</pre>";
}
$source = $ts->undoHtmlSpecialChars($source);
$source = stripslashes($source);
if ($config['highlight'] == 'geshi') {
$language = str_replace('=', '', $language);
$language = $language ? $language : $config['language'];
$language = strtolower($language);
if ($source2 = MytsSyntaxhighlight::geshi($source, $language)) {
return $source2;
}
}
$source = MytsSyntaxhighlight::php($source);
return $source;
}