]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/TitleSearch.php
Finish conversion to new OO HTML generation scheme.
[SourceForge/phpwiki.git] / lib / plugin / TitleSearch.php
1 <?php // -*-php-*-
2 rcs_id('$Id: TitleSearch.php,v 1.7 2002-01-22 03:17:47 dairiki 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         $args = $this->getArgs($argstr, $request);
28         if (empty($args['s']))
29             return '';
30
31         extract($args);
32         
33         $query = new TextSearchQuery($s);
34         $pages = $dbi->titleSearch($query);
35
36         $pagelist = new PageList();
37 //        $pagelist->insertColumn(_("Hits"));
38 //        $pagelist->addColumn(_("Last Modified"));
39
40         while ($page = $pages->next()) {
41             $pagelist->addPage($page);
42             $last_name = $page->getName();
43         }
44
45         if ($auto_redirect && ($pagelist->getTotal() == 1))
46             $request->redirect(WikiURL($last_name));
47
48         if (!$noheader)
49             $pagelist->setCaption(fmt("Title search results for '%s'", $s));
50
51         return $pagelist;
52     }
53 };
54         
55 // Local Variables:
56 // mode: php
57 // tab-width: 8
58 // c-basic-offset: 4
59 // c-hanging-comment-ender-p: nil
60 // indent-tabs-mode: nil
61 // End:   
62 ?>