]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RecentChanges.php
Hackish fix for SF bug #622784.
[SourceForge/phpwiki.git] / lib / plugin / RecentChanges.php
1 <?php // -*-php-*-
2 rcs_id('$Id: RecentChanges.php,v 1.75 2003-02-22 21:39:05 dairiki 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 $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 $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, false, 'absurl') . "?format=sidebar";
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 = $this->_javascript($addsidebarjsfunc);
274
275         $addsidebarjsclick = " " . "<small style=\"font-weight:normal;\"><a href=\"javascript:addPanel();\">sidebar</a></small>";
276         $jsc = $this->_javascript("if ((typeof window.sidebar == 'object') &&\n"
277                                 ."    (typeof window.sidebar.addPanel == 'function'))\n"
278                                 ."   {\n"
279                                 ."       document.write('$addsidebarjsclick');\n"
280                                 ."   }\n"
281                                 );
282         return HTML(new RawXML("\n"), $jsf, new RawXML("\n"), $jsc);
283     }
284
285     function _javascript($script) {
286         return HTML::script(array('language' => 'JavaScript',
287                                   'type'     => 'text/javascript'),
288                             new RawXml("<!-- //\n$script\n// -->"));
289     }
290
291     function format ($changes) {
292         include_once('lib/InlineParser.php');
293         
294         $html = HTML(HTML::h2(false, $this->title()));
295         if (($desc = $this->description()))
296             $html->pushContent(HTML::p(false, $desc));
297
298         if ($this->_args['daylist'])
299             $html->pushContent(new DayButtonBar($this->_args));
300
301         $last_date = '';
302         $lines = false;
303         $first = true;
304
305         while ($rev = $changes->next()) {
306             if (($date = $this->date($rev)) != $last_date) {
307                 if ($lines)
308                     $html->pushContent($lines);
309                 $html->pushContent(HTML::h3($date));
310                 $lines = HTML::ul();
311                 $last_date = $date;
312
313             }
314             $lines->pushContent($this->format_revision($rev));
315
316             if ($first)
317                 $this->setValidators($rev);
318             $first = false;
319         }
320         if ($lines)
321             $html->pushContent($lines);
322         if ($first)
323             $html->pushContent(HTML::p(array('class' => 'rc-empty'),
324                                        $this->empty_message()));
325         
326         return $html;
327     }
328
329     function format_revision ($rev) {
330         $args = &$this->_args;
331
332         $class = 'rc-' . $this->importance($rev);
333
334         $time = $this->time($rev);
335         if (! $rev->get('is_minor_edit'))
336             $time = HTML::strong(array('class' => 'pageinfo-majoredit'), $time);
337
338         $line = HTML::li(array('class' => $class));
339
340
341         if ($args['difflinks'])
342             $line->pushContent($this->diffLink($rev), ' ');
343
344         if ($args['historylinks'])
345             $line->pushContent($this->historyLink($rev), ' ');
346
347         $line->pushContent($this->pageLink($rev), ' ',
348                            $time, ' ',
349                            $this->summaryAsHTML($rev),
350                            ' ... ',
351                            $this->authorLink($rev));
352         return $line;
353     }
354 }
355
356
357 class _RecentChanges_SideBarFormatter
358 extends _RecentChanges_HtmlFormatter
359 {
360     function description () {
361         //omit description
362     }
363     function rss_icon () {
364         //omit rssicon
365     }
366     function title () {
367         //title click opens the normal RC or RE page in the main browser frame
368         extract($this->_args);
369         $titlelink = WikiLink($show_minor ? _("RecentEdits") : _("RecentChanges"));
370         $titlelink->setAttr('target', '_content');
371         return HTML($this->logo(), $titlelink);
372     }
373     function logo () {
374         //logo click opens the HomePage in the main browser frame
375         global $Theme;
376         $img = HTML::img(array('src' => $Theme->getImageURL('logo'),
377                                'border' => 0,
378                                'align' => 'right',
379                                'width' => 32
380                                ));
381         $linkurl = WikiLink(HOME_PAGE, false, $img);
382         $linkurl->setAttr('target', '_content');
383         return $linkurl;
384     }
385
386     function authorLink ($rev) {
387         $author = $rev->get('author');
388         if ( $this->authorHasPage($author) ) {
389             $linkurl = WikiLink($author);
390             $linkurl->setAttr('target', '_content'); // way to do this using parent::authorLink ??
391             return $linkurl;
392         } else
393             return $author;
394     }
395     function diffLink ($rev) {
396         $linkurl = parent::diffLink($rev);
397         $linkurl->setAttr('target', '_content');
398         return $linkurl;
399     }
400     function historyLink ($rev) {
401         $linkurl = parent::historyLink($rev);
402         $linkurl->setAttr('target', '_content');
403         return $linkurl;
404     }
405     function pageLink ($rev) {
406         $linkurl = parent::pageLink($rev);
407         $linkurl->setAttr('target', '_content');
408         return $linkurl;
409     }
410     // Overriding summaryAsHTML, because there is no way yet to
411     // return summary as transformed text with
412     // links setAttr('target', '_content') in Mozilla sidebar.
413     // So for now don't create clickable links inside summary
414     // in the sidebar, or else they target the sidebar and not the
415     // main content window.
416     function summaryAsHTML ($rev) {
417         if ( !($summary = $this->summary($rev)) )
418             return '';
419         return HTML::strong(array('class' => 'wiki-summary'),
420                                 "[",
421                                 /*TransformLinks(*/$summary,/* $rev->get('markup')),*/
422                                 "]");
423     }
424
425
426     function format ($changes) {
427         $this->_args['daylist'] = false; //only 1 day for Mozilla sidebar
428         $html = _RecentChanges_HtmlFormatter::format ($changes);
429         $html = HTML::div(array('class' => 'wikitext'), $html);
430
431         printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", CHARSET);
432         printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"');
433         printf('  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
434         printf('<html xmlns="http://www.w3.org/1999/xhtml">');
435
436         printf("<head>\n");
437         extract($this->_args);
438         $title = WIKI_NAME . $show_minor ? _("RecentEdits") : _("RecentChanges");
439         printf("<title>" . $title . "</title>\n");
440         global $Theme;
441         $css = $Theme->getCSS();
442         $css->PrintXML();
443         printf("</head>\n");
444
445         printf("<body class=\"sidebar\">\n");
446         $html->PrintXML();
447         printf("\n</body>\n");
448         printf("</html>\n");
449
450         flush();
451
452         global $request;
453         $request->finish(); // cut rest of page processing short
454     }
455 }
456
457
458 class _RecentChanges_RssFormatter
459 extends _RecentChanges_Formatter
460 {
461     var $_absurls = true;
462
463     function time ($rev) {
464         return Iso8601DateTime($rev->get('mtime'));
465     }
466
467     function pageURI ($rev) {
468         return WikiURL($rev, '', 'absurl');
469     }
470
471     function format ($changes) {
472         include_once('lib/RssWriter.php');
473         $rss = new RssWriter;
474
475
476         $rss->channel($this->channel_properties());
477
478         if (($props = $this->image_properties()))
479             $rss->image($props);
480         if (($props = $this->textinput_properties()))
481             $rss->textinput($props);
482
483         $first = true;
484         while ($rev = $changes->next()) {
485             $rss->addItem($this->item_properties($rev),
486                           $this->pageURI($rev));
487             if ($first)
488                 $this->setValidators($rev);
489             $first = false;
490         }
491
492         $rss->finish();
493         printf("\n<!-- Generated by PhpWiki:\n%s-->\n", $GLOBALS['RCS_IDS']);
494
495         // Flush errors in comment, otherwise it's invalid XML.
496         global $ErrorManager;
497         if (($errors = $ErrorManager->getPostponedErrorsAsHTML()))
498             printf("\n<!-- PHP Warnings:\n%s-->\n", AsXML($errors));
499
500         global $request;        // FIXME
501         $request->finish();     // NORETURN!!!!
502     }
503
504     function image_properties () {
505         global $Theme;
506
507         $img_url = SERVER_URL . $Theme->getImageURL('logo');
508         if (!$img_url)
509             return false;
510
511         return array('title' => WIKI_NAME,
512                      'link' => WikiURL(HOME_PAGE, false, 'absurl'),
513                      'url' => $img_url);
514     }
515
516     function textinput_properties () {
517         return array('title' => _("Search"),
518                      'description' => _("Title Search"),
519                      'name' => 's',
520                      'link' => WikiURL(_("TitleSearch"), false, 'absurl'));
521     }
522
523     function channel_properties () {
524         global $request;
525
526         $rc_url = WikiURL($request->getArg('pagename'), false, 'absurl');
527
528         return array('title' => WIKI_NAME,
529                      'link' => $rc_url,
530                      'description' => _("RecentChanges"),
531                      'dc:date' => Iso8601DateTime(time()));
532
533         /* FIXME: other things one might like in <channel>:
534          * sy:updateFrequency
535          * sy:updatePeriod
536          * sy:updateBase
537          * dc:subject
538          * dc:publisher
539          * dc:language
540          * dc:rights
541          * rss091:language
542          * rss091:managingEditor
543          * rss091:webmaster
544          * rss091:lastBuildDate
545          * rss091:copyright
546          */
547     }
548
549
550
551
552     function item_properties ($rev) {
553         $page = $rev->getPage();
554         $pagename = $page->getName();
555
556         return array( 'title'           => split_pagename($pagename),
557                       'description'     => $this->summary($rev),
558                       'link'            => $this->pageURL($rev),
559                       'dc:date'         => $this->time($rev),
560                       'dc:contributor'  => $rev->get('author'),
561                       'wiki:version'    => $rev->getVersion(),
562                       'wiki:importance' => $this->importance($rev),
563                       'wiki:status'     => $this->status($rev),
564                       'wiki:diff'       => $this->diffURL($rev),
565                       'wiki:history'    => $this->historyURL($rev)
566                       );
567     }
568 }
569
570 class NonDeletedRevisionIterator extends WikiDB_PageRevisionIterator
571 {
572     /** Constructor
573      *
574      * @param $revisions object a WikiDB_PageRevisionIterator.
575      */
576     function NonDeletedRevisionIterator ($revisions, $check_current_revision = true) {
577         $this->_revisions = $revisions;
578         $this->_check_current_revision = $check_current_revision;
579     }
580
581     function next () {
582         while (($rev = $this->_revisions->next())) {
583             if ($this->_check_current_revision) {
584                 $page = $rev->getPage();
585                 $check_rev = $page->getCurrentRevision();
586             }
587             else {
588                 $check_rev = $rev;
589             }
590             if (! $check_rev->hasDefaultContents())
591                 return $rev;
592         }
593         $this->free();
594         return false;
595     }
596
597     function free () {
598         $this->_revisions->free();
599     }
600 }
601
602 class WikiPlugin_RecentChanges
603 extends WikiPlugin
604 {
605     function getName () {
606         return _("RecentChanges");
607     }
608
609     function getVersion() {
610         return preg_replace("/[Revision: $]/", '',
611                             "\$Revision: 1.75 $");
612     }
613
614     function managesValidators() {
615         // Note that this is a bit of a fig.
616         // We set validators based on the most recently changed page,
617         // but this fails when the most-recent page is deleted.
618         // (Consider that the Last-Modified time will decrease
619         // when this happens.)
620
621         // We might be better off, leaving this as false (and junking
622         // the validator logic above) and just falling back to the
623         // default behavior (handled by WikiPlugin) of just using
624         // the WikiDB global timestamp as the mtime.
625
626         // Nevertheless, for now, I leave this here, mostly as an
627         // example for how to use appendValidators() and managesValidators().
628         
629         return true;
630     }
631             
632     function getDefaultArguments() {
633         return array('days'         => 2,
634                      'show_minor'   => false,
635                      'show_major'   => true,
636                      'show_all'     => false,
637                      'show_deleted' => 'sometimes',
638                      'limit'        => false,
639                      'format'       => false,
640                      'daylist'      => false,
641                      'difflinks'    => true,
642                      'historylinks' => false,
643                      'caption'      => ''
644                      );
645     }
646
647     function getArgs ($argstr, $request, $defaults = false) {
648         $args = WikiPlugin::getArgs($argstr, $request, $defaults);
649
650         $action = $request->getArg('action');
651         if ($action != 'browse' && ! $request->isActionPage($action))
652             $args['format'] = false; // default -> HTML
653
654         if ($args['format'] == 'rss' && empty($args['limit']))
655             $args['limit'] = 15; // Fix default value for RSS.
656
657         if ($args['format'] == 'sidebar' && empty($args['limit']))
658             $args['limit'] = 1; // Fix default value for sidebar.
659
660         return $args;
661     }
662
663     function getMostRecentParams ($args) {
664         extract($args);
665
666         $params = array('include_minor_revisions' => $show_minor,
667                         'exclude_major_revisions' => !$show_major,
668                         'include_all_revisions' => !empty($show_all));
669
670         if ($limit != 0)
671             $params['limit'] = $limit;
672
673         if ($days > 0.0)
674             $params['since'] = time() - 24 * 3600 * $days;
675         elseif ($days < 0.0)
676             $params['since'] = 24 * 3600 * $days - time();
677
678
679         return $params;
680     }
681
682     function getChanges ($dbi, $args) {
683         $changes = $dbi->mostRecent($this->getMostRecentParams($args));
684
685         $show_deleted = $args['show_deleted'];
686         if ($show_deleted == 'sometimes')
687             $show_deleted = $args['show_minor'];
688
689         if (!$show_deleted)
690             $changes = new NonDeletedRevisionIterator($changes, !$args['show_all']);
691
692         return $changes;
693     }
694
695     function format ($changes, $args) {
696         global $Theme;
697         $format = $args['format'];
698
699         $fmt_class = $Theme->getFormatter('RecentChanges', $format);
700         if (!$fmt_class) {
701             if ($format == 'rss')
702                 $fmt_class = '_RecentChanges_RssFormatter';
703             elseif ($format == 'rss091') {
704                 include_once "lib/RSSWriter091.php";
705                 $fmt_class = '_RecentChanges_RssFormatter091';
706             }
707             elseif ($format == 'sidebar')
708                 $fmt_class = '_RecentChanges_SideBarFormatter';
709             else
710                 $fmt_class = '_RecentChanges_HtmlFormatter';
711         }
712
713         $fmt = new $fmt_class($args);
714         return $fmt->format($changes);
715     }
716
717     function run ($dbi, $argstr, $request) {
718         $args = $this->getArgs($argstr, $request);
719
720         // HACKish: fix for SF bug #622784  (1000 years of RecentChanges ought
721         // to be enough for anyone.)
722         $args['days'] = min($args['days'], 365000);
723         
724         // Hack alert: format() is a NORETURN for rss formatters.
725         return $this->format($this->getChanges($dbi, $args), $args);
726     }
727 };
728
729
730 class DayButtonBar extends HtmlElement {
731
732     function DayButtonBar ($plugin_args) {
733         $this->HtmlElement('p', array('class' => 'wiki-rc-action'));
734
735         // Display days selection buttons
736         extract($plugin_args);
737
738         // Custom caption
739         if (! $caption) {
740             if ($show_minor)
741                 $caption = _("Show minor edits for:");
742             elseif ($show_all)
743                 $caption = _("Show all changes for:");
744             else
745                 $caption = _("Show changes for:");
746         }
747
748         $this->pushContent($caption, ' ');
749
750         global $Theme;
751         $sep = $Theme->getButtonSeparator();
752
753         $n = 0;
754         foreach (explode(",", $daylist) as $days) {
755             if ($n++)
756                 $this->pushContent($sep);
757             $this->pushContent($this->_makeDayButton($days));
758         }
759     }
760
761     function _makeDayButton ($days) {
762         global $Theme, $request;
763
764         if ($days == 1)
765             $label = _("1 day");
766         elseif ($days < 1)
767             $label = "..."; //alldays
768         else
769             $label = sprintf(_("%s days"), abs($days));
770
771         $url = $request->getURLtoSelf(array('action' => 'browse', 'days' => $days));
772
773         return $Theme->makeButton($label, $url, 'wiki-rc-action');
774     }
775 }
776
777 // $Log: not supported by cvs2svn $
778 // Revision 1.74  2003/02/21 22:52:21  dairiki
779 // Make sure to interpret relative links (like [/Subpage]) in summary
780 // relative to correct basepage.
781 //
782 // Revision 1.73  2003/02/21 04:12:06  dairiki
783 // Minor fixes for new cached markup.
784 //
785 // Revision 1.72  2003/02/17 02:19:01  dairiki
786 // Fix so that PageHistory will work when the current revision
787 // of a page has been "deleted".
788 //
789 // Revision 1.71  2003/02/16 20:04:48  dairiki
790 // Refactor the HTTP validator generation/checking code.
791 //
792 // This also fixes a number of bugs with yesterdays validator mods.
793 //
794 // Revision 1.70  2003/02/16 05:09:43  dairiki
795 // Starting to fix handling of the HTTP validator headers, Last-Modified,
796 // and ETag.
797 //
798 // Last-Modified was being set incorrectly (but only when DEBUG was not
799 // defined!)  Setting a Last-Modified without setting an appropriate
800 // Expires: and/or Cache-Control: header results in browsers caching
801 // the page unconditionally (for a certain period of time).
802 // This is generally bad, since it means people don't see updated
803 // page contents right away --- this is particularly confusing to
804 // the people who are editing pages since their edits don't show up
805 // next time they browse the page.
806 //
807 // Now, we don't allow caching of pages without revalidation
808 // (via the If-Modified-Since and/or If-None-Match request headers.)
809 // (You can allow caching by defining CACHE_CONTROL_MAX_AGE to an
810 // appropriate value in index.php, but I advise against it.)
811 //
812 // Problems:
813 //
814 //   o Even when request is aborted due to the content not being
815 //     modified, we currently still do almost all the work involved
816 //     in producing the page.  So the only real savings from all
817 //     this logic is in network bandwidth.
818 //
819 //   o Plugins which produce "dynamic" output need to be inspected
820 //     and made to call $request->addToETag() and
821 //     $request->setModificationTime() appropriately, otherwise the
822 //     page can change without the change being detected.
823 //     This leads to stale pages in cache again...
824 //
825 // Revision 1.69  2003/01/18 22:01:43  carstenklapp
826 // Code cleanup:
827 // Reformatting & tabs to spaces;
828 // Added copyleft, getVersion, getDescription, rcs_id.
829 //
830
831 // (c-file-style: "gnu")
832 // Local Variables:
833 // mode: php
834 // tab-width: 8
835 // c-basic-offset: 4
836 // c-hanging-comment-ender-p: nil
837 // indent-tabs-mode: nil
838 // End:
839 ?>