getSummary 개선

No-break space 문자에 대한 처리가 제대로 되지 않아 띄워쓰기가 엉망으로 표시되었던 문제 수정
This commit is contained in:
conory 2017-05-17 16:24:06 +09:00
parent 07ede48e7c
commit f4db8adddb

View file

@ -630,37 +630,27 @@ class documentItem extends Object
return $content; return $content;
} }
function getSummary($str_size = 50, $tail = '...') function getSummary($str_size = 50, $tail = '...')
{ {
$content = $this->getContent(FALSE, FALSE); // Remove tags
$content = strip_tags($this->getContent(false, false));
// Remove html entity of No-break space
$content = str_replace(' ', ' ', $content);
// Remove whitespaces and No-break space character
$content = trim(preg_replace('/\s+|[\\pZ\\pC]+/u', ' ', $content));
// Convert temporarily html entity for truncate
$content = htmlspecialchars_decode($content, ENT_QUOTES);
$content = nl2br($content);
// For a newlink, inert a whitespace
$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 Tags
$content = preg_replace('!<([^>]*?)>!is', '', $content);
// Replace < , >, "
$content = str_replace(array('&lt;', '&gt;', '&quot;', '&nbsp;'), array('<', '>', '"', ' '), $content);
// Delete a series of whitespaces
$content = preg_replace('/ ( +)/is', ' ', $content);
// Truncate string // Truncate string
$content = trim(cut_str($content, $str_size, $tail)); $content = trim(cut_str($content, $str_size, $tail));
// Replace back < , <, " return escape($content, false);
$content = str_replace(array('<', '>', '"'),array('&lt;', '&gt;', '&quot;'), $content);
return $content;
} }
function getRegdate($format = 'Y.m.d H:i:s', $conversion = true) function getRegdate($format = 'Y.m.d H:i:s', $conversion = true)
{ {
return zdate($this->get('regdate'), $format, $conversion); return zdate($this->get('regdate'), $format, $conversion);