]> git.mjollnir.org Git - s9y.git/commitdiff
The archive sidebar plugin shiped with s9y now displays numbers of articles correctly...
authorbrockhaus <brockhaus>
Fri, 13 Jul 2007 12:05:22 +0000 (12:05 +0000)
committerbrockhaus <brockhaus>
Fri, 13 Jul 2007 12:05:22 +0000 (12:05 +0000)
docs/NEWS
include/functions_entries.inc.php
include/plugin_internal.inc.php

index 2b808dcda481bf2a4469670fdc91837c9180bf6c..9f6801f071ba808457050d441f4f239ccaa9f623 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,10 @@
 Version 1.3 ()
 ------------------------------------------------------------------------
 
+       * The archive sidebar plugin shiped with s9y now displays numbers
+         of articles correctly for month, catergories and so on, even
+         if multicategory articles are used. (brockhaus)
+
     * Trackbacks to links without a description now get properly
       evaluated. (brockhaus)
 
index 673f5c14c2078d0ba1276dfe21757e68f4e343d5..b61ae711ebcb2b7866dc812cc77893f39bdf76d7 100644 (file)
@@ -206,7 +206,7 @@ function &serendipity_fetchEntryCategories($entryid) {
  * @param   string      If set to "array", the array of entries will be returned. "flat-array" will only return the articles without their entryproperties. "single" will only return a 1-dimensional array. "query" will only return the used SQL.
  * @return  array       Holds the super-array of all entries with all additional information
  */
-function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fetchDrafts = false, $modified_since = false, $orderby = 'timestamp DESC', $filter_sql = '', $noCache = false, $noSticky = false, $select_key = null, $group_by = null, $returncode = 'array') {
+function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fetchDrafts = false, $modified_since = false, $orderby = 'timestamp DESC', $filter_sql = '', $noCache = false, $noSticky = false, $select_key = null, $group_by = null, $returncode = 'array',$joinauthors = true, $joincategories =true) {
     global $serendipity;
 
     $cond = array();
@@ -376,13 +376,18 @@ function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fe
     // Store the unique query condition for entries for later reference, like getting the total article count.
     $serendipity['fullCountQuery'] = "
                 FROM
-                    {$serendipity['dbPrefix']}entries AS e
+                    {$serendipity['dbPrefix']}entries AS e";
+    if ($joinauthors)
+        $serendipity['fullCountQuery'] .="
                     LEFT JOIN {$serendipity['dbPrefix']}authors a
-                        ON e.authorid = a.authorid
+                        ON e.authorid = a.authorid";
+    if ($joincategories)
+        $serendipity['fullCountQuery'] .="
                     LEFT JOIN {$serendipity['dbPrefix']}entrycat ec
                         ON e.id = ec.entryid
                     LEFT JOIN {$serendipity['dbPrefix']}category c
-                        ON ec.categoryid = c.categoryid
+                        ON ec.categoryid = c.categoryid";
+    $serendipity['fullCountQuery'] .="
                     {$cond['joins']}
                     {$cond['and']}";
 
index 2f0a9628eff390d7f09b1d741a51cdc47255838c..e0e6585d55d590d42646b10dafe3627218057e26 100644 (file)
@@ -400,7 +400,7 @@ class serendipity_archives_plugin extends serendipity_plugin {
         $propbag->add('stackable',     true);
         $propbag->add('author',        'Serendipity Team');
         $propbag->add('version',       '1.0');
-        $propbag->add('configuration', array('title', 'frequency', 'count', 'show_count'));
+        $propbag->add('configuration', array('title', 'frequency', 'count', 'show_count','hide_zero_count'));
         $propbag->add('groups',        array('FRONTEND_VIEWS'));
     }
 
@@ -436,6 +436,13 @@ class serendipity_archives_plugin extends serendipity_plugin {
                 $propbag->add('default',     false);
                 break;
 
+            case 'hide_zero_count':
+                $propbag->add('type',        'boolean');
+                $propbag->add('name',        CATEGORY_PLUGIN_HIDEZEROCOUNT);
+                $propbag->add('description', '');
+                $propbag->add('default',     false);
+                break;
+
             default:
                 return false;
         }
@@ -451,15 +458,18 @@ class serendipity_archives_plugin extends serendipity_plugin {
         $ts = mktime(0, 0, 0, date('m'), 1);
 
         $add_query = '';
-        if (isset($serendipity['GET']['category'])) {
+        
+        $category_set = isset($serendipity['GET']['category']);
+        if ($category_set) {
             $base_query   = 'C' . (int)$serendipity['GET']['category'];
             $add_query    = '/' . $base_query;
         }
 
         $max_x = $this->get_config('count', 3);
         $show_count = serendipity_db_bool($this->get_config('show_count', false));
+        $hide_zero_count = serendipity_db_bool($this->get_config('hide_zero_count', false));
         $freq = $this->get_config('frequency', 'months');
-
+        
         for($x = 0; $x < $max_x; $x++) {
             $current_ts = $ts;
             switch($freq) {
@@ -515,6 +525,7 @@ class serendipity_archives_plugin extends serendipity_plugin {
             $link = serendipity_rewriteURL(PATH_ARCHIVES . '/' . $linkStamp . $add_query . '.html', 'serendipityHTTPPath');
 
             $html_count = '';
+            $hidden_by_zero_count = false;
             if ($show_count) {
                 switch($freq) {
                     case 'months':
@@ -540,18 +551,21 @@ class serendipity_archives_plugin extends serendipity_plugin {
                     true,
                     'count(e.id) AS orderkey',
                     '',
-                    'single'
+                    'single',
+                    false, $category_set // the joins used
                 );
 
                 if (is_array($ec)) {
                     if (empty($ec['orderkey'])) {
                         $ec['orderkey'] = '0';
                     }
+                    $hidden_by_zero_count = $hide_zero_count && ( $ec['orderkey'] == '0'); 
                     $html_count .= ' (' . $ec['orderkey'] . ')';
                 }
             }
 
-            echo '<a href="' . $link . '" title="' . $ts_title . '">' . $ts_title . $html_count . '</a><br />' . "\n";
+            if (!$hidden_by_zero_count)
+                echo '<a href="' . $link . '" title="' . $ts_title . '">' . $ts_title . $html_count . '</a><br />' . "\n";
 
         }