id_element parameter. */ require_once '../includes/common.php'; require_once 'FeedMagick/SaxFeedFilter.php'; class FeedUniqFilter extends FeedMagick_SaxFeedFilter { var $seen_ids; var $curr_id; var $SUBJECT_TAGS = array( 'http://purl.org/dc/elements/1.1/:subject', 'dc:subject', ); function additionalFormParameters() { ?>
seen_ids = array(); FeedMagick_SaxFeedFilter::startDoc(); } function startItem() { $this->allow_item = true; $this->curr_id = null; FeedMagick_SaxFeedFilter::startItem(); } function close(&$tag) { $id_element = ($_GET['id_element']) ? $_GET['id_element'] : 'link'; if ($id_element == $tag) { $this->curr_id = $this->getCDATA(); } // Proceed as normal with tag processing. FeedMagick_SaxFeedFilter::close($tag); } function endItem() { if ($this->curr_id) { if (array_search($this->curr_id, $this->seen_ids) !== false) { $this->allow_item = false; } array_push($this->seen_ids, $this->curr_id); } FeedMagick_SaxFeedFilter::endItem(); } /* */ } // Instantiate and run the filter only when not being used as an include. if (strpos(basename(__FILE__), basename($_SERVER['SCRIPT_FILENAME'])) !== false) { processFilter(new FeedUniqFilter()); } ?>