2 rcs_id('$Id: RecentComments.php,v 1.1 2004-05-14 17:33:12 rurban Exp $');
5 * List of basepages with recently added comments
8 require_once("lib/plugin/RecentChanges.php");
9 require_once("lib/plugin/WikiBlog.php");
11 class WikiPlugin_RecentComments
12 extends WikiPlugin_RecentChanges
15 return _("RecentComments");
17 function getVersion() {
18 return preg_replace("/[Revision: $]/", '',
21 function getDefaultArguments() {
22 //php-4.0.4pl1 breaks at the parent:: line even if the
23 // code doesn't reach this line
24 //if (!check_php_version(4,0,6))
25 $args = WikiPlugin_RecentChanges::getDefaultArguments();
26 //else $args = parent::getDefaultArguments();
27 $args['type'] = 'RecentComments';
28 $args['show_minor'] = false;
29 $args['show_all'] = true;
30 $args['caption'] = _("Recent Comments");
34 function getChanges ($dbi, $args) {
35 $changes = $dbi->mostRecent($this->getMostRecentParams($args));
37 $show_deleted = $args['show_deleted'];
38 if ($show_deleted == 'sometimes')
39 $show_deleted = $args['show_minor'];
41 $changes = new NonDeletedRevisionIterator($changes, !$args['show_all']);
43 // sort out pages with no comments
44 $changes = new RecentCommentsRevisionIterator($changes, $dbi);
48 // box is used to display a fixed-width, narrow version with common header.
49 // just a numbered list of limit pagenames, without date.
50 function box($args = false, $request = false, $basepage = false) {
51 if (!$request) $request =& $GLOBALS['request'];
52 if (!isset($args['limit'])) $args['limit'] = 15;
53 $args['format'] = 'box';
54 $args['show_minor'] = false;
55 $args['show_major'] = true;
56 $args['show_deleted'] = false;
57 $args['show_all'] = false;
59 return $this->makeBox(WikiLink(_("RecentComments"),'',_("Recent Comments")),
60 $this->format($this->getChanges($request->_dbi, $args), $args));
65 * List of pages which have comments
66 * i.e. sort out all non-commented pages.
68 class RecentCommentsRevisionIterator extends WikiDB_PageRevisionIterator
70 function RecentCommentsRevisionIterator ($revisions, &$dbi) {
71 $this->_revisions = $revisions;
72 $this->_wikidb = $dbi;
74 $this->_blog = new WikiPlugin_WikiBlog();
78 if (!empty($this->comments) and $this->_current) {
79 if (isset($this->comments[$this->_current])) {
81 return $this->comments[$this->_current];
86 while (($rev = $this->_revisions->next())) {
87 $this->comments = $this->_blog->findBlogs($this->_wikidb, $rev->getPageName(), 'comment');
88 if ($this->comments) {
89 usort($this->comments, array("WikiPlugin_WikiBlog",
91 if (isset($this->comments[$this->_current])) {
93 return $this->comments[$this->_current];
105 // $Log: not supported by cvs2svn $
107 // (c-file-style: "gnu")
112 // c-hanging-comment-ender-p: nil
113 // indent-tabs-mode: nil