From 2eb9c95c970644f8408da9d22b60a66caadd36fb Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 26 Jan 2009 11:07:53 +0100 Subject: [PATCH] support colored labels --- functions.php | 53 ++++++++++++++++++++++++++++++----------- modules/backend-rpc.php | 10 ++------ modules/pref-labels.php | 14 ++++++++--- tt-rss.css | 11 +++++++++ 4 files changed, 63 insertions(+), 25 deletions(-) diff --git a/functions.php b/functions.php index 51be96f7..a79b2345 100644 --- a/functions.php +++ b/functions.php @@ -1572,7 +1572,8 @@ } 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 = ""; @@ -1598,6 +1599,18 @@ $feed = "$feed_title"; +/* if ($feed_id < -10) { + $bg_color = "#00ccff"; + $fg_color = "white"; + } + + if ($fg_color || $bg_color) { + $color_str = "
l
"; + } + + print $color_str; */ + print "
  • "; if (get_pref($link, 'ENABLE_FEED_ICONS')) { print "$feed_icon"; @@ -1619,7 +1632,7 @@ print "
    $last_updated ($total total) $error_notify_msg
    "; } - + print "
  • "; } @@ -4086,7 +4099,7 @@ 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) { @@ -4118,7 +4131,9 @@ 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']); } @@ -4815,16 +4830,11 @@ $feed_id = $line["feed_id"]; $labels = get_article_labels($link, $id); + $labels_str = ""; - - foreach ($labels as $l) { - $labels_str .= "". - $l[1].""; - } - + $labels_str .= format_article_labels($labels, $id); $labels_str .= ""; - + if (count($topmost_article_ids) < 5) { array_push($topmost_article_ids, $id); } @@ -5815,7 +5825,7 @@ 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' @@ -5825,7 +5835,8 @@ $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); } @@ -5991,4 +6002,18 @@ return $tags_str; } + + function format_article_labels($labels, $id) { + + $labels_str = ""; + + foreach ($labels as $l) { + $labels_str .= sprintf("%s", + $l[2], $l[3], $l[1]); + } + + return $labels_str; + + } ?> diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 855d54aa..04e2858c 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -444,10 +444,7 @@ print "".$l[1].""; - } + print format_article_labels($labels, $id); print "]]>"; @@ -483,10 +480,7 @@ print "".$l[1].""; - } + print format_article_labels($labels, $id); print "]]>"; diff --git a/modules/pref-labels.php b/modules/pref-labels.php index b09a16cf..059079a7 100644 --- a/modules/pref-labels.php +++ b/modules/pref-labels.php @@ -110,7 +110,7 @@ } $result = db_query($link, "SELECT - id,caption + * FROM ttrss_labels2 WHERE @@ -149,12 +149,20 @@ print ""; $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 ""; - print "" . $line["caption"] . + print "" . $line["caption"] . ""; print ""; diff --git a/tt-rss.css b/tt-rss.css index cc98fbd2..fcc4c7b5 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -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; +}