6
Got it, edit class/article.php around line 192(function getSummary())
Replace by this
function getSummary($actionOnEmpty = false, $dohtml = true)
{
$myts =& MyTextSanitizer::getInstance();
$summary = $this->getVar("art_summary", "n");
if (empty($summary) && !empty($actionOnEmpty)) {
$pages = $this->getPages();
$text_handler =& xoops_getmodulehandler("text", $GLOBALS["artdirname"]);
if (count($pages) > 1) {
$texts =array_filter($text_handler->getList(new Criteria("text_id", "(" . implode(",", $pages) . ")", "IN")), "trim"); // fixed by Steven Chu
$summary = implode( $dohtml ? "
" : ". ", $texts);
} else {
$text_obj =& $text_handler->get($pages[0]);
$summary = $text_obj->getVar("text_body");
mod_loadFunctions("render", $GLOBALS["artdirname"]);
//$summary = art_html2text($summary);
$length = empty($GLOBALS["xoopsModuleConfig"]["length_excerpt"]) ? 255 : $GLOBALS["xoopsModuleConfig"]["length_excerpt"];
//$summary = $myts->displayTarea( xoops_substr($summary, 0, $length), 1);
$summary = art_truncateTagSafe($summary, $length, '...', false);
}
} else {
$summary = $myts->displayTarea($summary, 1);
if (!$dohtml) {
mod_loadFunctions("render", $GLOBALS["artdirname"]);
$summary = art_html2text($summary);
}
}
return $summary;
}
Now edit include/functions.render.php and add this 2 functions:
function &art_truncateTagSafe($string, $length = 80, $etc = '...', $break_words = false)
{
if ($length == 0) return '';
if (strlen($string) > $length) {
$length -= strlen($etc);
if (!$break_words) {
$string = preg_replace('/s+?(S+)?$/', '', substr($string, 0, $length+1));
$string = preg_replace('/<[^>]*$/', '', $string);
$string = art_closeTags($string);
}
return $string . $etc;
} else {
return $string;
}
}
function &art_closeTags($string)
{
// match opened tags
if(preg_match_all('/<([a-z:-]+)[^/]>/', $string, $start_tags)) {
$start_tags = $start_tags[1];
// match closed tags
if(preg_match_all('/([a-z]+)>/', $string, $end_tags)) {
$complete_tags = array();
$end_tags = $end_tags[1];
foreach($start_tags as $key => $val) {
$posb = array_search($val, $end_tags);
if(is_integer($posb)) {
unset($end_tags[$posb]);
} else {
$complete_tags[] = $val;
}
}
} else {
$complete_tags = $start_tags;
}
$complete_tags = array_reverse($complete_tags);
for($i = 0; $i < count($complete_tags); $i++) {
$string .= '' . $complete_tags[$i] . '>';
}
}
return $string;
}