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 * Displays 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 return _("AuthorHistory");
67 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()
75 return array('exclude' => '',
77 'includeminor' => false,
78 'includedeleted' => false,
79 'author' => $request->_user->UserName(),
80 'page' => '[pagename]',
81 'info' => 'version,minor,author,summary,mtime'
85 // info arg allows multiple columns
86 // info=mtime,hits,summary,version,author,locked,minor
87 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
89 function run($dbi, $argstr, &$request, $basepage)
91 $this->_args = $this->getArgs($argstr, $request);
92 extract($this->_args);
93 //trigger_error("1 p= $page a= $author");
94 if ($page && $page == 'username') //FIXME: use [username]!!!!!
96 //trigger_error("2 p= $page a= $author");
97 if (!$page || !$author) //user not signed in or no author specified
99 //$pagelist = new PageList($info, $exclude);
100 ///////////////////////////
102 $nbsp = HTML::raw(' ');
104 global $WikiTheme; // date & time formatting
106 $table = HTML::table(array('class' => 'pagelist'));
107 $thead = HTML::thead();
108 $tbody = HTML::tbody();
110 if (!($page == 'all')) {
111 $p = $dbi->getPage($page);
113 $thead->pushContent(HTML::tr(HTML::th(array('align' => 'right'),
115 $includeminor ? HTML::th(_("Minor")) : "",
116 HTML::th(_("Author")),
117 HTML::th(_("Summary")),
118 HTML::th(_("Modified"))
121 $allrevisions_iter = $p->getAllRevisions();
122 while ($rev = $allrevisions_iter->next()) {
124 $isminor = $rev->get('is_minor_edit');
125 $authordoesmatch = $author == $rev->get('author');
127 if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) {
128 $difflink = Button(array('action' => 'diff',
129 'previous' => 'minor'),
130 $rev->getversion(), $rev);
131 $tr = HTML::tr(HTML::td(array('align' => 'right'),
133 $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "",
134 HTML::td($nbsp, WikiLink($rev->get('author'),
136 HTML::td($nbsp, $rev->get('summary')),
137 HTML::td(array('align' => 'right'),
138 $WikiTheme->formatdatetime($rev->get('mtime')))
141 $class = $isminor ? 'evenrow' : 'oddrow';
142 $tr->setAttr('class', $class);
143 $tbody->pushContent($tr);
144 //$pagelist->addPage($rev->getPage());
147 $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.",
148 WikiLink($author, 'auto'),
149 WikiLink($page, 'auto'));
152 //search all pages for all edits by this author
154 $thead->pushContent(HTML::tr(HTML::th(_("Page Name")),
155 HTML::th(array('align' => 'right'),
157 $includeminor ? HTML::th(_("Minor")) : "",
158 HTML::th(_("Summary")),
159 HTML::th(_("Modified"))
162 $allpages_iter = $dbi->getAllPages($includedeleted);
163 while ($p = $allpages_iter->next()) {
165 $allrevisions_iter = $p->getAllRevisions();
166 while ($rev = $allrevisions_iter->next()) {
167 $isminor = $rev->get('is_minor_edit');
168 $authordoesmatch = $author == $rev->get('author');
169 if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) {
170 $difflink = Button(array('action' => 'diff',
171 'previous' => 'minor'),
172 $rev->getversion(), $rev);
175 ($isminor ? $rev->_pagename : WikiLink($rev->_pagename, 'auto'))
177 HTML::td(array('align' => 'right'),
179 $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "",
180 HTML::td($nbsp, $rev->get('summary')),
181 HTML::td(array('align' => 'right'),
182 $WikiTheme->formatdatetime($rev->get('mtime')), $nbsp)
185 $class = $isminor ? 'evenrow' : 'oddrow';
186 $tr->setAttr('class', $class);
187 $tbody->pushContent($tr);
188 //$pagelist->addPage($rev->getPage());
193 $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.",
194 WikiLink($author, 'auto'));
197 $table->pushContent(HTML::caption($captext));
198 $table->pushContent($thead, $tbody);
201 // total minor, major edits. if include minoredits was specified
206 // $pagelink = WikiLink($page, 'auto');
208 // if ($pagelist->isEmpty())
209 // return HTML::p(fmt("No pages link to %s.", $pagelink));
211 // if ($pagelist->getTotal() == 1)
212 // $pagelist->setCaption(fmt("One page links to %s:",
215 // $pagelist->setCaption(fmt("%s pages link to %s:",
216 // $pagelist->getTotal(), $pagelink));
230 // c-hanging-comment-ender-p: nil
231 // indent-tabs-mode: nil