]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/TitleSearch.php
Updated comments for new column version.
[SourceForge/phpwiki.git] / lib / plugin / TitleSearch.php
1 <?php // -*-php-*-
2 rcs_id('$Id: TitleSearch.php,v 1.10 2002-01-27 04:23:26 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                      'info'             => false
25                      );
26     }
27     // info arg allows multiple columns info=mtime,hits,summary,version,author,locked,minor
28
29     function run($dbi, $argstr, $request) {
30         $args = $this->getArgs($argstr, $request);
31         if (empty($args['s']))
32             return '';
33
34         extract($args);
35         
36         $query = new TextSearchQuery($s);
37         $pages = $dbi->titleSearch($query);
38
39         $pagelist = new PageList();
40
41         if ($info)
42             foreach (explode(",", $info) as $col)
43                 $pagelist->insertColumn($col);
44
45         while ($page = $pages->next()) {
46             $pagelist->addPage($page);
47             $last_name = $page->getName();
48         }
49
50         if ($auto_redirect && ($pagelist->getTotal() == 1))
51             $request->redirect(WikiURL($last_name));
52
53         if (!$noheader)
54             $pagelist->setCaption(fmt("Title search results for '%s'", $s));
55
56         return $pagelist;
57     }
58 };
59         
60 // Local Variables:
61 // mode: php
62 // tab-width: 8
63 // c-basic-offset: 4
64 // c-hanging-comment-ender-p: nil
65 // indent-tabs-mode: nil
66 // End:   
67 ?>