From 9c01a3d59b1e0a2013469c14e70eb531b525bffe Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Fri, 28 Feb 2014 11:16:03 +0400 Subject: [PATCH] support text+tags mode in prettyPrint --- twisterpost.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/twisterpost.php b/twisterpost.php index ab5c5a4..d49a340 100644 --- a/twisterpost.php +++ b/twisterpost.php @@ -113,24 +113,20 @@ 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); - } + } + + if (isset($tags)) { + foreach ($tags as $tag) { + $text .= ' #' . str_replace(' ', '_', (string)$tag); } $text = mb_substr($text, 0, $maxLen + 1); $pos = $maxLen; @@ -138,7 +134,6 @@ class TwisterPost $pos--; } $text = mb_substr($text, 0, $pos); - } return $text;