3 * Copyright 1999,2000,2001,2002,2004,2005 $ThePhpWikiProgrammingTeam
5 * This file is part of PhpWiki.
7 * PhpWiki is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * PhpWiki is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 require_once 'lib/PageList.php';
25 * Supports author=[] (current user), owner=[] and creator=[]
26 * to be able to have the action pages:
27 * AllPagesCreatedByMe, AllPagesOwnedByMe, AllPagesLastAuthoredByMe
29 class WikiPlugin_AllPages
36 function getDescription () {
37 return _("List all pages in this wiki.");
40 function getDefaultArguments() {
43 PageList::supportedArgs(),
46 'include_empty' => false,
53 // info arg allows multiple columns
54 // info=mtime,hits,summary,version,author,locked,minor,markup or all
55 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
56 // sortby: [+|-] pagename|mtime|hits
58 // 2004-07-08 22:05:35 rurban: turned off &$request to prevent from strange bug below
59 function run($dbi, $argstr, $request, $basepage) {
60 $args = $this->getArgs($argstr, $request);
63 // Todo: extend given _GET args
64 if (DEBUG && $args['debug']) {
65 $timer = new DebugTimer;
67 $caption = _("All pages in this wiki (%d total):");
69 if ( !empty($args['userpages']) ) {
70 $pages = PageList::allUserPages($args['include_empty'],
73 $caption = _("List of user-created pages (%d total):");
74 $args['count'] = $request->getArg('count');
75 } elseif ( !empty($args['owner']) ) {
76 $pages = PageList::allPagesByOwner($args['owner'], $args['include_empty'],
79 $args['count'] = $request->getArg('count');
81 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
82 $caption = fmt("List of pages owned by [%s] (%d total):",
83 WikiLink($args['owner'] == '[]'
84 ? $request->_user->getAuthenticatedId()
86 'if_known'), $args['count']);
87 $pages->_options['count'] = $args['count'];
88 } elseif ( !empty($args['author']) ) {
89 $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'],
92 $args['count'] = $request->getArg('count');
94 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
95 $caption = fmt("List of pages last edited by [%s] (%d total):",
96 WikiLink($args['author'] == '[]'
97 ? $request->_user->getAuthenticatedId()
99 'if_known'), $args['count']);
100 $pages->_options['count'] = $args['count'];
101 } elseif ( !empty($args['creator']) ) {
102 $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'],
105 $args['count'] = $request->getArg('count');
107 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
108 $caption = fmt("List of pages created by [%s] (%d total):",
109 WikiLink($args['creator'] == '[]'
110 ? $request->_user->getAuthenticatedId()
112 'if_known'), $args['count']);
113 $pages->_options['count'] = $args['count'];
114 //} elseif ($pages) {
115 // $args['count'] = count($pages);
117 if (! $request->getArg('count'))
118 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
120 $args['count'] = $request->getArg('count');
122 if (empty($args['count']) and !empty($pages))
123 $args['count'] = count($pages);
124 $pagelist = new PageList($args['info'], $args['exclude'], $args);
125 if (!$args['noheader']) $pagelist->setCaption($caption);
127 // deleted pages show up as version 0.
128 //if ($args['include_empty'])
129 // $pagelist->_addColumn('version');
131 if ($pages !== false)
132 $pagelist->addPageList($pages);
134 $pagelist->addPages( $dbi->getAllPages($args['include_empty'], $args['sortby'],
136 if (DEBUG && $args['debug']) {
137 return HTML($pagelist,
138 HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
149 // c-hanging-comment-ender-p: nil
150 // indent-tabs-mode: nil