From 7a8656042216a8701edcaf5c15ac75fc4ac0f246 Mon Sep 17 00:00:00 2001 From: rurban Date: Wed, 21 Apr 2004 04:29:10 +0000 Subject: [PATCH] Two convenient RecentChanges extensions RelatedChanges (only links from current page) RecentEdits (just change the default args) git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3359 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/plugin/RecentChanges.php | 17 +++--- lib/plugin/RecentEdits.php | 51 +++++++++++++++++ lib/plugin/RelatedChanges.php | 100 ++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+), 7 deletions(-) create mode 100644 lib/plugin/RecentEdits.php create mode 100644 lib/plugin/RelatedChanges.php diff --git a/lib/plugin/RecentChanges.php b/lib/plugin/RecentChanges.php index 8644e4adf..c1460f778 100644 --- a/lib/plugin/RecentChanges.php +++ b/lib/plugin/RecentChanges.php @@ -1,5 +1,5 @@ _args['page'])) // RelatedChanges + return HTML::p(false, $desc, HTML::br(), fmt("(to pages linked from \"%s\")",$this->_args['page'])); return HTML::p(false, $desc); } @@ -643,9 +645,6 @@ class NonDeletedRevisionIterator extends WikiDB_PageRevisionIterator return false; } - function free () { - $this->_revisions->free(); - } } class WikiPlugin_RecentChanges @@ -657,7 +656,7 @@ extends WikiPlugin function getVersion() { return preg_replace("/[Revision: $]/", '', - "\$Revision: 1.91 $"); + "\$Revision: 1.92 $"); } function managesValidators() { @@ -715,7 +714,6 @@ extends WikiPlugin $params = array('include_minor_revisions' => $show_minor, 'exclude_major_revisions' => !$show_major, 'include_all_revisions' => !empty($show_all)); - if ($limit != 0) $params['limit'] = $limit; @@ -724,7 +722,6 @@ extends WikiPlugin elseif ($days < 0.0) $params['since'] = 24 * 3600 * $days - time(); - return $params; } @@ -842,6 +839,12 @@ class DayButtonBar extends HtmlElement { } // $Log: not supported by cvs2svn $ +// 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 +// Removed unneccesary UpgradeUser lines +// Changed WikiLink to omit version if current (RecentChanges) +// // Revision 1.90 2004/04/18 01:11:52 rurban // more numeric pagename fixes. // fixed action=upload with merge conflict warnings. diff --git a/lib/plugin/RecentEdits.php b/lib/plugin/RecentEdits.php new file mode 100644 index 000000000..bdcf1a1d3 --- /dev/null +++ b/lib/plugin/RecentEdits.php @@ -0,0 +1,51 @@ +makeBox(WikiLink(_("RecentEdits"),'',_("Recent Edits")), + $this->format($this->getChanges($request->_dbi, $args), $args)); + } +} + +// $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/RelatedChanges.php b/lib/plugin/RelatedChanges.php new file mode 100644 index 000000000..f0908c4e8 --- /dev/null +++ b/lib/plugin/RelatedChanges.php @@ -0,0 +1,100 @@ +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 not linked from our page + $changes = new RelatedChangesRevisionIterator($changes, $dbi, $args['page']); + 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(_("RelatedChanges"),'',_("Related Changes")), + $this->format($this->getChanges($request->_dbi, $args), $args)); + } +} + +/** + * list of pages which are linked from the current page. + * i.e. sort out all non-linked pages. + */ +class RelatedChangesRevisionIterator extends WikiDB_PageRevisionIterator +{ + function RelatedChangesRevisionIterator ($revisions, &$dbi, $pagename) { + $this->_revisions = $revisions; + $this->_wikidb = $dbi; + $page = $dbi->getPage($pagename); + $links = $page->getLinks(); + $this->_links = array(); + while ($linked_page = $links->next()) { + $this->_links[$linked_page->_pagename] = 1; + } + $links->free(); + } + + function next () { + while (($rev = $this->_revisions->next())) { + if (isset($this->_links[$rev->_pagename])) + return $rev; + } + $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 -- 2.45.0