)
for the whole feed or its individual items. This plugin adds fake
timestamps to all items. It assigns the fake dates interval-wise.
So the items get "stretched" and are not displayed block-wise in the
gregarius feed view. You can configure the stepping of the fake dates,
and specifically penalize the whole feed with a time offset. You want
to tweak this individually (12h offset and 24 hours interval default)
based on how often your subscribed feeds get really updated.
This plugin is useful if you have a for-public Gregarius installation,
but some feeds always would pop up at the very top, because of their
technical/contentual shortcomings. The broken feeds however won't move
down over time, but reside in a somewhat fixed position instead. So
this may not be useful for some rather outdating / half-dead feeds.
You could also run into problems if Magpie/Gregarius however decide to
add items multiple times because of the varying timestamps (that might
influence database-internal GUID generation).
*/
#-- plugin hooks
rss_set_hook("rss.plugins.rssitem", "g_plugin_fixfeedtimes_rssitem");
rss_set_hook("rss.plugins.admin.activate", "g_plugin_fixfeedtimes_init_config");
#rss_set_hook("rss.plugins.updates.before", "g_plugin_fixfeedtimes_updates_before");
#rss_set_hook("rss.plugins.updates.after", "g_plugin_fixfeedtimes_updates_after");
#rss_set_hook("rss.plugins.items.new", "g_plugin_fixfeedtimes_items_new");
#rss_set_hook("rss.plugins.items.updated", "g_plugin_fixfeedtimes_items_new");
#rss_set_hook("rss.plugins.items.updated", "g_plugin_fixfeedtimes_items_updated");
define("FFT_FIRST", 12); // first items time is postponed 12 hours
define("FFT_INTERVAL", 24); // every next item gets a date further 24 hours later
#-- initialize config database table with defaults,
# when this plugin first gets enabled in the plugin admin page
function g_plugin_fixfeedtimes_init_config() {
if (rss_plugins_get_option("fft.first") === NULL) {
rss_plugins_add_option("fft.first", FFT_FIRST, "string", "", "fake time delay for first item (12 hours per default)");
rss_plugins_add_option("fft.interval", FFT_INTERVAL, "string", "", "interval in which following items get postponed (24 hours per default)");
}
}
#-- config page
function g_plugin_fixfeedtimes_config_dialog() {
#-- store new config
if (rss_plugins_is_submit()) {
rss_plugins_add_option("fft.first", $_REQUEST["fft_first"], "string", "");
rss_plugins_add_option("fft.interval", $_REQUEST["fft_interval"], "string");
}
#-- output dialog
else {
$first = rss_plugins_get_option("fft.first");
$interval = rss_plugins_get_option("fft.interval");
echo<<
END; } return; } #-- called before new item gets injected into database # UNUSED # (this hook didn't allow timestamp-modifications anyhow..) function g_plugin_fixfeedtimes_items_new($d) { global $fft_time; list($cid, $title, $url, $description) = $d; $d = array($cid, $title, $url, $description); return $d; } #-- called whenever a feed item is added, # we modify the dates then function g_plugin_fixfeedtimes_rssitem($item) { static $fft_time = 0; static $fft_last_domain = "about:blank"; #-- broken call (other plugins might leave an empty parameter already) if (empty($item)) { return $item; } #-- item has no timestamp # BTW: how useful of Magpie to leave feed type and tag name # differntiation entirely to us, *rolling_eyes* if (empty($item["dc"]["date"]) && empty($item["pubdate"]) && empty($item["published"]) && empty($item["issued"]) && empty($item["updated"]) && empty($item["created"])) { #-- get config or defaults $first = rss_plugins_get_option("fft.first"); $interval = rss_plugins_get_option("fft.interval"); #-- check if this an $item out of a new $rss feed preg_match("#//([^/]+)", "$item[link]$item[guid]$item[link_]", $domain) && ($domain = $domain[1]); if ($domain != $fft_last_domain) { $fft_last_domain = $domain[1]; $fft_time = time() - 60 * 60 * $first; } #-- add timestamp $item["pubdate"] = gmdate("r", $fft_time); #-- prepare for next item in same feed $fft_time -= 60 * 60 * $interval; } #-- modified hash return $item; } ?>