Guest User

Untitled

a guest
Feb 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. Index: include/feedcreator.class.php
  2. ===================================================================
  3. --- include/feedcreator.class.php (revision 17)
  4. +++ include/feedcreator.class.php (working copy)
  5. @@ -521,6 +521,9 @@
  6. * @return string the truncated string
  7. */
  8. function iTrunc($string, $length) {
  9. + if (extension_loaded('mbstring')) {
  10. + return FeedCreator::iTrunc_mb($string, $length);
  11. + }
  12. if (strlen($string)<=$length) {
  13. return $string;
  14. }
  15. @@ -547,7 +550,33 @@
  16.  
  17. }
  18.  
  19. + function iTrunc_mb($string, $length) {
  20. + $encoding = strtoupper($this->encoding);
  21. + if (@mb_strlen($string,$encoding)<=$length) {
  22. + return $string;
  23. + }
  24.  
  25. + $pos = mb_strrpos($string,".",$encoding);
  26. + if ($pos>=$length-4) {
  27. + $string = mb_substr($string,0,$length-4,$encoding);
  28. + $pos = mb_strrpos($string,".",$encoding);
  29. + }
  30. + if ($pos>=$length*0.4) {
  31. + return mb_substr($string,0,$pos+1,$encoding)." ...";
  32. + }
  33. +
  34. + $pos = mb_strrpos($string," ",$encoding);
  35. + if ($pos>=$length-4) {
  36. + $string = mb_substr($string,0,$length-4,$encoding);
  37. + $pos = mb_strrpos($string," ",$encoding);
  38. + }
  39. + if ($pos>=$length*0.4) {
  40. + return mb_substr($string,0,$pos,$encoding)." ...";
  41. + }
  42. +
  43. + return mb_substr($string,0,$length-4,$encoding)." ...";
  44. + }
  45. +
  46. /**
  47. * Creates a comment indicating the generator of this feed.
  48. * The format of this comment seems to be recognized by
Add Comment
Please, Sign In to add comment