2 rcs_id('$Id: TitleSearch.php,v 1.12 2002-01-30 22:47:31 carstenklapp Exp $');
4 require_once('lib/TextSearchQuery.php');
5 require_once('lib/PageList.php');
9 class WikiPlugin_TitleSearch
13 return _("TitleSearch");
16 function getDescription () {
17 return _("Title Search");
20 function getDefaultArguments() {
21 return array('s' => false,
22 'auto_redirect' => false,
26 'pagename' => '[pagename]', // hackish
30 // info arg allows multiple columns info=mtime,hits,summary,version,author,locked,minor
31 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
33 function run($dbi, $argstr, $request) {
34 $args = $this->getArgs($argstr, $request);
35 if (empty($args['s']))
40 $query = new TextSearchQuery($s);
41 $pages = $dbi->titleSearch($query);
43 $pagelist = new PageList();
44 $this->_init($pagename, &$pagelist, $info, $exclude, $include_self);
46 while ($page = $pages->next()) {
47 $pagelist->addPage($page);
48 // if (!$pagelist->page_excluded($page->getName())); // not necessary
49 $last_name = $page->getName();
52 if ($auto_redirect && ($pagelist->getTotal() == 1))
53 $request->redirect(WikiURL($last_name));
56 $pagelist->setCaption(fmt("Title search results for '%s'", $s));
61 function _init(&$page, &$pagelist, $info = '', $exclude = '', $include_self = '') {
63 foreach (explode(",", $info) as $col)
64 $pagelist->insertColumn($col);
67 foreach (explode(",", $exclude) as $excludepage)
68 $pagelist->excludePageName($excludepage);
70 $pagelist->excludePageName($page);
79 // c-hanging-comment-ender-p: nil
80 // indent-tabs-mode: nil