---- try this in a subpage of your UserName: (UserName/AuthorHistory) * Displays a list of revision edits by one particular user, for the * current page, a specified page, or all pages. * This is a big hack to create a PageList like table. (PageList * doesn't support page revisions yet, only pages.) * Make a new subclass of PageHistory to filter changes of one (or all) * page(s) by a single author? */ /* reference _PageHistory_PageRevisionIter WikiDB_PageIterator(&$wikidb, &$pages WikiDB_PageRevisionIterator(&$wikidb, &$revisions) */ /** */ require_once('lib/PageList.php'); //include_once('lib/debug.php'); class WikiPlugin_AuthorHistory extends WikiPlugin { function getName() { return _("AuthorHistory"); } function getDescription() { 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.")); } function getVersion() { return preg_replace("/[Revision: $]/", '', "\$Revision$"); } function getDefaultArguments() { global $request; return array('exclude' => '', 'noheader' => false, 'includeminor' => false, 'includedeleted' => false, 'author' => $request->_user->UserName(), 'page' => '[pagename]', 'info' => 'version,minor,author,summary,mtime' ); } // info arg allows multiple columns // info=mtime,hits,summary,version,author,locked,minor // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges function run($dbi, $argstr, &$request, $basepage) { $this->_args = $this->getArgs($argstr, $request); extract($this->_args); //trigger_error("1 p= $page a= $author"); if ($page && $page == 'username') //FIXME: use [username]!!!!! $page = $author; //trigger_error("2 p= $page a= $author"); if (!$page || !$author) //user not signed in or no author specified return ''; //$pagelist = new PageList($info, $exclude); /////////////////////////// $nbsp = HTML::raw(' '); global $WikiTheme; // date & time formatting $table = HTML::table(array('class'=> 'pagelist')); $thead = HTML::thead(); $tbody = HTML::tbody(); if (! ($page == 'all')) { $p = $dbi->getPage($page); $thead->pushContent(HTML::tr(HTML::th(array('align'=> 'right'), _("Version")), $includeminor ? HTML::th(_("Minor")) : "", HTML::th(_("Author")), HTML::th(_("Summary")), HTML::th(_("Modified")) )); $allrevisions_iter = $p->getAllRevisions(); while ($rev = $allrevisions_iter->next()) { $isminor = $rev->get('is_minor_edit'); $authordoesmatch = $author == $rev->get('author'); if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) { $difflink = Button(array('action' => 'diff', 'previous' => 'minor'), $rev->getversion(), $rev); $tr = HTML::tr(HTML::td(array('align'=> 'right'), $difflink, $nbsp), $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "", HTML::td($nbsp, WikiLink($rev->get('author'), 'if_known'), $nbsp), HTML::td($nbsp, $rev->get('summary')), HTML::td(array('align'=> 'right'), $WikiTheme->formatdatetime($rev->get('mtime'))) ); $class = $isminor ? 'evenrow' : 'oddrow'; $tr->setAttr('class', $class); $tbody->pushContent($tr); //$pagelist->addPage($rev->getPage()); } } $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." , WikiLink($author, 'auto'), WikiLink($page, 'auto')); } else { //search all pages for all edits by this author $thead->pushContent(HTML::tr(HTML::th(_("Page Name")), HTML::th(array('align'=> 'right'), _("Version")), $includeminor ? HTML::th(_("Minor")) : "", HTML::th(_("Summary")), HTML::th(_("Modified")) )); $allpages_iter = $dbi->getAllPages($includedeleted); while ($p = $allpages_iter->next()) { $allrevisions_iter = $p->getAllRevisions(); while ($rev = $allrevisions_iter->next()) { $isminor = $rev->get('is_minor_edit'); $authordoesmatch = $author == $rev->get('author'); if ($authordoesmatch && (!$isminor || ($includeminor && $isminor))) { $difflink = Button(array('action' => 'diff', 'previous' => 'minor'), $rev->getversion(), $rev); $tr = HTML::tr( HTML::td($nbsp, ($isminor ? $rev->_pagename : WikiLink($rev->_pagename, 'auto')) ), HTML::td(array('align'=> 'right'), $difflink, $nbsp), $includeminor ? (HTML::td($nbsp, ($isminor ? "minor" : "major"), $nbsp)) : "", HTML::td($nbsp, $rev->get('summary')), HTML::td(array('align'=> 'right'), $WikiTheme->formatdatetime($rev->get('mtime')), $nbsp) ); $class = $isminor ? 'evenrow' : 'oddrow'; $tr->setAttr('class', $class); $tbody->pushContent($tr); //$pagelist->addPage($rev->getPage()); } } } $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." , WikiLink($author, 'auto')); } $table->pushContent(HTML::caption($captext)); $table->pushContent($thead, $tbody); // if (!$noheader) { // total minor, major edits. if include minoredits was specified // } return $table; // if (!$noheader) { // $pagelink = WikiLink($page, 'auto'); // // if ($pagelist->isEmpty()) // return HTML::p(fmt("No pages link to %s.", $pagelink)); // // if ($pagelist->getTotal() == 1) // $pagelist->setCaption(fmt("One page links to %s:", // $pagelink)); // else // $pagelist->setCaption(fmt("%s pages link to %s:", // $pagelist->getTotal(), $pagelink)); // } // // return $pagelist; } }; // For emacs users // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: ?>