| Re: xoopsCodeDecode |
| by trabis on 2009/1/8 19:06:07 Quote:
I know, that is why you use strlen($imagetag) |
| Re: xoopsCodeDecode |
| by Anonymous on 2009/1/8 17:48:50 I think herve can fix this issue ( since latestnews based on his news module ) by improving news_truncate_tagsafe with ghia's idea or by adding story image hack then we can use image as separated item. |
| Re: xoopsCodeDecode |
| by Anonymous on 2009/1/8 15:32:47 Quote: Or thinking better, you can use the code provided by ghia to get the image code, then you get the length of the image code, then you use truncate 100+length. Length of the image code is not fixed .. using some attributes and name of image file will effect this lenght. Ghia .. I test your function and it useful but when I set text lenght to zero, I got whole text. |
| Re: xoopsCodeDecode |
| by ghia on 2009/1/8 14:20:27 Truncate a text to a length without counting tags and not breaking words and suitable for UTF. le="color: #000000"><?php function truncate_text($Text, $Limit) { $len = strlen($Text); if (strlen($Text) <= $Limit) return $Text; $Cnt = 0; $DoCnt = 1; $InUTF = 0; for ($i = 0; $i< $len; $i++) { if ($Text{$i} == '<') $DoCnt = 0; if ($DoCnt > 0) { $ord_c = ord($Text{$i}); if (($ord_c & 0xE0) == 0xC0) { $InUTF = 2; } if (($ord_c & 0xF0) == 0xE0) { $InUTF = 3; } if (($ord_c & 0xF8) == 0xF0) { $InUTF = 4; } if (($ord_c & 0xFC) == 0xF8) { $InUTF = 5; } if (($ord_c & 0xFE) == 0xFC) { $InUTF = 6; } } if ($InUTF > 0) { $InUTF--; if ($InUTF > 0) { $DoCnt = 0; } else { $DoCnt = 1; } } if ($DoCnt == 1) { $Cnt++; } if ($Text{$i} == '>') $DoCnt = 1; $Result .= $Text{$i}; if ($Cnt >= $Limit && $Text{$i} == ' ') break; } return $Result . '...'; } To try!
|
| Re: xoopsCodeDecode |
| by trabis on 2009/1/8 13:41:41 Well, I will need that for mytabs to! My ideia is to replace image with for something like [XXX], then use the truncate feature, and then replace [XXX] with the image again! Or thinking better, you can use the code provided by ghia to get the image code, then you get the length of the image code, then you use truncate 100+length. |