]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RecentChanges.php
Theme & appearance tweaks: Converted Mozilla sidebar link into a Theme
[SourceForge/phpwiki.git] / lib / plugin / RecentChanges.php
1 <?php // -*-php-*-
2 rcs_id('$Id: RecentChanges.php,v 1.80 2003-11-27 15:17:01 carstenklapp Exp $');
3 /**
4  Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
5
6  This file is part of PhpWiki.
7
8  PhpWiki is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12
13  PhpWiki is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with PhpWiki; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 /**
24  */
25 class _RecentChanges_Formatter
26 {
27     var $_absurls = false;
28
29     function _RecentChanges_Formatter ($rc_args) {
30         $this->_args = $rc_args;
31         $this->_diffargs = array('action' => 'diff');
32
33         if ($rc_args['show_minor'] || !$rc_args['show_major'])
34             $this->_diffargs['previous'] = 'minor';
35
36         // PageHistoryPlugin doesn't have a 'daylist' arg.
37         if (!isset($this->_args['daylist']))
38             $this->_args['daylist'] = false;
39     }
40
41     function include_versions_in_URLs() {
42         return (bool) $this->_args['show_all'];
43     }
44
45     function date ($rev) {
46         global $Theme;
47         return $Theme->getDay($rev->get('mtime'));
48     }
49
50     function time ($rev) {
51         global $Theme;
52         return $Theme->formatTime($rev->get('mtime'));
53     }
54
55     function diffURL ($rev) {
56         $args = $this->_diffargs;
57         if ($this->include_versions_in_URLs())
58             $args['version'] = $rev->getVersion();
59         $page = $rev->getPage();
60         return WikiURL($page->getName(), $args, $this->_absurls);
61     }
62
63     function historyURL ($rev) {
64         $page = $rev->getPage();
65         return WikiURL($page, array('action' => _("PageHistory")),
66                        $this->_absurls);
67     }
68
69     function pageURL ($rev) {
70         return WikiURL($this->include_versions_in_URLs() ? $rev : $rev->getPage(),
71                        '', $this->_absurls);
72     }
73
74     function authorHasPage ($author) {
75         global $WikiNameRegexp, $request;
76         $dbi = $request->getDbh();
77         return preg_match("/^$WikiNameRegexp\$/", $author) && $dbi->isWikiPage($author);
78     }
79
80     function authorURL ($author) {
81         return $this->authorHasPage() ? WikiURL($author) : false;
82     }
83
84
85     function status ($rev) {
86         if ($rev->hasDefaultContents())
87             return 'deleted';
88         $page = $rev->getPage();
89         $prev = $page->getRevisionBefore($rev->getVersion());
90         if ($prev->hasDefaultContents())
91             return 'new';
92         return 'updated';
93     }
94
95     function importance ($rev) {
96         return $rev->get('is_minor_edit') ? 'minor' : 'major';
97     }
98
99     function summary($rev) {
100         if ( ($summary = $rev->get('summary')) )
101             return $summary;
102
103         switch ($this->status($rev)) {
104             case 'deleted':
105                 return _("Deleted.");
106             case 'new':
107                 return _("New page.");
108             default:
109                 return '';
110         }
111     }
112
113     function setValidators($most_recent_rev) {
114         $rev = $most_recent_rev;
115         $validators = array('RecentChanges-top' =>
116                             array($rev->getPageName(), $rev->getVersion()),
117                             '%mtime' => $rev->get('mtime'));
118         global $request;
119         $request->appendValidators($validators);
120     }
121 }
122
123 class _RecentChanges_HtmlFormatter
124 extends _RecentChanges_Formatter
125 {
126     function diffLink ($rev) {
127         global $Theme;
128         return $Theme->makeButton(_("(diff)"), $this->diffURL($rev), 'wiki-rc-action');
129     }
130
131     function historyLink ($rev) {
132         global $Theme;
133         return $Theme->makeButton(_("(hist)"), $this->historyURL($rev), 'wiki-rc-action');
134     }
135
136     function pageLink ($rev, $link_text=false) {
137         $page = $rev->getPage();
138         global $Theme;
139         if ($this->include_versions_in_URLs()) {
140             $version = $rev->getVersion();
141             $exists = !$rev->hasDefaultContents();
142         }
143         else {
144             $version = false;
145             $cur = $page->getCurrentRevision();
146             $exists = !$cur->hasDefaultContents();
147         }
148         if ($exists)
149             return $Theme->linkExistingWikiWord($page->getName(), $link_text, $version);
150         else
151             return $Theme->linkUnknownWikiWord($page->getName(), $link_text);
152     }
153
154     function authorLink ($rev) {
155         $author = $rev->get('author');
156         if ( $this->authorHasPage($author) ) {
157             return WikiLink($author);
158         } else
159             return $author;
160     }
161
162     function summaryAsHTML ($rev) {
163         if ( !($summary = $this->summary($rev)) )
164             return '';
165         return  HTML::strong( array('class' => 'wiki-summary'),
166                               "[",
167                               TransformLinks($summary, $rev->get('markup'), $rev->getPageName()),
168                               "]");
169     }
170
171     function rss_icon () {
172         global $request, $Theme;
173
174         $rss_url = $request->getURLtoSelf(array('format' => 'rss'));
175         return HTML::small(array('style' => 'font-weight:normal;vertical-align:middle;'), $Theme->makeButton("RSS", $rss_url, 'rssicon'));
176     }
177
178     function description () {
179         extract($this->_args);
180         // FIXME: say something about show_all.
181         if ($show_major && $show_minor)
182             $edits = _("edits");
183         elseif ($show_major)
184             $edits = _("major edits");
185         else
186             $edits = _("minor edits");
187
188         if ($timespan = $days > 0) {
189             if (intval($days) != $days)
190                 $days = sprintf("%.1f", $days);
191         }
192         $lmt = abs($limit);
193         /**
194          * Depending how this text is split up it can be tricky or
195          * impossible to translate with good grammar. So the seperate
196          * strings for 1 day and %s days are necessary in this case
197          * for translating to multiple languages, due to differing
198          * overlapping ideal word cutting points.
199          *
200          * en: day/days "The %d most recent %s [during (the past] day) are listed below."
201          * de: 1 Tag    "Die %d jüngste %s [innerhalb (von des letzten] Tages) sind unten aufgelistet."
202          * de: %s days  "Die %d jüngste %s [innerhalb (von] %s Tagen) sind unten aufgelistet."
203          *
204          * en: day/days "The %d most recent %s during [the past] (day) are listed below."
205          * fr: 1 jour   "Les %d %s les plus récentes pendant [le dernier (d'une] jour) sont énumérées ci-dessous."
206          * fr: %s jours "Les %d %s les plus récentes pendant [les derniers (%s] jours) sont énumérées ci-dessous."
207          */
208         if ($limit > 0) {
209             if ($timespan) {
210                 if (intval($days) == 1)
211                     $desc = fmt("The %d most recent %s during the past day are listed below.",
212                                 $limit, $edits);
213                 else
214                     $desc = fmt("The %d most recent %s during the past %s days are listed below.",
215                                 $limit, $edits, $days);
216             } else
217                 $desc = fmt("The %d most recent %s are listed below.",
218                             $limit, $edits);
219         }
220         elseif ($limit < 0) {  //$limit < 0 means we want oldest pages
221             if ($timespan) {
222                 if (intval($days) == 1)
223                     $desc = fmt("The %d oldest %s during the past day are listed below.",
224                                 $lmt, $edits);
225                 else
226                     $desc = fmt("The %d oldest %s during the past %s days are listed below.",
227                                 $lmt, $edits, $days);
228             } else
229                 $desc = fmt("The %d oldest %s are listed below.",
230                             $lmt, $edits);
231         }
232
233         else {
234             if ($timespan) {
235                 if (intval($days) == 1)
236                     $desc = fmt("The most recent %s during the past day are listed below.",
237                                 $edits);
238                 else
239                     $desc = fmt("The most recent %s during the past %s days are listed below.",
240                                 $edits, $days);
241             } else
242                 $desc = fmt("All %s are listed below.", $edits);
243         }
244         return HTML::p(false, $desc);
245     }
246
247
248     function title () {
249         extract($this->_args);
250         return array($show_minor ? _("RecentEdits") : _("RecentChanges"),
251                      ' ',
252                      $this->rss_icon(),
253                      $this->sidebar_link());
254     }
255
256     function empty_message () {
257         return _("No changes found");
258     }
259     
260         
261     function sidebar_link() {
262         extract($this->_args);
263         $pagetitle = $show_minor ? _("RecentEdits") : _("RecentChanges");
264
265         global $request;
266         $sidebarurl = WikiURL($pagetitle, array('format' => 'sidebar'), 'absurl');
267
268         $addsidebarjsfunc =
269             "function addPanel() {\n"
270             ."    window.sidebar.addPanel (\"" . sprintf("%s - %s", WIKI_NAME, $pagetitle) . "\",\n"
271             ."       \"$sidebarurl\",\"\");\n"
272             ."}\n";
273         $jsf = JavaScript($addsidebarjsfunc);
274
275         global $Theme;
276         $sidebar_button = $Theme->makeButton("sidebar", 'javascript:addPanel();', 'sidebaricon');
277         $addsidebarjsclick = asXML(HTML::small(array('style' => 'font-weight:normal;vertical-align:middle;'), $sidebar_button));
278         $jsc = JavaScript("if ((typeof window.sidebar == 'object') &&\n"
279                                 ."    (typeof window.sidebar.addPanel == 'function'))\n"
280                                 ."   {\n"
281                                 ."       document.write('$addsidebarjsclick');\n"
282                                 ."   }\n"
283                                 );
284         return HTML(new RawXML("\n"), $jsf, new RawXML("\n"), $jsc);
285     }
286
287     function format ($changes) {
288         include_once('lib/InlineParser.php');
289         
290         $html = HTML(HTML::h2(false, $this->title()));
291         if (($desc = $this->description()))
292             $html->pushContent($desc);
293         
294         if ($this->_args['daylist'])
295             $html->pushContent(new DayButtonBar($this->_args));
296
297         $last_date = '';
298         $lines = false;
299         $first = true;
300
301         while ($rev = $changes->next()) {
302             if (($date = $this->date($rev)) != $last_date) {
303                 if ($lines)
304                     $html->pushContent($lines);
305                 $html->pushContent(HTML::h3($date));
306                 $lines = HTML::ul();
307                 $last_date = $date;
308
309             }
310             $lines->pushContent($this->format_revision($rev));
311
312             if ($first)
313                 $this->setValidators($rev);
314             $first = false;
315         }
316         if ($lines)
317             $html->pushContent($lines);
318         if ($first)
319             $html->pushContent(HTML::p(array('class' => 'rc-empty'),
320                                        $this->empty_message()));
321         
322         return $html;
323     }
324
325     function format_revision ($rev) {
326         $args = &$this->_args;
327
328         $class = 'rc-' . $this->importance($rev);
329
330         $time = $this->time($rev);
331         if (! $rev->get('is_minor_edit'))
332             $time = HTML::strong(array('class' => 'pageinfo-majoredit'), $time);
333
334         $line = HTML::li(array('class' => $class));
335
336
337         if ($args['difflinks'])
338             $line->pushContent($this->diffLink($rev), ' ');
339
340         if ($args['historylinks'])
341             $line->pushContent($this->historyLink($rev), ' ');
342
343         $line->pushContent($this->pageLink($rev), ' ',
344                            $time, ' ',
345                            $this->summaryAsHTML($rev),
346                            ' ... ',
347                            $this->authorLink($rev));
348         return $line;
349     }
350 }
351
352
353 class _RecentChanges_SideBarFormatter
354 extends _RecentChanges_HtmlFormatter
355 {
356     function description () {
357         //omit description
358     }
359     function rss_icon () {
360         //omit rssicon
361     }
362     function title () {
363         //title click opens the normal RC or RE page in the main browser frame
364         extract($this->_args);
365         $titlelink = WikiLink($show_minor ? _("RecentEdits") : _("RecentChanges"));
366         $titlelink->setAttr('target', '_content');
367         return HTML($this->logo(), $titlelink);
368     }
369     function logo () {
370         //logo click opens the HomePage in the main browser frame
371         global $Theme;
372         $img = HTML::img(array('src' => $Theme->getImageURL('logo'),
373                                'border' => 0,
374                                'align' => 'right',
375                                'width' => 32
376                                ));
377         $linkurl = WikiLink(HOME_PAGE, false, $img);
378         $linkurl->setAttr('target', '_content');
379         return $linkurl;
380     }
381
382     function authorLink ($rev) {
383         $author = $rev->get('author');
384         if ( $this->authorHasPage($author) ) {
385             $linkurl = WikiLink($author);
386             $linkurl->setAttr('target', '_content'); // way to do this using parent::authorLink ??
387             return $linkurl;
388         } else
389             return $author;
390     }
391     function diffLink ($rev) {
392         $linkurl = parent::diffLink($rev);
393         $linkurl->setAttr('target', '_content');
394         return $linkurl;
395     }
396     function historyLink ($rev) {
397         $linkurl = parent::historyLink($rev);
398         $linkurl->setAttr('target', '_content');
399         return $linkurl;
400     }
401     function pageLink ($rev) {
402         $linkurl = parent::pageLink($rev);
403         $linkurl->setAttr('target', '_content');
404         return $linkurl;
405     }
406     // Overriding summaryAsHTML, because there is no way yet to
407     // return summary as transformed text with
408     // links setAttr('target', '_content') in Mozilla sidebar.
409     // So for now don't create clickable links inside summary
410     // in the sidebar, or else they target the sidebar and not the
411     // main content window.
412     function summaryAsHTML ($rev) {
413         if ( !($summary = $this->summary($rev)) )
414             return '';
415         return HTML::strong(array('class' => 'wiki-summary'),
416                                 "[",
417                                 /*TransformLinks(*/$summary,/* $rev->get('markup')),*/
418                                 "]");
419     }
420
421
422     function format ($changes) {
423         $this->_args['daylist'] = false; //only 1 day for Mozilla sidebar
424         $html = _RecentChanges_HtmlFormatter::format ($changes);
425         $html = HTML::div(array('class' => 'wikitext'), $html);
426         global $request;
427         $request->discardOutput();
428         
429         printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", CHARSET);
430         printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"');
431         printf('  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
432         printf('<html xmlns="http://www.w3.org/1999/xhtml">');
433
434         printf("<head>\n");
435         extract($this->_args);
436         $title = WIKI_NAME . $show_minor ? _("RecentEdits") : _("RecentChanges");
437         printf("<title>" . $title . "</title>\n");
438         global $Theme;
439         $css = $Theme->getCSS();
440         $css->PrintXML();
441         printf("</head>\n");
442
443         printf("<body class=\"sidebar\">\n");
444         $html->PrintXML();
445         printf("\n</body>\n");
446         printf("</html>\n");
447
448         $request->finish(); // cut rest of page processing short
449     }
450 }
451
452
453 class _RecentChanges_RssFormatter
454 extends _RecentChanges_Formatter
455 {
456     var $_absurls = true;
457
458     function time ($rev) {
459         return Iso8601DateTime($rev->get('mtime'));
460     }
461
462     function pageURI ($rev) {
463         return WikiURL($rev, '', 'absurl');
464     }
465
466     function format ($changes) {
467         
468         include_once('lib/RssWriter.php');
469         $rss = new RssWriter;
470
471
472         $rss->channel($this->channel_properties());
473
474         if (($props = $this->image_properties()))
475             $rss->image($props);
476         if (($props = $this->textinput_properties()))
477             $rss->textinput($props);
478
479         $first = true;
480         while ($rev = $changes->next()) {
481             $rss->addItem($this->item_properties($rev),
482                           $this->pageURI($rev));
483             if ($first)
484                 $this->setValidators($rev);
485             $first = false;
486         }
487
488         global $request;
489         $request->discardOutput();
490         $rss->finish();
491         printf("\n<!-- Generated by PhpWiki:\n%s-->\n", $GLOBALS['RCS_IDS']);
492
493         // Flush errors in comment, otherwise it's invalid XML.
494         global $ErrorManager;
495         if (($errors = $ErrorManager->getPostponedErrorsAsHTML()))
496             printf("\n<!-- PHP Warnings:\n%s-->\n", AsXML($errors));
497
498         $request->finish();     // NORETURN!!!!
499     }
500
501     function image_properties () {
502         global $Theme;
503
504         $img_url = AbsoluteURL($Theme->getImageURL('logo'));
505         if (!$img_url)
506             return false;
507
508         return array('title' => WIKI_NAME,
509                      'link' => WikiURL(HOME_PAGE, false, 'absurl'),
510                      'url' => $img_url);
511     }
512
513     function textinput_properties () {
514         return array('title' => _("Search"),
515                      'description' => _("Title Search"),
516                      'name' => 's',
517                      'link' => WikiURL(_("TitleSearch"), false, 'absurl'));
518     }
519
520     function channel_properties () {
521         global $request;
522
523         $rc_url = WikiURL($request->getArg('pagename'), false, 'absurl');
524
525         return array('title' => WIKI_NAME,
526                      'link' => $rc_url,
527                      'description' => _("RecentChanges"),
528                      'dc:date' => Iso8601DateTime(time()));
529
530         /* FIXME: other things one might like in <channel>:
531          * sy:updateFrequency
532          * sy:updatePeriod
533          * sy:updateBase
534          * dc:subject
535          * dc:publisher
536          * dc:language
537          * dc:rights
538          * rss091:language
539          * rss091:managingEditor
540          * rss091:webmaster
541          * rss091:lastBuildDate
542          * rss091:copyright
543          */
544     }
545
546
547
548
549     function item_properties ($rev) {
550         $page = $rev->getPage();
551         $pagename = $page->getName();
552
553         return array( 'title'           => split_pagename($pagename),
554                       'description'     => $this->summary($rev),
555                       'link'            => $this->pageURL($rev),
556                       'dc:date'         => $this->time($rev),
557                       'dc:contributor'  => $rev->get('author'),
558                       'wiki:version'    => $rev->getVersion(),
559                       'wiki:importance' => $this->importance($rev),
560                       'wiki:status'     => $this->status($rev),
561                       'wiki:diff'       => $this->diffURL($rev),
562                       'wiki:history'    => $this->historyURL($rev)
563                       );
564     }
565 }
566
567 class NonDeletedRevisionIterator extends WikiDB_PageRevisionIterator
568 {
569     /** Constructor
570      *
571      * @param $revisions object a WikiDB_PageRevisionIterator.
572      */
573     function NonDeletedRevisionIterator ($revisions, $check_current_revision = true) {
574         $this->_revisions = $revisions;
575         $this->_check_current_revision = $check_current_revision;
576     }
577
578     function next () {
579         while (($rev = $this->_revisions->next())) {
580             if ($this->_check_current_revision) {
581                 $page = $rev->getPage();
582                 $check_rev = $page->getCurrentRevision();
583             }
584             else {
585                 $check_rev = $rev;
586             }
587             if (! $check_rev->hasDefaultContents())
588                 return $rev;
589         }
590         $this->free();
591         return false;
592     }
593
594     function free () {
595         $this->_revisions->free();
596     }
597 }
598
599 class WikiPlugin_RecentChanges
600 extends WikiPlugin
601 {
602     function getName () {
603         return _("RecentChanges");
604     }
605
606     function getVersion() {
607         return preg_replace("/[Revision: $]/", '',
608                             "\$Revision: 1.80 $");
609     }
610
611     function managesValidators() {
612         // Note that this is a bit of a fig.
613         // We set validators based on the most recently changed page,
614         // but this fails when the most-recent page is deleted.
615         // (Consider that the Last-Modified time will decrease
616         // when this happens.)
617
618         // We might be better off, leaving this as false (and junking
619         // the validator logic above) and just falling back to the
620         // default behavior (handled by WikiPlugin) of just using
621         // the WikiDB global timestamp as the mtime.
622
623         // Nevertheless, for now, I leave this here, mostly as an
624         // example for how to use appendValidators() and managesValidators().
625         
626         return true;
627     }
628             
629     function getDefaultArguments() {
630         return array('days'         => 2,
631                      'show_minor'   => false,
632                      'show_major'   => true,
633                      'show_all'     => false,
634                      'show_deleted' => 'sometimes',
635                      'limit'        => false,
636                      'format'       => false,
637                      'daylist'      => false,
638                      'difflinks'    => true,
639                      'historylinks' => false,
640                      'caption'      => ''
641                      );
642     }
643
644     function getArgs ($argstr, $request, $defaults = false) {
645         $args = WikiPlugin::getArgs($argstr, $request, $defaults);
646
647         $action = $request->getArg('action');
648         if ($action != 'browse' && ! $request->isActionPage($action))
649             $args['format'] = false; // default -> HTML
650
651         if ($args['format'] == 'rss' && empty($args['limit']))
652             $args['limit'] = 15; // Fix default value for RSS.
653
654         if ($args['format'] == 'sidebar' && empty($args['limit']))
655             $args['limit'] = 1; // Fix default value for sidebar.
656
657         return $args;
658     }
659
660     function getMostRecentParams ($args) {
661         extract($args);
662
663         $params = array('include_minor_revisions' => $show_minor,
664                         'exclude_major_revisions' => !$show_major,
665                         'include_all_revisions' => !empty($show_all));
666
667         if ($limit != 0)
668             $params['limit'] = $limit;
669
670         if ($days > 0.0)
671             $params['since'] = time() - 24 * 3600 * $days;
672         elseif ($days < 0.0)
673             $params['since'] = 24 * 3600 * $days - time();
674
675
676         return $params;
677     }
678
679     function getChanges ($dbi, $args) {
680         $changes = $dbi->mostRecent($this->getMostRecentParams($args));
681
682         $show_deleted = $args['show_deleted'];
683         if ($show_deleted == 'sometimes')
684             $show_deleted = $args['show_minor'];
685
686         if (!$show_deleted)
687             $changes = new NonDeletedRevisionIterator($changes, !$args['show_all']);
688
689         return $changes;
690     }
691
692     function format ($changes, $args) {
693         global $Theme;
694         $format = $args['format'];
695
696         $fmt_class = $Theme->getFormatter('RecentChanges', $format);
697         if (!$fmt_class) {
698             if ($format == 'rss')
699                 $fmt_class = '_RecentChanges_RssFormatter';
700             elseif ($format == 'rss091') {
701                 include_once "lib/RSSWriter091.php";
702                 $fmt_class = '_RecentChanges_RssFormatter091';
703             }
704             elseif ($format == 'sidebar')
705                 $fmt_class = '_RecentChanges_SideBarFormatter';
706             else
707                 $fmt_class = '_RecentChanges_HtmlFormatter';
708         }
709
710         $fmt = new $fmt_class($args);
711         return $fmt->format($changes);
712     }
713
714     function run ($dbi, $argstr, $request) {
715         $args = $this->getArgs($argstr, $request);
716
717         // HACKish: fix for SF bug #622784  (1000 years of RecentChanges ought
718         // to be enough for anyone.)
719         $args['days'] = min($args['days'], 365000);
720         
721         // Hack alert: format() is a NORETURN for rss formatters.
722         return $this->format($this->getChanges($dbi, $args), $args);
723     }
724 };
725
726
727 class DayButtonBar extends HtmlElement {
728
729     function DayButtonBar ($plugin_args) {
730         $this->HtmlElement('p', array('class' => 'wiki-rc-action'));
731
732         // Display days selection buttons
733         extract($plugin_args);
734
735         // Custom caption
736         if (! $caption) {
737             if ($show_minor)
738                 $caption = _("Show minor edits for:");
739             elseif ($show_all)
740                 $caption = _("Show all changes for:");
741             else
742                 $caption = _("Show changes for:");
743         }
744
745         $this->pushContent($caption, ' ');
746
747         global $Theme;
748         $sep = $Theme->getButtonSeparator();
749
750         $n = 0;
751         foreach (explode(",", $daylist) as $days) {
752             if ($n++)
753                 $this->pushContent($sep);
754             $this->pushContent($this->_makeDayButton($days));
755         }
756     }
757
758     function _makeDayButton ($days) {
759         global $Theme, $request;
760
761         if ($days == 1)
762             $label = _("1 day");
763         elseif ($days < 1)
764             $label = "..."; //alldays
765         else
766             $label = sprintf(_("%s days"), abs($days));
767
768         $url = $request->getURLtoSelf(array('action' => 'browse', 'days' => $days));
769
770         return $Theme->makeButton($label, $url, 'wiki-rc-action');
771     }
772 }
773
774 // $Log: not supported by cvs2svn $
775 // Revision 1.79  2003/04/29 14:34:20  dairiki
776 // Bug fix: "add sidebar" link didn't work when USE_PATH_INFO was false.
777 //
778 // Revision 1.78  2003/03/04 01:55:05  dairiki
779 // Fix to ensure absolute URL for logo in RSS recent changes.
780 //
781 // Revision 1.77  2003/02/27 23:23:38  dairiki
782 // Fix my breakage of CSS and sidebar RecentChanges output.
783 //
784 // Revision 1.76  2003/02/27 22:48:44  dairiki
785 // Fixes invalid HTML generated by PageHistory plugin.
786 //
787 // (<noscript> is block-level and not allowed within <p>.)
788 //
789 // Revision 1.75  2003/02/22 21:39:05  dairiki
790 // Hackish fix for SF bug #622784.
791 //
792 // (The root of the problem is clearly a PHP bug.)
793 //
794 // Revision 1.74  2003/02/21 22:52:21  dairiki
795 // Make sure to interpret relative links (like [/Subpage]) in summary
796 // relative to correct basepage.
797 //
798 // Revision 1.73  2003/02/21 04:12:06  dairiki
799 // Minor fixes for new cached markup.
800 //
801 // Revision 1.72  2003/02/17 02:19:01  dairiki
802 // Fix so that PageHistory will work when the current revision
803 // of a page has been "deleted".
804 //
805 // Revision 1.71  2003/02/16 20:04:48  dairiki
806 // Refactor the HTTP validator generation/checking code.
807 //
808 // This also fixes a number of bugs with yesterdays validator mods.
809 //
810 // Revision 1.70  2003/02/16 05:09:43  dairiki
811 // Starting to fix handling of the HTTP validator headers, Last-Modified,
812 // and ETag.
813 //
814 // Last-Modified was being set incorrectly (but only when DEBUG was not
815 // defined!)  Setting a Last-Modified without setting an appropriate
816 // Expires: and/or Cache-Control: header results in browsers caching
817 // the page unconditionally (for a certain period of time).
818 // This is generally bad, since it means people don't see updated
819 // page contents right away --- this is particularly confusing to
820 // the people who are editing pages since their edits don't show up
821 // next time they browse the page.
822 //
823 // Now, we don't allow caching of pages without revalidation
824 // (via the If-Modified-Since and/or If-None-Match request headers.)
825 // (You can allow caching by defining CACHE_CONTROL_MAX_AGE to an
826 // appropriate value in index.php, but I advise against it.)
827 //
828 // Problems:
829 //
830 //   o Even when request is aborted due to the content not being
831 //     modified, we currently still do almost all the work involved
832 //     in producing the page.  So the only real savings from all
833 //     this logic is in network bandwidth.
834 //
835 //   o Plugins which produce "dynamic" output need to be inspected
836 //     and made to call $request->addToETag() and
837 //     $request->setModificationTime() appropriately, otherwise the
838 //     page can change without the change being detected.
839 //     This leads to stale pages in cache again...
840 //
841 // Revision 1.69  2003/01/18 22:01:43  carstenklapp
842 // Code cleanup:
843 // Reformatting & tabs to spaces;
844 // Added copyleft, getVersion, getDescription, rcs_id.
845 //
846
847 // (c-file-style: "gnu")
848 // Local Variables:
849 // mode: php
850 // tab-width: 8
851 // c-basic-offset: 4
852 // c-hanging-comment-ender-p: nil
853 // indent-tabs-mode: nil
854 // End:
855 ?>