3 * Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
4 * Copyright 2009 Marc-Etienne Vargenau, Alcatel-Lucent
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 along
19 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 *** EXPERIMENTAL PLUGIN ******************
25 Needs a lot of work! Use at your own risk.
26 ******************************************
28 try this in a page called AuthorHistory:
30 <?plugin AuthorHistory page=username includeminor=true ?>
32 <?plugin AuthorHistory page=all ?>
34 try this in a subpage of your UserName: (UserName/AuthorHistory)
36 <?plugin AuthorHistory page=all includeminor=true ?>
38 * Displays a list of revision edits by one particular user, for the
39 * current page, a specified page, or all pages.
41 * This is a big hack to create a PageList like table. (PageList
42 * doesn't support page revisions yet, only pages.)
44 * Make a new subclass of PageHistory to filter changes of one (or all)
45 * page(s) by a single author?
51 _PageHistory_PageRevisionIter
52 WikiDB_PageIterator(&$wikidb, &$pages
53 WikiDB_PageRevisionIterator(&$wikidb, &$revisions)
56 require_once 'lib/PageList.php';
58 class WikiPlugin_AuthorHistory
62 return _("AuthorHistory");
65 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() {
71 return array('exclude' => '',
73 'includeminor' => false,
74 'includedeleted' => false,
75 'author' => $request->_user->UserName(),
76 'page' => '[pagename]',
77 'info' => 'version,minor,author,summary,mtime'
80 // info arg allows multiple columns
81 // info=mtime,hits,summary,version,author,locked,minor
82 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
84 function run($dbi, $argstr, &$request, $basepage) {
85 $this->_args = $this->getArgs($argstr, $request);
86 extract($this->_args);
87 //trigger_error("1 p= $page a= $author");
88 if ($page && $page == 'username') //FIXME: use [username]!!!!!
90 //trigger_error("2 p= $page a= $author");
91 if (!$page || !$author) //user not signed in or no author specified
93 //$pagelist = new PageList($info, $exclude);
94 ///////////////////////////
96 $nbsp = HTML::raw(' ');
98 global $WikiTheme; // date & time formatting
100 $table = HTML::table(array('class'=> 'pagelist'));
101 $thead = HTML::thead();
102 $tbody = HTML::tbody();
104 if (! ($page == 'all')) {
105 $p = $dbi->getPage($page);
107 $thead->pushContent(HTML::tr(HTML::th(array('align'=> 'right'),
109 $includeminor ? HTML::th(_("Minor")) : "",
110 HTML::th(_("Author")),
111 HTML::th(_("Summary")),
112 HTML::th(_("Modified"))
115 $allrevisions_iter = $p->getAllRevisions();
116 while ($rev = $allrevisions_iter->next()) {
118 $isminor = $rev->get('is_minor_edit');
119 $authordoesmatch = $author == $rev->get('author');
121 if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) {
122 $difflink = Button(array('action' => 'diff',
123 'previous' => 'minor'),
124 $rev->getversion(), $rev);
125 $tr = HTML::tr(HTML::td(array('align'=> 'right'),
127 $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "",
128 HTML::td($nbsp, WikiLink($rev->get('author'),
130 HTML::td($nbsp, $rev->get('summary')),
131 HTML::td(array('align'=> 'right'),
132 $WikiTheme->formatdatetime($rev->get('mtime')))
135 $class = $isminor ? 'evenrow' : 'oddrow';
136 $tr->setAttr('class', $class);
137 $tbody->pushContent($tr);
138 //$pagelist->addPage($rev->getPage());
141 $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." ,
142 WikiLink($author, 'auto'),
143 WikiLink($page, 'auto'));
147 //search all pages for all edits by this author
149 $thead->pushContent(HTML::tr(HTML::th(_("Page Name")),
150 HTML::th(array('align'=> 'right'),
152 $includeminor ? HTML::th(_("Minor")) : "",
153 HTML::th(_("Summary")),
154 HTML::th(_("Modified"))
157 $allpages_iter = $dbi->getAllPages($includedeleted);
158 while ($p = $allpages_iter->next()) {
160 $allrevisions_iter = $p->getAllRevisions();
161 while ($rev = $allrevisions_iter->next()) {
162 $isminor = $rev->get('is_minor_edit');
163 $authordoesmatch = $author == $rev->get('author');
164 if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) {
165 $difflink = Button(array('action' => 'diff',
166 'previous' => 'minor'),
167 $rev->getversion(), $rev);
170 ($isminor ? $rev->_pagename : WikiLink($rev->_pagename, 'auto'))
172 HTML::td(array('align'=> 'right'),
174 $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "",
175 HTML::td($nbsp, $rev->get('summary')),
176 HTML::td(array('align'=> 'right'),
177 $WikiTheme->formatdatetime($rev->get('mtime')), $nbsp)
180 $class = $isminor ? 'evenrow' : 'oddrow';
181 $tr->setAttr('class', $class);
182 $tbody->pushContent($tr);
183 //$pagelist->addPage($rev->getPage());
188 $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." ,
189 WikiLink($author, 'auto'));
192 $table->pushContent(HTML::caption($captext));
193 $table->pushContent($thead, $tbody);
196 // total minor, major edits. if include minoredits was specified
201 // $pagelink = WikiLink($page, 'auto');
203 // if ($pagelist->isEmpty())
204 // return HTML::p(fmt("No pages link to %s.", $pagelink));
206 // if ($pagelist->getTotal() == 1)
207 // $pagelist->setCaption(fmt("One page links to %s:",
210 // $pagelist->setCaption(fmt("%s pages link to %s:",
211 // $pagelist->getTotal(), $pagelink));
223 // c-hanging-comment-ender-p: nil
224 // indent-tabs-mode: nil