]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllPages.php
empty list of pages if user=[] and not authenticated.
[SourceForge/phpwiki.git] / lib / plugin / AllPages.php
1 <?php // -*-php-*-
2 rcs_id('$Id: AllPages.php,v 1.24 2004-06-13 16:02:12 rurban Exp $');
3 /**
4  Copyright 1999, 2000, 2001, 2002, 2004 $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  * TODO: support author=[] (current user) and owner, creator
27  * to be able to have pages: 
28  * AllPagesCreatedByMe, AllPagesOwnedByMe, AllPagesLastAuthoredByMe
29  */
30 class WikiPlugin_AllPages
31 extends WikiPlugin
32 {
33     function getName () {
34         return _("AllPages");
35     }
36
37     function getDescription () {
38         return _("List all pages in this wiki.");
39     }
40
41     function getVersion() {
42         return preg_replace("/[Revision: $]/", '',
43                             "\$Revision: 1.24 $");
44     }
45
46     function getDefaultArguments() {
47         return array('noheader'      => false,
48                      'include_empty' => false,
49                      /* select pages by meta-data: */
50                      'author'   => false, // current user with '[]'
51                      'owner'    => false, // current user with '[]'
52                      'creator'  => false, // current user with '[]'
53                      'exclude'       => '',
54                      'info'          => '',
55                      'sortby'        => 'pagename',   // +mtime,-pagename
56                      'limit'         => 0,
57                      'paging'        => 'auto',
58                      'debug'         => false
59                      );
60     }
61     // info arg allows multiple columns
62     // info=mtime,hits,summary,version,author,locked,minor,markup or all
63     // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
64     // sortby: [+|-] pagename|mtime|hits
65
66     function run($dbi, $argstr, &$request, $basepage) {
67         $args = $this->getArgs($argstr, $request);
68         extract($args);
69         // Todo: extend given _GET args
70         if ($sorted = $request->getArg('sortby'))
71             $sortby = $sorted;
72         elseif ($sortby)
73             $request->setArg('sortby',$sortby);
74
75         if ($debug)
76             $timer = new DebugTimer;
77         if ( !empty($args['owner']) )
78             $pages = PageList::allPagesByOwner($args['owner'],$include_empty,$args['sortby'],$args['limit']);
79         elseif ( !empty($args['author']) )
80             $pages = PageList::allPagesByAuthor($args['author'],$include_empty,$args['sortby'],$args['limit']);
81         elseif ( !empty($args['creator']) ) {
82             $pages = PageList::allPagesByCreator($args['creator'],$include_empty,$args['sortby'],$args['limit']);
83         } else {
84             if (! $request->getArg('count'))  $args['count'] = $dbi->numPages(false,$exclude);
85             else $args['count'] = $request->getArg('count');
86         }
87         if (empty($args['count']) and is_array($pages))
88             $args['count'] = count($pages);
89         $pagelist = new PageList($info, $exclude, $args);
90         //if (!$sortby) $sorted='pagename';
91         if (!$noheader) {
92             if (!is_array($pages))
93                 $pagelist->setCaption(_("All pages in this wiki (%d total):"));
94             else
95                 $pagelist->setCaption(_("List of pages (%d total):"));
96         }
97
98         // deleted pages show up as version 0.
99         if ($include_empty)
100             $pagelist->_addColumn('version');
101
102         if (is_array($pages))
103             $pagelist->addPageList($pages);
104         else
105             $pagelist->addPages( $dbi->getAllPages($include_empty, $sortby, $limit) );
106         if ($debug) {
107             return HTML($pagelist,
108                         HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
109         } else {
110             return $pagelist;
111         }
112     }
113
114     function getmicrotime(){
115         list($usec, $sec) = explode(" ",microtime());
116         return (float)$usec + (float)$sec;
117     }
118 };
119
120 // $Log: not supported by cvs2svn $
121 // Revision 1.23  2004/06/13 15:51:37  rurban
122 // Support pagelist filter for current author,owner,creator by []
123 //
124 // Revision 1.22  2004/06/13 15:33:20  rurban
125 // new support for arguments owner, author, creator in most relevant
126 // PageList plugins. in WikiAdmin* via preSelectS()
127 //
128 // Revision 1.21  2004/04/20 00:06:53  rurban
129 // paging support
130 //
131 // Revision 1.20  2004/02/22 23:20:33  rurban
132 // fixed DumpHtmlToDir,
133 // enhanced sortby handling in PageList
134 //   new button_heading th style (enabled),
135 // added sortby and limit support to the db backends and plugins
136 //   for paging support (<<prev, next>> links on long lists)
137 //
138 // Revision 1.19  2004/02/17 12:11:36  rurban
139 // 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, ...)
140 //
141 // Revision 1.18  2004/01/25 07:58:30  rurban
142 // PageList sortby support in PearDB and ADODB backends
143 //
144 // Revision 1.17  2003/02/27 20:10:30  dairiki
145 // Disable profiling output when DEBUG is defined but false.
146 //
147 // Revision 1.16  2003/02/21 04:08:26  dairiki
148 // New class DebugTimer in prepend.php to help report timing.
149 //
150 // Revision 1.15  2003/01/18 21:19:25  carstenklapp
151 // Code cleanup:
152 // Reformatting; added copyleft, getVersion, getDescription
153 //
154
155 // Local Variables:
156 // mode: php
157 // tab-width: 8
158 // c-basic-offset: 4
159 // c-hanging-comment-ender-p: nil
160 // indent-tabs-mode: nil
161 // End:
162 ?>