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
62 function getDescription()
64 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."));
67 function getDefaultArguments()
70 return array('exclude' => '',
72 'includeminor' => false,
73 'includedeleted' => false,
74 'author' => $request->_user->UserName(),
75 'page' => '[pagename]',
76 '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)
86 $this->_args = $this->getArgs($argstr, $request);
87 extract($this->_args);
88 //trigger_error("1 p= $page a= $author");
89 if ($page && $page == 'username') //FIXME: use [username]!!!!!
91 //trigger_error("2 p= $page a= $author");
92 if (!$page || !$author) //user not signed in or no author specified
94 //$pagelist = new PageList($info, $exclude);
95 ///////////////////////////
97 $nbsp = HTML::raw(' ');
99 global $WikiTheme; // date & time formatting
101 $table = HTML::table(array('class' => 'pagelist'));
102 $thead = HTML::thead();
103 $tbody = HTML::tbody();
105 if (!($page == 'all')) {
106 $p = $dbi->getPage($page);
108 $thead->pushContent(HTML::tr(HTML::th(array('align' => 'right'),
110 $includeminor ? HTML::th(_("Minor")) : "",
111 HTML::th(_("Author")),
112 HTML::th(_("Summary")),
113 HTML::th(_("Modified"))
116 $allrevisions_iter = $p->getAllRevisions();
117 while ($rev = $allrevisions_iter->next()) {
119 $isminor = $rev->get('is_minor_edit');
120 $authordoesmatch = $author == $rev->get('author');
122 if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) {
123 $difflink = Button(array('action' => 'diff',
124 'previous' => 'minor'),
125 $rev->getversion(), $rev);
126 $tr = HTML::tr(HTML::td(array('align' => 'right'),
128 $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "",
129 HTML::td($nbsp, WikiLink($rev->get('author'),
131 HTML::td($nbsp, $rev->get('summary')),
132 HTML::td(array('align' => 'right'),
133 $WikiTheme->formatdatetime($rev->get('mtime')))
136 $class = $isminor ? 'evenrow' : 'oddrow';
137 $tr->setAttr('class', $class);
138 $tbody->pushContent($tr);
139 //$pagelist->addPage($rev->getPage());
142 $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.",
143 WikiLink($author, 'auto'),
144 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