4 * Copyright 1999,2000,2001,2002,2004,2005 $ThePhpWikiProgrammingTeam
6 * This file is part of PhpWiki.
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.
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.
18 * You should have received a copy of the GNU General Public License along
19 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 require_once 'lib/PageList.php';
26 * Supports author=[] (current user), owner=[] and creator=[]
27 * to be able to have the action pages:
28 * AllPagesCreatedByMe, AllPagesOwnedByMe, AllPagesLastAuthoredByMe
30 class WikiPlugin_AllPages
33 function getDescription()
35 return _("List all pages in this wiki.");
38 function getDefaultArguments()
42 PageList::supportedArgs(),
45 'include_empty' => false,
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
57 function run($dbi, $argstr, &$request, $basepage)
59 $args = $this->getArgs($argstr, $request);
62 // Todo: extend given _GET args
63 if (DEBUG && $args['debug']) {
64 $timer = new DebugTimer;
66 $caption = _("All pages in this wiki (%d total):");
68 if (!empty($args['userpages'])) {
69 $pages = PageList::allUserPages($args['include_empty'],
72 $caption = _("List of user-created pages (%d total):");
73 $args['count'] = $request->getArg('count');
74 } elseif (!empty($args['owner'])) {
75 $pages = PageList::allPagesByOwner($args['owner'], $args['include_empty'],
78 $args['count'] = $request->getArg('count');
80 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
81 $caption = fmt("List of pages owned by [%s] (%d total):",
82 WikiLink($args['owner'] == '[]'
83 ? $request->_user->getAuthenticatedId()
85 'if_known'), $args['count']);
86 } elseif (!empty($args['author'])) {
87 $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'],
90 $args['count'] = $request->getArg('count');
92 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
93 $caption = fmt("List of pages last edited by [%s] (%d total):",
94 WikiLink($args['author'] == '[]'
95 ? $request->_user->getAuthenticatedId()
97 'if_known'), $args['count']);
98 } elseif (!empty($args['creator'])) {
99 $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'],
102 $args['count'] = $request->getArg('count');
104 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
105 $caption = fmt("List of pages created by [%s] (%d total):",
106 WikiLink($args['creator'] == '[]'
107 ? $request->_user->getAuthenticatedId()
109 'if_known'), $args['count']);
110 //} elseif ($pages) {
111 // $args['count'] = count($pages);
113 if (!$request->getArg('count'))
114 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
116 $args['count'] = $request->getArg('count');
118 if (empty($args['count']) and !empty($pages))
119 $args['count'] = count($pages);
120 $pagelist = new PageList($args['info'], $args['exclude'], $args);
121 if (!$args['noheader']) $pagelist->setCaption($caption);
123 // deleted pages show up as version 0.
124 //if ($args['include_empty'])
125 // $pagelist->_addColumn('version');
127 if ($pages !== false)
128 $pagelist->addPageList($pages);
130 $pagelist->addPages($dbi->getAllPages($args['include_empty'], $args['sortby'],
132 if (DEBUG && $args['debug']) {
133 return HTML($pagelist,
134 HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
145 // c-hanging-comment-ender-p: nil
146 // indent-tabs-mode: nil