]> git.wh0rd.org - tt-rss.git/commitdiff
simplify search, remove search_mode as useless
authorAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Tue, 7 Jul 2015 12:59:32 +0000 (15:59 +0300)
committerAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Tue, 7 Jul 2015 12:59:32 +0000 (15:59 +0300)
remove dialog to select by tags, simplify browsing by tag query

classes/api.php
classes/dlg.php
classes/feeds.php
classes/handler/public.php
include/functions2.php
index.php
js/tt-rss.js

index 3c5d084087ba592ef39b9656688ee0830403f78f..8267572f442fb646a758350356c3c0fcecce7b0e 100644 (file)
@@ -222,11 +222,10 @@ class API extends Handler {
                        /* do not rely on params below */
 
                        $search = $this->dbh->escape_string($_REQUEST["search"]);
-                       $search_mode = $this->dbh->escape_string($_REQUEST["search_mode"]);
 
                        $headlines = $this->api_get_headlines($feed_id, $limit, $offset,
                                $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order,
-                               $include_attachments, $since_id, $search, $search_mode,
+                               $include_attachments, $since_id, $search,
                                $include_nested, $sanitize_content, $force_update, $excerpt_length);
 
                        $this->wrap(self::STATUS_OK, $headlines);
@@ -636,8 +635,7 @@ class API extends Handler {
        static function api_get_headlines($feed_id, $limit, $offset,
                                $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order,
                                $include_attachments, $since_id,
-                               $search = "", $search_mode = "",
-                               $include_nested = false, $sanitize_content = true, $force_update = false, $excerpt_length = 100) {
+                               $search = "", $include_nested = false, $sanitize_content = true, $force_update = false, $excerpt_length = 100) {
 
                        if ($force_update && $feed_id > 0 && is_numeric($feed_id)) {
                                // Update the feed if required with some basic flood control
@@ -661,7 +659,7 @@ class API extends Handler {
                        }
 
                        $qfh_ret = queryFeedHeadlines($feed_id, $limit,
-                               $view_mode, $is_cat, $search, $search_mode,
+                               $view_mode, $is_cat, $search, false,
                                $order, $offset, 0, false, $since_id, $include_nested);
 
                        $result = $qfh_ret[0];
index eee720ed40a25c271c706e26790d9a400b90d1dd..7b1abca3a49ce1857a7248e2a95ab19afd84a96c 100644 (file)
@@ -161,37 +161,6 @@ class Dlg extends Handler_Protected {
 
        }
 
-       function printTagSelect() {
-
-               print __("Match:"). "&nbsp;" .
-                       "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\" id=\"tag_mode_any\">";
-               print "<label for=\"tag_mode_any\">".__("Any")."</label>";
-               print "&nbsp;";
-               print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\" id=\"tag_mode_all\">";
-               print "<label for=\"tag_mode_all\">".__("All tags.")."</input>";
-
-               print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
-               $result = $this->dbh->query("SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
-                       AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
-
-               while ($row = $this->dbh->fetch_assoc($result)) {
-                       $tmp = htmlspecialchars($row["tag_name"]);
-                       print "<option value=\"$tmp\">$tmp</option>";
-               }
-
-               print "</select>";
-
-               print "<div align='right'>";
-               print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')),
-                       get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>";
-               print "&nbsp;";
-               print "<button dojoType=\"dijit.form.Button\"
-               onclick=\"return closeInfoBox()\">" .
-                       __('Close this window') . "</button>";
-               print "</div>";
-
-       }
-
        function generatedFeed() {
 
                $this->params = explode(":", $this->param, 3);
index bedfe649992001f5ccff3d5696622bb82c79b311..ed66be291a116424bd6e0cff750b9dce9066ef53 100644 (file)
@@ -13,7 +13,7 @@ class Feeds extends Handler_Protected {
 
        private function format_headline_subtoolbar($feed_site_url, $feed_title,
                        $feed_id, $is_cat, $search,
-                       $search_mode, $view_mode, $error, $feed_last_updated) {
+                       $view_mode, $error, $feed_last_updated) {
 
                $catchup_sel_link = "catchupSelection()";
 
@@ -34,7 +34,7 @@ class Feeds extends Handler_Protected {
                if ($is_cat) $cat_q = "&is_cat=$is_cat";
 
                if ($search) {
-                       $search_q = "&q=$search&smode=$search_mode";
+                       $search_q = "&q=$search";
                } else {
                        $search_q = "";
                }
@@ -207,29 +207,19 @@ class Feeds extends Handler_Protected {
                        $disable_cache = true;
                }
 
-               @$search_mode = $this->dbh->escape_string($_REQUEST["search_mode"]);
-
                if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
 
-//             error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");
-               if($search_mode == '' && $method != '' ){
-                   $search_mode = $method;
-               }
-//             error_log("search_mode: " . $search_mode);
 
                if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
                        $handler = PluginHost::getInstance()->get_feed_handler(
                                PluginHost::feed_to_pfeed_id($feed));
 
-               //      function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) {
-
                        if ($handler) {
                                $options = array(
                                        "limit" => $limit,
                                        "view_mode" => $view_mode,
                                        "cat_view" => $cat_view,
                                        "search" => $search,
-                                       "search_mode" => $search_mode,
                                        "override_order" => $override_order,
                                        "offset" => $offset,
                                        "owner_uid" => $_SESSION["uid"],
@@ -243,7 +233,7 @@ class Feeds extends Handler_Protected {
 
                } else {
                        $qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view,
-                               $search, $search_mode, $override_order, $offset, 0,
+                               $search, false, $override_order, $offset, 0,
                                false, 0, $include_children);
                }
 
@@ -263,7 +253,7 @@ class Feeds extends Handler_Protected {
 
                $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
                        $feed_title,
-                       $feed, $cat_view, $search, $search_mode, $view_mode,
+                       $feed, $cat_view, $search, $view_mode,
                        $last_error, $last_updated);
 
                $headlines_count = $this->dbh->num_rows($result);
@@ -1118,36 +1108,7 @@ class Feeds extends Handler_Protected {
                        style=\"font-size : 16px; width : 20em;\"
                        required=\"1\" name=\"query\" type=\"search\" value=''>";
 
-               print "<hr/>".__('Limit search to:')." ";
-
-               print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\">
-                       <option value=\"all_feeds\">".__('All feeds')."</option>";
-
-               $feed_title = getFeedTitle($active_feed_id);
-
-               if (!$is_cat) {
-                       $feed_cat_title = getFeedCatTitle($active_feed_id);
-               } else {
-                       $feed_cat_title = getCategoryTitle($active_feed_id);
-               }
-
-               if ($active_feed_id && !$is_cat) {
-                       print "<option selected=\"1\" value=\"this_feed\">$feed_title</option>";
-               } else {
-                       print "<option disabled=\"1\" value=\"false\">".__('This feed')."</option>";
-               }
-
-               if ($is_cat) {
-                       $cat_preselected = "selected=\"1\"";
-               }
-
-               if (get_pref('ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
-                       print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
-               } else {
-                       //print "<option disabled>".__('This category')."</option>";
-               }
-
-               print "</select>";
+               print "<hr/><span style='float : right'>".T_sprintf('in %s', getFeedTitle($active_feed_id, $is_cat))."</span>";
 
                print "</div>";
 
index 46c74041c85c33a6de6b1036552ce2a8bac5ee80..74e837846e18ca0a3cefe94e34207f5b5392a83e 100644 (file)
@@ -2,7 +2,7 @@
 class Handler_Public extends Handler {
 
        private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
-               $limit, $offset, $search, $search_mode,
+               $limit, $offset, $search,
                $view_mode = false, $format = 'atom', $order = false, $orig_guid = false, $start_ts = false) {
 
                require_once "lib/MiniTemplator.class.php";
@@ -37,10 +37,8 @@ class Handler_Public extends Handler {
                        break;
                }
 
-               //function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false) {
-
                $qfh_ret = queryFeedHeadlines($feed,
-                       1, $view_mode, $is_cat, $search, $search_mode,
+                       1, $view_mode, $is_cat, $search, false,
                        $date_sort_field, $offset, $owner_uid,
                        false, 0, true, true, false, false, $start_ts);
 
@@ -61,7 +59,7 @@ class Handler_Public extends Handler {
                }
 
                $qfh_ret = queryFeedHeadlines($feed,
-                       $limit, $view_mode, $is_cat, $search, $search_mode,
+                       $limit, $view_mode, $is_cat, $search, false,
                        $date_sort_field, $offset, $owner_uid,
                        false, 0, true, true, false, false, $start_ts);
 
@@ -374,7 +372,6 @@ class Handler_Public extends Handler {
                $offset = (int)$this->dbh->escape_string($_REQUEST["offset"]);
 
                $search = $this->dbh->escape_string($_REQUEST["q"]);
-               $search_mode = $this->dbh->escape_string($_REQUEST["smode"]);
                $view_mode = $this->dbh->escape_string($_REQUEST["view-mode"]);
                $order = $this->dbh->escape_string($_REQUEST["order"]);
                $start_ts = $this->dbh->escape_string($_REQUEST["ts"]);
@@ -400,7 +397,7 @@ class Handler_Public extends Handler {
 
                if ($owner_id) {
                        $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
-                               $offset, $search, $search_mode, $view_mode, $format, $order, $orig_guid, $start_ts);
+                               $offset, $search, $view_mode, $format, $order, $orig_guid, $start_ts);
                } else {
                        header('HTTP/1.1 403 Forbidden');
                }
index 1936d146d081813740bc43f9841422a1cb3f8378..e3b6e535cc9259339e43d3cb1a5f563cc1250027 100644 (file)
                return $rv;
        }
 
+       // $search_mode is obsolete/unused
        function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false) {
 
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
                        $vfeed_query_part = "";
 
-                       // override query strategy and enable feed display when searching globally
-                       if ($search && $search_mode == "all_feeds") {
-                               $query_strategy_part = "true";
-                               $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
                        /* tags */
-                       } else if (!is_numeric($feed)) {
+                       if (!is_numeric($feed)) {
                                $query_strategy_part = "true";
                                $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
                                        id = feed_id) as feed_title,";
-                       } else if ($search && $search_mode == "this_cat") {
-                               $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
-
-                               if ($feed > 0) {
-                                       if ($include_children) {
-                                               $subcats = getChildCategories($feed, $owner_uid);
-                                               array_push($subcats, $feed);
-                                               $cats_qpart = join(",", $subcats);
-                                       } else {
-                                               $cats_qpart = $feed;
-                                       }
-
-                                       $query_strategy_part = "ttrss_feeds.cat_id IN ($cats_qpart)";
-
-                               } else {
-                                       $query_strategy_part = "ttrss_feeds.cat_id IS NULL";
-                               }
-
                        } else if ($feed > 0) {
 
                                if ($cat_view) {
 
                                if (!$override_order) $override_order = "last_read DESC";
 
-/*                     } else if ($feed == -7) { // shared
-                               $query_strategy_part = "uuid != ''";
-                               $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
-                               $allow_archived = true; */
                        } else if ($feed == -3) { // fresh virtual feed
                                $query_strategy_part = "unread = true AND score >= 0";
 
 
                        $content_query_part = "content, ";
 
+                       if ($limit_query_part) {
+                               $offset_query_part = "OFFSET $offset";
+                       } else {
+                               $offset_query_part = "";
+                       }
 
                        if (is_numeric($feed)) {
-
-                               if ($feed >= 0) {
-                                       $feed_kind = "Feeds";
-                               } else {
-                                       $feed_kind = "Labels";
-                               }
-
-                               if ($limit_query_part) {
-                                       $offset_query_part = "OFFSET $offset";
-                               }
-
                                // proper override_order applied above
                                if ($vfeed_query_part && !$ignore_vfeed_group && get_pref('VFEED_GROUP_BY_FEED', $owner_uid)) {
                                        if (!$override_order) {
                                                LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)";
                                }
 
-                               if ($vfeed_query_part)
-                                       $vfeed_query_part .= "favicon_avg_color,";
+                               if ($vfeed_query_part) $vfeed_query_part .= "favicon_avg_color,";
 
                                if ($start_ts) {
                                        $start_ts_formatted = date("Y/m/d H:i:s", strtotime($start_ts));
                        } else {
                                // browsing by tag
 
-                               $select_qpart = "SELECT DISTINCT " .
-                                                               "date_entered," .
-                                                               "guid," .
-                                                               "note," .
-                                                               "ttrss_entries.id as id," .
-                                                               "title," .
-                                                               "updated," .
-                                                               "unread," .
-                                                               "feed_id," .
-                                                               "orig_feed_id," .
-                                                               "marked," .
-                                                               "num_comments, " .
-                                                               "comments, " .
-                                                               "tag_cache," .
-                                                               "label_cache," .
-                                                               "link," .
-                                                               "lang," .
-                                                               "uuid," .
-                                                               "last_read," .
-                                                               "(SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) AS hide_images," .
-                                                               "last_marked, last_published, " .
-                                                               $since_id_part .
-                                                               $vfeed_query_part .
-                                                               $content_query_part .
-                                                               "score ";
-
-                               $feed_kind = "Tags";
-                               $all_tags = explode(",", $feed);
-                               if ($search_mode == 'any') {
-                                       $tag_sql = "tag_name in (" . implode(", ", array_map("db_quote", $all_tags)) . ")";
-                                       $from_qpart = " FROM ttrss_entries,ttrss_user_entries,ttrss_tags ";
-                                       $where_qpart = " WHERE " .
-                                                                  "ref_id = ttrss_entries.id AND " .
-                                                                  "ttrss_user_entries.owner_uid = $owner_uid AND " .
-                                                                  "post_int_id = int_id AND $tag_sql AND " .
-                                                                  $view_query_part .
-                                                                  $search_query_part .
-                                                                  $query_strategy_part . " ORDER BY $order_by " .
-                                                                  $limit_query_part;
+                               $query = "SELECT DISTINCT
+                                                       date_entered,
+                                                       guid,
+                                                       note,
+                                                       ttrss_entries.id as id,
+                                                       title,
+                                                       updated,
+                                                       unread,
+                                                       feed_id,
+                                                       orig_feed_id,
+                                                       marked,
+                                                       num_comments,
+                                                       comments,
+                                                       tag_cache,
+                                                       label_cache,
+                                                       link,
+                                                       lang,
+                                                       uuid,
+                                                       last_read,
+                                                       (SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) AS hide_images,
+                                                       last_marked, last_published,
+                                                       $since_id_part
+                                                       $vfeed_query_part
+                                                       $content_query_part
+                                                       author, score
+                                               FROM ttrss_entries, ttrss_user_entries, ttrss_tags
+                                               WHERE
+                                                       ref_id = ttrss_entries.id AND
+                                                       ttrss_user_entries.owner_uid = $owner_uid AND
+                                                       post_int_id = int_id AND
+                                                       tag_name = '$feed' AND
+                                                       $view_query_part
+                                                       $search_query_part
+                                                       $query_strategy_part ORDER BY $order_by
+                                                       $limit_query_part $offset_query_part";
 
-                               } else {
-                                       $i = 1;
-                                       $sub_selects = array();
-                                       $sub_ands = array();
-                                       foreach ($all_tags as $term) {
-                                               array_push($sub_selects, "(SELECT post_int_id from ttrss_tags WHERE tag_name = " . db_quote($term) . " AND owner_uid = $owner_uid) as A$i");
-                                               $i++;
-                                       }
-                                       if ($i > 2) {
-                                               $x = 1;
-                                               $y = 2;
-                                               do {
-                                                       array_push($sub_ands, "A$x.post_int_id = A$y.post_int_id");
-                                                       $x++;
-                                                       $y++;
-                                               } while ($y < $i);
-                                       }
-                                       array_push($sub_ands, "A1.post_int_id = ttrss_user_entries.int_id and ttrss_user_entries.owner_uid = $owner_uid");
-                                       array_push($sub_ands, "ttrss_user_entries.ref_id = ttrss_entries.id");
-                                       $from_qpart = " FROM " . implode(", ", $sub_selects) . ", ttrss_user_entries, ttrss_entries";
-                                       $where_qpart = " WHERE " . implode(" AND ", $sub_ands);
-                               }
-                               //                              error_log("TAG SQL: " . $tag_sql);
-                               // $tag_sql = "tag_name = '$feed'";   DEFAULT way
+                               if ($_REQUEST["debug"]) print $query;
 
-                               //                              error_log("[". $select_qpart . "][" . $from_qpart . "][" .$where_qpart . "]");
-                               $result = db_query($select_qpart . $from_qpart . $where_qpart);
+                               $result = db_query($query);
                        }
 
                        return array($result, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words);
index f7ff97c688ed8b354ede05ef0c292eecf85955ee..95fb91d22d5887c9d360e8b461dec60f37890920 100644 (file)
--- a/index.php
+++ b/index.php
                                        <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div>
                                        <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Other actions:') ?></div>
                                        <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcToggleWidescreen')"><?php echo __('Toggle widescreen mode') ?></div>
-                                       <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagSelect')"><?php echo __('Select by tags...') ?></div>
                                        <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddLabel')"><?php echo __('Create label...') ?></div>
                                        <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFilter')"><?php echo __('Create filter...') ?></div> -->
                                        <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div>
index 602c953b1ed0f0955cf29902ddbe2ef9f6161040..f2a65b5399e1db21d3c2aea56343fd7aabe0b14b 100644 (file)
@@ -652,9 +652,6 @@ function quickMenuGo(opid) {
                case "qmcTagCloud":
                        displayDlg(__("Tag cloud"), "printTagCloud");
                        break;
-               case "qmcTagSelect":
-                       displayDlg(__("Select item(s) by tags"), "printTagSelect");
-                       break;
                case "qmcSearch":
                        search();
                        break;