<?php
if (!defined('IN_OELOVE')) {
    exit('OElove[OEPHP] Access Denied');
}
function smarty_modifier_words($string, $persent=50, $end='...', $showcount=0){
    $result = '';
    $cut_words = '';
    if (!empty($string)) {
        $words_count = XHandle::getWordLength($string);
        if ($words_count > 1) {
            //截取字数
            $cut_nums = intval($words_count*($persent/100));
            $cut_words = XHandle::cutStrLen($string, $cut_nums);
        }
        else {
            $cut_words = $string;
        }
        if ($showcount == 1) {
            $result = "({$words_count}个字)".$cut_words.$end;
        }
        else {
            $result = $cut_words.$end;
        }
    }
    return $result;
}
?>