]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/TitleSearch.php
Reverting back to old version, WikiPlugin already has arg named 'formsize'.
[SourceForge/phpwiki.git] / lib / plugin / TitleSearch.php
1 <?php // -*-php-*-
2 rcs_id('$Id: TitleSearch.php,v 1.15 2002-02-28 00:46:51 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                      'exclude'          => '',
25                      'info'             => false
26                      );
27     }
28     // info arg allows multiple columns info=mtime,hits,summary,version,author,locked,minor
29     // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
30
31     function run($dbi, $argstr, $request) {
32         $args = $this->getArgs($argstr, $request);
33         if (empty($args['s']))
34             return '';
35
36         extract($args);
37         
38         $query = new TextSearchQuery($s);
39         $pages = $dbi->titleSearch($query);
40
41         $pagelist = new PageList($info, $exclude);
42         if (!$noheader)
43             $pagelist->setCaption(fmt("Title search results for '%s'", $s));
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, false, 'absurl'));
52
53         return $pagelist;
54     }
55 };
56         
57 // Local Variables:
58 // mode: php
59 // tab-width: 8
60 // c-basic-offset: 4
61 // c-hanging-comment-ender-p: nil
62 // indent-tabs-mode: nil
63 // End:   
64 ?>