Add new view "archive by authors"
authorgarvinhicking <garvinhicking>
Fri, 14 Jul 2006 11:14:51 +0000 (11:14 +0000)
committergarvinhicking <garvinhicking>
Fri, 14 Jul 2006 11:14:51 +0000 (11:14 +0000)
docs/NEWS
include/functions_entries.inc.php
index.php

index c147f6925e8e47b34340407465d521c8d9198a60..7885682383792c4a25f7bbfe815fb160ae98c8a5 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,11 @@
 Version 1.1-alpha7()
 ------------------------------------------------------------------------
 
+    * Add new frontend view "Archive by Authors": /archive/Axx.html to
+      view the archive listing for specific authors only (like viewing
+      archive by specific categories only via /archive/Cxx.html etc.)
+      (garvinhicking)
+
     * Templating: Add new {$entry.html_title} variable that holds
       unescaped HTML code of the Entry's title (garvinhicking)
 
index 148a73d97db3fe6890d89d4783ea6c880388dd10..1e5a940c7e8a0565c23d5fb03bd0313b86cb63ae 100644 (file)
@@ -1350,6 +1350,7 @@ function serendipity_updateEntryCategories($postid, $categories) {
  *
  * The archives are created according to the current timestamp and show the current year.
  * $serendipity['GET']['category'] is honoured like in serendipity_fetchEntries()
+ * $serendipity['GET']['viewAuthor'] is honoured like in serendipity_fetchEntries()
  *
  * @access public
  * @return null
@@ -1384,6 +1385,12 @@ function serendipity_printArchives() {
         $cat_get = '';
     }
 
+    if (isset($serendipity['GET']['viewAuthor'])) {
+        $author_get = '/A' . (int)$serendipity['GET']['viewAuthor'];
+    } else {
+        $author_get = '';
+    }
+
     $output = array();
     for ($y = $thisYear; $y >= $lastYear; $y--) {
         $output[$y]['year'] = $y;
@@ -1422,7 +1429,8 @@ function serendipity_printArchives() {
                                                 AND timestamp >= $s
                                                 AND timestamp <= $e "
                                                     . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . time() : '')
-                                                    . (!empty($cat_sql) ? ' AND ' . $cat_sql : '') . "
+                                                    . (!empty($cat_sql) ? ' AND ' . $cat_sql : '')
+                                                    . (!empty($serendipity['GET']['viewAuthor']) ? ' AND e.authorid = ' . (int)$serendipity['GET']['viewAuthor'] : '') . "
                                            GROUP BY ec.entryid", false, 'assoc');
             if (is_array($entries)) {
                 $entry_count = count($entries);
@@ -1437,8 +1445,8 @@ function serendipity_printArchives() {
 
             $data = array();
             $data['entry_count']    = $entry_count;
-            $data['link']           = serendipity_archiveDateUrl($y . '/'. sprintf('%02s', $m) . $cat_get);
-            $data['link_summary']   = serendipity_archiveDateUrl($y . '/'. sprintf('%02s', $m) . $cat_get, true);
+            $data['link']           = serendipity_archiveDateUrl($y . '/'. sprintf('%02s', $m) . $cat_get . $author_get);
+            $data['link_summary']   = serendipity_archiveDateUrl($y . '/'. sprintf('%02s', $m) . $cat_get . $author_get, true);
             $data['date']           = $s;
             $output[$y]['months'][] = $data;
         }
index 166ef83f5411d43840a4f6383cfcd25dfaf2a21b..85ea8afeec363317f2d31b89abb6281eb77b39a6 100644 (file)
--- a/index.php
+++ b/index.php
@@ -93,6 +93,9 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
                 $serendipity['GET']['category'] = $cat;
                 unset($_args[$k]);
             }
+        } elseif ($v{0} == 'A') { /* Author */
+            $serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)substr($v, 1);
+            unset($_args[$k]);
         } elseif ($v{0} == 'W') { /* Week */
             $week = substr($v, 1);
             if (is_numeric($week)) {
@@ -334,6 +337,9 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
                 $serendipity['GET']['category'] = $cat;
                 unset($_args[$k]);
             }
+        } elseif ($v{0} == 'A') { /* Author */
+            $serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)substr($v, 1);
+            unset($_args[$k]);
         }
     }
 
@@ -372,6 +378,9 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
                 unset($_args[$k]);
                 unset($serendipity['uriArguments'][$k]);
             }
+        } elseif ($v{0} == 'A') { /* Author */
+            $serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)substr($v, 1);
+            unset($_args[$k]);
         }
     }