]> git.wh0rd.org Git - tt-rss.git/commitdiff
format_article_tags: improve performance
authorAndrew Dolgov <fox@fakecake.org>
Thu, 2 May 2013 06:20:56 +0000 (10:20 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Thu, 2 May 2013 06:20:56 +0000 (10:20 +0400)
classes/feeds.php
include/functions.php

index 31bcbac570fc215dabb07f5cb7bb49f141c9b49f..1a17981515789667db241b4daafc8c7117bbac39 100644 (file)
@@ -629,7 +629,6 @@ class Feeds extends Handler_Protected {
                                        }
                                        $reply['content'] .= "</div>";
 
-
                                        $reply['content'] .= "<div class=\"cdmContentInner\">";
 
                        if ($line["orig_feed_id"]) {
index 0b8f5b0d5b9cd0b2a18182bc789d605a47ba23af..15a8757460e9d8d68eb6c4a2ea9739fb79848845 100644 (file)
        }
 
        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 = "<a href=\"javascript:viewfeed('$tag_escaped')\">$tag</a>";
-
-                       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 .= "<a href=\"#\" onclick=\"viewfeed('".$tags[$i]."'\")>" . $tags[$i] . "</a>, ";
                        }
-               }
 
-               $tags_str = implode(", ", $formatted_tags);
+                       $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2);
 
-               if ($num_tags < count($tags)) {
-                       $tags_str .= ", &hellip;";
-               }
+                       if (count($tags) > $maxtags)
+                               $tags_str .= ", &hellip;";
 
-               if ($num_tags == 0) {
-                       $tags_str = __("no tags");
+                       return $tags_str;
                }
-
-               return $tags_str;
-
        }
 
        function format_article_labels($labels, $id) {