From 43343cbcd554c584eb9637087b8151aefed962d6 Mon Sep 17 00:00:00 2001 From: rurban Date: Sat, 19 Jun 2010 20:16:19 +0000 Subject: [PATCH] Exact Title Search fails with blank page patch 3018192 by Sebastien Le Callonnec plus some more fixes to enable the redirect. whitespace fixes git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@7551 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/PageList.php | 7 +++++++ lib/plugin/TitleSearch.php | 30 +++++++++--------------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/lib/PageList.php b/lib/PageList.php index d5735f2a8..8db35d0c6 100644 --- a/lib/PageList.php +++ b/lib/PageList.php @@ -904,6 +904,13 @@ class PageList { return false; } + function first() { + if (count($this->_pages) > 0) { + return $this->_pages[0]; + } + return false; + } + function getContent() { // Note that the element wants inline content. $caption = $this->getCaption(); diff --git a/lib/plugin/TitleSearch.php b/lib/plugin/TitleSearch.php index dc780c5e0..d0c0d725d 100644 --- a/lib/plugin/TitleSearch.php +++ b/lib/plugin/TitleSearch.php @@ -1,7 +1,7 @@ is enough. - * Fancier Inputforms can be made using WikiForm Rich, to support regex and case_exact args. + * Provides no own input box, just <> is enough. + * Fancier Inputforms can be made using <> to support regex and case_exact args. * * If only one pages is found and auto_redirect is true, this page is displayed immediatly, * otherwise the found pagelist is displayed. @@ -58,8 +58,8 @@ extends WikiPlugin 'exclude' => false, 'info' => false, 'case_exact' => false, - 'regex' => 'auto', - 'format' => false, + 'regex' => 'auto', + 'format' => false, )); } // info arg allows multiple columns @@ -79,18 +79,7 @@ extends WikiPlugin $pagelist = new PageList($args['info'], $args['exclude'], $args); $pagelist->addPages($pages); - // this hack will go away - if ($args['format'] == 'livesearch') { - $request->discardOutput(); - $request->buffer_output(false); - echo '
'; - echo $pagelist->asXml(); - echo '
'; - if (empty($WikiTheme->DUMP_MODE)) { - unset($GLOBALS['ErrorManager']->_postponed_errors); - $request->finish(); - } - } + // Provide an unknown WikiWord link to allow for page creation // when a search returns no results if (!$args['noheader']) { @@ -100,16 +89,15 @@ extends WikiPlugin $s = WikiLink($args['s'], 'auto'); } if ($total) { - $pagelist->setCaption(fmt("Title search results for '%s' (%d total)", $s, $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)) { - $page = $pages->next(); - return HTML($request->redirect(WikiURL($page->getName(), false, 'absurl'), false), - $pagelist); + $page = $pagelist->first(); + $request->redirect(WikiURL($page->getName(), false, 'absurl'), false); } return $pagelist; -- 2.45.0