From: Andrew Dolgov Date: Thu, 2 May 2013 06:20:56 +0000 (+0400) Subject: format_article_tags: improve performance X-Git-Tag: 1.7.9~25^2~20 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=54b7590c7f4c071b86724ef0e77981c23874d40b;p=tt-rss.git format_article_tags: improve performance --- diff --git a/classes/feeds.php b/classes/feeds.php index 31bcbac5..1a179815 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -629,7 +629,6 @@ class Feeds extends Handler_Protected { } $reply['content'] .= ""; - $reply['content'] .= "
"; if ($line["orig_feed_id"]) { diff --git a/include/functions.php b/include/functions.php index 0b8f5b0d..15a87574 100644 --- a/include/functions.php +++ b/include/functions.php @@ -3391,47 +3391,22 @@ } function format_tags_string($tags, $id) { + if (!is_array($tags) || count($tags) == 0) { + return __("no tags"); + } else { + $maxtags = min(5, count($tags)); - $tags_str = ""; - $tags_nolinks_str = ""; - - $num_tags = 0; - - $tag_limit = 6; - - $formatted_tags = array(); - - foreach ($tags as $tag) { - $num_tags++; - $tag_escaped = str_replace("'", "\\'", $tag); - - if (mb_strlen($tag) > 30) { - $tag = truncate_string($tag, 30); - } - - $tag_str = "$tag"; - - array_push($formatted_tags, $tag_str); - - $tmp_tags_str = implode(", ", $formatted_tags); - - if ($num_tags == $tag_limit || mb_strlen($tmp_tags_str) > 150) { - break; + for ($i = 0; $i < $maxtags; $i++) { + $tags_str .= "" . $tags[$i] . ", "; } - } - $tags_str = implode(", ", $formatted_tags); + $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2); - if ($num_tags < count($tags)) { - $tags_str .= ", …"; - } + if (count($tags) > $maxtags) + $tags_str .= ", …"; - if ($num_tags == 0) { - $tags_str = __("no tags"); + return $tags_str; } - - return $tags_str; - } function format_article_labels($labels, $id) {