]> git.mjollnir.org Git - s9y.git/commitdiff
Make plugins be able to emit custom RSS feeds, see http://board.s9y.org/viewtopic...
authorgarvinhicking <garvinhicking>
Sun, 1 Apr 2007 11:55:46 +0000 (11:55 +0000)
committergarvinhicking <garvinhicking>
Sun, 1 Apr 2007 11:55:46 +0000 (11:55 +0000)
docs/NEWS
include/admin/category.inc.php
rss.php

index 32539efa0060ea281842612bb3a6b1ab819faef2..f8e29d0d00401f59f8874779495faaf4dc010dbb 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -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)
index 1cb81ad892dc2c8860c4ae33d6de19c8fcac6a22..e9c25a5b8837502dc0ddf2cfc017cfc74ca44443 100644 (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>
diff --git a/rss.php b/rss.php
index 973fd98e22d4c828c7647a22d06ddfb467bce3f4..83d5db12dce107f57e1ea5727beb5f072fe0899e 100644 (file)
--- a/rss.php
+++ b/rss.php
@@ -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 : */