|
|
@ -113,32 +113,27 @@ 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)) { |
|
|
|
if (isset($tags)) { |
|
|
|
foreach ($tags as $tag) { |
|
|
|
foreach ($tags as $tag) { |
|
|
|
$text .= ' #' . str_replace(' ', '_', (string)$tag); |
|
|
|
$text .= ' #' . str_replace(' ', '_', (string)$tag); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$text = mb_substr($text, 0, $maxLen + 1); |
|
|
|
$text = mb_substr($text, 0, $maxLen + 1); |
|
|
|
$pos = $maxLen; |
|
|
|
$pos = $maxLen; |
|
|
|
while (mb_substr($text, $pos, 1) !== ' ') { |
|
|
|
while (mb_substr($text, $pos, 1) !== ' ') { |
|
|
|
$pos--; |
|
|
|
$pos--; |
|
|
|
} |
|
|
|
} |
|
|
|
$text = mb_substr($text, 0, $pos); |
|
|
|
$text = mb_substr($text, 0, $pos); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $text; |
|
|
|
return $text; |
|
|
|