]> git.wh0rd.org - tt-rss.git/blobdiff - classes/pref/filters.php
filters: remove sql_bool_to_bool()
[tt-rss.git] / classes / pref / filters.php
index 7049630b1dad32ba4331d8239587c78c5b85d5c6..e1c2e776d3dc8e6a6358d7b29f04b804c832367e 100755 (executable)
@@ -52,10 +52,8 @@ class Pref_Filters extends Handler_Protected {
                $filter = array();
 
                $filter["enabled"] = true;
-               $filter["match_any_rule"] = sql_bool_to_bool(
-                       checkbox_to_sql_bool($_REQUEST["match_any_rule"]));
-               $filter["inverse"] = sql_bool_to_bool(
-                       checkbox_to_sql_bool($_REQUEST["inverse"]));
+               $filter["match_any_rule"] = checkbox_to_sql_bool($_REQUEST["match_any_rule"]);
+               $filter["inverse"] = checkbox_to_sql_bool($_REQUEST["inverse"]);
 
                $filter["rules"] = array();
                $filter["actions"] = array("dummy-action");
@@ -111,76 +109,76 @@ class Pref_Filters extends Handler_Protected {
 
                //while ($found < $limit && $offset < $limit * 1000 && time() - $started < ini_get("max_execution_time") * 0.7) {
 
-                       $sth = $this->pdo->prepare("SELECT ttrss_entries.id,
-                                       ttrss_entries.title,
-                                       ttrss_feeds.id AS feed_id,
-                                       ttrss_feeds.title AS feed_title,
-                                       ttrss_feed_categories.id AS cat_id,
-                                       content,
-                                       date_entered,
-                                       link,
-                                       author,
-                                       tag_cache
-                               FROM
-                                       ttrss_entries, ttrss_user_entries
-                                               LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)
-                                               LEFT JOIN ttrss_feed_categories ON (ttrss_feeds.cat_id = ttrss_feed_categories.id)
-                               WHERE
-                                       ref_id = ttrss_entries.id AND
-                                       ($scope_qpart) AND
-                                       ttrss_user_entries.owner_uid = ?
-                               ORDER BY date_entered DESC LIMIT ?OFFSET ?");
-
-                       $sth->execute([$_SESSION['uid'], $limit, $offset]);;
-
-                       while ($line = $sth->fetch()) {
-
-                               $rc = RSSUtils::get_article_filters(array($filter), $line['title'], $line['content'], $line['link'],
-                                       $line['author'], explode(",", $line['tag_cache']));
-
-                               if (count($rc) > 0) {
-
-                                       $line["content_preview"] = truncate_string(strip_tags($line["content"]), 200, '&hellip;');
-
-                                       foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
-                                               $line = $p->hook_query_headlines($line, 100);
-                                       }
+               $sth = $this->pdo->prepare("SELECT ttrss_entries.id,
+                               ttrss_entries.title,
+                               ttrss_feeds.id AS feed_id,
+                               ttrss_feeds.title AS feed_title,
+                               ttrss_feed_categories.id AS cat_id,
+                               content,
+                               date_entered,
+                               link,
+                               author,
+                               tag_cache
+                       FROM
+                               ttrss_entries, ttrss_user_entries
+                                       LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)
+                                       LEFT JOIN ttrss_feed_categories ON (ttrss_feeds.cat_id = ttrss_feed_categories.id)
+                       WHERE
+                               ref_id = ttrss_entries.id AND
+                               ($scope_qpart) AND
+                               ttrss_user_entries.owner_uid = ?
+                       ORDER BY date_entered DESC LIMIT $limit OFFSET $offset");
+
+               $sth->execute([$_SESSION['uid']]);
 
-                                       $content_preview = $line["content_preview"];
+               while ($line = $sth->fetch()) {
 
-                                       $tmp = "<tr style='margin-top : 5px'>";
+                       $rc = RSSUtils::get_article_filters(array($filter), $line['title'], $line['content'], $line['link'],
+                               $line['author'], explode(",", $line['tag_cache']));
 
-                                       #$tmp .= "<td width='5%' align='center'><input dojoType=\"dijit.form.CheckBox\"
-                                       #       checked=\"1\" disabled=\"1\" type=\"checkbox\"></td>";
+                       if (count($rc) > 0) {
 
-                                       $id = $line['id'];
-                                       $tmp .= "<td width='5%' align='center'><img style='cursor : pointer' title='".__("Preview article")."'
-                                               src='images/information.png' onclick='openArticlePopup($id)'></td><td>";
+                               $line["content_preview"] = truncate_string(strip_tags($line["content"]), 200, '&hellip;');
 
-                                       /*foreach ($filter['rules'] as $rule) {
-                                               $reg_exp = str_replace('/', '\/', $rule["reg_exp"]);
+                               foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
+                                       $line = $p->hook_query_headlines($line, 100);
+                               }
 
-                                               $line["title"] = preg_replace("/($reg_exp)/i",
-                                                       "<span class=\"highlight\">$1</span>", $line["title"]);
+                               $content_preview = $line["content_preview"];
 
-                                               $content_preview = preg_replace("/($reg_exp)/i",
-                                                       "<span class=\"highlight\">$1</span>", $content_preview);
-                                       }*/
+                               $tmp = "<tr style='margin-top : 5px'>";
 
-                                       $tmp .= "<strong>" . $line["title"] . "</strong><br/>";
-                                       $tmp .= $line['feed_title'] . ", " . mb_substr($line["date_entered"], 0, 16);
-                                       $tmp .= "<div class='insensitive'>" . $content_preview . "</div>";
-                                       $tmp .= "</td></tr>";
+                               #$tmp .= "<td width='5%' align='center'><input dojoType=\"dijit.form.CheckBox\"
+                               #       checked=\"1\" disabled=\"1\" type=\"checkbox\"></td>";
 
-                                       array_push($rv, $tmp);
+                               $id = $line['id'];
+                               $tmp .= "<td width='5%' align='center'><img style='cursor : pointer' title='".__("Preview article")."'
+                                       src='images/information.png' onclick='openArticlePopup($id)'></td><td>";
 
-                                       /*array_push($rv, array("title" => $line["title"],
-                                               "content" => $content_preview,
-                                               "date" => $line["date_entered"],
-                                               "feed" => $line["feed_title"])); */
+                               /*foreach ($filter['rules'] as $rule) {
+                                       $reg_exp = str_replace('/', '\/', $rule["reg_exp"]);
+
+                                       $line["title"] = preg_replace("/($reg_exp)/i",
+                                               "<span class=\"highlight\">$1</span>", $line["title"]);
+
+                                       $content_preview = preg_replace("/($reg_exp)/i",
+                                               "<span class=\"highlight\">$1</span>", $content_preview);
+                               }*/
+
+                               $tmp .= "<strong>" . $line["title"] . "</strong><br/>";
+                               $tmp .= $line['feed_title'] . ", " . mb_substr($line["date_entered"], 0, 16);
+                               $tmp .= "<div class='insensitive'>" . $content_preview . "</div>";
+                               $tmp .= "</td></tr>";
+
+                               array_push($rv, $tmp);
+
+                               /*array_push($rv, array("title" => $line["title"],
+                                       "content" => $content_preview,
+                                       "date" => $line["date_entered"],
+                                       "feed" => $line["feed_title"])); */
 
-                               }
                        }
+               }
 
                        //$offset += $limit;
                //}
@@ -252,7 +250,7 @@ class Pref_Filters extends Handler_Protected {
 
             } else {
 
-                $where = sql_bool_to_bool($line["cat_filter"]) ?
+                $where = $line["cat_filter"] ?
                     Feeds::getCategoryTitle($line["cat_id"]) :
                     ($line["feed_id"] ?
                         Feeds::getFeedTitle($line["feed_id"]) : __("All feeds"));
@@ -260,13 +258,13 @@ class Pref_Filters extends Handler_Protected {
 
 #                      $where = $line["cat_id"] . "/" . $line["feed_id"];
 
-                       $inverse = sql_bool_to_bool($line["inverse"]) ? "inverse" : "";
+                       $inverse = $line["inverse"] ? "inverse" : "";
 
                        $rv .= "<span class='$inverse'>" . T_sprintf("%s on %s in %s %s",
                                htmlspecialchars($line["reg_exp"]),
                                $line["field"],
                                $where,
-                               sql_bool_to_bool($line["inverse"]) ? __("(inverse)") : "") . "</span>";
+                               $line["inverse"] ? __("(inverse)") : "") . "</span>";
                }
 
                return $rv;
@@ -335,7 +333,7 @@ class Pref_Filters extends Handler_Protected {
                        $filter['name'] = $name[0];
                        $filter['param'] = $name[1];
                        $filter['checkbox'] = false;
-                       $filter['enabled'] = sql_bool_to_bool($line["enabled"]);
+                       $filter['enabled'] = $line["enabled"];
                        $filter['rules'] = $this->getfilterrules_concise($line['id']);
 
                        if (!$filter_search || $match_ok) {
@@ -364,9 +362,9 @@ class Pref_Filters extends Handler_Protected {
 
                if ($row = $sth->fetch()) {
 
-                       $enabled = sql_bool_to_bool($row["enabled"]);
-                       $match_any_rule = sql_bool_to_bool($row["match_any_rule"]);
-                       $inverse = sql_bool_to_bool($row["inverse"]);
+                       $enabled = $row["enabled"];
+                       $match_any_rule = $row["match_any_rule"];
+                       $inverse = $row["inverse"];
                        $title = htmlspecialchars($row["title"]);
 
                        print "<form id=\"filter_edit_form\" onsubmit='return false'>";
@@ -413,7 +411,7 @@ class Pref_Filters extends Handler_Protected {
                                if ($line["match_on"]) {
                                        $line["feed_id"] = json_decode($line["match_on"], true);
                                } else {
-                                       if (sql_bool_to_bool($line["cat_filter"])) {
+                                       if ($line["cat_filter"]) {
                                                $feed_id = "CAT:" . (int)$line["cat_id"];
                                        } else {
                                                $feed_id = (int)$line["feed_id"];
@@ -426,7 +424,7 @@ class Pref_Filters extends Handler_Protected {
                                unset($line["cat_id"]);
                                unset($line["filter_id"]);
                                unset($line["id"]);
-                               if (!sql_bool_to_bool($line["inverse"])) unset($line["inverse"]);
+                               if (!$line["inverse"]) unset($line["inverse"]);
                                unset($line["match_on"]);
 
                                $data = htmlspecialchars(json_encode($line));
@@ -696,7 +694,7 @@ class Pref_Filters extends Handler_Protected {
                                if ($rule) {
 
                                        $reg_exp = trim($rule["reg_exp"]);
-                                       $inverse = isset($rule["inverse"]) ? "true" : "false";
+                                       $inverse = isset($rule["inverse"]) ? 1 : 0;
 
                                        $filter_type = (int)trim($rule["filter_type"]);
                                        $match_on = json_encode($rule["feed_id"]);
@@ -822,11 +820,6 @@ class Pref_Filters extends Handler_Protected {
                print "<button dojoType=\"dijit.form.Button\" onclick=\"return removeSelectedFilters()\">".
                        __('Remove')."</button> ";
 
-               if (defined('_ENABLE_FEED_DEBUGGING')) {
-                       print "<button dojoType=\"dijit.form.Button\" onclick=\"rescore_all_feeds()\">".
-                               __('Rescore articles')."</button> ";
-               }
-
                print "</div>"; # toolbar
                print "</div>"; # toolbar-frame
                print "<div id=\"pref-filter-content\" dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
@@ -1144,7 +1137,7 @@ class Pref_Filters extends Handler_Protected {
                        $title = $row["title"];
                        $num_rules = $row["num_rules"];
                        $num_actions = $row["num_actions"];
-                       $match_any_rule = sql_bool_to_bool($row["match_any_rule"]);
+                       $match_any_rule = $row["match_any_rule"];
 
                        if (!$title) $title = __("[No caption]");