]> git.wh0rd.org Git - tt-rss.git/commitdiff
prefs: rudimentary multiple keyword search
authorAndrew Dolgov <fox@bah.org.ru>
Wed, 7 Oct 2009 11:12:21 +0000 (15:12 +0400)
committerAndrew Dolgov <fox@bah.org.ru>
Wed, 7 Oct 2009 11:12:21 +0000 (15:12 +0400)
modules/pref-feeds.php
modules/pref-filters.php
modules/pref-labels.php
modules/pref-users.php

index ce12806ee9e025b4de02ccd853124f7bdc96ea06..b0269243e4f22b75cd49e277369edd847458e3d8 100644 (file)
                $_SESSION["pref_sort_feeds"] = $feeds_sort;
 
                if ($feed_search) {
-                       $search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR
-                               UPPER(C1.title) LIKE UPPER('%$feed_search%') OR
-                               UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND";
+
+                       $feed_search = split(" ", $feed_search);
+                       $tokens = array();
+
+                       foreach ($feed_search as $token) {
+
+                               $token = trim($token);
+
+                               array_push($tokens, "(UPPER(F1.title) LIKE UPPER('%$token%') OR
+                                       UPPER(C1.title) LIKE UPPER('%$token%') OR
+                                       UPPER(F1.feed_url) LIKE UPPER('%$token%'))");
+                       }
+
+                       $search_qpart = "(" . join($tokens, " AND ") . ") AND ";
+
                } else {
                        $search_qpart = "";
                }
index 9e3e100f1da0ded7f82879451379460d2705520c..238ceb151d5c90dcc3069a614ec11bc5692fd5ae 100644 (file)
                        value=\"".__('Rescore articles')."\">"; 
 
                if ($filter_search) {
-                       $filter_search = db_escape_string($filter_search);
-                       $filter_search_query = "(
-                               UPPER(ttrss_filter_actions.description) LIKE UPPER('%$filter_search%') OR 
-                               UPPER(reg_exp) LIKE UPPER('%$filter_search%') OR 
-                               UPPER(action_param) LIKE UPPER('%$filter_search%') OR 
-                               UPPER(ttrss_feeds.title) LIKE UPPER('%$filter_search%') OR
-                               UPPER(ttrss_filter_types.description) LIKE UPPER('%$filter_search%')) AND";
+                       $filter_search = split(' ', db_escape_string($filter_search));
+
+                       $tokens = array();
+
+                       foreach ($filter_search as $token) {
+                               $token = trim($token);
+
+                               array_push($tokens, "(
+                                       UPPER(ttrss_filter_actions.description) LIKE UPPER('%$token%') OR 
+                                       UPPER(reg_exp) LIKE UPPER('%$token%') OR 
+                                       UPPER(action_param) LIKE UPPER('%$token%') OR 
+                                       UPPER(ttrss_feeds.title) LIKE UPPER('%$token%') OR
+                                       UPPER(ttrss_filter_types.description) LIKE UPPER('%$token%'))");
+                       }
+
+                       $filter_search_query = "(" . join($tokens, " AND ") . ") AND ";
+
                } else {
                        $filter_search_query = "";
                }
index 165765b89dcd2d4552789b3a534c7db1745bd536..3362288017d1ed1cb3b959816fa4ac9f6a4528a6 100644 (file)
                        value=\"".__('Create label')."\"></div>";
 
                if ($label_search) {
-                       $label_search_query = "caption LIKE '%$label_search%' AND";
+
+                       $label_search = split(" ", $label_search);
+                       $tokens = array();
+
+                       foreach ($label_search as $token) {
+
+                               $token = trim($token);
+                               array_push($tokens, "(UPPER(caption) LIKE UPPER('%$token%'))");
+
+                       }
+
+                       $label_search_query = "(" . join($tokens, " AND ") . ") AND ";
+                       
                } else {
                        $label_search_query = "";
                }
index 7e38fd5d43e81a69778ff9c15531ab7f43ca3bbd..7a878b18f503b78e453d140ab87818049d106109 100644 (file)
                        onclick=\"javascript:addUser()\" value=\"".__('Create user')."\"></div>";
 
                if ($user_search) {
-                       $user_search_query = "UPPER(login) LIKE UPPER('%$user_search%') AND";
+
+                       $user_search = split(" ", $user_search);
+                       $tokens = array();
+
+                       foreach ($user_search as $token) {                      
+                               $token = trim($token);
+                               array_push($tokens, "(UPPER(login) LIKE UPPER('%$token%'))");
+                       }
+
+                       $user_search_query = "(" . join($tokens, " AND ") . ") AND ";
+
                } else {
                        $user_search_query = "";
                }