]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/TitleSearch.php
Converted to use new PageList class.
[SourceForge/phpwiki.git] / lib / plugin / TitleSearch.php
1 <?php // -*-php-*-
2 rcs_id('$Id: TitleSearch.php,v 1.6 2002-01-21 19:14:30 carstenklapp Exp $');
3
4 require_once('lib/TextSearchQuery.php');
5 require_once('lib/PageList.php');
6
7 /**
8  */
9 class WikiPlugin_TitleSearch
10 extends WikiPlugin
11 {
12     function getName () {
13         return _("TitleSearch");
14     }
15
16     function getDescription () {
17         return _("Title Search");
18     }
19     
20     function getDefaultArguments() {
21         return array('s'                => false,
22                      'auto_redirect'    => false,
23                      'noheader'         => false);
24     }
25
26     function run($dbi, $argstr, $request) {
27         global $Theme;
28         
29         $args = $this->getArgs($argstr, $request);
30         if (empty($args['s']))
31             return '';
32
33         extract($args);
34         
35         $query = new TextSearchQuery($s);
36         $pages = $dbi->titleSearch($query);
37
38         $pagelist = new PageList();
39 //        $pagelist->insertColumn(_("Hits"));
40 //        $pagelist->addColumn(_("Last Modified"));
41
42         while ($page = $pages->next()) {
43             $pagelist->addPage($page);
44             $last_name = $page->getName();
45         }
46
47         if ($auto_redirect && ($pagelist->getTotal() == 1))
48             $request->redirect(WikiURL($last_name));
49         if ($pagelist->getTotal() == 0)
50             $list = HTML::blockquote(_("<no matches>"));
51         if ($noheader)
52             return $pagelist->getContent();
53         
54         return array(HTML::p(fmt("Title search results for '%s'", $s)),
55                      $pagelist->getContent());
56     }
57 };
58         
59 // Local Variables:
60 // mode: php
61 // tab-width: 8
62 // c-basic-offset: 4
63 // c-hanging-comment-ender-p: nil
64 // indent-tabs-mode: nil
65 // End:   
66 ?>