2 rcs_id('$Id: RelatedChanges.php,v 1.2 2004-05-08 14:06:13 rurban Exp $');
5 * List of changes on all pages which are linked to from this page.
6 * This is good usage for an action button, similar to LikePages.
9 require_once("lib/plugin/RecentChanges.php");
11 class WikiPlugin_RelatedChanges
12 extends WikiPlugin_RecentChanges
15 return _("RecentEdits");
18 function getVersion() {
19 return preg_replace("/[Revision: $]/", '',
23 function getDefaultArguments() {
24 //php-4.0.4pl1 breaks at the parent:: line even if the
25 // code doesn't reach this line
26 //if (!check_php_version(4,0,6))
27 $args = WikiPlugin_RecentChanges::getDefaultArguments();
28 //else $args = parent::getDefaultArguments();
29 $args['page'] = '[pagename]';
30 $args['show_minor'] = true;
31 $args['show_all'] = true;
32 $args['caption'] = _("Related Changes");
36 function getChanges ($dbi, $args) {
37 $changes = $dbi->mostRecent($this->getMostRecentParams($args));
39 $show_deleted = $args['show_deleted'];
40 if ($show_deleted == 'sometimes')
41 $show_deleted = $args['show_minor'];
43 $changes = new NonDeletedRevisionIterator($changes, !$args['show_all']);
45 // sort out pages not linked from our page
46 $changes = new RelatedChangesRevisionIterator($changes, $dbi, $args['page']);
50 // box is used to display a fixed-width, narrow version with common header.
51 // just a numbered list of limit pagenames, without date.
52 function box($args = false, $request = false, $basepage = false) {
53 if (!$request) $request =& $GLOBALS['request'];
54 if (!isset($args['limit'])) $args['limit'] = 15;
55 $args['format'] = 'box';
56 $args['show_minor'] = false;
57 $args['show_major'] = true;
58 $args['show_deleted'] = false;
59 $args['show_all'] = false;
61 return $this->makeBox(WikiLink(_("RelatedChanges"),'',_("Related Changes")),
62 $this->format($this->getChanges($request->_dbi, $args), $args));
67 * list of pages which are linked from the current page.
68 * i.e. sort out all non-linked pages.
70 class RelatedChangesRevisionIterator extends WikiDB_PageRevisionIterator
72 function RelatedChangesRevisionIterator ($revisions, &$dbi, $pagename) {
73 $this->_revisions = $revisions;
74 $this->_wikidb = $dbi;
75 $page = $dbi->getPage($pagename);
76 $links = $page->getLinks();
77 $this->_links = array();
78 while ($linked_page = $links->next()) {
79 $this->_links[$linked_page->_pagename] = 1;
85 while (($rev = $this->_revisions->next())) {
86 if (isset($this->_links[$rev->_pagename]))
94 // $Log: not supported by cvs2svn $
95 // Revision 1.1 2004/04/21 04:29:10 rurban
96 // Two convenient RecentChanges extensions
97 // RelatedChanges (only links from current page)
98 // RecentEdits (just change the default args)
101 // (c-file-style: "gnu")
106 // c-hanging-comment-ender-p: nil
107 // indent-tabs-mode: nil