diff --git a/html/inc/more.inc b/html/inc/more.inc index 0ad56151db..c50aaefa46 100644 --- a/html/inc/more.inc +++ b/html/inc/more.inc @@ -24,48 +24,53 @@ // $text can't contain HTML tags (else would have to do lots of parsing) // function show_text_more($text, $nchars) { + echo show_text_more_aux($test, $nchars); +} + +// same, but returns text rather than outputting it +// +function show_text_more_aux($text, $nchars) { static $count = 0; $n = strlen($text); if ($n < $nchars) { - echo $text; - return; + return $text; } // find where to break $b = strpos($text, ' ', $nchars); if ($b === false) { - echo $text; - return; + return $text; } // don't break if tail is short if (($n - $b) < 40) { - echo $text; - return; + return $text; } + $x = ''; if ($count == 0) { - more_text_script(); + $x .= more_text_script(); } - echo substr($text, 0, $b); - echo sprintf('...', $count); - echo sprintf('', $count); - echo substr($text, $b); - echo ''; - echo sprintf( + $x .= substr($text, 0, $b); + $x .= sprintf('...', $count); + $x .= sprintf('', $count); + $x .= substr($text, $b); + $x .= ''; + $x .= sprintf( ' (more)', $count, $count, $count, $count ); - echo sprintf(' + $x .= sprintf(' ', $count ); $count++; + return $x; } function more_text_script() { - echo ' + return '