}
function sql_bool_to_bool($s) {
- if ($s == "t" || $s == "1") {
+ if ($s == "t" || $s == "1" || $s == "true") {
return true;
} else {
return false;
return $search_query_part;
}
- function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order = false, $offset = 0, $owner_uid = 0) {
+ function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false) {
if (!$owner_uid) $owner_uid = $_SESSION["uid"];
$search_query_part = "";
}
+ if ($filter) {
+ $filter_query_part = filter_to_sql($filter);
+ } else {
+ $filter_query_part = "";
+ }
+
$view_query_part = "";
if ($view_mode == "adaptive" || $view_query_part == "noscores") {
ttrss_user_entries.ref_id = ttrss_entries.id AND
ttrss_user_entries.owner_uid = '$owner_uid' AND
$search_query_part
+ $filter_query_part
$view_query_part
$query_strategy_part ORDER BY $order_by
$limit_query_part $offset_query_part";
return $result;
}
+ function filter_to_sql($filter) {
+ $query = "";
+
+ if (DB_TYPE == "pgsql")
+ $reg_qpart = "~";
+ else
+ $reg_qpart = "REGEXP";
+
+ switch ($filter["type"]) {
+ case "title":
+ $query = "LOWER(ttrss_entries.title) $reg_qpart LOWER('".
+ $filter['reg_exp'] . "')";
+ break;
+ case "content":
+ $query = "LOWER(ttrss_entries.content) $reg_qpart LOWER('".
+ $filter['reg_exp'] . "')";
+ break;
+ case "both":
+ $query = "LOWER(ttrss_entries.title) $reg_qpart LOWER('".
+ $filter['reg_exp'] . "') OR LOWER(" .
+ "ttrss_entries.content) $reg_qpart LOWER('" . $filter['reg_exp'] . "')";
+ break;
+ case "tag":
+ $query = "LOWER(ttrss_user_entries.tag_cache) $reg_qpart LOWER('".
+ $filter['reg_exp'] . "')";
+ break;
+ case "link":
+ $query = "LOWER(ttrss_entries.link) $reg_qpart LOWER('".
+ $filter['reg_exp'] . "')";
+ break;
+ case "date":
+
+ if ($filter["filter_param"] == "before")
+ $cmp_qpart = "<";
+ else
+ $cmp_qpart = ">=";
+
+ $timestamp = date("Y-m-d H:N:s", strtotime($filter["reg_exp"]));
+ $query = "ttrss_entries.date_entered $cmp_qpart '$timestamp'";
+ break;
+ case "author":
+ $query = "LOWER(ttrss_entries.author) $reg_qpart LOWER('".
+ $filter['reg_exp'] . "')";
+ break;
+ }
+
+ if ($filter["inverse"])
+ $query = "NOT ($query)";
+
+ if ($query)
+ $query .= " AND ";
+
+ return $query;
+ }
?>
$filter["reg_exp"] = $reg_exp;
$filter["action"] = $action_name;
-
+ $filter["type"] = $type_name;
$filter["action_param"] = $action_param;
$filter["filter_param"] = $filter_param;
- $filter["inverse"] = sql_bool_to_bool($inverse);
+ $filter["inverse"] = $inverse;
$filters[$type_name] = array($filter);
$feed_title = getFeedTitle($link, $feed);
$qfh_ret = queryFeedHeadlines($link, $feed,
- 300, "", false, false, false,
- false, "date_entered DESC", 0, $_SESSION["uid"]);
+ 30, "", false, false, false,
+ false, "date_entered DESC", 0, $_SESSION["uid"], $filter);
$result = $qfh_ret[0];
$entry_timestamp = strtotime($line["updated"]);
$entry_tags = get_article_tags($link, $line["id"], $_SESSION["uid"]);
- $article_filters = get_article_filters($filters, $line["title"],
- $line["content_preview"], $line["link"],
- $entry_timestamp, $line["author"], $entry_tags);
-
- if (count($article_filters) != 0) {
-
- $content_preview = truncate_string(
- strip_tags($line["content_preview"]), 100, '...');
+ $content_preview = truncate_string(
+ strip_tags($line["content_preview"]), 100, '...');
- if ($line["feed_title"])
- $feed_title = $line["feed_title"];
+ if ($line["feed_title"])
+ $feed_title = $line["feed_title"];
- print "<tr>";
+ print "<tr>";
- print "<td width='5%' align='center'><input
- dojoType=\"dijit.form.CheckBox\" checked=\"1\"
- disabled=\"1\" type=\"checkbox\"></td>";
- print "<td>";
+ print "<td width='5%' align='center'><input
+ dojoType=\"dijit.form.CheckBox\" checked=\"1\"
+ disabled=\"1\" type=\"checkbox\"></td>";
+ print "<td>";
- print $line["title"];
- print " (";
- print "<b>" . $feed_title . "</b>";
- print "): ";
- print "<span class=\"insensitive\">" . $content_preview . "</span>";
+ print $line["title"];
+ print " (";
+ print "<b>" . $feed_title . "</b>";
+ print "): ";
+ print "<span class=\"insensitive\">" . $content_preview . "</span>";
+ print $line["date_entered"];
- print "</td></tr>";
-
- $found++;
- }
+ print "</td></tr>";
- if ($found >= 30)
- break;
+ $found++;
}
if ($found == 0) {
print "<tr><td align='center'>" .
- __("No recent articles matching this filter has been found.") . "</td></tr>";
+ __("No articles matching this filter has been found.") . "</td></tr>";
}
print "</table>";