Commit b37d0f6d by pupi1985

Turned the hardcoded ellipsis into a parameter

parent 292a33cd
...@@ -495,14 +495,14 @@ ...@@ -495,14 +495,14 @@
* @param string $ellipsis Text used to replace the removed words from the original text * @param string $ellipsis Text used to replace the removed words from the original text
* @return string The string turned into a single line and cut to fit the given length * @return string The string turned into a single line and cut to fit the given length
*/ */
function qa_shorten_string_line($string, $length) function qa_shorten_string_line($string, $length, $ellipsis = ' ... ')
{ {
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 - qa_strlen($ellipsis);
$words = qa_string_to_words($string, false, true); $words = qa_string_to_words($string, false, true);
$countwords = count($words); $countwords = count($words);
...@@ -528,7 +528,7 @@ ...@@ -528,7 +528,7 @@
$remaining -= $wordLength; $remaining -= $wordLength;
} }
$string = $prefix . ' ... ' . $suffix; $string = $prefix . $ellipsis . $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