From 50e04efdc854fc58fab9692f0d6d4b83e60d79c7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 2 Apr 2014 08:15:33 +0000 Subject: [PATCH] expand filtertree display to make filters easier to distinguish --- classes/pref/filters.php | 40 ++++++++++++++++++++++++++++++++++++++-- css/dijit.css | 22 ++++++++++++++++++++++ include/functions.php | 2 ++ js/PrefFilterTree.js | 8 ++++++++ 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 2e1e841f..cfc20e41 100644 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -147,6 +147,38 @@ class Pref_Filters extends Handler_Protected { } + private function getfilterrules_concise($filter_id) { + $result = $this->dbh->query("SELECT reg_exp, + inverse, + feed_id, + cat_id, + cat_filter, + ttrss_filter_types.description AS field + FROM + ttrss_filters2_rules, ttrss_filter_types + WHERE + filter_id = '$filter_id' AND filter_type = ttrss_filter_types.id"); + + $rv = ""; + + while ($line = $this->dbh->fetch_assoc($result)) { + + $where = sql_bool_to_bool($line["cat_filter"]) ? + getCategoryTitle($line["cat_id"]) : getFeedTitle($line["feed_id"]); + +# $where = $line["cat_id"] . "/" . $line["feed_id"]; + + $inverse = sql_bool_to_bool($line["inverse"]) ? "inverse" : ""; + + $rv .= "" . T_sprintf("%s on %s in %s %s", + strip_tags($line["reg_exp"]), + $line["field"], + $where, + sql_bool_to_bool($line["inverse"]) ? __("(inverse)") : "") . ""; + } + + return $rv; + } function getfiltertree() { $root = array(); @@ -210,6 +242,7 @@ class Pref_Filters extends Handler_Protected { $filter['param'] = $name[1]; $filter['checkbox'] = false; $filter['enabled'] = sql_bool_to_bool($line["enabled"]); + $filter['rules'] = $this->getfilterrules_concise($line['id']); if (!$filter_search || $match_ok) { array_push($folder['items'], $filter); @@ -416,8 +449,11 @@ class Pref_Filters extends Handler_Protected { WHERE id = ".(int)$rule["filter_type"]); $filter_type = $this->dbh->fetch_result($result, 0, "description"); - return T_sprintf("%s on %s in %s %s", strip_tags($rule["reg_exp"]), - $filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : ""); + $inverse = isset($rule["inverse"]) ? "inverse" : ""; + + return "" . + T_sprintf("%s on %s in %s %s", strip_tags($rule["reg_exp"]), + $filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : "") . ""; } function printRuleName() { diff --git a/css/dijit.css b/css/dijit.css index 9379f926..bd51929a 100644 --- a/css/dijit.css +++ b/css/dijit.css @@ -15,6 +15,28 @@ margin-right : 1em; } +.claro .dijitTree .filterRules { + display : block; + color : #ccc; + font-size : 10px; + margin-left : 100px; +} + +.claro .dijitTree .filterRules span { + display : block; + color : green; +} + +#filterDlg_Matches span.filterRule { + color : green; +} + +.claro .dijitTree .filterRules span.inverse, +#filterDlg_Matches span.filterRule.inverse { + color : red; +} + + .claro .dijitTree .labelParam { float : right; margin-right : 1em; diff --git a/include/functions.php b/include/functions.php index 5af20aa1..1390d818 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1965,6 +1965,8 @@ function getFeedTitle($id, $cat = false) { if ($cat) { return getCategoryTitle($id); + } else if ($id == 0) { + return __("All feeds"); } else if ($id == -1) { return __("Starred articles"); } else if ($id == -2) { diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index d9391c13..7a561c55 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -24,6 +24,7 @@ dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, { var enabled = this.model.store.getValue(args.item, 'enabled'); var param = this.model.store.getValue(args.item, 'param'); + var rules = this.model.store.getValue(args.item, 'rules'); if (param) { param = dojo.doc.createElement('span'); @@ -32,6 +33,13 @@ dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, { dojo.place(param, tnode.rowNode, 'first'); } + if (rules) { + param = dojo.doc.createElement('span'); + param.className = 'filterRules'; + param.innerHTML = rules; + dojo.place(param, tnode.rowNode, 'next'); + } + if (this.model.store.getValue(args.item, 'id') != 'root') { var img = dojo.doc.createElement('img'); img.src ='images/filter.png'; -- 2.39.5