4 Copyright 1999, 2000, 2001, 2002 $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
25 *** EXPERIMENTAL PLUGIN ******************
26 Needs a lot of work! Use at your own risk.
27 ******************************************
29 try this in a page called AuthorHistory:
31 <?plugin AuthorHistory page=username includeminor=true ?>
33 <?plugin AuthorHistory page=all ?>
36 try this in a subpage of your UserName: (UserName/AuthorHistory)
38 <?plugin AuthorHistory page=all includeminor=true ?>
41 * Displays a list of revision edits by one particular user, for the
42 * current page, a specified page, or all pages.
44 * This is a big hack to create a PageList like table. (PageList
45 * doesn't support page revisions yet, only pages.)
47 * Make a new subclass of PageHistory to filter changes of one (or all)
48 * page(s) by a single author?
54 _PageHistory_PageRevisionIter
55 WikiDB_PageIterator(&$wikidb, &$pages
56 WikiDB_PageRevisionIterator(&$wikidb, &$revisions)
62 require_once('lib/PageList.php');
64 //include_once('lib/debug.php');
66 class WikiPlugin_AuthorHistory
70 return _("AuthorHistory");
73 function getDescription() {
74 return sprintf(_("List all page revisions edited by one user with diff links, or show a PageHistory-like list of a single page for only one user."));
77 function getVersion() {
78 return preg_replace("/[Revision: $]/", '',
82 function getDefaultArguments() {
84 return array('exclude' => '',
86 'includeminor' => false,
87 'includedeleted' => false,
88 'author' => $request->_user->UserName(),
89 'page' => '[pagename]',
90 'info' => 'version,minor,author,summary,mtime'
93 // info arg allows multiple columns
94 // info=mtime,hits,summary,version,author,locked,minor
95 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
97 function run($dbi, $argstr, &$request, $basepage) {
98 $this->_args = $this->getArgs($argstr, $request);
99 extract($this->_args);
100 //trigger_error("1 p= $page a= $author");
101 if ($page && $page == 'username') //FIXME: use [username]!!!!!
103 //trigger_error("2 p= $page a= $author");
104 if (!$page || !$author) //user not signed in or no author specified
106 //$pagelist = new PageList($info, $exclude);
107 ///////////////////////////
109 $nbsp = HTML::raw(' ');
111 global $WikiTheme; // date & time formatting
113 if (! ($page == 'all')) {
114 $p = $dbi->getPage($page);
116 $t = HTML::table(array('class'=> 'pagelist',
117 'style' => 'font-size:smaller'));
122 $th->pushContent(HTML::tr(HTML::td(array('align'=> 'right'),
124 $includeminor ? HTML::td(_("Minor")) : "",
125 HTML::td(_("Author")),
126 HTML::td(_("Summary")),
127 HTML::td(_("Modified"))
130 $allrevisions_iter = $p->getAllRevisions();
131 while ($rev = $allrevisions_iter->next()) {
133 $isminor = $rev->get('is_minor_edit');
134 $authordoesmatch = $author == $rev->get('author');
136 if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) {
137 $difflink = Button(array('action' => 'diff',
138 'previous' => 'minor'),
139 $rev->getversion(), $rev);
140 $tr = HTML::tr(HTML::td(array('align'=> 'right'),
142 $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "",
143 HTML::td($nbsp, WikiLink($rev->get('author'),
145 HTML::td($nbsp, $rev->get('summary')),
146 HTML::td(array('align'=> 'right'),
147 $WikiTheme->formatdatetime($rev->get('mtime')))
150 $class = $isminor ? 'evenrow' : 'oddrow';
151 $tr->setAttr('class', $class);
152 $tb->pushContent($tr);
153 //$pagelist->addPage($rev->getPage());
156 $captext = fmt($includeminor ? "History of all major and minor edits by %s to page %s." : "History of all major edits by %s to page %s." ,
157 WikiLink($author, 'auto'),
158 WikiLink($page, 'auto'));
159 $t->pushContent(HTML::caption($captext));
160 $t->pushContent($th, $tb);
164 //search all pages for all edits by this author
166 /////////////////////////////////////////////////////////////
168 $t = HTML::table(array('class'=> 'pagelist',
169 'style' => 'font-size:smaller'));
174 $th->pushContent(HTML::tr(HTML::td(_("Page Name")),
175 HTML::td(array('align'=> 'right'),
177 $includeminor ? HTML::td(_("Minor")) : "",
178 HTML::td(_("Summary")),
179 HTML::td(_("Modified"))
181 /////////////////////////////////////////////////////////////
183 $allpages_iter = $dbi->getAllPages($includedeleted);
184 while ($p = $allpages_iter->next()) {
185 /////////////////////////////////////////////////////////////
187 $allrevisions_iter = $p->getAllRevisions();
188 while ($rev = $allrevisions_iter->next()) {
189 $isminor = $rev->get('is_minor_edit');
190 $authordoesmatch = $author == $rev->get('author');
191 if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) {
192 $difflink = Button(array('action' => 'diff',
193 'previous' => 'minor'),
194 $rev->getversion(), $rev);
197 ($isminor ? $rev->_pagename : WikiLink($rev->_pagename, 'auto'))
199 HTML::td(array('align'=> 'right'),
201 $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "",
202 HTML::td($nbsp, $rev->get('summary')),
203 HTML::td(array('align'=> 'right'),
204 $WikiTheme->formatdatetime($rev->get('mtime')), $nbsp)
207 $class = $isminor ? 'evenrow' : 'oddrow';
208 $tr->setAttr('class', $class);
209 $tb->pushContent($tr);
210 //$pagelist->addPage($rev->getPage());
214 /////////////////////////////////////////////////////////////
218 $captext = fmt($includeminor ? "History of all major and minor modifications for any page edited by %s." : "History of major modifications for any page edited by %s." ,
219 WikiLink($author, 'auto'));
220 $t->pushContent(HTML::caption($captext));
221 $t->pushContent($th, $tb);
225 // total minor, major edits. if include minoredits was specified
230 // $pagelink = WikiLink($page, 'auto');
232 // if ($pagelist->isEmpty())
233 // return HTML::p(fmt("No pages link to %s.", $pagelink));
235 // if ($pagelist->getTotal() == 1)
236 // $pagelist->setCaption(fmt("One page links to %s:",
239 // $pagelist->setCaption(fmt("%s pages link to %s:",
240 // $pagelist->getTotal(), $pagelink));
248 // $Log: not supported by cvs2svn $
249 // Revision 1.5 2004/02/28 21:14:08 rurban
250 // generally more PHPDOC docs
251 // see http://xarch.tu-graz.ac.at/home/rurban/phpwiki/xref/
252 // fxied WikiUserNew pref handling: empty theme not stored, save only
253 // changed prefs, sql prefs improved, fixed password update,
254 // removed REPLACE sql (dangerous)
255 // moved gettext init after the locale was guessed
256 // + some minor changes
258 // Revision 1.4 2004/02/17 12:11:36 rurban
259 // 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, ...)
261 // Revision 1.3 2004/01/26 09:18:00 rurban
262 // * changed stored pref representation as before.
263 // the array of objects is 1) bigger and 2)
264 // less portable. If we would import packed pref
265 // objects and the object definition was changed, PHP would fail.
266 // This doesn't happen with an simple array of non-default values.
267 // * use $prefs->retrieve and $prefs->store methods, where retrieve
268 // understands the interim format of array of objects also.
269 // * simplified $prefs->get() and fixed $prefs->set()
270 // * added $user->_userid and class '_WikiUser' portability functions
271 // * fixed $user object ->_level upgrading, mostly using sessions.
272 // this fixes yesterdays problems with loosing authorization level.
273 // * fixed WikiUserNew::checkPass to return the _level
274 // * fixed WikiUserNew::isSignedIn
275 // * added explodePageList to class PageList, support sortby arg
276 // * fixed UserPreferences for WikiUserNew
277 // * fixed WikiPlugin for empty defaults array
278 // * UnfoldSubpages: added pagename arg, renamed pages arg,
279 // removed sort arg, support sortby arg
281 // Revision 1.2 2003/12/08 22:44:58 carstenklapp
282 // Code cleanup: fixed rcsid
284 // Revision 1.1 2003/12/08 22:43:30 carstenklapp
285 // New experimental plugin to provide a different kind of
286 // PageHistory. Functional as-is, but is in need of much cleanup and
287 // refactoring. Probably very, very slow on wikis with many pages!
295 // c-hanging-comment-ender-p: nil
296 // indent-tabs-mode: nil