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