From dd05ebb8db8bf49174499f998a57c2eec34c83eb Mon Sep 17 00:00:00 2001 From: rurban Date: Fri, 14 May 2004 17:33:12 +0000 Subject: [PATCH] new plugin RecentChanges git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3507 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/plugin/RecentChanges.php | 19 ++++- lib/plugin/RecentComments.php | 115 +++++++++++++++++++++++++++++++ lib/plugin/SyntaxHighlighter.php | 11 +-- lib/plugin/WikiBlog.php | 12 +++- 4 files changed, 147 insertions(+), 10 deletions(-) create mode 100644 lib/plugin/RecentComments.php diff --git a/lib/plugin/RecentChanges.php b/lib/plugin/RecentChanges.php index c1460f778..6a898a0d3 100644 --- a/lib/plugin/RecentChanges.php +++ b/lib/plugin/RecentChanges.php @@ -1,5 +1,5 @@ 0) { if (intval($days) != $days) @@ -255,6 +257,9 @@ extends _RecentChanges_Formatter function title () { extract($this->_args); + if (isset($caption) and $caption == _("Recent Comments")) + return array(_("RecentComments"),' ',$this->rss_icon(), + $this->sidebar_link()); return array($show_minor ? _("RecentEdits") : _("RecentChanges"), ' ', $this->rss_icon(), @@ -262,7 +267,10 @@ extends _RecentChanges_Formatter } function empty_message () { - return _("No changes found"); + if (isset($this->_args['caption']) and $this->_args['caption'] == _("Recent Comments")) + return _("No comments found"); + else + return _("No changes found"); } function sidebar_link() { @@ -656,7 +664,7 @@ extends WikiPlugin function getVersion() { return preg_replace("/[Revision: $]/", '', - "\$Revision: 1.92 $"); + "\$Revision: 1.93 $"); } function managesValidators() { @@ -839,6 +847,11 @@ class DayButtonBar extends HtmlElement { } // $Log: not supported by cvs2svn $ +// Revision 1.92 2004/04/21 04:29:10 rurban +// Two convenient RecentChanges extensions +// RelatedChanges (only links from current page) +// RecentEdits (just change the default args) +// // Revision 1.91 2004/04/19 18:27:46 rurban // Prevent from some PHP5 warnings (ref args, no :: object init) // php5 runs now through, just one wrong XmlElement object init missing diff --git a/lib/plugin/RecentComments.php b/lib/plugin/RecentComments.php new file mode 100644 index 000000000..095fecab4 --- /dev/null +++ b/lib/plugin/RecentComments.php @@ -0,0 +1,115 @@ +mostRecent($this->getMostRecentParams($args)); + + $show_deleted = $args['show_deleted']; + if ($show_deleted == 'sometimes') + $show_deleted = $args['show_minor']; + if (!$show_deleted) + $changes = new NonDeletedRevisionIterator($changes, !$args['show_all']); + + // sort out pages with no comments + $changes = new RecentCommentsRevisionIterator($changes, $dbi); + return $changes; + } + + // box is used to display a fixed-width, narrow version with common header. + // just a numbered list of limit pagenames, without date. + function box($args = false, $request = false, $basepage = false) { + if (!$request) $request =& $GLOBALS['request']; + if (!isset($args['limit'])) $args['limit'] = 15; + $args['format'] = 'box'; + $args['show_minor'] = false; + $args['show_major'] = true; + $args['show_deleted'] = false; + $args['show_all'] = false; + $args['days'] = 90; + return $this->makeBox(WikiLink(_("RecentComments"),'',_("Recent Comments")), + $this->format($this->getChanges($request->_dbi, $args), $args)); + } +} + +/** + * List of pages which have comments + * i.e. sort out all non-commented pages. + */ +class RecentCommentsRevisionIterator extends WikiDB_PageRevisionIterator +{ + function RecentCommentsRevisionIterator ($revisions, &$dbi) { + $this->_revisions = $revisions; + $this->_wikidb = $dbi; + $this->_current = 0; + $this->_blog = new WikiPlugin_WikiBlog(); + } + + function next () { + if (!empty($this->comments) and $this->_current) { + if (isset($this->comments[$this->_current])) { + $this->_current++; + return $this->comments[$this->_current]; + } else { + $this->_current = 0; + } + } + while (($rev = $this->_revisions->next())) { + $this->comments = $this->_blog->findBlogs($this->_wikidb, $rev->getPageName(), 'comment'); + if ($this->comments) { + usort($this->comments, array("WikiPlugin_WikiBlog", + "cmp")); + if (isset($this->comments[$this->_current])) { + $this->_current++; + return $this->comments[$this->_current]; + } + } else { + $this->_current = 0; + } + } + $this->free(); + return false; + } + +} + +// $Log: not supported by cvs2svn $ + +// (c-file-style: "gnu") +// Local Variables: +// mode: php +// tab-width: 8 +// c-basic-offset: 4 +// c-hanging-comment-ender-p: nil +// indent-tabs-mode: nil +// End: +?> \ No newline at end of file diff --git a/lib/plugin/SyntaxHighlighter.php b/lib/plugin/SyntaxHighlighter.php index 4f9519d70..b705347bb 100644 --- a/lib/plugin/SyntaxHighlighter.php +++ b/lib/plugin/SyntaxHighlighter.php @@ -1,5 +1,5 @@ titleSearch(new TextSearchQuery ($prefix)); + $pages = $dbi->titleSearch(new TextSearchQuery($prefix)); $blogs = array(); while ($page = $pages->next()) { @@ -350,6 +350,12 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.16 2004/04/19 18:27:46 rurban +// Prevent from some PHP5 warnings (ref args, no :: object init) +// php5 runs now through, just one wrong XmlElement object init missing +// Removed unneccesary UpgradeUser lines +// Changed WikiLink to omit version if current (RecentChanges) +// // Revision 1.15 2004/04/18 05:42:17 rurban // more fixes for page="0" // better WikiForum support -- 2.45.0