]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllPages.php
rcs_id no longer makes sense with Subversion global version number
[SourceForge/phpwiki.git] / lib / plugin / AllPages.php
1 <?php // -*-php-*-
2 // rcs_id('$Id$');
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
19  * along with PhpWiki; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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         return _("AllPages");
35     }
36
37     function getDescription () {
38         return _("List all pages in this wiki.");
39     }
40
41     function getDefaultArguments() {
42         return array_merge
43             (
44              PageList::supportedArgs(),
45              array(
46                    'noheader'      => false,
47                    'include_empty' => false,
48                    //'pages'         => false, // DONT, this would be ListPages then.
49                    'info'          => '',
50                    'debug'         => false,
51                    'userpages'     => false
52                    ));
53     }
54
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
59
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);
63
64         $pages = false;
65         // Todo: extend given _GET args
66         if (defined('DEBUG') && DEBUG && $args['debug']) {
67             $timer = new DebugTimer;
68         }
69         $caption = _("All pages in this wiki ({total} total):");
70
71         if ( !empty($args['userpages']) ) {
72             $pages = PageList::allUserPages($args['include_empty'],
73                                                $args['sortby'], ''
74                                                );
75             $caption = _("List of user-created pages ({total} total):");
76             $args['count'] = $request->getArg('count');
77         } elseif ( !empty($args['owner']) ) {
78             $pages = PageList::allPagesByOwner($args['owner'], $args['include_empty'],
79                                                $args['sortby'], ''
80                                                );
81             $caption = fmt("List of pages owned by [%s] ({total} total):",
82                            WikiLink($args['owner'] == '[]'
83                                     ? $request->_user->getAuthenticatedId()
84                                     : $args['owner'],
85                                     'if_known'));
86             $args['count'] = $request->getArg('count');
87             $pages->_options['count'] = $args['count'];
88         } elseif ( !empty($args['author']) ) {
89             $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'],
90                                                 $args['sortby'], ''
91                                                 );
92             $caption = fmt("List of pages last edited by [%s] ({total} total):",
93                            WikiLink($args['author'] == '[]'
94                                     ? $request->_user->getAuthenticatedId()
95                                     : $args['author'],
96                                     'if_known'));
97             $args['count'] = $request->getArg('count');
98             $pages->_options['count'] = $args['count'];
99         } elseif ( !empty($args['creator']) ) {
100             $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'],
101                                                  $args['sortby'], ''
102                                                  );
103             $caption = fmt("List of pages created by [%s] ({total} total):",
104                            WikiLink($args['creator'] == '[]'
105                                     ? $request->_user->getAuthenticatedId()
106                                     : $args['creator'],
107                                     'if_known'));
108             $args['count'] = $request->getArg('count');
109             $pages->_options['count'] = $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 (defined('DEBUG') && 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:
148 ?>