]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllPages.php
getName should not translate
[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     // 2004-07-08 22:05:35 rurban: turned off &$request to prevent from strange bug below
58     function run($dbi, $argstr, $request, $basepage)
59     {
60         $args = $this->getArgs($argstr, $request);
61
62         $pages = false;
63         // Todo: extend given _GET args
64         if (DEBUG && $args['debug']) {
65             $timer = new DebugTimer;
66         }
67         $caption = _("All pages in this wiki (%d total):");
68
69         if (!empty($args['userpages'])) {
70             $pages = PageList::allUserPages($args['include_empty'],
71                 $args['sortby'], ''
72             );
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'],
77                 $args['sortby'], ''
78             );
79             $args['count'] = $request->getArg('count');
80             if (!$args['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()
85                         : $args['owner'],
86                     'if_known'), $args['count']);
87         } elseif (!empty($args['author'])) {
88             $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'],
89                 $args['sortby'], ''
90             );
91             $args['count'] = $request->getArg('count');
92             if (!$args['count'])
93                 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
94             $caption = fmt("List of pages last edited by [%s] (%d total):",
95                 WikiLink($args['author'] == '[]'
96                         ? $request->_user->getAuthenticatedId()
97                         : $args['author'],
98                     'if_known'), $args['count']);
99         } elseif (!empty($args['creator'])) {
100             $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'],
101                 $args['sortby'], ''
102             );
103             $args['count'] = $request->getArg('count');
104             if (!$args['count'])
105                 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
106             $caption = fmt("List of pages created by [%s] (%d total):",
107                 WikiLink($args['creator'] == '[]'
108                         ? $request->_user->getAuthenticatedId()
109                         : $args['creator'],
110                     'if_known'), $args['count']);
111             //} elseif ($pages) {
112             //    $args['count'] = count($pages);
113         } else {
114             if (!$request->getArg('count'))
115                 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
116             else
117                 $args['count'] = $request->getArg('count');
118         }
119         if (empty($args['count']) and !empty($pages))
120             $args['count'] = count($pages);
121         $pagelist = new PageList($args['info'], $args['exclude'], $args);
122         if (!$args['noheader']) $pagelist->setCaption($caption);
123
124         // deleted pages show up as version 0.
125         //if ($args['include_empty'])
126         //    $pagelist->_addColumn('version');
127
128         if ($pages !== false)
129             $pagelist->addPageList($pages);
130         else
131             $pagelist->addPages($dbi->getAllPages($args['include_empty'], $args['sortby'],
132                 $args['limit']));
133         if (DEBUG && $args['debug']) {
134             return HTML($pagelist,
135                 HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
136         } else {
137             return $pagelist;
138         }
139     }
140 }
141
142 // Local Variables:
143 // mode: php
144 // tab-width: 8
145 // c-basic-offset: 4
146 // c-hanging-comment-ender-p: nil
147 // indent-tabs-mode: nil
148 // End: