]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/TitleSearch.php
Code cleanup:
[SourceForge/phpwiki.git] / lib / plugin / TitleSearch.php
1 <?php // -*-php-*-
2 rcs_id('$Id: TitleSearch.php,v 1.17 2003-01-18 22:08:01 carstenklapp Exp $');
3 /**
4  Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
5
6  This file is part of PhpWiki.
7
8  PhpWiki is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12
13  PhpWiki is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with PhpWiki; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 require_once('lib/TextSearchQuery.php');
24 require_once('lib/PageList.php');
25 /**
26  */
27 class WikiPlugin_TitleSearch
28 extends WikiPlugin
29 {
30     function getName () {
31         return _("TitleSearch");
32     }
33
34     function getDescription () {
35         return _("Search the titles of all pages in this wiki.");
36     }
37
38     function getVersion() {
39         return preg_replace("/[Revision: $]/", '',
40                             "\$Revision: 1.17 $");
41     }
42
43     function getDefaultArguments() {
44         return array('s'             => false,
45                      'auto_redirect' => false,
46                      'noheader'      => false,
47                      'exclude'       => '',
48                      'info'          => false
49                      );
50     }
51     // info arg allows multiple columns
52     // info=mtime,hits,summary,version,author,locked,minor
53     // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
54
55     function run($dbi, $argstr, $request) {
56         $args = $this->getArgs($argstr, $request);
57         if (empty($args['s']))
58             return '';
59
60         extract($args);
61
62         $query = new TextSearchQuery($s);
63         $pages = $dbi->titleSearch($query);
64
65         $pagelist = new PageList($info, $exclude);
66         if (!$noheader)
67             $pagelist->setCaption(fmt("Title search results for '%s'", $s));
68
69         while ($page = $pages->next()) {
70             $pagelist->addPage($page);
71             $last_name = $page->getName();
72         }
73
74         if ($auto_redirect && ($pagelist->getTotal() == 1))
75             $request->redirect(WikiURL($last_name, false, 'absurl'));
76
77         return $pagelist;
78     }
79 };
80
81 // $Log: not supported by cvs2svn $
82
83 // Local Variables:
84 // mode: php
85 // tab-width: 8
86 // c-basic-offset: 4
87 // c-hanging-comment-ender-p: nil
88 // indent-tabs-mode: nil
89 // End:
90 ?>