END; } #-- store config into per-plugin config fields (no space in the DB table for feeds) function g_plugin_perfeeditemfilter_admin_submit_feed_prop($null=NULL) { #-- get submitted form field values $cid = (int)$_REQUEST["cid"]; $regex = $_REQUEST["plugin_pfif_regex"]; $channel = $_REQUEST["plugin_pfif_channel"]; $hide = $_REQUEST["plugin_pfif_hide"]; $incoming = $_REQUEST["plugin_pfif_incoming"]; $listhide = $_REQUEST["plugin_pfif_listhide"]; #-- from list to regex if (!defined("PFIF_SIMPLE_REGEX_COMMAS") || PFIF_SIMPLE_REGEX_COMMAS) { $regex = preg_replace("/\s*[,\s]\s*/", "|", $regex); } #-- store settings rss_plugins_add_option("pfif.regex.feed.$cid", $regex, "string", "", "regex for filtering items from individual feed"); rss_plugins_add_option("pfif.channel.feed.$cid", $channel, "string", "", "apply filter to channel as well"); rss_plugins_add_option("pfif.hide.feed.$cid", $hide, "string", "", "boolean to hide individual feed"); rss_plugins_add_option("pfif.incoming.feed.$cid", $incoming, "string", "", "apply filter while parsing RSS feeds / before writing items to the DB at all"); rss_plugins_add_option("pfif.listhide.feed.$cid", $listhide, "string", "", "do not display feed in front page list"); } #-- filter engaged on frontpage (or in feed folder), # checks options and removes items function g_plugin_perfeeditemfilter_exec_beforerender($item) { $cid = $item->feed; $hide = rss_plugins_get_option("pfif.hide.feed.$cid"); $channelhide = rss_plugins_get_option("pfif.channel.feed.$cid"); $regex = rss_plugins_get_option("pfif.regex.feed.$cid"); #-- must filter be checked in channel view at all? if ($_GET["channel"] && !$channelhide) { return $item; } #-- or hide items on frontpage always? if ($hide && !$_GET["channel"]) { return NULL; } #-- see if a filter was given if ($regex) { if (preg_match("#($regex)#i", $item->title . "\n" . $item->description . "\n" . $item->author, $uu)) { // ok #$item->description .= "\n\n"; } else { // hide return NULL; } } #-- done return $item; } #-- filter a feed while it gets parsed / before items are written to the DB at all function g_plugin_perfeeditemfilter_exec_rssitem($item) { $cid = $item["feed"]; $incoming = rss_plugins_get_option("pfif.incoming.feed.$cid"); $regex = rss_plugins_get_option("pfif.regex.feed.$cid"); #-- check for required data if ($cid && $incoming && $regex && !empty($item)) { #-- kill item if regex DOES NOT match if (!preg_match("#($regex)#i", $item->title . "\n" . $item->description . "\n" . $item->author, $uu)) { $item = NULL; } } #-- send back return($item); } #-- ??? function g_plugin_exec_feed_list_name($list=NULL) { // $cid = $hide = rss_plugins_get_option("pfif.listhide.feed.$cid"); // ... } ?>