]> git.mjollnir.org Git - s9y.git/commitdiff
Pimp the entryproperties plugin to allow hiding the content of certain RSS entries...
authorgarvinhicking <garvinhicking>
Fri, 30 Sep 2005 13:17:51 +0000 (13:17 +0000)
committergarvinhicking <garvinhicking>
Fri, 30 Sep 2005 13:17:51 +0000 (13:17 +0000)
I won't propagate this one as I don't like reading such feeds. *g*

docs/NEWS
include/functions_rss.inc.php
plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php

index ec40222f5bc0d8bfa32f3815910706e6fb2d2df1..6fa27516651095c290a0d43d3a391daadb62d357 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 0.9-beta2 ()
 ------------------------------------------------------------------------
 
+    * Enhance entryproperties plugin so that single entries can hide
+      their content from the RSS feeds. (garvinhicking)
+
     * Fix using the "realname" of the author in entry preview instead of
       username. Also fix printing category info when no category was
       assigned. Thanks to Manuel Charisius! (garvinhicking)
index b295123c2ac0a19be1d0af29651f62b5d161451d..49ce94cced0b07c93e3b32c42705b55472690c16 100644 (file)
@@ -5,6 +5,14 @@
 function serendipity_printEntries_rss($entries, $version, $comments = false, $fullFeed = false, $showMail = true) {\r
     global $serendipity;\r
 \r
+    $options = array(\r
+        'version'  => $version,\r
+        'comments' => $comments,\r
+        'fullFeed' => $fullFeed,\r
+        'showMail' => $showMail\r
+    );\r
+    serendipity_plugin_api::hook_event('frontend_entries_rss', $entries, $options);\r
+\r
     if (is_array($entries)) {\r
         foreach ($entries as $entry) {\r
             $id   = (isset($entry['entryid']) && !empty($entry['entryid']) ? $entry['entryid'] : $entry['id']);\r
@@ -18,6 +26,7 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fu
             // Embed a link to extended entry, if existing\r
             if ($fullFeed) {\r
                 $entry['body'] .= ' ' . $entry['extended'];\r
+                $ext = '';\r
             } elseif ($entry['exflag']) {\r
                 $ext = '<br /><a href="' . $guid . '#extended">' . sprintf(VIEW_EXTENDED_ENTRY, htmlspecialchars($entry['title'])) . '</a>';\r
             } else {\r
@@ -70,6 +79,7 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fu
 \r
     <id><?php echo $guid; ?></id>\r
     <title mode="escaped" type="text/html"><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>\r
+<?php               if (!empty($entry['body'])) { ?>\r
     <content type="application/xhtml+xml" xml:base="<?php echo $serendipity['baseURL']; ?>">\r
         <div xmlns="http://www.w3.org/1999/xhtml">\r
 <?php\r
@@ -78,6 +88,7 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fu
         </div>\r
     </content>\r
 <?php\r
+                    }\r
                     $entry['display_dat'] = '';\r
                     serendipity_plugin_api::hook_event('frontend_display:atom-0.3:per_entry', $entry);\r
                     echo $entry['display_dat'];\r
@@ -114,6 +125,7 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fu
 ?>\r
     <id><?php echo $guid; ?></id>\r
     <title type="html"><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>\r
+<?php               if (!empty($entry['body'])) { ?>\r
     <content type="xhtml" xml:base="<?php echo $serendipity['baseURL']; ?>">\r
         <div xmlns="http://www.w3.org/1999/xhtml">\r
 <?php\r
@@ -122,6 +134,7 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fu
         </div>\r
     </content>\r
 <?php\r
+                    }\r
                     $entry['display_dat'] = '';\r
                     serendipity_plugin_api::hook_event('frontend_display:atom-1.0:per_entry', $entry);\r
                     echo $entry['display_dat'];\r
@@ -155,11 +168,15 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fu
                     }\r
 ?>\r
     <author><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['author'])) . ')'; ?></author>\r
+<?php               if (!empty($entry['body'])) { ?>\r
     <content:encoded>\r
 <?php\r
-                    echo serendipity_utf8_encode(htmlspecialchars($entry['body'].$ext));\r
+                        echo serendipity_utf8_encode(htmlspecialchars($entry['body'].$ext));\r
 ?>\r
     </content:encoded>\r
+<?php\r
+                    }\r
+?>                \r
     <pubDate><?php echo date('r', serendipity_serverOffsetHour($entry['timestamp'])); ?></pubDate>\r
     <guid isPermaLink="false"><?php echo $guid; ?></guid>\r
     <?php\r
@@ -172,10 +189,14 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fu
                     /*********** END 2.0 FEED EXTRAS *************/\r
                 } else {\r
                     /*********** BEGIN RSS 0.91 FEED EXTRAS *************/\r
+                    if (!empty($entry['body'])) { ?>\r
 ?>\r
     <description>\r
         <?php echo serendipity_utf8_encode(htmlspecialchars($entry['body'] . $ext)); ?>\r
     </description>\r
+<?php\r
+                    }\r
+?>\r
 </item>\r
 <?php\r
                     /*********** END RSS 0.91 FEED EXTRAS *************/\r
@@ -190,16 +211,19 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fu
 <item rdf:about="<?php echo $guid; ?>">\r
     <title><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>\r
     <link><?php echo $entryLink; ?></link>\r
+<?php           if (!empty($entry['body'])) { ?>\r
     <description>\r
 <?php\r
                 echo serendipity_utf8_encode(htmlspecialchars($entry['body'].$ext));\r
 ?>\r
     </description>\r
-    <?php\r
-      $entry['display_dat'] = '';\r
-      serendipity_plugin_api::hook_event('frontend_display:rss-1.0:per_entry', $entry);\r
-      echo $entry['display_dat'];\r
-    ?>\r
+<?php\r
+                }\r
+\r
+                $entry['display_dat'] = '';\r
+                serendipity_plugin_api::hook_event('frontend_display:rss-1.0:per_entry', $entry);\r
+                echo $entry['display_dat'];\r
+?>\r
     <dc:publisher><?php echo serendipity_utf8_encode(htmlspecialchars($serendipity['blogTitle'])); ?></dc:publisher>\r
     <dc:creator><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['author'])) . ')'; ?></dc:creator>\r
     <dc:subject><?php echo serendipity_utf8_encode(htmlspecialchars(implode(', ', $categories))); ?></dc:subject>\r
