]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllPages.php
Remove wiki warning
[SourceForge/phpwiki.git] / lib / plugin / AllPages.php
1 <?php
2
3 /**
4  * Copyright 1999,2000,2001,2002,2004,2005 $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 along
19  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 require_once 'lib/PageList.php';
24
25 /**
26  * Supports author=[] (current user), owner=[] and creator=[]
27  * to be able to have the action pages:
28  *   AllPagesCreatedByMe, AllPagesOwnedByMe, AllPagesLastAuthoredByMe
29  */
30 class WikiPlugin_AllPages
31     extends WikiPlugin
32 {
33     function getName()
34     {
35         return _("AllPages");
36     }
37
38     function getDescription()
39     {
40         return _("List all pages in this wiki.");
41     }
42
43     function getDefaultArguments()
44     {
45         return array_merge
46         (
47             PageList::supportedArgs(),
48             array(
49                 'noheader' => false,
50                 'include_empty' => false,
51                 'info' => '',
52                 'debug' => false,
53                 'userpages' => false
54             ));
55     }
56
57     // info arg allows multiple columns
58     // info=mtime,hits,summary,version,author,locked,minor,markup or all
59     // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
60     // sortby: [+|-] pagename|mtime|hits
61
62     // 2004-07-08 22:05:35 rurban: turned off &$request to prevent from strange bug below
63     function run($dbi, $argstr, $request, $basepage)
64     {
65         $args = $this->getArgs($argstr, $request);
66
67         $pages = false;
68         // Todo: extend given _GET args
69         if (DEBUG && $args['debug']) {
70             $timer = new DebugTimer;
71         }
72         $caption = _("All pages in this wiki (%d total):");
73
74         if (!empty($args['userpages'])) {
75             $pages = PageList::allUserPages($args['include_empty'],
76                 $args['sortby'], ''
77             );
78             $caption = _("List of user-created pages (%d total):");
79             $args['count'] = $request->getArg('count');
80         } elseif (!empty($args['owner'])) {
81             $pages = PageList::allPagesByOwner($args['owner'], $args['include_empty'],
82                 $args['sortby'], ''
83             );
84             $args['count'] = $request->getArg('count');
85             if (!$args['count'])
86                 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
87             $caption = fmt("List of pages owned by [%s] (%d total):",
88                 WikiLink($args['owner'] == '[]'
89                         ? $request->_user->getAuthenticatedId()
90                         : $args['owner'],
91                     'if_known'), $args['count']);
92         } elseif (!empty($args['author'])) {
93             $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'],
94                 $args['sortby'], ''
95             );
96             $args['count'] = $request->getArg('count');
97             if (!$args['count'])
98                 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
99             $caption = fmt("List of pages last edited by [%s] (%d total):",
100                 WikiLink($args['author'] == '[]'
101                         ? $request->_user->getAuthenticatedId()
102                         : $args['author'],
103                     'if_known'), $args['count']);
104         } elseif (!empty($args['creator'])) {
105             $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'],
106                 $args['sortby'], ''
107             );
108             $args['count'] = $request->getArg('count');
109             if (!$args['count'])
110                 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
111             $caption = fmt("List of pages created by [%s] (%d total):",
112                 WikiLink($args['creator'] == '[]'
113                         ? $request->_user->getAuthenticatedId()
114                         : $args['creator'],
115                     'if_known'), $args['count']);
116             //} elseif ($pages) {
117             //    $args['count'] = count($pages);
118         } else {
119             if (!$request->getArg('count'))
120                 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
121             else
122                 $args['count'] = $request->getArg('count');
123         }
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);
128
129         // deleted pages show up as version 0.
130         //if ($args['include_empty'])
131         //    $pagelist->_addColumn('version');
132
133         if ($pages !== false)
134             $pagelist->addPageList($pages);
135         else
136             $pagelist->addPages($dbi->getAllPages($args['include_empty'], $args['sortby'],
137                 $args['limit']));
138         if (DEBUG && $args['debug']) {
139             return HTML($pagelist,
140                 HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
141         } else {
142             return $pagelist;
143         }
144     }
145 }
146
147 // Local Variables:
148 // mode: php
149 // tab-width: 8
150 // c-basic-offset: 4
151 // c-hanging-comment-ender-p: nil
152 // indent-tabs-mode: nil
153 // End: