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 along
20 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 ?>
35 try this in a subpage of your UserName: (UserName/AuthorHistory)
37 <?plugin AuthorHistory page=all includeminor=true ?>
39 * Display a list of revision edits by one particular user, for the
40 * current page, a specified page, or all pages.
42 * This is a big hack to create a PageList like table. (PageList
43 * doesn't support page revisions yet, only pages.)
45 * Make a new subclass of PageHistory to filter changes of one (or all)
46 * page(s) by a single author?
52 _PageHistory_PageRevisionIter
53 WikiDB_PageIterator(&$wikidb, &$pages
54 WikiDB_PageRevisionIterator(&$wikidb, &$revisions)
57 require_once 'lib/PageList.php';
59 class WikiPlugin_AuthorHistory
64 function getDescription()
66 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."));
69 function getDefaultArguments()
72 return array('exclude' => '',
74 'includeminor' => false,
75 'includedeleted' => false,
76 'author' => $request->_user->UserName(),
77 'page' => '[pagename]',
78 'info' => 'version,minor,author,summary,mtime'
82 // info arg allows multiple columns
83 // info=mtime,hits,summary,version,author,locked,minor
84 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
88 * @param string $argstr
89 * @param WikiRequest $request
90 * @param string $basepage
93 function run($dbi, $argstr, &$request, $basepage)
95 $this->_args = $this->getArgs($argstr, $request);
96 extract($this->_args);
97 if ($page && $page == 'username') //FIXME: use [username]!!!!!
99 if (!$page || !$author) //user not signed in or no author specified
101 //$pagelist = new PageList($info, $exclude);
103 $nbsp = HTML::raw(' ');
105 global $WikiTheme; // date & time formatting
107 $table = HTML::table(array('class' => 'pagelist'));
108 $thead = HTML::thead();
109 $tbody = HTML::tbody();
111 if (!($page == 'all')) {
112 $p = $dbi->getPage($page);
114 $thead->pushContent(HTML::tr(HTML::th(array('class' => 'align-right'),
116 $includeminor ? HTML::th(_("Minor")) : "",
117 HTML::th(_("Author")),
118 HTML::th(_("Summary")),
119 HTML::th(_("Modified"))
122 $allrevisions_iter = $p->getAllRevisions();
123 while ($rev = $allrevisions_iter->next()) {
125 $isminor = $rev->get('is_minor_edit');
126 $authordoesmatch = $author == $rev->get('author');
128 if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) {
129 $difflink = Button(array('action' => 'diff',
130 'previous' => 'minor'),
131 $rev->getversion(), $rev);
132 $tr = HTML::tr(HTML::td(array('class' => 'align-right'),
134 $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "",
135 HTML::td($nbsp, WikiLink($rev->get('author'),
137 HTML::td($nbsp, $rev->get('summary')),
138 HTML::td(array('class' => 'align-right'),
139 $WikiTheme->formatdatetime($rev->get('mtime')))
142 $class = $isminor ? 'evenrow' : 'oddrow';
143 $tr->setAttr('class', $class);
144 $tbody->pushContent($tr);
145 //$pagelist->addPage($rev->getPage());
148 $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.",
149 WikiLink($author, 'auto'),
150 WikiLink($page, 'auto'));
153 //search all pages for all edits by this author
155 $thead->pushContent(HTML::tr(HTML::th(_("Page Name")),
156 HTML::th(array('class' => 'align-right'),
158 $includeminor ? HTML::th(_("Minor")) : "",
159 HTML::th(_("Summary")),
160 HTML::th(_("Modified"))
163 $allpages_iter = $dbi->getAllPages($includedeleted);
164 while ($p = $allpages_iter->next()) {
166 $allrevisions_iter = $p->getAllRevisions();
167 while ($rev = $allrevisions_iter->next()) {
168 $isminor = $rev->get('is_minor_edit');
169 $authordoesmatch = $author == $rev->get('author');
170 if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) {
171 $difflink = Button(array('action' => 'diff',
172 'previous' => 'minor'),
173 $rev->getversion(), $rev);
176 ($isminor ? $rev->_pagename : WikiLink($rev->_pagename, 'auto'))
178 HTML::td(array('class' => 'align-right'),
180 $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "",
181 HTML::td($nbsp, $rev->get('summary')),
182 HTML::td(array('class' => 'align-right'),
183 $WikiTheme->formatdatetime($rev->get('mtime')), $nbsp)
186 $class = $isminor ? 'evenrow' : 'oddrow';
187 $tr->setAttr('class', $class);
188 $tbody->pushContent($tr);
189 //$pagelist->addPage($rev->getPage());
194 $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.",
195 WikiLink($author, 'auto'));
198 $table->pushContent(HTML::caption($captext));
199 $table->pushContent($thead, $tbody);
202 // total minor, major edits. if include minoredits was specified
207 // $pagelink = WikiLink($page, 'auto');
209 // if ($pagelist->isEmpty())
210 // return HTML::p(fmt("No pages link to %s.", $pagelink));
212 // if ($pagelist->getTotal() == 1)
213 // $pagelist->setCaption(fmt("One page links to %s:",
216 // $pagelist->setCaption(fmt("%s pages link to %s:",
217 // $pagelist->getTotal(), $pagelink));
229 // c-hanging-comment-ender-p: nil
230 // indent-tabs-mode: nil