'getSummary 개선' 추가 적용

This commit is contained in:
conory 2017-05-22 23:16:31 +09:00
parent 855e4ce9f1
commit eb339c8101
3 changed files with 45 additions and 53 deletions

View file

@ -379,22 +379,22 @@ class mcontent extends WidgetHandler
function _getSummary($content, $str_size = 50)
{
$content = preg_replace('!(<br[\s]*/{0,1}>[\s]*)+!is', ' ', $content);
// Replace tags such as </p> , </div> , </li> and others to a whitespace
$content = str_replace(array('</p>', '</div>', '</li>'), ' ', $content);
// Remove Tag
$content = preg_replace('!<([^>]*?)>!is','', $content);
// Replace tags to < , > , "
$content = str_replace(array('&lt;','&gt;','&quot;','&nbsp;'), array('<','>','"',' '), $content);
// Delete a series of whitespaces
$content = preg_replace('/ ( +)/is', ' ', $content);
// Remove tags
$content = strip_tags($content);
// Convert temporarily html entity for truncate
$content = html_entity_decode($content, ENT_QUOTES);
// Replace unicode whitespace characters (no-break space)
$content = utf8_normalize_spaces($content);
// Replace all whitespaces to single space
$content = trim(preg_replace('/\s+/', ' ', $content));
// Truncate string
$content = trim(cut_str($content, $str_size, $tail));
// Replace back < , > , " to theoriginal tags
$content = str_replace(array('<','>','"'),array('&lt;','&gt;','&quot;'), $content);
// Fixed a newline bug on a set of consecutive English letters
$content = preg_replace('/([a-z0-9\+:\/\.\~,\|\!\@\#\$\%\^\&\*\(\)\_]){20}/is',"$0-",$content);
return $content;
$content = cut_str($content, $str_size, '...');
return escape($content);
}