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,
51 // info arg allows multiple columns
52 // info=mtime,hits,summary,version,author,locked,minor,markup or all
53 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
54 // sortby: [+|-] pagename|mtime|hits
58 * @param string $argstr
59 * @param WikiRequest $request
60 * @param string $basepage
63 function run($dbi, $argstr, &$request, $basepage)
65 $args = $this->getArgs($argstr, $request);
67 if (empty($args['sortby'])) {
68 $args['sortby'] = 'pagename';
72 // Todo: extend given _GET args
73 $caption = _("All pages in this wiki (%d total):");
75 if (!empty($args['userpages'])) {
76 $pages = PageList::allUserPages($args['include_empty'], $args['sortby'], '');
77 $caption = _("List of user-created pages (%d total):");
78 $args['count'] = count($pages);
79 } elseif (!empty($args['owner'])) {
80 $pages = PageList::allPagesByOwner($args['owner'], $args['include_empty'], $args['sortby'], '');
81 $args['count'] = count($pages);
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 } elseif (!empty($args['author'])) {
88 $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'], $args['sortby'], '');
89 $args['count'] = count($pages);
90 $caption = fmt("List of pages last edited by %s (%d total):",
91 WikiLink($args['author'] == '[]'
92 ? $request->_user->getAuthenticatedId()
94 'if_known'), $args['count']);
95 } elseif (!empty($args['creator'])) {
96 $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'], $args['sortby'], '');
97 $args['count'] = count($pages);
98 $caption = fmt("List of pages created by %s (%d total):",
99 WikiLink($args['creator'] == '[]'
100 ? $request->_user->getAuthenticatedId()
102 'if_known'), $args['count']);
104 $args['count'] = count($pages);
106 if (!$request->getArg('count'))
107 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
109 $args['count'] = $request->getArg('count');
111 if (empty($args['count']) and !empty($pages)) {
112 $args['count'] = count($pages);
114 $pagelist = new PageList($args['info'], $args['exclude'], $args);
115 if (!$args['noheader']) {
116 $pagelist->setCaption($caption);
119 if ($pages !== false)
120 $pagelist->addPageList($pages);
122 $pagelist->addPages($dbi->getAllPages($args['include_empty'], $args['sortby'],
132 // c-hanging-comment-ender-p: nil
133 // indent-tabs-mode: nil