]> git.wh0rd.org Git - tt-rss.git/commitdiff
support colored labels
authorAndrew Dolgov <fox@bah.spb.su>
Mon, 26 Jan 2009 10:07:53 +0000 (11:07 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Mon, 26 Jan 2009 10:07:53 +0000 (11:07 +0100)
functions.php
modules/backend-rpc.php
modules/pref-labels.php
tt-rss.css

index 51be96f7a88aa1428e958f336b77b24b2be30ff3..a79b2345ab73d9450c6c7e5aac112fe9e492d8c3 100644 (file)
        }
 
        function printFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link,
-               $rtl_content = false, $last_updated = false, $last_error = false) {
+               $rtl_content = false, $last_updated = false, $last_error = false,
+               $fg_content = false, $bg_content = false) {
 
                if (file_exists($icon_file) && filesize($icon_file) > 0) {
                                $feed_icon = "<img id=\"FIMG-$feed_id\" src=\"$icon_file\">";
                $feed = "<a title=\"$link_title\" id=\"FEEDL-$feed_id\" 
                        href=\"javascript:viewfeed('$feed_id', '', false, '', false, 0);\">$feed_title</a>";
 
+/*             if ($feed_id < -10) {
+                       $bg_color = "#00ccff";
+                       $fg_color = "white";
+               }
+
+               if ($fg_color || $bg_color) {
+                       $color_str = "<div class='labelColorIndicator'
+                               style='color : $fg_color; background-color : $bg_color'>l</div>";
+               } 
+
+               print $color_str; */
+
                print "<li id=\"FEEDR-$feed_id\" class=\"$class\">";
                if (get_pref($link, 'ENABLE_FEED_ICONS')) {
                        print "$feed_icon";
                        print "<div class=\"feedExtInfo\">
                                <span id=\"FLUPD-$feed_id\">$last_updated ($total total) $error_notify_msg</span></div>";
                }
-                        
+
                print "</li>";
 
        }
                if (!$tags) {
 
 
-                               $result = db_query($link, "SELECT id,caption FROM                                       
+                               $result = db_query($link, "SELECT * FROM
                                        ttrss_labels2 WHERE owner_uid = '$owner_uid' ORDER by caption");
                
                                if (db_num_rows($result) > 0) {
        
                                        printFeedEntry($label_id, 
                                                $class, $line["caption"], 
-                                               $count, "images/label.png", $link);
+                                               $count, "images/label.png", $link, 
+                                               false, false, false,
+                                               $line['fg_color'], $line['bg_color']);
                
                                }
 
                                $feed_id = $line["feed_id"];
 
                                $labels = get_article_labels($link, $id);
-                               $labels_str = "<span id=\"HLLCTR-$id\">";
-
-                               foreach ($labels as $l) {
-                                       $labels_str .= "<span 
-                                               class='hlLabelRef'>".
-                                               $l[1]."</span>";
-                               }
 
+                               $labels_str = "<span id=\"HLLCTR-$id\">";
+                               $labels_str .= format_article_labels($labels, $id);
                                $labels_str .= "</span>";
-
+       
                                if (count($topmost_article_ids) < 5) {
                                        array_push($topmost_article_ids, $id);
                                }
 
        function get_article_labels($link, $id) {
                $result = db_query($link, 
-                       "SELECT DISTINCT label_id,caption 
+                       "SELECT DISTINCT label_id,caption,fg_color,bg_color 
                                FROM ttrss_labels2, ttrss_user_labels2 
                        WHERE id = label_id 
                                AND article_id = '$id' 
                $rv = array();
 
                while ($line = db_fetch_assoc($result)) {
-                       $rk = array($line["label_id"], $line["caption"]);
+                       $rk = array($line["label_id"], $line["caption"], $line["fg_color"],
+                               $line["bg_color"]);
                        array_push($rv, $rk);
                }
 
                return $tags_str;
 
        }
+
+       function format_article_labels($labels, $id) {
+
+               $labels_str = "";
+
+               foreach ($labels as $l) {
+                       $labels_str .= sprintf("<span class='hlLabelRef' 
+                               style='color : %s; background-color : %s'>%s</span>",
+                                       $l[2], $l[3], $l[1]);
+                       }
+
+               return $labels_str;
+
+       }
 ?>
index 855d54aa79030a421dfbdec12a69bd5ebab8c65b..04e2858ca4474601a81d28d1612a77ec04a0a01a 100644 (file)
                                        print "<entry id=\"$id\"><![CDATA[";
 
                                        $labels = get_article_labels($link, $id, $_SESSION["uid"]);
-
-                                       foreach ($labels as $l) {
-                                               print  "<span class='hlLabelRef'>".$l[1]."</span>";
-                                       }
+                                       print format_article_labels($labels, $id);
 
                                        print "]]></entry>";
 
                                        print "<entry id=\"$id\"><![CDATA[";
 
                                        $labels = get_article_labels($link, $id, $_SESSION["uid"]);
-
-                                       foreach ($labels as $l) {
-                                               print  "<span class='hlLabelRef'>".$l[1]."</span>";
-                                       }
+                                       print format_article_labels($labels, $id);
 
                                        print "]]></entry>";
 
index b09a16cf56568ff21592dc47dd5341416543c506..059079a7169fb37225c83c979b1b2ff90cdee946 100644 (file)
                }
 
                $result = db_query($link, "SELECT 
-                               id,caption
+                               *
                        FROM 
                                ttrss_labels2
                        WHERE 
                                print "<tr class=\"$class\" $this_row_id>";
        
                                $line["caption"] = htmlspecialchars($line["caption"]);
-       
+
+                               $fg_color = $line["fg_color"];
+                               $bg_color = $line["bg_color"];
+
+                               if (!$fg_color) $fg_color = "black";
+                               if (!$bg_color) $bg_color = "transparent";
+
                                print "<td width='5%' align='center'><input 
                                        onclick='toggleSelectPrefRow(this, \"label\");' 
                                        type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
        
-                               print "<td><span id=\"LILT-".$line["id"]."\">" . $line["caption"] . 
+                               print "<td><span class='prefsLabelEntry' 
+                                       style='color : $fg_color; background-color : $bg_color'
+                                       id=\"LILT-".$line["id"]."\">" . $line["caption"] . 
                                        "</span></td>";
 
                                print "</tr>";
index cc98fbd2411a744182043766fade3b5b093b9536..fcc4c7b59e39d79aaa6ab74b08ef487c2d591d33 100644 (file)
@@ -2087,4 +2087,15 @@ div#errorBox input {
        margin-bottom : 10px;
 }
 
+span.prefsLabelEntry {
+       padding : 2px;
+}
 
+div.labelColorIndicator {
+       float : right;
+       height : 14px;
+       width : 14px;
+       line-height : 14px;
+       font-height : 9px;
+       text-align : center;
+}