Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8714
Modified Files:
serendipity_functions.inc.php NEWS
Log Message:
Pagination now properly works for browsing months and categories.
Previously paging worked through all entries and not a filter by
date/category. [Bug #1009715]
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -d -r1.203 -r1.204
--- NEWS 20 Aug 2004 07:44:36 -0000 1.203
+++ NEWS 20 Aug 2004 10:55:32 -0000 1.204
@@ -3,6 +3,10 @@
Version 0.7 ()
------------------------------------------------------------------------
+ * Pagination now properly works for browsing months and categories.
+ Previously paging worked through all entries and not a filter
+ by date/category. [Bug #1009715] (garvinhicking)
+
* Remote RSS feed can now contain a bullet image, skip blank head-
lines and toggle the display of the date. Thanks to Joseph Guhlin!
(garvinhicking)
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.399
retrieving revision 1.400
diff -u -d -r1.399 -r1.400
--- serendipity_functions.inc.php 19 Aug 2004 20:51:55 -0000 1.399
+++ serendipity_functions.inc.php 20 Aug 2004 10:55:32 -0000 1.400
@@ -743,6 +743,18 @@
$distinct = '';
}
+ // Store the unique query condition for entries for later reference, like getting the total article count.
+ $serendipity['fullCountQuery'] = "
+ FROM
+ {$serendipity['dbPrefix']}entries AS e
+ LEFT JOIN {$serendipity['dbPrefix']}authors a
+ ON e.authorid = a.authorid
+ LEFT JOIN {$serendipity['dbPrefix']}entrycat ec
+ ON e.id = ec.entryid
+ LEFT JOIN {$serendipity['dbPrefix']}category c
+ ON ec.categoryid = c.categoryid
+ $and";
+
$query = "SELECT $distinct
e.id,
e.title,
@@ -760,17 +772,9 @@
a.email
$body
- FROM
- {$serendipity['dbPrefix']}entries AS e
- LEFT JOIN {$serendipity['dbPrefix']}authors a
- ON e.authorid = a.authorid
- LEFT JOIN {$serendipity['dbPrefix']}entrycat ec
- ON e.id = ec.entryid
- LEFT JOIN {$serendipity['dbPrefix']}category c
- ON ec.categoryid = c.categoryid $and
+ {$serendipity['fullCountQuery']}
$group
- ORDER BY
- $orderby
+ ORDER BY $orderby
$limit";
$ret = serendipity_db_query($query);
@@ -1075,9 +1079,8 @@
$add_query = '';
if (is_array($serendipity['GET'])) {
$page_get_array = $serendipity['GET'];
- unset($page_get_array['calendarZoom']);
- unset($page_get_array['page']);
unset($page_get_array['range']);
+ unset($page_get_array['page']);
unset($page_get_array['action']);
unset($page_get_array['adminAction']);
@@ -1086,26 +1089,7 @@
}
}
- if (isset($serendipity['GET']['category'])) {
- $_categoryid = explode('_', $serendipity['GET']['category']);
- $categoryid = serendipity_db_escape_string($_categoryid[0]);
-
- if (is_numeric($categoryid)) {
- $querystring = "SELECT count(e.id)
- FROM {$serendipity['dbPrefix']}entries e,
- {$serendipity['dbPrefix']}entrycat ec,
- {$serendipity['dbPrefix']}category c
- WHERE e.isdraft = 'false'
- AND e.id = ec.entryid AND ec.categoryid = c.categoryid
- AND c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid));
- }
- }
- if (empty($querystring)) {
- $querystring = "SELECT count(e.id)
- FROM {$serendipity['dbPrefix']}entries e
- WHERE e.isdraft = 'false'";
- }
-
+ $querystring = "SELECT count(e.id) {$serendipity['fullCountQuery']}"; // The unique query condition was built previously in serendipity_fetchEntries()
$query = serendipity_db_query($querystring);
$totalEntries = $query[0][0];
|