Browse Source

support text+tags mode in prettyPrint

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

15
twisterpost.php

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

Loading…
Cancel
Save