diff options
author | Andrew Dolgov <[email protected]> | 2006-12-08 08:32:27 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2006-12-08 08:32:27 +0100 |
commit | 240054f1a23e2b3c5bfd99dc2212e32430b04172 (patch) | |
tree | e8073c49c91d7af8cb90b08716f0134d872e5ffe /functions.php | |
parent | 073ca0e663781bb90e01c56b058b7c0801f19bcb (diff) |
add function to match all filters
Diffstat (limited to 'functions.php')
-rw-r--r-- | functions.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/functions.php b/functions.php index c03264213..dbc432358 100644 --- a/functions.php +++ b/functions.php @@ -893,6 +893,51 @@ return false; } + function get_filter_matches($title, $content, $link, $filters) { + + $matches = array(); + + if ($filters["title"]) { + foreach ($filters["title"] as $filter) { + $reg_exp = $filter["reg_exp"]; + if (preg_match("/$reg_exp/i", $title)) { + array_push($matches, 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)) { + array_push($matches, 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)) { + array_push($matches, 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)) { + array_push($matches, array($filter["action"], $filter["action_param"])); + } + } + } + + return $matches; + } + function printFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link, $rtl_content = false, $last_updated = false, $last_error = false) { |