From d6c7b08fbeab979bd1f363b8d15c6dfe8de6e96c Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Fri, 14 Jul 2006 11:14:51 +0000 Subject: [PATCH] Add new view "archive by authors" --- docs/NEWS | 5 +++++ include/functions_entries.inc.php | 14 +++++++++++--- index.php | 9 +++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index c147f69..7885682 100644 --- 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) diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php index 148a73d..1e5a940 100644 --- a/include/functions_entries.inc.php +++ b/include/functions_entries.inc.php @@ -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; } diff --git a/index.php b/index.php index 166ef83..85ea8af 100644 --- 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]); } } -- 2.39.5