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 _RelatedChanges_HtmlFormatter
14 extends _RecentChanges_HtmlFormatter
16 function description() {
17 return HTML::p(false, $this->pre_description(),
18 fmt(" (to pages linked from \"%s\")",$this->_args['page']));
23 class WikiPlugin_RelatedChanges
24 extends WikiPlugin_RecentChanges
27 return _("RecentEdits");
30 function getVersion() {
31 return preg_replace("/[Revision: $]/", '',
35 function getDefaultArguments() {
36 //php-4.0.4pl1 breaks at the parent:: line even if the
37 // code doesn't reach this line
38 //if (!check_php_version(4,0,6))
39 $args = WikiPlugin_RecentChanges::getDefaultArguments();
40 //else $args = parent::getDefaultArguments();
41 $args['page'] = '[pagename]';
42 $args['show_minor'] = true;
43 $args['show_all'] = true;
44 $args['caption'] = _("Related Changes");
48 function getChanges ($dbi, $args) {
49 $changes = $dbi->mostRecent($this->getMostRecentParams($args));
51 $show_deleted = $args['show_deleted'];
52 if ($show_deleted == 'sometimes')
53 $show_deleted = $args['show_minor'];
55 $changes = new NonDeletedRevisionIterator($changes, !$args['show_all']);
57 // sort out pages not linked from our page
58 $changes = new RelatedChangesRevisionIterator($changes, $dbi, $args['page']);
62 // box is used to display a fixed-width, narrow version with common header.
63 // just a numbered list of limit pagenames, without date.
64 function box($args = false, $request = false, $basepage = false) {
65 if (!$request) $request =& $GLOBALS['request'];
66 if (!isset($args['limit'])) $args['limit'] = 15;
67 $args['format'] = 'box';
68 $args['show_minor'] = false;
69 $args['show_major'] = true;
70 $args['show_deleted'] = false;
71 $args['show_all'] = false;
73 return $this->makeBox(WikiLink(_("RelatedChanges"),'',_("Related Changes")),
74 $this->format($this->getChanges($request->_dbi, $args), $args));
77 function format ($changes, $args) {
79 $format = $args['format'];
81 $fmt_class = $WikiTheme->getFormatter('RelatedChanges', $format);
84 $fmt_class = '_RecentChanges_RssFormatter';
85 elseif ($format == 'rss2')
86 $fmt_class = '_RecentChanges_Rss2Formatter';
87 elseif ($format == 'rss091') {
88 include_once "lib/RSSWriter091.php";
89 $fmt_class = '_RecentChanges_RssFormatter091';
91 elseif ($format == 'sidebar')
92 $fmt_class = '_RecentChanges_SideBarFormatter';
93 elseif ($format == 'box')
94 $fmt_class = '_RecentChanges_BoxFormatter';
96 $fmt_class = '_RelatedChanges_HtmlFormatter';
99 $fmt = new $fmt_class($args);
100 return $fmt->format($changes);
105 * list of pages which are linked from the current page.
106 * i.e. sort out all non-linked pages.
108 class RelatedChangesRevisionIterator extends WikiDB_PageRevisionIterator
110 function RelatedChangesRevisionIterator ($revisions, &$dbi, $pagename) {
111 $this->_revisions = $revisions;
112 $this->_wikidb = $dbi;
113 $page = $dbi->getPage($pagename);
114 $links = $page->getLinks();
115 $this->_links = array();
116 while ($linked_page = $links->next()) {
117 $this->_links[$linked_page->_pagename] = 1;
123 while (($rev = $this->_revisions->next())) {
124 if (isset($this->_links[$rev->_pagename]))
132 // $Log: not supported by cvs2svn $
133 // Revision 1.4 2005/01/24 23:15:27 uckelman
134 // The extra description for RelatedChanges was appearing in RecentChanges
135 // and PageHistory due to a bad test in _RecentChanges_HtmlFormatter. Fixed.
137 // Revision 1.3 2004/06/03 18:58:27 rurban
138 // days links requires action=RelatedChanges arg
140 // Revision 1.2 2004/05/08 14:06:13 rurban
141 // new support for inlined image attributes: [image.jpg size=50x30 align=right]
142 // minor stability and portability fixes
144 // Revision 1.1 2004/04/21 04:29:10 rurban
145 // Two convenient RecentChanges extensions
146 // RelatedChanges (only links from current page)
147 // RecentEdits (just change the default args)
150 // (c-file-style: "gnu")
155 // c-hanging-comment-ender-p: nil
156 // indent-tabs-mode: nil