implement HOOK_FEED_PARSED, add example plugin (refs #424)

This commit is contained in:
Andrew Dolgov 2012-12-24 14:13:03 +04:00
parent fa6fbd3659
commit 4412b877d0
3 changed files with 27 additions and 1 deletions

View File

@ -11,6 +11,7 @@ class PluginHost {
const HOOK_PREFS_TAB = 3;
const HOOK_PREFS_SECTION = 4;
const HOOK_PREFS_TABS = 5;
const HOOK_FEED_PARSED = 6;
function __construct($link) {
$this->link = $link;

View File

@ -261,6 +261,9 @@
if (!$rss->error()) {
global $pluginhost;
$pluginhost->run_hooks($pluginhost::HOOK_FEED_PARSED, "hook_feed_parsed", $rss);
if ($debug_enabled) {
_debug("update_rss_feed: processing feed data...");
}
@ -521,7 +524,6 @@
}
// TODO: less memory-hungry implementation
global $pluginhost;
if ($debug_enabled) {
_debug("update_rss_feed: applying plugin filters..");
@ -534,6 +536,7 @@
"tags" => $entry_tags,
"author" => $entry_author);
global $pluginhost;
foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_FILTER) as $plugin) {
$article = $plugin->hook_article_filter($article);
}

View File

@ -0,0 +1,22 @@
<?php
class Example_Feed extends Plugin {
// Demonstrates how to query data from the parsed feed object (SimplePie)
// don't enable unless debugging feed through f D hotkey or manually.
private $link;
private $host;
function __construct($host) {
$this->link = $host->get_link();
$this->host = $host;
$host->add_hook($host::HOOK_FEED_PARSED, $this);
}
function hook_feed_parsed($feed) {
_debug("I'm a little feed short and stout, here's my title: " . $feed->get_title());
_debug("... here's my link element: " . $feed->get_link());
}
}
?>