2 rcs_id('$Id: AllPages.php,v 1.28 2004-07-08 20:30:07 rurban Exp $');
4 Copyright 1999, 2000, 2001, 2002, 2004 $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
19 along with PhpWiki; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 require_once('lib/PageList.php');
26 * DONE: support author=[] (current user) and owner, creator
27 * to be able to have pages:
28 * AllPagesCreatedByMe, AllPagesOwnedByMe, AllPagesLastAuthoredByMe
30 class WikiPlugin_AllPages
37 function getDescription () {
38 return _("List all pages in this wiki.");
41 function getVersion() {
42 return preg_replace("/[Revision: $]/", '',
43 "\$Revision: 1.28 $");
46 function getDefaultArguments() {
49 PageList::supportedArgs(),
52 'include_empty' => false,
58 // info arg allows multiple columns
59 // info=mtime,hits,summary,version,author,locked,minor,markup or all
60 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
61 // sortby: [+|-] pagename|mtime|hits
63 // 2004-07-08 22:05:35 rurban: turned off &$request to prevent from strange bug below
64 function run($dbi, $argstr, &$request, $basepage) {
65 $args = $this->getArgs($argstr, $request);
66 // very strange php reference bug: dbi gets destroyed at array_merge with defaults
67 if (!is_object($dbi)) $dbi = $request->getDbh();
68 if (!is_object($request->_dbi)) {
69 trigger_error("strange php reference bug destroyed request->_dbi", E_USER_WARNING);
73 // Todo: extend given _GET args
74 if ($sorted = $request->getArg('sortby'))
75 $args['sortby'] = $sorted;
76 elseif (!empty($args['sortby']))
77 $request->setArg('sortby',$args['sortby']);
80 $timer = new DebugTimer;
81 if ( !empty($args['owner']) )
82 $pages = PageList::allPagesByOwner($args['owner'],$args['include_empty'],$args['sortby'],$args['limit']);
83 elseif ( !empty($args['author']) )
84 $pages = PageList::allPagesByAuthor($args['author'],$args['include_empty'],$args['sortby'],$args['limit']);
85 elseif ( !empty($args['creator']) ) {
86 $pages = PageList::allPagesByCreator($args['creator'],$args['include_empty'],$args['sortby'],$args['limit']);
88 if (! $request->getArg('count')) $args['count'] = $dbi->numPages(false,$args['exclude']);
89 else $args['count'] = $request->getArg('count');
90 $args['pages'] = false;
92 if (empty($args['count']) and is_array($args['pages']))
93 $args['count'] = count($args['pages']);
94 $pagelist = new PageList($args['info'], $args['exclude'], $args);
95 //if (!$sortby) $sorted='pagename';
96 if (!$args['noheader']) {
97 if (!is_array($args['pages']))
98 $pagelist->setCaption(_("All pages in this wiki (%d total):"));
100 $pagelist->setCaption(_("List of pages (%d total):"));
103 // deleted pages show up as version 0.
104 if ($args['include_empty'])
105 $pagelist->_addColumn('version');
107 if (is_array($args['pages']))
108 $pagelist->addPageList($args['pages']);
110 $pagelist->addPages( $dbi->getAllPages($args['include_empty'], $args['sortby'], $args['limit']) );
111 if ($args['debug']) {
112 return HTML($pagelist,
113 HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
119 function getmicrotime(){
120 list($usec, $sec) = explode(" ",microtime());
121 return (float)$usec + (float)$sec;
125 // $Log: not supported by cvs2svn $
126 // Revision 1.27 2004/07/08 17:31:43 rurban
127 // improve numPages for file (fixing AllPagesTest)
129 // Revision 1.26 2004/06/21 16:22:32 rurban
130 // add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps,
131 // fixed dumping buttons locally (images/buttons/),
132 // support pages arg for dumphtml,
133 // optional directory arg for dumpserial + dumphtml,
134 // fix a AllPages warning,
135 // show dump warnings/errors on DEBUG,
136 // don't warn just ignore on wikilens pagelist columns, if not loaded.
137 // RateIt pagelist column is called "rating", not "ratingwidget" (Dan?)
139 // Revision 1.25 2004/06/14 11:31:38 rurban
140 // renamed global $Theme to $WikiTheme (gforge nameclash)
141 // inherit PageList default options from PageList
142 // default sortby=pagename
143 // use options in PageList_Selectable (limit, sortby, ...)
144 // added action revert, with button at action=diff
145 // added option regex to WikiAdminSearchReplace
147 // Revision 1.24 2004/06/13 16:02:12 rurban
148 // empty list of pages if user=[] and not authenticated.
150 // Revision 1.23 2004/06/13 15:51:37 rurban
151 // Support pagelist filter for current author,owner,creator by []
153 // Revision 1.22 2004/06/13 15:33:20 rurban
154 // new support for arguments owner, author, creator in most relevant
155 // PageList plugins. in WikiAdmin* via preSelectS()
157 // Revision 1.21 2004/04/20 00:06:53 rurban
160 // Revision 1.20 2004/02/22 23:20:33 rurban
161 // fixed DumpHtmlToDir,
162 // enhanced sortby handling in PageList
163 // new button_heading th style (enabled),
164 // added sortby and limit support to the db backends and plugins
165 // for paging support (<<prev, next>> links on long lists)
167 // Revision 1.19 2004/02/17 12:11:36 rurban
168 // added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...)
170 // Revision 1.18 2004/01/25 07:58:30 rurban
171 // PageList sortby support in PearDB and ADODB backends
173 // Revision 1.17 2003/02/27 20:10:30 dairiki
174 // Disable profiling output when DEBUG is defined but false.
176 // Revision 1.16 2003/02/21 04:08:26 dairiki
177 // New class DebugTimer in prepend.php to help report timing.
179 // Revision 1.15 2003/01/18 21:19:25 carstenklapp
181 // Reformatting; added copyleft, getVersion, getDescription
188 // c-hanging-comment-ender-p: nil
189 // indent-tabs-mode: nil