]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllPages.php
Same signature for all functions run
[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 getDescription()
34     {
35         return _("List all pages in this wiki.");
36     }
37
38     function getDefaultArguments()
39     {
40         return array_merge
41         (
42             PageList::supportedArgs(),
43             array(
44                 'noheader' => false,
45                 'include_empty' => false,
46                 'info' => '',
47                 'debug' => false,
48                 'userpages' => false
49             ));
50     }
51
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
56
57     function run($dbi, $argstr, &$request, $basepage)
58     {
59         $args = $this->getArgs($argstr, $request);
60
61         $pages = false;
62         // Todo: extend given _GET args
63         if (DEBUG && $args['debug']) {
64             $timer = new DebugTimer;
65         }
66         $caption = _("All pages in this wiki (%d total):");
67
68         if (!empty($args['userpages'])) {
69             $pages = PageList::allUserPages($args['include_empty'],
70                 $args['sortby'], ''
71             );
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'],
76                 $args['sortby'], ''
77             );
78             $args['count'] = $request->getArg('count');
79             if (!$args['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()
84                         : $args['owner'],
85                     'if_known'), $args['count']);
86         } elseif (!empty($args['author'])) {
87             $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'],
88                 $args['sortby'], ''
89             );
90             $args['count'] = $request->getArg('count');
91             if (!$args['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()
96                         : $args['author'],
97                     'if_known'), $args['count']);
98         } elseif (!empty($args['creator'])) {
99             $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'],
100                 $args['sortby'], ''
101             );
102             $args['count'] = $request->getArg('count');
103             if (!$args['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()
108                         : $args['creator'],
109                     'if_known'), $args['count']);
110             //} elseif ($pages) {
111             //    $args['count'] = count($pages);
112         } else {
113             if (!$request->getArg('count'))
114                 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
115             else
116                 $args['count'] = $request->getArg('count');
117         }
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);
122
123         // deleted pages show up as version 0.
124         //if ($args['include_empty'])
125         //    $pagelist->_addColumn('version');
126
127         if ($pages !== false)
128             $pagelist->addPageList($pages);
129         else
130             $pagelist->addPages($dbi->getAllPages($args['include_empty'], $args['sortby'],
131                 $args['limit']));
132         if (DEBUG && $args['debug']) {
133             return HTML($pagelist,
134                 HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
135         } else {
136             return $pagelist;
137         }
138     }
139 }
140
141 // Local Variables:
142 // mode: php
143 // tab-width: 8
144 // c-basic-offset: 4
145 // c-hanging-comment-ender-p: nil
146 // indent-tabs-mode: nil
147 // End: