Update of /cvsroot/php-blog/serendipity/include
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16871/include
Modified Files:
functions_entries.inc.php functions_installer.inc.php
Log Message:
* Allow pagination for searched entries
* Pretty URLs for search: http://blog/search/SEARCHTERM and
http://blog/search/SEARCHTERM/Pn.html for succeeding pages
- Requires version bump to work with mod_rewrite (not done yet, waiting
for Tom)
- Done in a BC compatible way
- Needed to adjust RegExp for parsing uriArguments variable, because
"%" and "+" signs need to be allowed to search for Umlauts etc.
Please check if that may break things (don't know of any)
Index: functions_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions_installer.inc.php,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- functions_installer.inc.php 2 Jan 2005 16:10:58 -0000 1.24
+++ functions_installer.inc.php 10 Jan 2005 13:12:56 -0000 1.25
@@ -592,7 +592,8 @@
'{PAT_CATEGORIES}', '{PATH_CATEGORIES}',
'{PAT_PLUGIN}', '{PATH_PLUGIN}',
'{PAT_DELETE}', '{PATH_DELETE}',
- '{PAT_APPROVE}', '{PATH_APPROVE}'
+ '{PAT_APPROVE}', '{PATH_APPROVE}',
+ '{PAT_SEARCH}', '{PATH_SEARCH}',
),
array(
@@ -609,7 +610,8 @@
trim(PAT_CATEGORIES, '@/i'), PATH_CATEGORIES,
trim(PAT_PLUGIN, '@/i'), PATH_PLUGIN,
trim(PAT_DELETE, '@/i'), PATH_DELETE,
- trim(PAT_APPROVE, '@/i'), PATH_APPROVE
+ trim(PAT_APPROVE, '@/i'), PATH_APPROVE,
+ trim(PAT_SEARCH, '@/i'), PATH_SEARCH
),
implode('', $a)
Index: functions_entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions_entries.inc.php,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- functions_entries.inc.php 10 Jan 2005 12:22:51 -0000 1.41
+++ functions_entries.inc.php 10 Jan 2005 13:12:55 -0000 1.42
@@ -407,9 +407,19 @@
/**
* Give it a raw searchstring, it'll search
**/
-function serendipity_searchEntries($term) {
+function serendipity_searchEntries($term, $limit = '') {
global $serendipity;
+ if ($limit == '') {
+ $limit = $serendipity['fetchLimit'];
+ }
+
+ if (isset($serendipity['GET']['page']) && $serendipity['GET']['page'] > 1 && !strstr($limit, ',')) {
+ $limit = serendipity_db_limit(($serendipity['GET']['page']-1) * $limit, $limit);
+ }
+
+ $limit = serendipity_db_limit_sql($limit);
+
$term = serendipity_db_escape_string($term);
if (strtolower($serendipity['dbType']) == 'postgres') {
$group = '';
@@ -424,6 +434,19 @@
$cond = array();
$cond['and'] = " AND isdraft = 'false' " . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . time() : '');
serendipity_plugin_api::hook_event('frontend_fetchentries', $cond);
+
+ $serendipity['fullCountQuery'] = "
+ FROM
+ {$serendipity['dbPrefix']}entries e
+ LEFT JOIN {$serendipity['dbPrefix']}authors a
+ ON e.authorid = a.authorid
+ LEFT JOIN {$serendipity['dbPrefix']}entrycat ec
+ ON e.id = ec.entryid
+ {$cond['joins']}
+ WHERE
+ $find_part
+ {$cond['and']}";
+
$querystring = "SELECT $distinct
e.id,
e.author,
@@ -437,20 +460,11 @@
e.extended,
e.trackbacks,
e.exflag
- FROM
- {$serendipity['dbPrefix']}entries e
- LEFT JOIN {$serendipity['dbPrefix']}authors a
- ON e.authorid = a.authorid
- LEFT JOIN {$serendipity['dbPrefix']}entrycat ec
- ON e.id = ec.entryid
- {$cond['joins']}
- WHERE
- $find_part
- {$cond['and']}
+ {$serendipity['fullCountQuery']}
$group
- ORDER BY timestamp DESC";
+ ORDER BY timestamp DESC
+ $limit";
- $serendipity['hidefooter'] = true;
$search = serendipity_db_query($querystring);
return $search;
}
|