1
0

Make plugins be able to emit custom RSS feeds, see http://board.s9y.org/viewtopic.php?p=53320#53320

This commit is contained in:
Garvin Hicking
2007-04-01 11:55:46 +00:00
parent 44953ecea7
commit 30ccea2f96
3 changed files with 29 additions and 15 deletions

View File

@ -3,6 +3,10 @@
Version 1.2 ()
------------------------------------------------------------------------
* Make plugins be able to emit their own RSS-Feeds using
$eventData['template_file'] on the 'frontend_rss' event hook
(garvinhicking)
* Fix missing %username% permalink pattern in single entry view.
Patch by cress_cc
@ -11,7 +15,7 @@ Version 1.2 ()
* Show current captcha look in the plugin configuration menu
(garvinhicking)
* Add new category property to hide blog postings made into sub-
categories from the frontend view, per category. Thanks to
netmorix from the forums! (garvinhicking)

View File

@ -50,12 +50,12 @@ if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
$r = serendipity_db_query("SELECT categoryid FROM {$serendipity['dbPrefix']}category c
WHERE c.categoryid = ". (int)$parentid ."
AND c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange((int)$serendipity['GET']['cid'])));
if ( is_array($r) ) {
if (is_array($r)) {
$r = serendipity_db_query("SELECT category_name FROM {$serendipity['dbPrefix']}category
WHERE categoryid = ". (int)$parentid);
echo sprintf(ALREADY_SUBCATEGORY, htmlspecialchars($r[0]['category_name']), htmlspecialchars($name));
} else {
serendipity_updateCategory($serendipity['GET']['cid'], $name, $desc, $authorid, $icon, $parentid);
serendipity_updateCategory($serendipity['GET']['cid'], $name, $desc, $authorid, $icon, $parentid, $serendipity['POST']['cat']['sort_order'], $serendipity['POST']['cat']['hide_sub']);
serendipity_ACLGrant($serendipity['GET']['cid'], 'category', 'read', $serendipity['POST']['cat']['read_authors']);
serendipity_ACLGrant($serendipity['GET']['cid'], 'category', 'write', $serendipity['POST']['cat']['write_authors']);
echo '<div class="serendipityAdminMsgSuccess">'. CATEGORY_SAVED .'</div>';
@ -234,6 +234,15 @@ if ($serendipity['GET']['adminAction'] == 'doDelete' && serendipity_checkFormTok
</select>
</td>
</tr>
<tr>
<td><?php echo CATEGORY_HIDE_SUB ?><br /><em><?php echo CATEGORY_HIDE_SUB_DESC; ?></em></td>
<td valign="top">
<input type="radio" name="serendipity[cat][hide_sub]" value="0" <?php echo ($this_cat['hide_sub'] == 0 ? 'checked="checked"' : ''); ?> id="hide_sub_no" /> <label for="hide_sub_no"><?php echo NO; ?></label>
<input type="radio" name="serendipity[cat][hide_sub]" value="1" <?php echo ($this_cat['hide_sub'] == 1 ? 'checked="checked"' : ''); ?> id="hide_sub_yes" /> <label for="hide_sub_yes"><?php echo YES; ?></label>
</td>
</tr>
<?php serendipity_plugin_api::hook_event('backend_category_showForm', $cid, $this_cat); ?>
</table>
<div><input type="submit" name="SAVE" value="<?php echo $save; ?>" class="serendipityPrettyButton" /></div>

25
rss.php
View File

@ -30,7 +30,7 @@ if (!isset($_GET['type'])) {
}
if (!empty($_SERVER['HTTP_USER_AGENT']) && stristr($_SERVER['HTTP_USER_AGENT'], 'feedburner')) {
$_GET['nocache'] = true;
$_GET['nocache'] = true;
}
$serendipity['view'] = 'feed';
@ -164,10 +164,10 @@ if (is_array($plugins)) {
}
}
if ($_GET['type'] == 'content' &&
!isset($_GET['category']) &&
!isset($serendipity['GET']['tag']) &&
$plugin->get_config('show_feedburner') === 'force' &&
if ($_GET['type'] == 'content' &&
!isset($_GET['category']) &&
!isset($serendipity['GET']['tag']) &&
$plugin->get_config('show_feedburner') === 'force' &&
!preg_match('@FeedBurn@i', $_SERVER['HTTP_USER_AGENT']) &&
!(serendipity_userLoggedIn() && isset($_GET['forceLocal']))
) {
@ -181,9 +181,16 @@ if (is_array($plugins)) {
}
}
$file_version = preg_replace('@[^0-9a-z\.-_]@i', '', $version);
$metadata['template_file'] = serendipity_getTemplateFile('feed_' . $file_version . '.tpl', 'serendipityPath');
serendipity_smarty_init();
serendipity_plugin_api::hook_event('frontend_rss', $metadata);
if (!$metadata['template_file'] || $metadata['template_file'] == 'feed_' . $file_version . '.tpl') {
die("Invalid RSS version specified or RSS-template file not found\n");
}
$self_url = 'http://' . $_SERVER['HTTP_HOST'] . htmlspecialchars($_SERVER['REQUEST_URI']);
if (!is_array($entries)) {
$entries = array();
@ -195,12 +202,6 @@ if ($entries[0]['last_modified']) {
$gm_modified = gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour());
}
$file_version = preg_replace('@[^0-9a-z\.-_]@i', '', $version);
$template_file = serendipity_getTemplateFile('feed_' . $file_version . '.tpl', 'serendipityPath');
if (!$template_file) {
die("Invalid RSS version specified\n");
}
serendipity_printEntries_rss($entries, $version, $comments, $metadata['fullFeed'], $metadata['showMail']);
$namespace_hook = 'frontend_display:unknown:namespace';
@ -252,6 +253,6 @@ $serendipity['smarty']->assign(
'self_url' => $self_url,
)
);
$serendipity['smarty']->display($template_file);
$serendipity['smarty']->display($metadata['template_file']);
/* vim: set sts=4 ts=4 expandtab : */