Commit 2b8b27e7 by pupi1985

Reformatted qa_shorten_string_line function

parent 2eeea109
...@@ -493,39 +493,36 @@ ...@@ -493,39 +493,36 @@
{ {
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
$string=strtr($string, "\r\n\t", ' '); $string = strtr($string, "\r\n\t", ' ');
if (qa_strlen($string)>$length) { if (qa_strlen($string) > $length) {
$remaining=$length-5; $remaining = $length - 5;
$words=qa_string_to_words($string, false, true); $words = qa_string_to_words($string, false, true);
$countwords=count($words); $countwords = count($words);
$prefix=''; $prefix = '';
$suffix=''; $suffix = '';
for ($addword=0; $addword<$countwords; $addword++) { for ($addword = 0; $addword < $countwords; $addword++) {
$tosuffix=(($addword%3)==1); // order: prefix, suffix, prefix, prefix, suffix, prefix, ... $tosuffix = $addword % 3 == 1; // order: prefix, suffix, prefix, prefix, suffix, prefix, ...
if ($tosuffix) $word = $tosuffix ? array_pop($words) : array_shift($words);
$word=array_pop($words);
else
$word=array_shift($words);
$wordLength = qa_strlen($word); $wordLength = qa_strlen($word);
if ($wordLength>$remaining) if ($wordLength > $remaining)
break; break;
if ($tosuffix) if ($tosuffix)
$suffix=$word.$suffix; $suffix = $word . $suffix;
else else
$prefix.=$word; $prefix .= $word;
$remaining-=$wordLength; $remaining -= $wordLength;
} }
$string=$prefix.' ... '.$suffix; $string = $prefix . ' ... ' . $suffix;
} }
return $string; return $string;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment