makeShorterText function is unavailible

Please report bugs here!

Moderator: Thorsten

Post Reply
daoqu123
Posts: 6
Joined: Sat Jan 05, 2008 12:17 pm

makeShorterText function is unavailible

Post by daoqu123 »

/**
* Shortens a string for a given number of words
*
* @param string $str
* @param integer $char
* @return string
* @access public
* @since 2002-08-26
* @author Thorsten Rinne <thorsten@phpmyfaq.de
*/
function makeShorterText($str, $char)
{
$str = preg_replace('/\s+/', ' ', $str);
$arrStr = explode(' ', $str);
$shortStr = '';
$num = count($arrStr);

if ($num > $char) {
for ($j = 0; $j <= $char; $j++) {
$shortStr .= $arrStr[$j]." ";
}
$shortStr .= '...';
} else {
$shortStr = $str;
}

return $shortStr;
}

======================================
But in the file FAQ.php,
/**
* This function generates the Top Ten with the mosted viewed records
*
* @return string
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @since 2002-05-07
*/
function getTopTen()
{
$result = $this->getTopTenData(PMF_NUMBER_RECORDS_TOPTEN, 0, $this->language);

if (count($result) > 0) {
$output = '<ol>';
foreach ($result as $row) {
$output .= sprintf('<li><strong>%d %s:</strong><br />',
$row['visits'],
$this->pmf_lang['msgViews']);
$shortTitle = PMF_Utils::makeShorterText(PMF_htmlentities($row['thema'], ENT_QUOTES, $this->pmf_lang['metaCharset']), 8);
$output .= sprintf('<a href="%s">·%s</a></li>',
$row['url'],
$shortTitle);


I am trying many times for the interger 8. It is unavailable.i.e. It never shorten a string(title).


So May you tell me Why?


For the language I am using is Chinese Simplified. Does the function makeShorterText Support the language?
Thorsten
Posts: 15769
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

do you use UTF-8?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
daoqu123
Posts: 6
Joined: Sat Jan 05, 2008 12:17 pm

Post by daoqu123 »

Yes, I m using UTF-8?


Why it is UTF-8 again!!!!!!!!!!!!!!!! :(
Thorsten
Posts: 15769
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

with UTF-8 a cahracter isn't just a byte... I'll try to fix this. Please add this issue on http://bugs.phpmyfaq.de

Thanks.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply