]> git.mjollnir.org Git - s9y.git/commitdiff
entryproperties option: Hide from frontpage
authorgarvinhicking <garvinhicking>
Wed, 27 Apr 2005 07:48:18 +0000 (07:48 +0000)
committergarvinhicking <garvinhicking>
Wed, 27 Apr 2005 07:48:18 +0000 (07:48 +0000)
docs/NEWS
plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php

index 360ed9b6d3ce2e74601e0268af48d44658cdea10..2eaaaf9bf5d6dd231fb7d1fe9b240b00b85a04c1 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 0.9 ()
 ------------------------------------------------------------------------
 
+    * New entryproperties plugin option: Hide an entry from the frontpage
+      (garvinhicking)
+
     * Fix importers when source database is not the same as the target
       database (garvinhicking)
 
index 670d9f25780ddaa754b9a85cddb91b08fe9b0eed..41d7317cbb8ea34984ca52727338a111cd90615e 100644 (file)
@@ -26,6 +26,7 @@ switch ($serendipity['lang']) {
         @define('PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_ABORTED', 'Caching der Artikel ABGEBROCHEN.');
         @define('PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_TOTAL', ' (insgesamt %d Artikel vorhanden)...');
         @define('PLUGIN_EVENT_ENTRYPROPERTIES_NL2BR', 'Automatischen Zeilenumbruch deaktivieren');
+        @define('PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE', 'Nicht in Artikelübersicht zeigen');
         break;
 
     case 'en':
@@ -49,6 +50,7 @@ switch ($serendipity['lang']) {
         @define('PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_ABORTED', 'Entry caching ABORTED.');
         @define('PLUGIN_EVENT_ENTRYPROPERTIES_CACHE_TOTAL', ' (totalling %d entries)...');
         @define('PLUGIN_EVENT_ENTRYPROPERTIES_NL2BR', 'Disable nl2br');
+        @define('PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE', 'Hide from article overview / frontpage');
         break;
 }
 
@@ -139,7 +141,7 @@ class serendipity_event_entryproperties extends serendipity_event
     }
 
     function getSupportedProperties() {
-        static $supported_properties = array('is_sticky', 'access', 'cache_body', 'cache_extended', 'no_nl2br');
+        static $supported_properties = array('is_sticky', 'access', 'cache_body', 'cache_extended', 'no_nl2br', 'no_frontpage');
 
         return $supported_properties;
     }
@@ -196,6 +198,11 @@ class serendipity_event_entryproperties extends serendipity_event
                                ? 'checked="checked"'
                                : '';
 
+                    $no_frontpage =    (isset($eventData['properties']['ep_no_frontpage']) && serendipity_db_bool($eventData['properties']['ep_no_frontpage']))
+                                 || (isset($serendipity['POST']['properties']['no_frontpage']) && serendipity_db_bool($serendipity['POST']['properties']['no_frontpage']))
+                               ? 'checked="checked"'
+                               : '';
+
                     $access_values = array(
                         PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS_PRIVATE => 'private',
                         PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS_MEMBER  => 'member',
@@ -214,6 +221,8 @@ class serendipity_event_entryproperties extends serendipity_event
                         <legend><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_TITLE; ?></legend>
                             <input type="checkbox" name="serendipity[properties][is_sticky]" id="properties_is_sticky" value="true" <?php echo $is_sticky; ?> />
                                 <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_STICKYPOSTS; ?>" for="properties_is_sticky">&nbsp;<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_STICKYPOSTS; ?>&nbsp;&nbsp;</label><br />
+                            <input type="checkbox" name="serendipity[properties][no_frontpage]" id="properties_no_frontpage" value="true" <?php echo $no_frontpage; ?> />
+                                <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE; ?>" for="properties_no_frontpage">&nbsp;<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE; ?>&nbsp;&nbsp;</label><br />
 <?php if (class_exists('serendipity_event_nl2br')){ ?>
                             <input type="checkbox" name="serendipity[properties][no_nl2br]" id="properties_no_nl2br" value="true" <?php echo $nl2br; ?> />
                                 <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NL2BR; ?>" for="properties_no_nl2br">&nbsp;<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NL2BR; ?>&nbsp;&nbsp;</label><br />
@@ -375,6 +384,7 @@ class serendipity_event_entryproperties extends serendipity_event
 
                 case 'frontend_fetchentries':
                 case 'frontend_fetchentry':
+                    $joins = array();
                     $conds = array();
                     if ($_SESSION['serendipityAuthedUser'] === true) {
                         $conds[] = " (ep_access.property IS NULL OR ep_access.value = 'member' OR ep_access.value = 'public' OR (ep_access.value = 'private' AND e.authorid = " . (int)$serendipity['authorid'] . ")) ";
@@ -382,6 +392,12 @@ class serendipity_event_entryproperties extends serendipity_event
                         $conds[] = " (ep_access.property IS NULL OR ep_access.value = 'public') ";
                     }
 
+                    if (!isset($serendipity['GET']['category']) && $event == 'frontend_fetchentries') {
+                        $conds[] = " (ep_no_frontpage.property IS NULL OR ep_no_frontpage.value != 'true') ";
+                        $joins[] = "LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_no_frontpage
+                                                 ON (e.id = ep_no_frontpage.entryid AND ep_no_frontpage.property = 'ep_no_frontpage')";
+                    }
+
                     if (count($conds) > 0) {
                         $cond = implode(' AND ', $conds);
                         if (empty($eventData['and'])) {
@@ -402,7 +418,7 @@ class serendipity_event_entryproperties extends serendipity_event
                         $conds[] = 'ep_cache_extended.value AS ep_cache_extended,';
                         $conds[] = 'ep_cache_body.value     AS ep_cache_body,';
                     }
-
+                    
                     $cond = implode("\n", $conds);
                     if (empty($eventData['addkey'])) {
                         $eventData['addkey'] = $cond;
@@ -417,7 +433,6 @@ class serendipity_event_entryproperties extends serendipity_event
                         $eventData['orderby'] = $cond . ', ' . $eventData['orderby'];
                     }
 
-                    $joins = array();
                     if ($is_cache && (!isset($addData['noCache']) || !$addData['noCache'])) {
                         $joins[] = "LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_cache_extended
                                                  ON (e.id = ep_cache_extended.entryid AND ep_cache_extended.property = 'ep_cache_extended')";