index 505bb702d05ee28be4f55ec9c80b72bca97b88cd..99dfd9cce700b667265740b5aeddc8350a838fd8 100644 (file)
@@ -29,6 +29,8 @@ if (file_exists($probelang)) {
 @define('PLUGIN_EVENT_ENTRYPROPERTIES_GROUPS_DESC', 'If enabled, you can define which users of a usergroup may be able to read entries. This option has a large impact on the performance of your article overview. Only enable this if you are really going to use this feature.');
 @define('PLUGIN_EVENT_ENTRYPROPERTIES_USERS', 'Use user-based restrictions');
 @define('PLUGIN_EVENT_ENTRYPROPERTIES_USERS_DESC', 'If enabled, you can define which specific users may be able to read entries. This option has a large impact on the performance of your article overview. Only enable this if you are really going to use this feature.');
+@define('PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS', 'Hide content in RSS');
+@define('PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS_DESC', 'If enabled, the content of this entry will not be shown inside the RSS feed(s).');
 
 class serendipity_event_entryproperties extends serendipity_event
 {
@@ -63,7 +65,8 @@ class serendipity_event_entryproperties extends serendipity_event
             'backend_cache_entries'                             => true,
             'backend_cache_purge'                               => true,
             'backend_plugins_new_instance'                      => true,
-            'frontend_entryproperties_query'                    => true
+            'frontend_entryproperties_query'                    => true,
+            'frontend_entries_rss'                              => true
         ));
         $propbag->add('groups', array('BACKEND_EDITOR'));
         $propbag->add('configuration', array('cache', 'use_groups', 'use_users', 'default_read'));
@@ -146,7 +149,7 @@ class serendipity_event_entryproperties extends serendipity_event
     }
 
     function getSupportedProperties() {
-        static $supported_properties = array('is_sticky', 'access', 'access_groups', 'access_users', 'cache_body', 'cache_extended', 'no_nl2br', 'no_frontpage');
+        static $supported_properties = array('is_sticky', 'access', 'access_groups', 'access_users', 'cache_body', 'cache_extended', 'no_nl2br', 'no_frontpage', 'hiderss');
 
         return $supported_properties;
     }
@@ -214,6 +217,11 @@ class serendipity_event_entryproperties extends serendipity_event
                                ? 'checked="checked"'
                                : '';
 
+                    $hiderss      =     (isset($eventData['properties']['ep_hiderss']) && serendipity_db_bool($eventData['properties']['ep_hiderss']))
+                                 || (isset($serendipity['POST']['properties']['hiderss']) && serendipity_db_bool($serendipity['POST']['properties']['hiderss']))
+                               ? 'checked="checked"'
+                               : '';
+
                     $access_values = array(
                         PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS_PRIVATE => 'private',
                         PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS_PUBLIC  => 'public',
@@ -255,7 +263,9 @@ class serendipity_event_entryproperties extends serendipity_event
                                 <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NL2BR; ?>" for="properties_no_nl2br">&nbsp;<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NL2BR; ?>&nbsp;&nbsp;</label><br />
 
 <?php } ?>
-                            
+                            <input type="checkbox" name="serendipity[properties][hiderss]" id="properties_hiderss" value="true" <?php echo $hiderss; ?> />
+                                <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS_DESC; ?>" for="properties_hiderss">&nbsp;<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS; ?>&nbsp;&nbsp;</label><br />
+
                             <br />
                             <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS; ?>:<br />
                             <div style="margin-left: 10px">
@@ -585,6 +595,19 @@ class serendipity_event_entryproperties extends serendipity_event
                     return true;
                     break;
 
+                case 'frontend_entries_rss':
+                    if (is_array($eventData)) {
+                        foreach($eventData AS $idx => $entry) {
+                            if (is_array($entry['properties']) && isset($entry['properties']['ep_hiderss']) && $entry['properties']['ep_hiderss']) {
+                                unset($eventData[$idx]['body']);
+                                unset($eventData[$idx]['extended']);
+                                unset($eventData[$idx]['exflag']);
+                            }
+                        }
+                    }
+                    return true;
+                    break;
+
                 case 'backend_plugins_new_instance':
                     // This hook will always push the entryproperties plugin as last in queue.
                     // Happens always when a new plugin is added.