4 * Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
5 * Copyright 2009 Marc-Etienne Vargenau, Alcatel-Lucent
7 * This file is part of PhpWiki.
9 * PhpWiki is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * PhpWiki is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with PhpWiki; if not, write to the Free Software
21 * 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)
59 require_once('lib/PageList.php');
61 class WikiPlugin_AuthorHistory
65 return _("AuthorHistory");
68 function getDescription() {
69 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."));
72 function getDefaultArguments() {
74 return array('exclude' => '',
76 'includeminor' => false,
77 'includedeleted' => false,
78 'author' => $request->_user->UserName(),
79 'page' => '[pagename]',
80 'info' => 'version,minor,author,summary,mtime'
83 // info arg allows multiple columns
84 // info=mtime,hits,summary,version,author,locked,minor
85 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
87 function run($dbi, $argstr, &$request, $basepage) {
88 $this->_args = $this->getArgs($argstr, $request);
89 extract($this->_args);
90 //trigger_error("1 p= $page a= $author");
91 if ($page && $page == 'username') //FIXME: use [username]!!!!!
93 //trigger_error("2 p= $page a= $author");
94 if (!$page || !$author) //user not signed in or no author specified
96 //$pagelist = new PageList($info, $exclude);
97 ///////////////////////////
99 $nbsp = HTML::raw(' ');
101 global $WikiTheme; // date & time formatting
103 $table = HTML::table(array('class'=> 'pagelist'));
104 $thead = HTML::thead();
105 $tbody = HTML::tbody();
107 if (! ($page == 'all')) {
108 $p = $dbi->getPage($page);
110 $thead->pushContent(HTML::tr(HTML::th(array('align'=> 'right'),
112 $includeminor ? HTML::th(_("Minor")) : "",
113 HTML::th(_("Author")),
114 HTML::th(_("Summary")),
115 HTML::th(_("Modified"))
118 $allrevisions_iter = $p->getAllRevisions();
119 while ($rev = $allrevisions_iter->next()) {
121 $isminor = $rev->get('is_minor_edit');
122 $authordoesmatch = $author == $rev->get('author');
124 if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) {
125 $difflink = Button(array('action' => 'diff',
126 'previous' => 'minor'),
127 $rev->getversion(), $rev);
128 $tr = HTML::tr(HTML::td(array('align'=> 'right'),
130 $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "",
131 HTML::td($nbsp, WikiLink($rev->get('author'),
133 HTML::td($nbsp, $rev->get('summary')),
134 HTML::td(array('align'=> 'right'),
135 $WikiTheme->formatdatetime($rev->get('mtime')))
138 $class = $isminor ? 'evenrow' : 'oddrow';
139 $tr->setAttr('class', $class);
140 $tbody->pushContent($tr);
141 //$pagelist->addPage($rev->getPage());
144 $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." ,
145 WikiLink($author, 'auto'),
146 WikiLink($page, 'auto'));
150 //search all pages for all edits by this author
152 $thead->pushContent(HTML::tr(HTML::th(_("Page Name")),
153 HTML::th(array('align'=> 'right'),
155 $includeminor ? HTML::th(_("Minor")) : "",
156 HTML::th(_("Summary")),
157 HTML::th(_("Modified"))
160 $allpages_iter = $dbi->getAllPages($includedeleted);
161 while ($p = $allpages_iter->next()) {
163 $allrevisions_iter = $p->getAllRevisions();
164 while ($rev = $allrevisions_iter->next()) {
165 $isminor = $rev->get('is_minor_edit');
166 $authordoesmatch = $author == $rev->get('author');
167 if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) {
168 $difflink = Button(array('action' => 'diff',
169 'previous' => 'minor'),
170 $rev->getversion(), $rev);
173 ($isminor ? $rev->_pagename : WikiLink($rev->_pagename, 'auto'))
175 HTML::td(array('align'=> 'right'),
177 $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "",
178 HTML::td($nbsp, $rev->get('summary')),
179 HTML::td(array('align'=> 'right'),
180 $WikiTheme->formatdatetime($rev->get('mtime')), $nbsp)
183 $class = $isminor ? 'evenrow' : 'oddrow';
184 $tr->setAttr('class', $class);
185 $tbody->pushContent($tr);
186 //$pagelist->addPage($rev->getPage());
191 $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." ,
192 WikiLink($author, 'auto'));
195 $table->pushContent(HTML::caption($captext));
196 $table->pushContent($thead, $tbody);
199 // total minor, major edits. if include minoredits was specified
204 // $pagelink = WikiLink($page, 'auto');
206 // if ($pagelist->isEmpty())
207 // return HTML::p(fmt("No pages link to %s.", $pagelink));
209 // if ($pagelist->getTotal() == 1)
210 // $pagelist->setCaption(fmt("One page links to %s:",
213 // $pagelist->setCaption(fmt("%s pages link to %s:",
214 // $pagelist->getTotal(), $pagelink));
226 // c-hanging-comment-ender-p: nil
227 // indent-tabs-mode: nil