add multiple-match to filters
This commit is contained in:
parent
0f088bfcde
commit
f838201190
|
@ -421,7 +421,7 @@
|
||||||
owner_uid = $owner_uid AND
|
owner_uid = $owner_uid AND
|
||||||
ttrss_filter_types.id = filter_type AND
|
ttrss_filter_types.id = filter_type AND
|
||||||
ttrss_filter_actions.id = action_id AND
|
ttrss_filter_actions.id = action_id AND
|
||||||
(feed_id IS NULL OR feed_id = '$feed')");
|
(feed_id IS NULL OR feed_id = '$feed') ORDER BY reg_exp");
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
while ($line = db_fetch_assoc($result)) {
|
||||||
if (!$filters[$line["name"]]) $filters[$line["name"]] = array();
|
if (!$filters[$line["name"]]) $filters[$line["name"]] = array();
|
||||||
|
@ -633,13 +633,10 @@
|
||||||
|
|
||||||
// error_reporting(0);
|
// error_reporting(0);
|
||||||
|
|
||||||
$tuple = get_filter_name($entry_title, $entry_content,
|
$article_filters = get_article_filters($filters, $entry_title,
|
||||||
$entry_link, $filters);
|
$entry_content, $entry_link);
|
||||||
|
|
||||||
$filter_name = $tuple[0];
|
if (find_article_filter($article_filters, "filter")) {
|
||||||
$filter_param = $tuple[1];
|
|
||||||
|
|
||||||
if ($filter_name == "filter") {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,7 +650,7 @@
|
||||||
// okay it doesn't exist - create user entry
|
// okay it doesn't exist - create user entry
|
||||||
if (db_num_rows($result) == 0) {
|
if (db_num_rows($result) == 0) {
|
||||||
|
|
||||||
if ($filter_name != 'catchup') {
|
if (!find_article_filter($article_filters, 'catchup')) {
|
||||||
$unread = 'true';
|
$unread = 'true';
|
||||||
$last_read_qpart = 'NULL';
|
$last_read_qpart = 'NULL';
|
||||||
} else {
|
} else {
|
||||||
|
@ -661,7 +658,7 @@
|
||||||
$last_read_qpart = 'NOW()';
|
$last_read_qpart = 'NOW()';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filter_name == 'mark') {
|
if (find_article_filter($article_filters, 'mark')) {
|
||||||
$marked = 'true';
|
$marked = 'true';
|
||||||
} else {
|
} else {
|
||||||
$marked = 'false';
|
$marked = 'false';
|
||||||
|
@ -735,9 +732,11 @@
|
||||||
|
|
||||||
# check for manual tags
|
# check for manual tags
|
||||||
|
|
||||||
if ($filter_name == "tag") {
|
$tag_filter = find_article_filter($article_filters, "tag");
|
||||||
|
|
||||||
$manual_tags = trim_array(split(",", $filter_param));
|
if ($tag_filter) {
|
||||||
|
|
||||||
|
$manual_tags = trim_array(split(",", $tag_filter[1]));
|
||||||
|
|
||||||
foreach ($manual_tags as $tag) {
|
foreach ($manual_tags as $tag) {
|
||||||
if (tag_is_valid($tag)) {
|
if (tag_is_valid($tag)) {
|
||||||
|
@ -836,51 +835,7 @@
|
||||||
print "</select>";
|
print "</select>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_filter_name($title, $content, $link, $filters) {
|
function get_article_filters($filters, $title, $content, $link) {
|
||||||
|
|
||||||
if ($filters["title"]) {
|
|
||||||
foreach ($filters["title"] as $filter) {
|
|
||||||
$reg_exp = $filter["reg_exp"];
|
|
||||||
if (preg_match("/$reg_exp/i", $title)) {
|
|
||||||
return array($filter["action"], $filter["action_param"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($filters["content"]) {
|
|
||||||
foreach ($filters["content"] as $filter) {
|
|
||||||
$reg_exp = $filter["reg_exp"];
|
|
||||||
if (preg_match("/$reg_exp/i", $content)) {
|
|
||||||
return array($filter["action"], $filter["action_param"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($filters["both"]) {
|
|
||||||
foreach ($filters["both"] as $filter) {
|
|
||||||
$reg_exp = $filter["reg_exp"];
|
|
||||||
if (preg_match("/$reg_exp/i", $title) ||
|
|
||||||
preg_match("/$reg_exp/i", $content)) {
|
|
||||||
return array($filter["action"], $filter["action_param"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($filters["link"]) {
|
|
||||||
$reg_exp = $filter["reg_exp"];
|
|
||||||
foreach ($filters["link"] as $filter) {
|
|
||||||
$reg_exp = $filter["reg_exp"];
|
|
||||||
if (preg_match("/$reg_exp/i", $link)) {
|
|
||||||
return array($filter["action"], $filter["action_param"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_filter_matches($title, $content, $link, $filters) {
|
|
||||||
|
|
||||||
$matches = array();
|
$matches = array();
|
||||||
|
|
||||||
if ($filters["title"]) {
|
if ($filters["title"]) {
|
||||||
|
@ -904,9 +859,8 @@
|
||||||
if ($filters["both"]) {
|
if ($filters["both"]) {
|
||||||
foreach ($filters["both"] as $filter) {
|
foreach ($filters["both"] as $filter) {
|
||||||
$reg_exp = $filter["reg_exp"];
|
$reg_exp = $filter["reg_exp"];
|
||||||
if (preg_match("/$reg_exp/i", $title) ||
|
if (preg_match("/$reg_exp/i", $title) || preg_match("/$reg_exp/i", $content)) {
|
||||||
preg_match("/$reg_exp/i", $content)) {
|
array_push($matches, array($filter["action"], $filter["action_param"]));
|
||||||
array_push($matches, array($filter["action"], $filter["action_param"]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -924,6 +878,15 @@
|
||||||
return $matches;
|
return $matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function find_article_filter($filters, $filter_name) {
|
||||||
|
foreach ($filters as $f) {
|
||||||
|
if ($f[0] == $filter_name) {
|
||||||
|
return $f;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function printFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link,
|
function printFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link,
|
||||||
$rtl_content = false, $last_updated = false, $last_error = false) {
|
$rtl_content = false, $last_updated = false, $last_error = false) {
|
||||||
|
|
||||||
|
|
|
@ -317,10 +317,9 @@
|
||||||
|
|
||||||
print "</p>";
|
print "</p>";
|
||||||
|
|
||||||
print "<div class=\"insensitive\" style=\"float : right\">
|
/* print "<div class=\"insensitive\" style=\"float : right\">
|
||||||
First matching filter is used, filtering is performed
|
First matching filter is used, filtering is performed
|
||||||
when importing articles from the feed.</div>";
|
when importing articles from the feed.</div>"; */
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue