From: garvinhicking Date: Fri, 30 Sep 2005 13:17:51 +0000 (+0000) Subject: Pimp the entryproperties plugin to allow hiding the content of certain RSS entries... X-Git-Tag: 0.9~106 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3c461aa122b99e44cd571b3466836eec19915f40;p=s9y.git Pimp the entryproperties plugin to allow hiding the content of certain RSS entries, so that users will go to the link instead. I won't propagate this one as I don't like reading such feeds. *g* --- diff --git a/docs/NEWS b/docs/NEWS index ec40222..6fa2751 100644 --- 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) diff --git a/include/functions_rss.inc.php b/include/functions_rss.inc.php index b295123..49ce94c 100644 --- a/include/functions_rss.inc.php +++ b/include/functions_rss.inc.php @@ -5,6 +5,14 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fullFeed = false, $showMail = true) { global $serendipity; + $options = array( + 'version' => $version, + 'comments' => $comments, + 'fullFeed' => $fullFeed, + 'showMail' => $showMail + ); + serendipity_plugin_api::hook_event('frontend_entries_rss', $entries, $options); + if (is_array($entries)) { foreach ($entries as $entry) { $id = (isset($entry['entryid']) && !empty($entry['entryid']) ? $entry['entryid'] : $entry['id']); @@ -18,6 +26,7 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fu // Embed a link to extended entry, if existing if ($fullFeed) { $entry['body'] .= ' ' . $entry['extended']; + $ext = ''; } elseif ($entry['exflag']) { $ext = '
' . sprintf(VIEW_EXTENDED_ENTRY, htmlspecialchars($entry['title'])) . ''; } else { @@ -70,6 +79,7 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fu <?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?> +
<?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?> +
+ + ?> + "> <?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?> + - + diff --git a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php index 505bb70..99dfd9c 100644 --- a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php +++ b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php @@ -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
- + /> +
+
:
@@ -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.