2 rcs_id('$Id: RelatedChanges.php,v 1.3 2004-06-03 18:58:27 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.
8 * DONE: days links requires action=RelatedChanges arg
11 require_once("lib/plugin/RecentChanges.php");
13 class WikiPlugin_RelatedChanges
14 extends WikiPlugin_RecentChanges
17 return _("RecentEdits");
20 function getVersion() {
21 return preg_replace("/[Revision: $]/", '',
25 function getDefaultArguments() {
26 //php-4.0.4pl1 breaks at the parent:: line even if the
27 // code doesn't reach this line
28 //if (!check_php_version(4,0,6))
29 $args = WikiPlugin_RecentChanges::getDefaultArguments();
30 //else $args = parent::getDefaultArguments();
31 $args['page'] = '[pagename]';
32 $args['show_minor'] = true;
33 $args['show_all'] = true;
34 $args['caption'] = _("Related Changes");
38 function getChanges ($dbi, $args) {
39 $changes = $dbi->mostRecent($this->getMostRecentParams($args));
41 $show_deleted = $args['show_deleted'];
42 if ($show_deleted == 'sometimes')
43 $show_deleted = $args['show_minor'];
45 $changes = new NonDeletedRevisionIterator($changes, !$args['show_all']);
47 // sort out pages not linked from our page
48 $changes = new RelatedChangesRevisionIterator($changes, $dbi, $args['page']);
52 // box is used to display a fixed-width, narrow version with common header.
53 // just a numbered list of limit pagenames, without date.
54 function box($args = false, $request = false, $basepage = false) {
55 if (!$request) $request =& $GLOBALS['request'];
56 if (!isset($args['limit'])) $args['limit'] = 15;
57 $args['format'] = 'box';
58 $args['show_minor'] = false;
59 $args['show_major'] = true;
60 $args['show_deleted'] = false;
61 $args['show_all'] = false;
63 return $this->makeBox(WikiLink(_("RelatedChanges"),'',_("Related Changes")),
64 $this->format($this->getChanges($request->_dbi, $args), $args));
69 * list of pages which are linked from the current page.
70 * i.e. sort out all non-linked pages.
72 class RelatedChangesRevisionIterator extends WikiDB_PageRevisionIterator
74 function RelatedChangesRevisionIterator ($revisions, &$dbi, $pagename) {
75 $this->_revisions = $revisions;
76 $this->_wikidb = $dbi;
77 $page = $dbi->getPage($pagename);
78 $links = $page->getLinks();
79 $this->_links = array();
80 while ($linked_page = $links->next()) {
81 $this->_links[$linked_page->_pagename] = 1;
87 while (($rev = $this->_revisions->next())) {
88 if (isset($this->_links[$rev->_pagename]))
96 // $Log: not supported by cvs2svn $
97 // Revision 1.2 2004/05/08 14:06:13 rurban
98 // new support for inlined image attributes: [image.jpg size=50x30 align=right]
99 // minor stability and portability fixes
101 // Revision 1.1 2004/04/21 04:29:10 rurban
102 // Two convenient RecentChanges extensions
103 // RelatedChanges (only links from current page)
104 // RecentEdits (just change the default args)
107 // (c-file-style: "gnu")
112 // c-hanging-comment-ender-p: nil
113 // indent-tabs-mode: nil