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