2 rcs_id('$Id: RelatedChanges.php,v 1.1 2004-04-21 04:29:10 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 $args = parent::getDefaultArguments();
25 $args['page'] = '[pagename]';
26 $args['show_minor'] = true;
27 $args['show_all'] = true;
28 $args['caption'] = _("Related Changes");
32 function getChanges ($dbi, $args) {
33 $changes = $dbi->mostRecent($this->getMostRecentParams($args));
35 $show_deleted = $args['show_deleted'];
36 if ($show_deleted == 'sometimes')
37 $show_deleted = $args['show_minor'];
39 $changes = new NonDeletedRevisionIterator($changes, !$args['show_all']);
41 // sort out pages not linked from our page
42 $changes = new RelatedChangesRevisionIterator($changes, $dbi, $args['page']);
46 // box is used to display a fixed-width, narrow version with common header.
47 // just a numbered list of limit pagenames, without date.
48 function box($args = false, $request = false, $basepage = false) {
49 if (!$request) $request =& $GLOBALS['request'];
50 if (!isset($args['limit'])) $args['limit'] = 15;
51 $args['format'] = 'box';
52 $args['show_minor'] = false;
53 $args['show_major'] = true;
54 $args['show_deleted'] = false;
55 $args['show_all'] = false;
57 return $this->makeBox(WikiLink(_("RelatedChanges"),'',_("Related Changes")),
58 $this->format($this->getChanges($request->_dbi, $args), $args));
63 * list of pages which are linked from the current page.
64 * i.e. sort out all non-linked pages.
66 class RelatedChangesRevisionIterator extends WikiDB_PageRevisionIterator
68 function RelatedChangesRevisionIterator ($revisions, &$dbi, $pagename) {
69 $this->_revisions = $revisions;
70 $this->_wikidb = $dbi;
71 $page = $dbi->getPage($pagename);
72 $links = $page->getLinks();
73 $this->_links = array();
74 while ($linked_page = $links->next()) {
75 $this->_links[$linked_page->_pagename] = 1;
81 while (($rev = $this->_revisions->next())) {
82 if (isset($this->_links[$rev->_pagename]))
90 // $Log: not supported by cvs2svn $
92 // (c-file-style: "gnu")
97 // c-hanging-comment-ender-p: nil
98 // indent-tabs-mode: nil