]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllPages.php
paging support
[SourceForge/phpwiki.git] / lib / plugin / AllPages.php
1 <?php // -*-php-*-
2 rcs_id('$Id: AllPages.php,v 1.21 2004-04-20 00:06:53 rurban 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.21 $");
41     }
42
43     function getDefaultArguments() {
44         return array('noheader'      => false,
45                      'include_empty' => false,
46                      'exclude'       => '',
47                      'info'          => '',
48                      'sortby'        => 'pagename',   // +mtime,-pagename
49                      'limit'         => 0,
50                      'paging'        => 'auto',
51                      'debug'         => false
52                      );
53     }
54     // info arg allows multiple columns
55     // info=mtime,hits,summary,version,author,locked,minor,markup or all
56     // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
57     // sortby: [+|-] pagename|mtime|hits
58
59     function run($dbi, $argstr, &$request, $basepage) {
60         $args = $this->getArgs($argstr, $request);
61         extract($args);
62         // Todo: extend given _GET args
63         if ($sorted = $request->getArg('sortby'))
64             $sortby = $sorted;
65         elseif ($sortby)
66             $request->setArg('sortby',$sortby);
67
68         if (! $request->getArg('count'))  $args['count'] = $dbi->numPages(false,$exclude);
69         else $args['count'] = $request->getArg('count');
70         $pagelist = new PageList($info, $exclude, $args);
71         //if (!$sortby) $sorted='pagename';
72         if (!$noheader)
73             $pagelist->setCaption(_("Pages in this wiki (%d total):"));
74
75         // deleted pages show up as version 0.
76         if ($include_empty)
77             $pagelist->_addColumn('version');
78
79         //if (defined('DEBUG') and DEBUG) $debug = true;
80         if ($debug)
81             $timer = new DebugTimer;
82         $pagelist->addPages( $dbi->getAllPages($include_empty, $sortby, $limit) );
83         if ($debug) {
84             return HTML($pagelist,
85                         HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
86         } else {
87             return $pagelist;
88         }
89     }
90
91     function getmicrotime(){
92         list($usec, $sec) = explode(" ",microtime());
93         return (float)$usec + (float)$sec;
94     }
95 };
96
97 // $Log: not supported by cvs2svn $
98 // Revision 1.20  2004/02/22 23:20:33  rurban
99 // fixed DumpHtmlToDir,
100 // enhanced sortby handling in PageList
101 //   new button_heading th style (enabled),
102 // added sortby and limit support to the db backends and plugins
103 //   for paging support (<<prev, next>> links on long lists)
104 //
105 // Revision 1.19  2004/02/17 12:11:36  rurban
106 // added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...)
107 //
108 // Revision 1.18  2004/01/25 07:58:30  rurban
109 // PageList sortby support in PearDB and ADODB backends
110 //
111 // Revision 1.17  2003/02/27 20:10:30  dairiki
112 // Disable profiling output when DEBUG is defined but false.
113 //
114 // Revision 1.16  2003/02/21 04:08:26  dairiki
115 // New class DebugTimer in prepend.php to help report timing.
116 //
117 // Revision 1.15  2003/01/18 21:19:25  carstenklapp
118 // Code cleanup:
119 // Reformatting; added copyleft, getVersion, getDescription
120 //
121
122 // Local Variables:
123 // mode: php
124 // tab-width: 8
125 // c-basic-offset: 4
126 // c-hanging-comment-ender-p: nil
127 // indent-tabs-mode: nil
128 // End:
129 ?>