From 394243c4f94b9590bd0e89c27aeaa2d911a651b0 Mon Sep 17 00:00:00 2001 From: rurban Date: Sat, 25 Aug 2007 18:55:01 +0000 Subject: [PATCH] fix TextSearch paging git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@5904 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/WikiDB/backend/dumb/TextSearchIter.php | 13 +++++++---- lib/plugin/TitleSearch.php | 25 ++++++++++++++-------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/lib/WikiDB/backend/dumb/TextSearchIter.php b/lib/WikiDB/backend/dumb/TextSearchIter.php index e4e3b3a6b..493294d12 100644 --- a/lib/WikiDB/backend/dumb/TextSearchIter.php +++ b/lib/WikiDB/backend/dumb/TextSearchIter.php @@ -1,5 +1,5 @@ _pages; while ($page = $pages->next()) { - if (($this->_from > 0) and ($this->_index < $this->_from)) - continue; if ($score = $this->_match($page)) { $this->_index++; - if ($this->_count and ($this->_index >= $this->_count)) return false; + if (($this->_from > 0) and ($this->_index <= $this->_from)) + // not yet reached the offset + continue; + /*if ($this->_count and ($this->_index > $this->_count)) { + // reached the limit, but need getTotal + $this->_count++; + return false; + }*/ if (is_array($page)) $page['score'] = $score; else diff --git a/lib/plugin/TitleSearch.php b/lib/plugin/TitleSearch.php index 05f87892e..cf843796b 100644 --- a/lib/plugin/TitleSearch.php +++ b/lib/plugin/TitleSearch.php @@ -1,5 +1,5 @@ titleSearch($query,$args['sortby'],$args['limit'],$args['exclude']); $pagelist = new PageList($args['info'], $args['exclude'], $args); - while ($page = $pages->next()) { - $pagelist->addPage($page); - $last_name = $page->getName(); - } + $pagelist->addPages($pages); // this hack will go away if ($args['format'] == 'livesearch') { $request->discardOutput(); @@ -99,13 +96,20 @@ extends WikiPlugin // when a search returns no results if (!$args['noheader']) { $s = $args['s']; - if (!$pagelist->getTotal() and !$query->_regex) + $total = $pagelist->getTotal(); + if (!$total and !$query->_regex) { $s = WikiLink($args['s'], 'auto'); - $pagelist->setCaption(fmt("Title search results for '%s'", $s)); + } + if ($total) { + $pagelist->setCaption(fmt("Title search results for '%s' (%d total)", $s, $total)); + } else { + $pagelist->setCaption(fmt("Title search results for '%s'", $s)); + } } if ($args['auto_redirect'] && ($pagelist->getTotal() == 1)) { - return HTML($request->redirect(WikiURL($last_name, false, 'absurl'), false), + $page = $pages->next(); + return HTML($request->redirect(WikiURL($page->getName(), false, 'absurl'), false), $pagelist); } @@ -114,6 +118,9 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.29 2007/01/02 13:23:30 rurban +// note to deprecate livesearch hack +// // Revision 1.28 2005/09/10 21:33:08 rurban // support enhanced API // -- 2.45.0