Menu

#1239 MyTextSanitizer::truncate() does not work properly

XOOPS_2.6.x
open
nobody
None
1
2012-11-19
2012-11-18
Alain91
No

here a patch:
:::php
static function truncate($text)
{
$instance = MyTextSanitizer::getInstance();
if (empty($text) || empty($instance->config['truncate_length']) || strlen($text) < $instance->config['truncate_length']) {
return $text;
}
$gap = $instance->config['truncate_length'] - 5;
if ($gap > 0) {
$len = floor(($instance->config['truncate_length'] - 5) / 2);
$ret = substr($text, 0, $len) . ' ... ' . substr($text, -$len);
} else {
$ret = substr($text, 0, 2) . '...';
}
return $ret;
}

Discussion

  • Alain91

    Alain91 - 2012-11-18

    Teste version : 2.6.0 alpha 1

     
  • Michael Beck

    Michael Beck - 2012-11-19
    • milestone: _inactive --> XOOPS_2.6.x
     

Log in to post a comment.