]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RecentChanges.php
Add getDescription function
[SourceForge/phpwiki.git] / lib / plugin / RecentChanges.php
1 <?php // -*-php-*-
2 rcs_id('$Id$');
3 /**
4  Copyright 1999,2000,2001,2002,2007 $ThePhpWikiProgrammingTeam
5  Copyright 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent
6
7  This file is part of PhpWiki.
8
9  PhpWiki is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13
14  PhpWiki is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with PhpWiki; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 include_once("lib/WikiPlugin.php");
25
26 class _RecentChanges_Formatter
27 {
28     var $_absurls = false;
29     var $action = "RecentChanges";
30
31     function _RecentChanges_Formatter ($rc_args) {
32         $this->_args = $rc_args;
33         $this->_diffargs = array('action' => 'diff');
34
35         if ($rc_args['show_minor'] || !$rc_args['show_major'])
36             $this->_diffargs['previous'] = 'minor';
37
38         // PageHistoryPlugin doesn't have a 'daylist' arg.
39         if (!isset($this->_args['daylist']))
40             $this->_args['daylist'] = false;
41     }
42
43     function title () {
44         global $request;
45         extract($this->_args);
46         if ($author) {
47             $title = $author;
48             if ($title == '[]') {
49                 $title = $request->_user->getID();
50             }
51             $title = _("UserContribs").": $title";
52         } elseif ($owner) {
53             $title = $owner;
54             if ($title == '[]') {
55                 $title = $request->_user->getID();
56             }
57             $title = _("UserContribs").": $title";
58         } elseif ($only_new) {
59             $title = _("RecentNewPages");
60         } elseif ($show_minor) {
61             $title = _("RecentEdits");
62         } else $title = _("RecentChanges");
63
64         if (!empty($category))
65             $title = $category;
66         elseif (!empty($pagematch))
67             $title .= ":$pagematch";
68         return $title;
69     }
70
71     function include_versions_in_URLs() {
72         return (bool) $this->_args['show_all'];
73     }
74
75     function date ($rev) {
76         global $WikiTheme;
77         return $WikiTheme->getDay($rev->get('mtime'));
78     }
79
80     function time ($rev) {
81         global $WikiTheme;
82         return $WikiTheme->formatTime($rev->get('mtime'));
83     }
84
85     function diffURL ($rev) {
86         $args = $this->_diffargs;
87         if ($this->include_versions_in_URLs())
88             $args['version'] = $rev->getVersion();
89         $page = $rev->getPage();
90         return WikiURL($page->getName(), $args, $this->_absurls);
91     }
92
93     function historyURL ($rev) {
94         $page = $rev->getPage();
95         return WikiURL($page, array('action' => _("PageHistory")),
96                        $this->_absurls);
97     }
98
99     function pageURL ($rev) {
100         return WikiURL($this->include_versions_in_URLs() ? $rev : $rev->getPage(),
101                        '', $this->_absurls);
102     }
103
104     function authorHasPage ($author) {
105         global $WikiNameRegexp, $request;
106         $dbi = $request->getDbh();
107         return isWikiWord($author) && $dbi->isWikiPage($author);
108     }
109
110     function authorURL ($author) {
111         return $this->authorHasPage() ? WikiURL($author) : false;
112     }
113
114
115     function status ($rev) {
116         if ($rev->hasDefaultContents())
117             return 'deleted';
118         $page = $rev->getPage();
119         $prev = $page->getRevisionBefore($rev->getVersion());
120         if ($prev->hasDefaultContents())
121             return 'new';
122         return 'updated';
123     }
124
125     function importance ($rev) {
126         return $rev->get('is_minor_edit') ? 'minor' : 'major';
127     }
128
129     function summary($rev) {
130         if ( ($summary = $rev->get('summary')) )
131             return $summary;
132
133         switch ($this->status($rev)) {
134             case 'deleted':
135                 return _("Deleted");
136             case 'new':
137                 return _("New page");
138             default:
139                 return '';
140         }
141     }
142
143     function setValidators($most_recent_rev) {
144         $rev = $most_recent_rev;
145         $validators = array('RecentChanges-top' =>
146                             array($rev->getPageName(), $rev->getVersion()),
147                             '%mtime' => $rev->get('mtime'));
148         global $request;
149         $request->appendValidators($validators);
150     }
151 }
152
153 class _RecentChanges_HtmlFormatter
154 extends _RecentChanges_Formatter
155 {
156     function diffLink ($rev) {
157         global $WikiTheme;
158         $button = $WikiTheme->makeButton(_("diff"), $this->diffURL($rev), 'wiki-rc-action');
159         $button->setAttr('rel', 'nofollow');
160         return HTML("(",$button,")");
161     }
162
163     /* deletions: red, additions: green */
164     function diffSummary ($rev) {
165         $html = $this->diffURL($rev);
166         return '';
167     }
168
169     function historyLink ($rev) {
170         global $WikiTheme;
171         $button = $WikiTheme->makeButton(_("hist"), $this->historyURL($rev), 'wiki-rc-action');
172         $button->setAttr('rel', 'nofollow');
173         return HTML("(",$button,")");
174     }
175
176     function pageLink ($rev, $link_text=false) {
177
178         return WikiLink($this->include_versions_in_URLs() ? $rev : $rev->getPage(),
179                         'auto', $link_text);
180         /*
181         $page = $rev->getPage();
182         global $WikiTheme;
183         if ($this->include_versions_in_URLs()) {
184             $version = $rev->getVersion();
185             if ($rev->isCurrent())
186                 $version = false;
187             $exists = !$rev->hasDefaultContents();
188         }
189         else {
190             $version = false;
191             $cur = $page->getCurrentRevision();
192             $exists = !$cur->hasDefaultContents();
193         }
194         if ($exists)
195             return $WikiTheme->linkExistingWikiWord($page->getName(), $link_text, $version);
196         else
197             return $WikiTheme->linkUnknownWikiWord($page->getName(), $link_text);
198         */
199     }
200
201     function authorLink ($rev) {
202         return WikiLink($rev->get('author'), 'if_known');
203     }
204
205     /* Link to all users contributions (contribs and owns) */
206     function authorContribs ($rev) {
207         $author = $rev->get('author');
208         if (preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $author)) return '';
209         return HTML('(',
210                     Button(array('action' => _("RecentChanges"), 
211                                  'format' => 'contribs',
212                                  'author' => $author,
213                                  'days' => 360),
214                            _("contribs"),
215                            $author),
216                     ' | ',
217                     Button(array('action' => _("RecentChanges"), 
218                                  'format' => 'contribs',
219                                  'owner' => $author,
220                                  'days' => 360),
221                            _("new pages"),
222                            $author),
223                     ')');
224     }
225
226     function summaryAsHTML ($rev) {
227         if ( !($summary = $this->summary($rev)) )
228             return '';
229         return  HTML::span( array('class' => 'wiki-summary'),
230                             "(",
231                             TransformLinks($summary, $rev->get('markup'), $rev->getPageName()),
232                             ")");
233     }
234
235     function format_icon ($format, $filter = array()) {
236         global $request, $WikiTheme;
237         $args = $this->_args;
238         // remove links not used for those formats
239         unset($args['daylist']);
240         unset($args['difflinks']);
241         unset($args['historylinks']);
242         $rss_url = $request->getURLtoSelf
243                 (array_merge($args,
244                              array('action' => $this->action, 'format' => $format), 
245                              $filter));
246         return $WikiTheme->makeButton($format, $rss_url, 'rssicon');
247     }
248
249     function rss_icon ($args=array())  { return $this->format_icon("rss", $args); }
250     function rss2_icon ($args=array()) { return $this->format_icon("rss2", $args); }
251     function atom_icon ($args=array()) { return $this->format_icon("atom", $args); }
252     function rdf_icon ($args=array())  { return DEBUG ? $this->format_icon("rdf", $args) : ''; }
253     function rdfs_icon ($args=array()) { return DEBUG ? $this->format_icon("rdfs", $args) : ''; }
254     function owl_icon ($args=array())  { return DEBUG ? $this->format_icon("owl", $args) : ''; }
255
256     function grazr_icon ($args = array()) {
257         global $request, $WikiTheme;
258         if (is_localhost()) return '';
259         if (SERVER_PROTOCOL == "https") return '';
260         $our_url = WikiURL($request->getArg('pagename'),
261                     array_merge(array('action' => $this->action, 'format' => 'rss2'), $args), 
262                     true);
263         $rss_url = 'http://grazr.com/gzpanel.html?' . $our_url;
264         return $WikiTheme->makeButton("grazr", $rss_url, 'rssicon');
265     }
266
267     function pre_description () {
268         extract($this->_args);
269         // FIXME: say something about show_all.
270         if ($show_major && $show_minor)
271             $edits = _("edits");
272         elseif ($show_major)
273             $edits = _("major edits");
274         else
275             $edits = _("minor edits");
276         if (isset($caption) and $caption == _("Recent Comments"))
277             $edits = _("comments");
278         if (!empty($only_new)) {
279             $edits = _("created new pages");
280         }
281         if (!empty($author)) {
282             global $request;
283             if ($author == '[]')
284                 $author = $request->_user->getID();
285             $edits .= sprintf(_(" for pages changed by %s"), $author);
286         }
287         if (!empty($owner)) {
288             global $request;
289             if ($owner == '[]')
290                 $owner = $request->_user->getID();
291             $edits .= sprintf(_(" for pages owned by %s"), $owner);
292         }
293         if (!empty($category)) {
294             $edits .= sprintf(_(" for all pages linking to %s"), $category);
295         }
296         if (!empty($pagematch)) {
297             $edits .= sprintf(_(" for all pages matching '%s'"), $pagematch);
298         }
299         if ($timespan = $days > 0) {
300             if (intval($days) != $days)
301                 $days = sprintf("%.1f", $days);
302         }
303         $lmt = abs($limit);
304         /**
305          * Depending how this text is split up it can be tricky or
306          * impossible to translate with good grammar. So the seperate
307          * strings for 1 day and %s days are necessary in this case
308          * for translating to multiple languages, due to differing
309          * overlapping ideal word cutting points.
310          *
311          * en: day/days "The %d most recent %s [during (the past] day) are listed below."
312          * de: 1 Tag    "Die %d jüngste %s [innerhalb (von des letzten] Tages) sind unten aufgelistet."
313          * de: %s days  "Die %d jüngste %s [innerhalb (von] %s Tagen) sind unten aufgelistet."
314          *
315          * en: day/days "The %d most recent %s during [the past] (day) are listed below."
316          * fr: 1 jour   "Les %d %s les plus récentes pendant [le dernier (d'une] jour) sont Ã©numérées ci-dessous."
317          * fr: %s jours "Les %d %s les plus récentes pendant [les derniers (%s] jours) sont Ã©numérées ci-dessous."
318          */
319         if ($limit > 0) {
320             if ($timespan) {
321                 if (intval($days) == 1)
322                     $desc = fmt("The %d most recent %s during the past day are listed below.",
323                                 $limit, $edits);
324                 else
325                     $desc = fmt("The %d most recent %s during the past %s days are listed below.",
326                                 $limit, $edits, $days);
327             } else
328                 $desc = fmt("The %d most recent %s are listed below.",
329                             $limit, $edits);
330         }
331         elseif ($limit < 0) {  //$limit < 0 means we want oldest pages
332             if ($timespan) {
333                 if (intval($days) == 1)
334                     $desc = fmt("The %d oldest %s during the past day are listed below.",
335                                 $lmt, $edits);
336                 else
337                     $desc = fmt("The %d oldest %s during the past %s days are listed below.",
338                                 $lmt, $edits, $days);
339             } else
340                 $desc = fmt("The %d oldest %s are listed below.",
341                             $lmt, $edits);
342         }
343
344         else {
345             if ($timespan) {
346                 if (intval($days) == 1)
347                     $desc = fmt("The most recent %s during the past day are listed below.",
348                                 $edits);
349                 else
350                     $desc = fmt("The most recent %s during the past %s days are listed below.",
351                                 $edits, $days);
352             } else
353                 $desc = fmt("All %s are listed below.", $edits);
354         }
355         return $desc;
356     }    
357
358     function description() {
359         return HTML::p(false, $this->pre_description());
360     }
361
362     /* was title */
363     function headline () {
364         extract($this->_args);
365         return array($this->title(),
366                      ' ',
367                      $this->rss_icon(), 
368                      $this->rss2_icon(),
369                      $this->atom_icon(),
370                      $this->rdf_icon(),
371                      /*$this->rdfs_icon(),
372                        $this->owl_icon(),*/
373                      $this->grazr_icon(),
374                      $this->sidebar_link());
375     }
376
377     function empty_message() {
378         if (isset($this->_args['caption']) and $this->_args['caption'] == _("Recent Comments"))
379             return _("No comments found");
380         else 
381             return _("No changes found");
382     }
383         
384     function sidebar_link() {
385         extract($this->_args);
386         $pagetitle = $show_minor ? _("RecentEdits") : _("RecentChanges");
387
388         global $request;
389         $sidebarurl = WikiURL($pagetitle, array('format' => 'sidebar'), 'absurl');
390
391         $addsidebarjsfunc =
392             "function addPanel() {\n"
393             ."    window.sidebar.addPanel (\"" . sprintf("%s - %s", WIKI_NAME, $pagetitle) . "\",\n"
394             ."       \"$sidebarurl\",\"\");\n"
395             ."}\n";
396         $jsf = JavaScript($addsidebarjsfunc);
397
398         global $WikiTheme;
399         $sidebar_button = $WikiTheme->makeButton("sidebar", 'javascript:addPanel();', 'sidebaricon', 
400                                                  array('title' => _("Click to add this feed to your sidebar"),
401                                                        'style' => 'font-size:9pt;font-weight:normal; vertical-align:middle;'));
402         $addsidebarjsclick = asXML($sidebar_button);
403         $jsc = JavaScript("if ((typeof window.sidebar == 'object') &&\n"
404                                 ."    (typeof window.sidebar.addPanel == 'function'))\n"
405                                 ."   {\n"
406                                 ."       document.write('$addsidebarjsclick');\n"
407                                 ."   }\n"
408                                 );
409         return HTML(new RawXML("\n"), $jsf, new RawXML("\n"), $jsc);
410     }
411
412     function format ($changes) {
413         include_once('lib/InlineParser.php');
414         
415         $html = HTML(HTML::h2(false, $this->headline()));
416         if (($desc = $this->description()))
417             $html->pushContent($desc);
418         
419         if ($this->_args['daylist']) {
420             $html->pushContent(new OptionsButtonBars($this->_args));
421         }
422
423         $last_date = '';
424         $lines = false;
425         $first = true;
426
427         while ($rev = $changes->next()) {
428             if (($date = $this->date($rev)) != $last_date) {
429                 if ($lines)
430                     $html->pushContent($lines);
431                 // for user contributions no extra date line
432                 $html->pushContent(HTML::h3($date));
433                 $lines = HTML::ul();
434                 $last_date = $date;
435
436             }
437             // enforce view permission
438             if (mayAccessPage('view', $rev->_pagename)) {
439                 $lines->pushContent($this->format_revision($rev));
440                 if ($first)
441                     $this->setValidators($rev);
442                 $first = false;
443             }
444         }
445         if ($lines)
446             $html->pushContent($lines);
447         if ($first)
448             $html->pushContent(HTML::p(array('class' => 'rc-empty'),
449                                        $this->empty_message()));
450         
451         return $html;
452     }
453
454     function format_revision ($rev) {
455         global $WikiTheme;
456         $args = &$this->_args;
457
458         $class = 'rc-' . $this->importance($rev);
459
460         $time = $this->time($rev);
461         if (! $rev->get('is_minor_edit'))
462             $time = HTML::span(array('class' => 'pageinfo-majoredit'), $time);
463
464         $line = HTML::li(array('class' => $class));
465
466         if ($args['difflinks'])
467             $line->pushContent($this->diffLink($rev), ' ');
468
469         if ($args['historylinks'])
470             $line->pushContent($this->historyLink($rev), ' ');
471
472         // Do not display a link for a deleted page, just the page name
473         if ($rev->hasDefaultContents()) {
474             $linkorname = $rev->_pagename;
475         } else {
476             $linkorname = $this->pageLink($rev);
477         }
478
479         if ((isa($WikiTheme, 'WikiTheme_MonoBook')) or (isa($WikiTheme, 'WikiTheme_gforge'))) {
480             $line->pushContent(
481                                $args['historylinks'] ? '' : $this->historyLink($rev),
482                                ' . . ', $linkorname, '; ',
483                                $time, ' . . ',
484                                $this->authorLink($rev),' ',
485                                $this->authorContribs($rev),' ',
486                                $this->summaryAsHTML($rev));
487         } else {
488             $line->pushContent($linkorname, ' ',
489                                $time, ' ',
490                                $this->summaryAsHTML($rev),
491                                ' ... ',
492                                $this->authorLink($rev));
493         }
494         return $line;
495     }
496
497 }
498
499 /* format=contribs: no seperation into extra dates
500  * 14:41, 3 December 2006 (hist) (diff) Talk:PhpWiki (added diff link)  (top)
501  */
502 class _RecentChanges_UserContribsFormatter
503 extends _RecentChanges_HtmlFormatter
504 {
505     function headline () {
506         global $request;
507         extract($this->_args);
508         if ($author == '[]') $author = $request->_user->getID();
509         if ($owner  == '[]') $owner = $request->_user->getID();
510         $author_args = $owner
511             ? array('owner' => $owner)
512             : array('author' => $author);
513         return array(_("UserContribs"),":",$owner ? $owner : $author,
514                      ' ',
515                      $this->rss_icon($author_args), 
516                      $this->rss2_icon($author_args),
517                      $this->atom_icon($author_args),
518                      $this->rdf_icon($author_args),
519                      $this->grazr_icon($author_args));
520     }
521
522     function format ($changes) {
523         include_once('lib/InlineParser.php');
524         
525         $html = HTML(HTML::h2(false, $this->headline()));
526         $lines = HTML::ol();
527         $first = true; $count = 0;
528         while ($rev = $changes->next()) {
529             if (mayAccessPage('view', $rev->_pagename)) {
530                 $lines->pushContent($this->format_revision($rev));
531                 if ($first)
532                     $this->setValidators($rev);
533                 $first = false;
534             }
535             $count++;
536         }
537         $this->_args['limit'] = $count;
538         if (($desc = $this->description()))
539             $html->pushContent($desc);
540         if ($this->_args['daylist']) {
541             $html->pushContent(new OptionsButtonBars($this->_args));
542         }
543         if ($first)
544             $html->pushContent(HTML::p(array('class' => 'rc-empty'),
545                                        $this->empty_message()));
546         else                               
547             $html->pushContent($lines);
548         
549         return $html;
550     }
551
552     function format_revision ($rev) {
553         $args = &$this->_args;
554         $class = 'rc-' . $this->importance($rev);
555         $time = $this->time($rev);
556         if (! $rev->get('is_minor_edit'))
557             $time = HTML::span(array('class' => 'pageinfo-majoredit'), $time);
558
559         $line = HTML::li(array('class' => $class));
560
561         $line->pushContent($this->time($rev),", ");
562         $line->pushContent($this->date($rev)," ");
563         $line->pushContent($this->diffLink($rev), ' ');
564         $line->pushContent($this->historyLink($rev), ' ');
565         $line->pushContent($this->pageLink($rev), ' ',
566                            $this->summaryAsHTML($rev));
567         return $line;
568     }
569 }
570
571 class _RecentChanges_SideBarFormatter
572 extends _RecentChanges_HtmlFormatter
573 {
574     function rss_icon () {
575         //omit rssicon
576     }
577     function rss2_icon () { }
578     function headline () {
579         //title click opens the normal RC or RE page in the main browser frame
580         extract($this->_args);
581         $titlelink = WikiLink($this->title());
582         $titlelink->setAttr('target', '_content');
583         return HTML($this->logo(), $titlelink);
584     }
585     function logo () {
586         //logo click opens the HomePage in the main browser frame
587         global $WikiTheme;
588         $img = HTML::img(array('src' => $WikiTheme->getImageURL('logo'),
589                                'border' => 0,
590                                'align' => 'right',
591                                'style' => 'height:2.5ex'
592                                ));
593         $linkurl = WikiLink(HOME_PAGE, false, $img);
594         $linkurl->setAttr('target', '_content');
595         return $linkurl;
596     }
597
598     function authorLink ($rev) {
599         $author = $rev->get('author');
600         if ( $this->authorHasPage($author) ) {
601             $linkurl = WikiLink($author);
602             $linkurl->setAttr('target', '_content'); // way to do this using parent::authorLink ??
603             return $linkurl;
604         } else
605             return $author;
606     }
607
608     function diffLink ($rev) {
609         $linkurl = parent::diffLink($rev);
610         $linkurl->setAttr('target', '_content');
611         $linkurl->setAttr('rel', 'nofollow');
612         // FIXME: Smelly hack to get smaller diff buttons in sidebar
613         $linkurl = new RawXML(str_replace('<img ', '<img style="height:2ex" ', asXML($linkurl)));
614         return $linkurl;
615     }
616     function historyLink ($rev) {
617         $linkurl = parent::historyLink($rev);
618         $linkurl->setAttr('target', '_content');
619         // FIXME: Smelly hack to get smaller history buttons in sidebar
620         $linkurl = new RawXML(str_replace('<img ', '<img style="height:2ex" ', asXML($linkurl)));
621         return $linkurl;
622     }
623     function pageLink ($rev) {
624         $linkurl = parent::pageLink($rev);
625         $linkurl->setAttr('target', '_content');
626         return $linkurl;
627     }
628     // Overriding summaryAsHTML, because there is no way yet to
629     // return summary as transformed text with
630     // links setAttr('target', '_content') in Mozilla sidebar.
631     // So for now don't create clickable links inside summary
632     // in the sidebar, or else they target the sidebar and not the
633     // main content window.
634     function summaryAsHTML ($rev) {
635         if ( !($summary = $this->summary($rev)) )
636             return '';
637         return HTML::span(array('class' => 'wiki-summary'),
638                           "[",
639                           /*TransformLinks(*/$summary,/* $rev->get('markup')),*/
640                           "]");
641     }
642
643
644     function format ($changes) {
645         $this->_args['daylist'] = false; //don't show day buttons in Mozilla sidebar
646         $html = _RecentChanges_HtmlFormatter::format ($changes);
647         $html = HTML::div(array('class' => 'wikitext'), $html);
648         global $request;
649         $request->discardOutput();
650         
651         printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", $GLOBALS['charset']);
652         printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"');
653         printf('  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
654         printf('<html xmlns="http://www.w3.org/1999/xhtml">');
655
656         printf("<head>\n");
657         extract($this->_args);
658         if (!empty($category))
659             $title = $category;
660         elseif (!empty($pagematch))
661             $title = $pagematch;
662         else
663             $title = WIKI_NAME . $show_minor ? _("RecentEdits") : _("RecentChanges");
664         printf("<title>" . $title . "</title>\n");
665         global $WikiTheme;
666         $css = $WikiTheme->getCSS();
667         $css->PrintXML();
668         printf("</head>\n");
669
670         printf("<body class=\"sidebar\">\n");
671         $html->PrintXML();
672         echo '<a href="http://www.feedvalidator.org/check.cgi?url=http://phpwiki.org/RecentChanges?format=rss"><img src="themes/default/buttons/valid-rss.png" alt="[Valid RSS]" title="Validate the RSS feed" width="44" height="15" /></a>';
673         printf("\n</body>\n");
674         printf("</html>\n");
675
676         $request->finish(); // cut rest of page processing short
677     }
678 }
679
680 class _RecentChanges_BoxFormatter
681 extends _RecentChanges_HtmlFormatter
682 {
683     function rss_icon () {
684     }
685     function rss2_icon () {
686     }
687     function headline () {
688     }
689     function authorLink ($rev) {
690     }
691     function diffLink ($rev) {
692     }
693     function historyLink ($rev) {
694     }
695     function summaryAsHTML ($rev) {
696     }
697     function description () {
698     }
699     function format ($changes) {
700         include_once('lib/InlineParser.php');
701         $last_date = '';
702         $first = true;
703         $html = HTML();
704         $counter = 1;
705         $sp = HTML::Raw("\n&nbsp;&middot;&nbsp;");
706         while ($rev = $changes->next()) {
707             // enforce view permission
708             if (mayAccessPage('view',$rev->_pagename)) {
709                 if ($link = $this->pageLink($rev)) // some entries may be empty 
710                                                    // (/Blog/.. interim pages)
711                     $html->pushContent($sp, $link, HTML::br());
712                 if ($first)
713                     $this->setValidators($rev);
714                 $first = false;
715             }
716         }
717         if ($first)
718             $html->pushContent(HTML::p(array('class' => 'rc-empty'),
719                                        $this->empty_message()));
720         return $html;
721     }
722 }
723
724 class _RecentChanges_RssFormatter
725 extends _RecentChanges_Formatter
726 {
727     var $_absurls = true;
728
729     function time ($rev) {
730         return Iso8601DateTime($rev->get('mtime'));
731     }
732
733     function pageURI ($rev) {
734         return WikiURL($rev, '', 'absurl');
735     }
736
737     function format ($changes) {
738         
739         include_once('lib/RssWriter.php');
740         $rss = new RssWriter;
741         $rss->channel($this->channel_properties());
742
743         if (($props = $this->image_properties()))
744             $rss->image($props);
745         if (($props = $this->textinput_properties()))
746             $rss->textinput($props);
747
748         $first = true;
749         while ($rev = $changes->next()) {
750             // enforce view permission
751             if (mayAccessPage('view', $rev->_pagename)) {
752                 $rss->addItem($this->item_properties($rev),
753                               $this->pageURI($rev));
754                 if ($first)
755                     $this->setValidators($rev);
756                 $first = false;
757             }
758         }
759
760         global $request;
761         $request->discardOutput();
762         $rss->finish();
763         //header("Content-Type: application/rss+xml; charset=" . $GLOBALS['charset']);
764         printf("\n<!-- Generated by PhpWiki-%s:\n%s-->\n", PHPWIKI_VERSION, $GLOBALS['RCS_IDS']);
765
766         // Flush errors in comment, otherwise it's invalid XML.
767         global $ErrorManager;
768         if (($errors = $ErrorManager->getPostponedErrorsAsHTML()))
769             printf("\n<!-- PHP Warnings:\n%s-->\n", AsXML($errors));
770
771         $request->finish();     // NORETURN!!!!
772     }
773
774     function image_properties () {
775         global $WikiTheme;
776
777         $img_url = AbsoluteURL($WikiTheme->getImageURL('logo'));
778         if (!$img_url)
779             return false;
780
781         return array('title' => WIKI_NAME,
782                      'link' => WikiURL(HOME_PAGE, false, 'absurl'),
783                      'url' => $img_url);
784     }
785
786     function textinput_properties () {
787         return array('title' => _("Search"),
788                      'description' => _("Title Search"),
789                      'name' => 's',
790                      'link' => WikiURL(_("TitleSearch"), false, 'absurl'));
791     }
792
793     function channel_properties () {
794         global $request;
795
796         $rc_url = WikiURL($request->getArg('pagename'), false, 'absurl');
797         extract($this->_args);
798         $title = WIKI_NAME;
799         $description = $this->title();
800         if ($category)
801             $title = $category;
802         elseif ($pagematch)
803             $title = $pagematch;
804         return array('title' => $title,
805                      'link' => $rc_url,
806                      'description' => $description,
807                      'dc:date' => Iso8601DateTime(time()),
808                      'dc:language' => $GLOBALS['LANG']);
809
810         /* FIXME: other things one might like in <channel>:
811          * sy:updateFrequency
812          * sy:updatePeriod
813          * sy:updateBase
814          * dc:subject
815          * dc:publisher
816          * dc:language
817          * dc:rights
818          * rss091:language
819          * rss091:managingEditor
820          * rss091:webmaster
821          * rss091:lastBuildDate
822          * rss091:copyright
823          */
824     }
825
826     function item_properties ($rev) {
827         $page = $rev->getPage();
828         $pagename = $page->getName();
829
830         return array( 'title'           => SplitPagename($pagename),
831                       'description'     => $this->summary($rev),
832                       'link'            => $this->pageURL($rev),
833                       'dc:date'         => $this->time($rev),
834                       'dc:contributor'  => $rev->get('author'),
835                       'wiki:version'    => $rev->getVersion(),
836                       'wiki:importance' => $this->importance($rev),
837                       'wiki:status'     => $this->status($rev),
838                       'wiki:diff'       => $this->diffURL($rev),
839                       'wiki:history'    => $this->historyURL($rev)
840                       );
841     }
842 }
843
844 /** explicit application/rss+xml Content-Type,
845  * simplified xml structure (no namespace),
846  * support for xml-rpc cloud registerProcedure (not yet)
847  */
848 class _RecentChanges_Rss2Formatter
849 extends _RecentChanges_RssFormatter {
850
851     function format ($changes) {
852         include_once('lib/RssWriter2.php');
853         $rss = new RssWriter2;
854
855         $rss->channel($this->channel_properties());
856         if (($props = $this->cloud_properties()))
857             $rss->cloud($props);
858         if (($props = $this->image_properties()))
859             $rss->image($props);
860         if (($props = $this->textinput_properties()))
861             $rss->textinput($props);
862         $first = true;
863         while ($rev = $changes->next()) {
864             // enforce view permission
865             if (mayAccessPage('view', $rev->_pagename)) {
866                 $rss->addItem($this->item_properties($rev),
867                               $this->pageURI($rev));
868                 if ($first)
869                     $this->setValidators($rev);
870                 $first = false;
871             }
872         }
873
874         global $request;
875         $request->discardOutput();
876         $rss->finish();
877         //header("Content-Type: application/rss+xml; charset=" . $GLOBALS['charset']);
878         printf("\n<!-- Generated by PhpWiki-%s:\n%s-->\n", PHPWIKI_VERSION, $GLOBALS['RCS_IDS']);
879         // Flush errors in comment, otherwise it's invalid XML.
880         global $ErrorManager;
881         if (($errors = $ErrorManager->getPostponedErrorsAsHTML()))
882             printf("\n<!-- PHP Warnings:\n%s-->\n", AsXML($errors));
883
884         $request->finish();     // NORETURN!!!!
885     }
886
887     function channel_properties () {
888         $chann_10 = parent::channel_properties();
889         return array_merge($chann_10,
890                            array('generator' => 'PhpWiki-'.PHPWIKI_VERSION,
891                                  //<pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
892                                  //<lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
893                                  //<docs>http://blogs.law.harvard.edu/tech/rss</docs>
894                                  'copyright' => COPYRIGHTPAGE_URL
895                                  ));
896     }
897
898     // xml-rpc registerProcedure not yet implemented
899     function cloud_properties () { return false; } 
900     function cloud_properties_test () {
901         return array('protocol' => 'xml-rpc', // xml-rpc or soap or http-post
902                      'registerProcedure' => 'wiki.rssPleaseNotify',
903                      'path' => DATA_PATH.'/RPC2.php',
904                      'port' => !SERVER_PORT ? '80' : (SERVER_PROTOCOL == 'https' ? '443' : '80'),
905                      'domain' => SERVER_NAME);
906     }
907 }
908
909 /** Explicit application/atom+xml Content-Type
910  *  A weird, questionable format
911  */
912 class _RecentChanges_AtomFormatter
913 extends _RecentChanges_RssFormatter {
914
915     function format ($changes) {
916         global $request;
917         include_once('lib/RssWriter.php');
918         $rss = new AtomFeed;
919
920         // "channel" is called "feed" in atom
921         $rc_url = WikiURL($request->getArg('pagename'), false, 'absurl');
922         extract($this->_args);
923         $title = WIKI_NAME;
924         $description = $this->title();
925         if ($category)
926             $title = $category;
927         elseif ($pagematch)
928             $title = $pagematch;
929         $feed_props = array('title' => $description,
930                             'link' => array('rel'=>"alternate",
931                                             'type'=>"text/html",
932                                             'href' => $rc_url),
933                             'id' => md5($rc_url),                
934                             'modified' => Iso8601DateTime(time()),
935                             'generator' => 'PhpWiki-'.PHPWIKI_VERSION,
936                             'tagline' => '');
937         $rss->feed($feed_props);
938         $first = true;
939         while ($rev = $changes->next()) {
940             // enforce view permission
941             if (mayAccessPage('view', $rev->_pagename)) {
942                 $props = $this->item_properties($rev);
943                 $rss->addItem($props,
944                               false,
945                               $this->pageURI($rev));
946                 if ($first)
947                     $this->setValidators($rev);
948                 $first = false;
949             }
950         }
951
952         $request->discardOutput();
953         $rss->finish();
954         //header("Content-Type: application/atom; charset=" . $GLOBALS['charset']);
955         printf("\n<!-- Generated by PhpWiki-%s:\n%s-->\n", PHPWIKI_VERSION, $GLOBALS['RCS_IDS']);
956         // Flush errors in comment, otherwise it's invalid XML.
957         global $ErrorManager;
958         if (($errors = $ErrorManager->getPostponedErrorsAsHTML()))
959             printf("\n<!-- PHP Warnings:\n%s-->\n", AsXML($errors));
960
961         $request->finish();     // NORETURN!!!!
962     }
963
964     function item_properties ($rev) {
965         $page = $rev->getPage();
966         $pagename = $page->getName();
967         return array( 'title'           => $pagename,
968                       'link'            => array('rel' => 'alternate',
969                                                  'type' => 'text/html',
970                                                  'href' => $this->pageURL($rev)),
971                       'summary'         => $this->summary($rev),
972                       'modified'        => $this->time($rev)."Z",
973                       'issued'          => $this->time($rev),
974                       'created'         => $this->time($rev)."Z",
975                       'author'          => new XmlElement('author', new XmlElement('name', $rev->get('author')))
976                       );
977     }
978 }
979
980 /**
981  * Filter by non-empty
982  */
983 class NonDeletedRevisionIterator extends WikiDB_PageRevisionIterator
984 {
985     /** Constructor
986      *
987      * @param $revisions object a WikiDB_PageRevisionIterator.
988      */
989     function NonDeletedRevisionIterator ($revisions, $check_current_revision = true) {
990         $this->_revisions = $revisions;
991         $this->_check_current_revision = $check_current_revision;
992     }
993
994     function next () {
995         while (($rev = $this->_revisions->next())) {
996             if ($this->_check_current_revision) {
997                 $page = $rev->getPage();
998                 $check_rev = $page->getCurrentRevision();
999             }
1000             else {
1001                 $check_rev = $rev;
1002             }
1003             if (! $check_rev->hasDefaultContents())
1004                 return $rev;
1005         }
1006         $this->free();
1007         return false;
1008     }
1009
1010 }
1011
1012 /**
1013  * Filter by only_new.
1014  * Only new created pages
1015  */
1016 class NewPageRevisionIterator extends WikiDB_PageRevisionIterator
1017 {
1018     /** Constructor
1019      *
1020      * @param $revisions object a WikiDB_PageRevisionIterator.
1021      */
1022     function NewPageRevisionIterator ($revisions) {
1023         $this->_revisions = $revisions;
1024     }
1025
1026     function next () {
1027         while (($rev = $this->_revisions->next())) {
1028             if ($rev->getVersion() == 1)
1029                 return $rev;
1030         }
1031         $this->free();
1032         return false;
1033     }
1034 }
1035
1036 /**
1037  * Only pages with links to a certain category
1038  */
1039 class LinkRevisionIterator extends WikiDB_PageRevisionIterator
1040 {
1041     function LinkRevisionIterator ($revisions, $category) {
1042         $this->_revisions = $revisions;
1043         if (preg_match("/[\?\.\*]/", $category)) {
1044           $backlinkiter = $this->_revisions->_wikidb->linkSearch
1045             (new TextSearchQuery("*", true), 
1046              new TextSearchQuery($category, true), 
1047              "linkfrom");
1048         } else {
1049           $basepage = $GLOBALS['request']->getPage($category);
1050           $backlinkiter = $basepage->getBackLinks(true);
1051         }
1052         $this->links = array();
1053         foreach ($backlinkiter->asArray() as $p) {
1054             if (is_object($p)) $this->links[] = $p->getName();
1055             elseif (is_array($p)) $this->links[] = $p['pagename'];
1056             else $this->links[] = $p;
1057         }
1058         $backlinkiter->free();
1059         sort($this->links);
1060     }
1061
1062     function next () {
1063         while (($rev = $this->_revisions->next())) {
1064             if (binary_search($rev->getName(), $this->links) != false)
1065                 return $rev;
1066         }
1067         $this->free();
1068         return false;
1069     }
1070
1071     function free () {
1072         unset ($this->links);
1073     }
1074 }
1075
1076 class PageMatchRevisionIterator extends WikiDB_PageRevisionIterator
1077 {
1078     function PageMatchRevisionIterator ($revisions, $match) {
1079         $this->_revisions = $revisions;
1080         $this->search = new TextSearchQuery($match, true);
1081     }
1082
1083     function next () {
1084         while (($rev = $this->_revisions->next())) {
1085             if ($this->search->match($rev->getName()))
1086                 return $rev;
1087         }
1088         $this->free();
1089         return false;
1090     }
1091
1092     function free () {
1093         unset ($this->search);
1094     }
1095 }
1096
1097 /**
1098  * Filter by author
1099  */
1100 class AuthorPageRevisionIterator extends WikiDB_PageRevisionIterator
1101 {
1102     function AuthorPageRevisionIterator ($revisions, $author) {
1103         $this->_revisions = $revisions;
1104         $this->_author = $author;
1105     }
1106
1107     function next () {
1108         while (($rev = $this->_revisions->next())) {
1109             if ($rev->get('author_id') == $this->_author)
1110                 return $rev;
1111         }
1112         $this->free();
1113         return false;
1114     }
1115 }
1116
1117 /**
1118  * Filter by owner
1119  */
1120 class OwnerPageRevisionIterator extends WikiDB_PageRevisionIterator
1121 {
1122     function OwnerPageRevisionIterator ($revisions, $owner) {
1123         $this->_revisions = $revisions;
1124         $this->_owner = $owner;
1125     }
1126
1127     function next () {
1128         while (($rev = $this->_revisions->next())) {
1129             $page = $rev->getPage();
1130             if ($page->getOwner() == $this->_owner)
1131                 return $rev;
1132         }
1133         $this->free();
1134         return false;
1135     }
1136 }
1137
1138 class WikiPlugin_RecentChanges
1139 extends WikiPlugin
1140 {
1141     function getName () {
1142         return _("RecentChanges");
1143     }
1144
1145     function getDescription () {
1146         return _("List all recent changes in this wiki.");
1147     }
1148
1149     function getVersion() {
1150         return preg_replace("/[Revision: $]/", '',
1151                             "\$Revision$");
1152     }
1153
1154     function managesValidators() {
1155         // Note that this is a bit of a fig.
1156         // We set validators based on the most recently changed page,
1157         // but this fails when the most-recent page is deleted.
1158         // (Consider that the Last-Modified time will decrease
1159         // when this happens.)
1160
1161         // We might be better off, leaving this as false (and junking
1162         // the validator logic above) and just falling back to the
1163         // default behavior (handled by WikiPlugin) of just using
1164         // the WikiDB global timestamp as the mtime.
1165
1166         // Nevertheless, for now, I leave this here, mostly as an
1167         // example for how to use appendValidators() and managesValidators().
1168         
1169         return true;
1170     }
1171             
1172     function getDefaultArguments() {
1173         return array('days'         => 2,
1174                      'show_minor'   => false,
1175                      'show_major'   => true,
1176                      'show_all'     => false,
1177                      'show_deleted' => 'sometimes',
1178                      'only_new'     => false,
1179                      'author'       => false,
1180                      'owner'        => false,
1181                      'limit'        => false,
1182                      'format'       => false,
1183                      'daylist'      => false,
1184                      'difflinks'    => true,
1185                      'historylinks' => false,
1186                      'caption'      => '',
1187                      'category'     => '',
1188                      'pagematch'    => ''
1189                      );
1190     }
1191
1192     function getArgs ($argstr, $request, $defaults = false) {
1193         if (!$defaults) $defaults = $this->getDefaultArguments();
1194         $args = WikiPlugin::getArgs($argstr, $request, $defaults);
1195
1196         $action = $request->getArg('action');
1197         if ($action != 'browse' && ! $request->isActionPage($action))
1198             $args['format'] = false; // default -> HTML
1199
1200         if ($args['format'] == 'rss' && empty($args['limit']))
1201             $args['limit'] = 15; // Fix default value for RSS.
1202         if ($args['format'] == 'rss2' && empty($args['limit']))
1203             $args['limit'] = 15; // Fix default value for RSS2.
1204
1205         if ($args['format'] == 'sidebar' && empty($args['limit']))
1206             $args['limit'] = 10; // Fix default value for sidebar.
1207
1208         return $args;
1209     }
1210
1211     function getMostRecentParams (&$args) {
1212         $show_all = false; $show_minor = false; $show_major = false;
1213         $limit = false;
1214         extract($args);
1215
1216         $params = array('include_minor_revisions' => $show_minor,
1217                         'exclude_major_revisions' => !$show_major,
1218                         'include_all_revisions' => !empty($show_all));
1219         if ($limit != 0)
1220             $params['limit'] = $limit;
1221         if (!empty($args['author'])) {
1222             global $request;
1223             if ($args['author'] == '[]')
1224                 $args['author'] = $request->_user->getID();
1225             $params['author'] = $args['author'];
1226         }
1227         if (!empty($args['owner'])) {
1228             global $request;
1229             if ($args['owner'] == '[]')
1230                 $args['owner'] = $request->_user->getID();
1231             $params['owner'] = $args['owner'];
1232         }
1233         if (!empty($days)) {
1234           if ($days > 0.0)
1235             $params['since'] = time() - 24 * 3600 * $days;
1236           elseif ($days < 0.0)
1237             $params['since'] = 24 * 3600 * $days - time();
1238         }
1239
1240         return $params;
1241     }
1242
1243     function getChanges ($dbi, $args) {
1244         $changes = $dbi->mostRecent($this->getMostRecentParams($args));
1245
1246         $show_deleted = @$args['show_deleted'];
1247         $show_all = @$args['show_all'];
1248         if ($show_deleted == 'sometimes')
1249             $show_deleted = @$args['show_minor'];
1250
1251         // only pages (e.g. PageHistory of subpages)
1252         if (!empty($args['pagematch'])) {
1253             require_once("lib/TextSearchQuery.php");
1254             $changes = new PageMatchRevisionIterator($changes, $args['pagematch']);
1255         }
1256         if (!empty($args['category'])) {
1257             require_once("lib/TextSearchQuery.php");
1258             $changes = new LinkRevisionIterator($changes, $args['category']);
1259         }
1260         if (!empty($args['only_new']))
1261             $changes = new NewPageRevisionIterator($changes);
1262         if (!empty($args['author']))
1263             $changes = new AuthorPageRevisionIterator($changes, $args['author']);
1264         if (!empty($args['owner']))
1265             $changes = new OwnerPageRevisionIterator($changes, $args['owner']);
1266         if (!$show_deleted)
1267             $changes = new NonDeletedRevisionIterator($changes, !$show_all);
1268
1269         return $changes;
1270     }
1271
1272     function format ($changes, $args) {
1273         global $WikiTheme;
1274         $format = $args['format'];
1275
1276         $fmt_class = $WikiTheme->getFormatter('RecentChanges', $format);
1277         if (!$fmt_class) {
1278             if ($format == 'rss')
1279                 $fmt_class = '_RecentChanges_RssFormatter';
1280             elseif ($format == 'rss2')
1281                 $fmt_class = '_RecentChanges_Rss2Formatter';
1282             elseif ($format == 'atom')
1283                 $fmt_class = '_RecentChanges_AtomFormatter';
1284             elseif ($format == 'rss091') {
1285                 include_once "lib/RSSWriter091.php";
1286                 $fmt_class = '_RecentChanges_RssFormatter091';
1287             }
1288             elseif ($format == 'sidebar')
1289                 $fmt_class = '_RecentChanges_SideBarFormatter';
1290             elseif ($format == 'box')
1291                 $fmt_class = '_RecentChanges_BoxFormatter';
1292             elseif ($format == 'contribs')
1293                 $fmt_class = '_RecentChanges_UserContribsFormatter';
1294             else
1295                 $fmt_class = '_RecentChanges_HtmlFormatter';
1296         }
1297
1298         $fmt = new $fmt_class($args);
1299         return $fmt->format($changes);
1300     }
1301
1302     function run($dbi, $argstr, &$request, $basepage) {
1303         $args = $this->getArgs($argstr, $request);
1304
1305         // HACKish: fix for SF bug #622784  (1000 years of RecentChanges ought
1306         // to be enough for anyone.)
1307         $args['days'] = min($args['days'], 365000);
1308
1309         // Within Categories just display Category Backlinks
1310         if (empty($args['category']) and empty($args['pagematch'])
1311             and preg_match("/^Category/", $request->getArg('pagename'))) 
1312         {
1313             $args['category'] = $request->getArg('pagename');
1314         }
1315         
1316         // Hack alert: format() is a NORETURN for rss formatters.
1317         return $this->format($this->getChanges($dbi, $args), $args);
1318     }
1319
1320     // box is used to display a fixed-width, narrow version with common header.
1321     // just a numbered list of limit pagenames, without date.
1322     function box($args = false, $request = false, $basepage = false) {
1323         if (!$request) $request =& $GLOBALS['request'];
1324         if (!isset($args['limit'])) $args['limit'] = 15;
1325         $args['format'] = 'box';
1326         $args['show_minor'] = false;
1327         $args['show_major'] = true;
1328         $args['show_deleted'] = 'sometimes';
1329         $args['show_all'] = false;
1330         $args['days'] = 90;
1331         return $this->makeBox(WikiLink($this->getName(),'',
1332                                        SplitPagename($this->getName())),
1333                               $this->format
1334                               ($this->getChanges($request->_dbi, $args), $args));
1335     }
1336
1337 };
1338
1339 class OptionsButtonBars extends HtmlElement {
1340
1341     function OptionsButtonBars ($plugin_args) {
1342         $this->__construct('fieldset', array('class' => 'wiki-rc-action'));
1343
1344         // Display selection buttons
1345         extract($plugin_args);
1346
1347         // Custom caption
1348         if (! $caption) {
1349             $caption = _("Show changes for:");
1350         }
1351
1352         $this->pushContent(HTML::legend($caption));
1353         $table = HTML::table();
1354
1355         $tr = HTML::tr();
1356         foreach (explode(",", $daylist) as $days) {
1357             $tr->pushContent($this->_makeDayButton($days));
1358         }
1359         $table->pushContent($tr);
1360
1361         $tr = HTML::tr();
1362         $tr->pushContent($this->_makeUsersButton(0));
1363         $tr->pushContent($this->_makeUsersButton(1));
1364         $table->pushContent($tr);
1365
1366         $tr = HTML::tr();
1367         $tr->pushContent($this->_makePagesButton(0));
1368         $tr->pushContent($this->_makePagesButton(1));
1369         $table->pushContent($tr);
1370
1371         $tr = HTML::tr();
1372         $tr->pushContent($this->_makeMinorButton(1));
1373         $tr->pushContent($this->_makeMinorButton(0));
1374         $table->pushContent($tr);
1375
1376         $tr = HTML::tr();
1377         $tr->pushContent($this->_makeShowAllButton(1));
1378         $tr->pushContent($this->_makeShowAllButton(0));
1379         $table->pushContent($tr);
1380
1381         $tr = HTML::tr();
1382         $tr->pushContent($this->_makeNewPagesButton(0));
1383         $tr->pushContent($this->_makeNewPagesButton(1));
1384         $table->pushContent($tr);
1385
1386         $this->pushContent($table);
1387     }
1388
1389     function _makeDayButton ($days) {
1390         global $request;
1391
1392         if ($days == 1)
1393             $label = _("1 day");
1394         elseif ($days < 1)
1395             $label = _("All time");
1396         else
1397             $label = sprintf(_("%s days"), abs($days));
1398
1399         $selfurl = $request->getURLtoSelf(array('action' => $request->getArg('action')));
1400         $url = $request->getURLtoSelf(array('action' => $request->getArg('action'), 'days' => $days));
1401         if ($url == $selfurl) {
1402             return HTML::td(array('class'=>'tdselected'), $label);
1403         }
1404         return HTML::td(array('class'=>'tdunselected'),
1405                         HTML::a(array('href'  => $url, 'class' => 'wiki-rc-action'), $label));
1406     }
1407
1408     function _makeUsersButton ($users) {
1409         global $request;
1410
1411         if ($users == 0) {
1412             $label = _("All users");
1413             $author = "";
1414         } else {
1415             $label = _("My modifications only");
1416             $author = "[]";
1417         }
1418
1419         $selfurl = $request->getURLtoSelf(array('action' => $request->getArg('action')));
1420         $url = $request->getURLtoSelf(array('action' => $request->getArg('action'), 'author' => $author));
1421         if ($url == $selfurl) {
1422             return HTML::td(array('colspan'=>3, 'class'=>'tdselected'), $label);
1423         }
1424         return HTML::td(array('colspan'=>3, 'class'=>'tdunselected'), 
1425                         HTML::a(array('href'  => $url, 'class' => 'wiki-rc-action'), $label));
1426     }
1427
1428     function _makePagesButton ($pages) {
1429         global $request;
1430
1431         if ($pages == 0) {
1432             $label = _("All pages");
1433             $owner = "";
1434         } else {
1435             $label = _("My pages only");
1436             $owner = "[]";
1437         }
1438
1439         $selfurl = $request->getURLtoSelf(array('action' => $request->getArg('action')));
1440         $url = $request->getURLtoSelf(array('action' => $request->getArg('action'), 'owner' => $owner));
1441         if ($url == $selfurl) {
1442             return HTML::td(array('colspan'=>3, 'class'=>'tdselected'), $label);
1443         }
1444         return HTML::td(array('colspan'=>3, 'class'=>'tdunselected'),
1445                         HTML::a(array('href'  => $url, 'class' => 'wiki-rc-action'), $label));
1446     }
1447
1448     function _makeMinorButton ($minor) {
1449         global $request;
1450
1451         if ($minor == 0) {
1452             $label = _("Major modifications only");
1453         } else {
1454             $label = _("All modifications");
1455         }
1456
1457         $selfurl = $request->getURLtoSelf(array('action' => $request->getArg('action')));
1458         $url = $request->getURLtoSelf(array('action' => $request->getArg('action'), 'show_minor' => $minor));
1459         if ($url == $selfurl) {
1460             return HTML::td(array('colspan'=>3, 'class'=>'tdselected'), $label);
1461         }
1462         return HTML::td(array('colspan'=>3, 'class'=>'tdunselected'),
1463                         HTML::a(array('href'  => $url, 'class' => 'wiki-rc-action'), $label));
1464     }
1465
1466     function _makeShowAllButton ($showall) {
1467         global $request;
1468
1469         if ($showall == 0) {
1470             $label = _("Page once only");
1471         } else {
1472             $label = _("Full changes");
1473         }
1474
1475         $selfurl = $request->getURLtoSelf(array('action' => $request->getArg('action')));
1476         $url = $request->getURLtoSelf(array('action' => $request->getArg('action'), 'show_all' => $showall));
1477         if ($url == $selfurl) {
1478             return HTML::td(array('colspan'=>3, 'class'=>'tdselected'), $label);
1479         }
1480         return HTML::td(array('colspan'=>3, 'class'=>'tdunselected'),
1481                         HTML::a(array('href'  => $url, 'class' => 'wiki-rc-action'), $label));
1482     }
1483
1484     function _makeNewPagesButton ($newpages) {
1485         global $request;
1486
1487         if ($newpages == 0) {
1488             $label = _("Old and new pages");
1489         } else {
1490             $label = _("New pages only");
1491         }
1492
1493         $selfurl = $request->getURLtoSelf(array('action' => $request->getArg('action')));
1494         $url = $request->getURLtoSelf(array('action' => $request->getArg('action'), 'only_new' => $newpages));
1495         if ($url == $selfurl) {
1496             return HTML::td(array('colspan'=>3, 'class'=>'tdselected'), $label);
1497         }
1498
1499         return HTML::td(array('colspan'=>3, 'class'=>'tdunselected'),
1500                         HTML::a(array('href'  => $url, 'class' => 'wiki-rc-action'), $label));
1501     }
1502 }
1503
1504 // (c-file-style: "gnu")
1505 // Local Variables:
1506 // mode: php
1507 // tab-width: 8
1508 // c-basic-offset: 4
1509 // c-hanging-comment-ender-p: nil
1510 // indent-tabs-mode: nil
1511 // End:
1512 ?>