Browse Source

support text+tags mode in prettyPrint

master
Denis Ryabov 11 years ago
parent
commit
9c01a3d59b
  1. 9
      twisterpost.php

9
twisterpost.php

@ -113,32 +113,27 @@ class TwisterPost @@ -113,32 +113,27 @@ class TwisterPost
$url_len = mb_strlen($url);
if ($url_len === 0) {
if ($title_len > $maxLen) {
$text = rtrim(mb_substr($title, 0, $maxLen - 1), ' ') . '…';
} else {
$text = $title;
}
} else if ($title_len + 1 + $url_len > $maxLen) {
$text = rtrim(mb_substr($title, 0, $maxLen - 2 - $url_len), ' ') . '… ' . $url;
} else {
$text = $title . ' ' . $url;
}
if (isset($tags)) {
foreach ($tags as $tag) {
$text .= ' #' . str_replace(' ', '_', (string)$tag);
}
}
$text = mb_substr($text, 0, $maxLen + 1);
$pos = $maxLen;
while (mb_substr($text, $pos, 1) !== ' ') {
$pos--;
}
$text = mb_substr($text, 0, $pos);
}
return $text;

Loading…
Cancel
Save