]> git.wh0rd.org Git - tt-rss.git/commitdiff
expand filtertree display to make filters easier to distinguish
authorAndrew Dolgov <noreply@fakecake.org>
Wed, 2 Apr 2014 08:15:33 +0000 (08:15 +0000)
committerAndrew Dolgov <noreply@fakecake.org>
Wed, 2 Apr 2014 08:15:33 +0000 (08:15 +0000)
classes/pref/filters.php
css/dijit.css
include/functions.php
js/PrefFilterTree.js

index 2e1e841fc48524db6b812065f7cb0f9b3f7978ee..cfc20e4192fa7f38c7150a5034e8f67604d21387 100644 (file)
@@ -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 .= "<span class='$inverse'>" . T_sprintf("%s on %s in %s %s",
+                               strip_tags($line["reg_exp"]),
+                               $line["field"],
+                               $where,
+                               sql_bool_to_bool($line["inverse"]) ? __("(inverse)") : "") . "</span>";
+               }
+
+               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 "<span class='filterRule $inverse'>" .
+                       T_sprintf("%s on %s in %s %s", strip_tags($rule["reg_exp"]),
+                       $filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : "") . "</span>";
        }
 
        function printRuleName() {
index 9379f92636694fa18a88412b9760576b8149b06b..bd51929a7792aeb139bd924f272ffd598188a357 100644 (file)
        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;
index 5af20aa1456344ee08901512eeeb25e8b2158014..1390d8185592fcdd3534eed21af9e55a8319d314 100644 (file)
        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) {
index d9391c13587accc5694ce904fed3f1f75e2d875b..7a561c55ba4e1b915f5eefef6e96eba13edf62fc 100644 (file)
@@ -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';