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
19 * along with PhpWiki; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
37 function getDescription () {
38 return _("List all pages in this wiki.");
41 function getDefaultArguments() {
44 PageList::supportedArgs(),
47 'include_empty' => true, // is faster
48 //'pages' => false, // DONT, this would be ListPages then.
55 // info arg allows multiple columns
56 // info=mtime,hits,summary,version,author,locked,minor,markup or all
57 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
58 // sortby: [+|-] pagename|mtime|hits
60 // 2004-07-08 22:05:35 rurban: turned off &$request to prevent from strange bug below
61 function run($dbi, $argstr, $request, $basepage) {
62 $args = $this->getArgs($argstr, $request);
65 // Todo: extend given _GET args
66 if (DEBUG && $args['debug']) {
67 $timer = new DebugTimer;
69 $caption = _("All pages in this wiki (%d total):");
70 $exclude_empty_pagename = array('');
72 if ( !empty($args['userpages']) ) {
73 $pages = PageList::allUserPages($args['include_empty'],
75 $exclude_empty_pagename);
76 $caption = _("List of user-created pages (%d total):");
77 $args['count'] = $request->getArg('count');
78 } elseif ( !empty($args['owner']) ) {
79 $pages = PageList::allPagesByOwner($args['owner'], $args['include_empty'],
81 $exclude_empty_pagename);
82 $args['count'] = $request->getArg('count');
84 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
85 $caption = fmt("List of pages owned by [%s] (%d total):",
86 WikiLink($args['owner'] == '[]'
87 ? $request->_user->getAuthenticatedId()
89 'if_known'), $args['count']);
90 $pages->_options['count'] = $args['count'];
91 } elseif ( !empty($args['author']) ) {
92 $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'],
94 $exclude_empty_pagename);
95 $args['count'] = $request->getArg('count');
97 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
98 $caption = fmt("List of pages last edited by [%s] (%d total):",
99 WikiLink($args['author'] == '[]'
100 ? $request->_user->getAuthenticatedId()
102 'if_known'), $args['count']);
103 $pages->_options['count'] = $args['count'];
104 } elseif ( !empty($args['creator']) ) {
105 $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'],
107 $exclude_empty_pagename
109 $args['count'] = $request->getArg('count');
111 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
112 $caption = fmt("List of pages created by [%s] (%d total):",
113 WikiLink($args['creator'] == '[]'
114 ? $request->_user->getAuthenticatedId()
116 'if_known'), $args['count']);
117 $pages->_options['count'] = $args['count'];
119 if (! $request->getArg('count'))
120 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
122 $args['count'] = $request->getArg('count');
124 if (empty($args['count']) and !empty($pages))
125 $args['count'] = count($pages);
126 $pagelist = new PageList($args['info'], $args['exclude'], $args);
127 if (!$args['noheader']) $pagelist->setCaption($caption);
129 if ($pages !== false) {
130 $pagelist->addPageList($pages);
133 // Clear count as previous value was for non-empty pages.
134 $pagelist->clearArg('count');
135 $pagelist->addPages($dbi->getAllPages($args['include_empty'],
138 $exclude_empty_pagename));
140 if (DEBUG && $args['debug']) {
141 return HTML($pagelist,
142 HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
153 // c-hanging-comment-ender-p: nil
154 // indent-tabs-mode: nil