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