]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllPages.php
New class DebugTimer in prepend.php to help report timing.
[SourceForge/phpwiki.git] / lib / plugin / AllPages.php
1 <?php // -*-php-*-
2 rcs_id('$Id: AllPages.php,v 1.16 2003-02-21 04:08:26 dairiki 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/PageList.php');
24
25 /**
26  */
27 class WikiPlugin_AllPages
28 extends WikiPlugin
29 {
30     function getName () {
31         return _("AllPages");
32     }
33
34     function getDescription () {
35         return _("List all pages in this wiki.");
36     }
37
38     function getVersion() {
39         return preg_replace("/[Revision: $]/", '',
40                             "\$Revision: 1.16 $");
41     }
42
43     function getDefaultArguments() {
44         return array('noheader'      => false,
45                      'include_empty' => false,
46                      'exclude'       => '',
47                      'info'          => '',
48                      'sortby'        => '',   // +mtime,-pagename
49                      'debug'         => false
50                      );
51     }
52     // info arg allows multiple columns
53     // info=mtime,hits,summary,version,author,locked,minor,markup or all
54     // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
55     // sortby: [+|-] pagename|mtime|hits
56
57     function run($dbi, $argstr, $request) {
58         extract($this->getArgs($argstr, $request));
59         // Todo: extend given _GET args
60         if ($sortby)
61             $request->setArg('sortby',$sortby);
62
63         $pagelist = new PageList($info, $exclude);
64         if (!$noheader)
65             $pagelist->setCaption(_("Pages in this wiki (%d total):"));
66
67         // deleted pages show up as version 0.
68         if ($include_empty)
69             $pagelist->_addColumn('version');
70
71         if (defined('DEBUG'))
72             $debug = true;
73
74         $timer = new DebugTimer;
75
76         $pagelist->addPages( $dbi->getAllPages($include_empty) );
77
78         if ($debug) {
79             return HTML($pagelist,
80                         HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
81         } else {
82             return $pagelist;
83         }
84     }
85
86     function getmicrotime(){
87         list($usec, $sec) = explode(" ",microtime());
88         return (float)$usec + (float)$sec;
89     }
90 };
91
92 // $Log: not supported by cvs2svn $
93 // Revision 1.15  2003/01/18 21:19:25  carstenklapp
94 // Code cleanup:
95 // Reformatting; added copyleft, getVersion, getDescription
96 //
97
98 // Local Variables:
99 // mode: php
100 // tab-width: 8
101 // c-basic-offset: 4
102 // c-hanging-comment-ender-p: nil
103 // indent-tabs-mode: nil
104 // End:
105 ?>