]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RecentChanges.php
added MonoBook UserContribs
[SourceForge/phpwiki.git] / lib / plugin / RecentChanges.php
1 <?php // -*-php-*-
2 rcs_id('$Id: RecentChanges.php,v 1.117 2007-05-30 20:43:31 rurban Exp $');
3 /**
4  Copyright 1999,2000,2001,2002,2007 $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 include_once("lib/WikiPlugin.php");
24
25 /**
26  */
27 class _RecentChanges_Formatter
28 {
29     var $_absurls = false;
30
31     function _RecentChanges_Formatter ($rc_args) {
32         $this->_args = $rc_args;
33         $this->_diffargs = array('action' => 'diff');
34
35         if ($rc_args['show_minor'] || !$rc_args['show_major'])
36             $this->_diffargs['previous'] = 'minor';
37
38         // PageHistoryPlugin doesn't have a 'daylist' arg.
39         if (!isset($this->_args['daylist']))
40             $this->_args['daylist'] = false;
41     }
42
43     function include_versions_in_URLs() {
44         return (bool) $this->_args['show_all'];
45     }
46
47     function date ($rev) {
48         global $WikiTheme;
49         return $WikiTheme->getDay($rev->get('mtime'));
50     }
51
52     function time ($rev) {
53         global $WikiTheme;
54         return $WikiTheme->formatTime($rev->get('mtime'));
55     }
56
57     function diffURL ($rev) {
58         $args = $this->_diffargs;
59         if ($this->include_versions_in_URLs())
60             $args['version'] = $rev->getVersion();
61         $page = $rev->getPage();
62         return WikiURL($page->getName(), $args, $this->_absurls);
63     }
64
65     function historyURL ($rev) {
66         $page = $rev->getPage();
67         return WikiURL($page, array('action' => _("PageHistory")),
68                        $this->_absurls);
69     }
70
71     function pageURL ($rev) {
72         return WikiURL($this->include_versions_in_URLs() ? $rev : $rev->getPage(),
73                        '', $this->_absurls);
74     }
75
76     function authorHasPage ($author) {
77         global $WikiNameRegexp, $request;
78         $dbi = $request->getDbh();
79         return isWikiWord($author) && $dbi->isWikiPage($author);
80     }
81
82     function authorURL ($author) {
83         return $this->authorHasPage() ? WikiURL($author) : false;
84     }
85
86
87     function status ($rev) {
88         if ($rev->hasDefaultContents())
89             return 'deleted';
90         $page = $rev->getPage();
91         $prev = $page->getRevisionBefore($rev->getVersion());
92         if ($prev->hasDefaultContents())
93             return 'new';
94         return 'updated';
95     }
96
97     function importance ($rev) {
98         return $rev->get('is_minor_edit') ? 'minor' : 'major';
99     }
100
101     function summary($rev) {
102         if ( ($summary = $rev->get('summary')) )
103             return $summary;
104
105         switch ($this->status($rev)) {
106             case 'deleted':
107                 return _("Deleted");
108             case 'new':
109                 return _("New page");
110             default:
111                 return '';
112         }
113     }
114
115     function setValidators($most_recent_rev) {
116         $rev = $most_recent_rev;
117         $validators = array('RecentChanges-top' =>
118                             array($rev->getPageName(), $rev->getVersion()),
119                             '%mtime' => $rev->get('mtime'));
120         global $request;
121         $request->appendValidators($validators);
122     }
123 }
124
125 class _RecentChanges_HtmlFormatter
126 extends _RecentChanges_Formatter
127 {
128     function diffLink ($rev) {
129         global $WikiTheme;
130         $button = $WikiTheme->makeButton(_("diff"), $this->diffURL($rev), 'wiki-rc-action');
131         $button->setAttr('rel', 'nofollow');
132         return HTML("(",$button,")");
133     }
134
135     /* deletions: red, additions: green */
136     function diffSummary ($rev) {
137         $html = $this->diffURL($rev);
138         return '';
139     }
140
141     function historyLink ($rev) {
142         global $WikiTheme;
143         $button = $WikiTheme->makeButton(_("hist"), $this->historyURL($rev), 'wiki-rc-action');
144         $button->setAttr('rel', 'nofollow');
145         return HTML("(",$button,")");
146     }
147
148     function pageLink ($rev, $link_text=false) {
149
150         return WikiLink($this->include_versions_in_URLs() ? $rev : $rev->getPage(),'auto',$link_text);
151         /*
152         $page = $rev->getPage();
153         global $WikiTheme;
154         if ($this->include_versions_in_URLs()) {
155             $version = $rev->getVersion();
156             if ($rev->isCurrent())
157                 $version = false;
158             $exists = !$rev->hasDefaultContents();
159         }
160         else {
161             $version = false;
162             $cur = $page->getCurrentRevision();
163             $exists = !$cur->hasDefaultContents();
164         }
165         if ($exists)
166             return $WikiTheme->linkExistingWikiWord($page->getName(), $link_text, $version);
167         else
168             return $WikiTheme->linkUnknownWikiWord($page->getName(), $link_text);
169         */
170     }
171
172     function authorLink ($rev) {
173         return WikiLink($rev->get('author'), 'if_known');
174     }
175
176     /* Link to all users contributions (contribs and owns) */
177     function authorContribs ($rev) {
178         $author = $rev->get('author');
179         if (preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $author)) return '';
180         return HTML('(',
181                     Button(array('action' => _("RecentChanges"), 
182                                  'format' => 'contribs',
183                                  'author' => $author,
184                                  'days' => 360),
185                            _("contribs"),
186                            $author),
187                     ' | ',
188                     Button(array('action' => _("RecentChanges"), 
189                                  'format' => 'contribs',
190                                  'owner' => $author,
191                                  'days' => 360),
192                            _("new pages"),
193                            $author),
194                     ')');
195     }
196
197     function summaryAsHTML ($rev) {
198         if ( !($summary = $this->summary($rev)) )
199             return '';
200         return  HTML::span( array('class' => 'wiki-summary'),
201                             "(",
202                             TransformLinks($summary, $rev->get('markup'), $rev->getPageName()),
203                             ")");
204     }
205
206     function rss_icon () {
207         global $request, $WikiTheme;
208
209         $rss_url = $request->getURLtoSelf(array('action' => 'RecentChanges', 'format' => 'rss'));
210         return HTML::small(array('style' => 'font-weight:normal;vertical-align:middle;'), 
211                            $WikiTheme->makeButton("RSS", $rss_url, 'rssicon'));
212     }
213     function rss2_icon () {
214         global $request, $WikiTheme;
215
216         $rss_url = $request->getURLtoSelf(array('action' => 'RecentChanges', 'format' => 'rss2'));
217         return HTML::small(array('style' => 'font-weight:normal;vertical-align:middle;'), 
218                            $WikiTheme->makeButton("xml", $rss_url, 'rssicon'));
219     }
220     function atom_icon () {
221         global $request, $WikiTheme;
222         if (DEBUG) {
223             $rss_url = $request->getURLtoSelf(array('action' => 'RecentChanges', 'format' => 'atom'));
224             return HTML::small(array('style' => 'font-weight:normal;vertical-align:middle;'), 
225                            $WikiTheme->makeButton("atom", $rss_url, 'rssicon'));
226         }
227     }
228     function grazr_icon () {
229         global $request, $WikiTheme;
230         $rss_url = 'http://grazr.com/gzpanel.html?' . 
231             WikiURL($request->getArg('pagename'),array('action' => 'RecentChanges', 'format' => 'rss2'),true);
232         return HTML::small(array('style' => 'font-weight:normal;vertical-align:middle;'), 
233                            $WikiTheme->makeButton("grazr-it", $rss_url, 'rssicon'));
234     }
235
236     function pre_description () {
237         extract($this->_args);
238         // FIXME: say something about show_all.
239         if ($show_major && $show_minor)
240             $edits = _("edits");
241         elseif ($show_major)
242             $edits = _("major edits");
243         else
244             $edits = _("minor edits");
245         if (isset($caption) and $caption == _("Recent Comments"))
246             $edits = _("comments");
247         if (!empty($only_new)) {
248             $edits = _("created new pages");
249         }
250         if (!empty($author)) {
251             global $request;
252             if ($author == '[]')
253                 $author = $request->_user->getID();
254             $edits .= sprintf(_(" for pages changed by %s"), $author);
255         }
256         if (!empty($owner)) {
257             global $request;
258             if ($owner == '[]')
259                 $owner = $request->_user->getID();
260             $edits .= sprintf(_(" for pages owned by %s"), $owner);
261         }
262         if ($timespan = $days > 0) {
263             if (intval($days) != $days)
264                 $days = sprintf("%.1f", $days);
265         }
266         $lmt = abs($limit);
267         /**
268          * Depending how this text is split up it can be tricky or
269          * impossible to translate with good grammar. So the seperate
270          * strings for 1 day and %s days are necessary in this case
271          * for translating to multiple languages, due to differing
272          * overlapping ideal word cutting points.
273          *
274          * en: day/days "The %d most recent %s [during (the past] day) are listed below."
275          * de: 1 Tag    "Die %d jüngste %s [innerhalb (von des letzten] Tages) sind unten aufgelistet."
276          * de: %s days  "Die %d jüngste %s [innerhalb (von] %s Tagen) sind unten aufgelistet."
277          *
278          * en: day/days "The %d most recent %s during [the past] (day) are listed below."
279          * fr: 1 jour   "Les %d %s les plus récentes pendant [le dernier (d'une] jour) sont Ã©numérées ci-dessous."
280          * fr: %s jours "Les %d %s les plus récentes pendant [les derniers (%s] jours) sont Ã©numérées ci-dessous."
281          */
282         if ($limit > 0) {
283             if ($timespan) {
284                 if (intval($days) == 1)
285                     $desc = fmt("The %d most recent %s during the past day are listed below.",
286                                 $limit, $edits);
287                 else
288                     $desc = fmt("The %d most recent %s during the past %s days are listed below.",
289                                 $limit, $edits, $days);
290             } else
291                 $desc = fmt("The %d most recent %s are listed below.",
292                             $limit, $edits);
293         }
294         elseif ($limit < 0) {  //$limit < 0 means we want oldest pages
295             if ($timespan) {
296                 if (intval($days) == 1)
297                     $desc = fmt("The %d oldest %s during the past day are listed below.",
298                                 $lmt, $edits);
299                 else
300                     $desc = fmt("The %d oldest %s during the past %s days are listed below.",
301                                 $lmt, $edits, $days);
302             } else
303                 $desc = fmt("The %d oldest %s are listed below.",
304                             $lmt, $edits);
305         }
306
307         else {
308             if ($timespan) {
309                 if (intval($days) == 1)
310                     $desc = fmt("The most recent %s during the past day are listed below.",
311                                 $edits);
312                 else
313                     $desc = fmt("The most recent %s during the past %s days are listed below.",
314                                 $edits, $days);
315             } else
316                 $desc = fmt("All %s are listed below.", $edits);
317         }
318         return $desc;
319     }    
320
321     function description() {
322         return HTML::p(false, $this->pre_description());
323     }
324
325
326     function title () {
327         extract($this->_args);
328         return array($show_minor ? _("RecentEdits") : _("RecentChanges"),
329                      ' ',
330                      $this->rss_icon(), 
331                      HTML::raw('&nbsp;'), $this->rss2_icon(),
332                      HTML::raw('&nbsp;'), $this->grazr_icon(),
333                      HTML::raw('&nbsp;'), $this->atom_icon(),
334                      $this->sidebar_link());
335     }
336
337     function empty_message() {
338         if (isset($this->_args['caption']) and $this->_args['caption'] == _("Recent Comments"))
339             return _("No comments found");
340         else 
341             return _("No changes found");
342     }
343         
344     function sidebar_link() {
345         extract($this->_args);
346         $pagetitle = $show_minor ? _("RecentEdits") : _("RecentChanges");
347
348         global $request;
349         $sidebarurl = WikiURL($pagetitle, array('format' => 'sidebar'), 'absurl');
350
351         $addsidebarjsfunc =
352             "function addPanel() {\n"
353             ."    window.sidebar.addPanel (\"" . sprintf("%s - %s", WIKI_NAME, $pagetitle) . "\",\n"
354             ."       \"$sidebarurl\",\"\");\n"
355             ."}\n";
356         $jsf = JavaScript($addsidebarjsfunc);
357
358         global $WikiTheme;
359         $sidebar_button = $WikiTheme->makeButton("sidebar", 'javascript:addPanel();', 'sidebaricon');
360         $addsidebarjsclick = asXML(HTML::small(array('style' => 'font-weight:normal;vertical-align:middle;'), $sidebar_button));
361         $jsc = JavaScript("if ((typeof window.sidebar == 'object') &&\n"
362                                 ."    (typeof window.sidebar.addPanel == 'function'))\n"
363                                 ."   {\n"
364                                 ."       document.write('$addsidebarjsclick');\n"
365                                 ."   }\n"
366                                 );
367         return HTML(new RawXML("\n"), $jsf, new RawXML("\n"), $jsc);
368     }
369
370     function format ($changes) {
371         include_once('lib/InlineParser.php');
372         
373         $html = HTML(HTML::h2(false, $this->title()));
374         if (($desc = $this->description()))
375             $html->pushContent($desc);
376         
377         if ($this->_args['daylist'])
378             $html->pushContent(new DayButtonBar($this->_args));
379
380         $last_date = '';
381         $lines = false;
382         $first = true;
383
384         while ($rev = $changes->next()) {
385             if (($date = $this->date($rev)) != $last_date) {
386                 if ($lines)
387                     $html->pushContent($lines);
388                 // for user contributions no extra date line
389                 $html->pushContent(HTML::h3($date));
390                 $lines = HTML::ul();
391                 $last_date = $date;
392
393             }
394             // enforce view permission
395             if (mayAccessPage('view', $rev->_pagename)) {
396                 $lines->pushContent($this->format_revision($rev));
397                 if ($first)
398                     $this->setValidators($rev);
399                 $first = false;
400             }
401         }
402         if ($lines)
403             $html->pushContent($lines);
404         if ($first)
405             $html->pushContent(HTML::p(array('class' => 'rc-empty'),
406                                        $this->empty_message()));
407         
408         return $html;
409     }
410
411     function format_revision ($rev) {
412         $args = &$this->_args;
413
414         $class = 'rc-' . $this->importance($rev);
415
416         $time = $this->time($rev);
417         if (! $rev->get('is_minor_edit'))
418             $time = HTML::span(array('class' => 'pageinfo-majoredit'), $time);
419
420         $line = HTML::li(array('class' => $class));
421
422         if ($args['difflinks'])
423             $line->pushContent($this->diffLink($rev), ' ');
424
425         if ($args['historylinks'])
426             $line->pushContent($this->historyLink($rev), ' ');
427
428         if (isa($GLOBALS['WikiTheme'],'Theme_MonoBook')) {
429             $line->pushContent(
430                                $args['historylinks'] ? '' : $this->historyLink($rev),
431                                ' . . ', $this->pageLink($rev), '; ',
432                                $time, ' . . ',
433                                $this->authorLink($rev),' ',
434                                $this->authorContribs($rev),' ',
435                                $this->summaryAsHTML($rev));
436         } else {
437             $line->pushContent($this->pageLink($rev), ' ',
438                                $time, ' ',
439                                $this->summaryAsHTML($rev),
440                                ' ... ',
441                                $this->authorLink($rev));
442         }
443         return $line;
444     }
445
446 }
447
448 /* format=contribs: no seperation into extra dates
449  * 14:41, 3 December 2006 (hist) (diff) Talk:PhpWiki (added diff link)  (top)
450  */
451 class _RecentChanges_UserContribsFormatter
452 extends _RecentChanges_HtmlFormatter
453 {
454     function title () {
455         extract($this->_args);
456         return array(_("UserContribs"),":",$author ? $author : $owner,
457                      ' ',
458                      $this->rss_icon(), 
459                      HTML::raw('&nbsp;'), $this->rss2_icon(),
460                      //HTML::raw('&nbsp;'), $this->grazr_icon(),
461                      HTML::raw('&nbsp;'), $this->atom_icon());
462     }
463
464     function format ($changes) {
465         include_once('lib/InlineParser.php');
466         
467         $html = HTML(HTML::h2(false, $this->title()));
468         $lines = HTML::ol();
469         $first = true; $count = 0;
470         while ($rev = $changes->next()) {
471             if (mayAccessPage('view', $rev->_pagename)) {
472                 $lines->pushContent($this->format_revision($rev));
473                 if ($first)
474                     $this->setValidators($rev);
475                 $first = false;
476             }
477             $count++;
478         }
479         $this->_args['limit'] = $count;
480         if (($desc = $this->description()))
481             $html->pushContent($desc);
482         if ($this->_args['daylist'])
483             $html->pushContent(new DayButtonBar($this->_args));
484         if ($first)
485             $html->pushContent(HTML::p(array('class' => 'rc-empty'),
486                                        $this->empty_message()));
487         else                               
488             $html->pushContent($lines);
489         
490         return $html;
491     }
492
493     function format_revision ($rev) {
494         $args = &$this->_args;
495         $class = 'rc-' . $this->importance($rev);
496         $time = $this->time($rev);
497         if (! $rev->get('is_minor_edit'))
498             $time = HTML::span(array('class' => 'pageinfo-majoredit'), $time);
499
500         $line = HTML::li(array('class' => $class));
501
502         $line->pushContent($this->time($rev),", ");
503         $line->pushContent($this->date($rev)," ");
504         $line->pushContent($this->diffLink($rev), ' ');
505         $line->pushContent($this->historyLink($rev), ' ');
506         $line->pushContent($this->pageLink($rev), ' ',
507                            $this->summaryAsHTML($rev));
508         return $line;
509     }
510 }
511
512 class _RecentChanges_SideBarFormatter
513 extends _RecentChanges_HtmlFormatter
514 {
515     function rss_icon () {
516         //omit rssicon
517     }
518     function rss2_icon () { }
519     function title () {
520         //title click opens the normal RC or RE page in the main browser frame
521         extract($this->_args);
522         $titlelink = WikiLink($show_minor ? _("RecentEdits") : _("RecentChanges"));
523         $titlelink->setAttr('target', '_content');
524         return HTML($this->logo(), $titlelink);
525     }
526     function logo () {
527         //logo click opens the HomePage in the main browser frame
528         global $WikiTheme;
529         $img = HTML::img(array('src' => $WikiTheme->getImageURL('logo'),
530                                'border' => 0,
531                                'align' => 'right',
532                                'style' => 'height:2.5ex'
533                                ));
534         $linkurl = WikiLink(HOME_PAGE, false, $img);
535         $linkurl->setAttr('target', '_content');
536         return $linkurl;
537     }
538
539     function authorLink ($rev) {
540         $author = $rev->get('author');
541         if ( $this->authorHasPage($author) ) {
542             $linkurl = WikiLink($author);
543             $linkurl->setAttr('target', '_content'); // way to do this using parent::authorLink ??
544             return $linkurl;
545         } else
546             return $author;
547     }
548
549     function diffLink ($rev) {
550         $linkurl = parent::diffLink($rev);
551         $linkurl->setAttr('target', '_content');
552         $linkurl->setAttr('rel', 'nofollow');
553         // FIXME: Smelly hack to get smaller diff buttons in sidebar
554         $linkurl = new RawXML(str_replace('<img ', '<img style="height:2ex" ', asXML($linkurl)));
555         return $linkurl;
556     }
557     function historyLink ($rev) {
558         $linkurl = parent::historyLink($rev);
559         $linkurl->setAttr('target', '_content');
560         // FIXME: Smelly hack to get smaller history buttons in sidebar
561         $linkurl = new RawXML(str_replace('<img ', '<img style="height:2ex" ', asXML($linkurl)));
562         return $linkurl;
563     }
564     function pageLink ($rev) {
565         $linkurl = parent::pageLink($rev);
566         $linkurl->setAttr('target', '_content');
567         return $linkurl;
568     }
569     // Overriding summaryAsHTML, because there is no way yet to
570     // return summary as transformed text with
571     // links setAttr('target', '_content') in Mozilla sidebar.
572     // So for now don't create clickable links inside summary
573     // in the sidebar, or else they target the sidebar and not the
574     // main content window.
575     function summaryAsHTML ($rev) {
576         if ( !($summary = $this->summary($rev)) )
577             return '';
578         return HTML::span(array('class' => 'wiki-summary'),
579                           "[",
580                           /*TransformLinks(*/$summary,/* $rev->get('markup')),*/
581                           "]");
582     }
583
584
585     function format ($changes) {
586         $this->_args['daylist'] = false; //don't show day buttons in Mozilla sidebar
587         $html = _RecentChanges_HtmlFormatter::format ($changes);
588         $html = HTML::div(array('class' => 'wikitext'), $html);
589         global $request;
590         $request->discardOutput();
591         
592         printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", $GLOBALS['charset']);
593         printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"');
594         printf('  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
595         printf('<html xmlns="http://www.w3.org/1999/xhtml">');
596
597         printf("<head>\n");
598         extract($this->_args);
599         $title = WIKI_NAME . $show_minor ? _("RecentEdits") : _("RecentChanges");
600         printf("<title>" . $title . "</title>\n");
601         global $WikiTheme;
602         $css = $WikiTheme->getCSS();
603         $css->PrintXML();
604         printf("</head>\n");
605
606         printf("<body class=\"sidebar\">\n");
607         $html->PrintXML();
608         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>';
609         printf("\n</body>\n");
610         printf("</html>\n");
611
612         $request->finish(); // cut rest of page processing short
613     }
614 }
615
616 class _RecentChanges_BoxFormatter
617 extends _RecentChanges_HtmlFormatter
618 {
619     function rss_icon () {
620     }
621     function rss2_icon () {
622     }
623     function title () {
624     }
625     function authorLink ($rev) {
626     }
627     function diffLink ($rev) {
628     }
629     function historyLink ($rev) {
630     }
631     function summaryAsHTML ($rev) {
632     }
633     function description () {
634     }
635     function format ($changes) {
636         include_once('lib/InlineParser.php');
637         $last_date = '';
638         $first = true;
639         $html = HTML();
640         $counter = 1;
641         $sp = HTML::Raw("\n&nbsp;&middot;&nbsp;");
642         while ($rev = $changes->next()) {
643             // enforce view permission
644             if (mayAccessPage('view',$rev->_pagename)) {
645                 if ($link = $this->pageLink($rev)) // some entries may be empty 
646                                                    // (/Blog/.. interim pages)
647                     $html->pushContent($sp, $link, HTML::br());
648                 if ($first)
649                     $this->setValidators($rev);
650                 $first = false;
651             }
652         }
653         if ($first)
654             $html->pushContent(HTML::p(array('class' => 'rc-empty'),
655                                        $this->empty_message()));
656         return $html;
657     }
658 }
659
660 class _RecentChanges_RssFormatter
661 extends _RecentChanges_Formatter
662 {
663     var $_absurls = true;
664
665     function time ($rev) {
666         return Iso8601DateTime($rev->get('mtime'));
667     }
668
669     function pageURI ($rev) {
670         return WikiURL($rev, '', 'absurl');
671     }
672
673     function format ($changes) {
674         
675         include_once('lib/RssWriter.php');
676         $rss = new RssWriter;
677
678         $rss->channel($this->channel_properties());
679
680         if (($props = $this->image_properties()))
681             $rss->image($props);
682         if (($props = $this->textinput_properties()))
683             $rss->textinput($props);
684
685         $first = true;
686         while ($rev = $changes->next()) {
687             // enforce view permission
688             if (mayAccessPage('view', $rev->_pagename)) {
689                 $rss->addItem($this->item_properties($rev),
690                               $this->pageURI($rev));
691                 if ($first)
692                     $this->setValidators($rev);
693                 $first = false;
694             }
695         }
696
697         global $request;
698         $request->discardOutput();
699         $rss->finish();
700         printf("\n<!-- Generated by PhpWiki-%s:\n%s-->\n", PHPWIKI_VERSION, $GLOBALS['RCS_IDS']);
701
702         // Flush errors in comment, otherwise it's invalid XML.
703         global $ErrorManager;
704         if (($errors = $ErrorManager->getPostponedErrorsAsHTML()))
705             printf("\n<!-- PHP Warnings:\n%s-->\n", AsXML($errors));
706
707         $request->finish();     // NORETURN!!!!
708     }
709
710     function image_properties () {
711         global $WikiTheme;
712
713         $img_url = AbsoluteURL($WikiTheme->getImageURL('logo'));
714         if (!$img_url)
715             return false;
716
717         return array('title' => WIKI_NAME,
718                      'link' => WikiURL(HOME_PAGE, false, 'absurl'),
719                      'url' => $img_url);
720     }
721
722     function textinput_properties () {
723         return array('title' => _("Search"),
724                      'description' => _("Title Search"),
725                      'name' => 's',
726                      'link' => WikiURL(_("TitleSearch"), false, 'absurl'));
727     }
728
729     function channel_properties () {
730         global $request;
731
732         $rc_url = WikiURL($request->getArg('pagename'), false, 'absurl');
733         return array('title' => WIKI_NAME,
734                      'link' => $rc_url,
735                      'description' => _("RecentChanges"),
736                      'dc:date' => Iso8601DateTime(time()),
737                      'dc:language' => $GLOBALS['LANG']);
738
739         /* FIXME: other things one might like in <channel>:
740          * sy:updateFrequency
741          * sy:updatePeriod
742          * sy:updateBase
743          * dc:subject
744          * dc:publisher
745          * dc:language
746          * dc:rights
747          * rss091:language
748          * rss091:managingEditor
749          * rss091:webmaster
750          * rss091:lastBuildDate
751          * rss091:copyright
752          */
753     }
754
755     function item_properties ($rev) {
756         $page = $rev->getPage();
757         $pagename = $page->getName();
758
759         return array( 'title'           => SplitPagename($pagename),
760                       'description'     => $this->summary($rev),
761                       'link'            => $this->pageURL($rev),
762                       'dc:date'         => $this->time($rev),
763                       'dc:contributor'  => $rev->get('author'),
764                       'wiki:version'    => $rev->getVersion(),
765                       'wiki:importance' => $this->importance($rev),
766                       'wiki:status'     => $this->status($rev),
767                       'wiki:diff'       => $this->diffURL($rev),
768                       'wiki:history'    => $this->historyURL($rev)
769                       );
770     }
771 }
772
773 /** explicit application/rss+xml Content-Type,
774  * simplified xml structure (no namespace),
775  * support for xml-rpc cloud registerProcedure (not yet)
776  */
777 class _RecentChanges_Rss2Formatter
778 extends _RecentChanges_RssFormatter {
779
780     function format ($changes) {
781         include_once('lib/RssWriter2.php');
782         $rss = new RssWriter2;
783
784         $rss->channel($this->channel_properties());
785         if (($props = $this->cloud_properties()))
786             $rss->cloud($props);
787         if (($props = $this->image_properties()))
788             $rss->image($props);
789         if (($props = $this->textinput_properties()))
790             $rss->textinput($props);
791         $first = true;
792         while ($rev = $changes->next()) {
793             // enforce view permission
794             if (mayAccessPage('view', $rev->_pagename)) {
795                 $rss->addItem($this->item_properties($rev),
796                               $this->pageURI($rev));
797                 if ($first)
798                     $this->setValidators($rev);
799                 $first = false;
800             }
801         }
802
803         global $request;
804         $request->discardOutput();
805         $rss->finish();
806         printf("\n<!-- Generated by PhpWiki-%s:\n%s-->\n", PHPWIKI_VERSION, $GLOBALS['RCS_IDS']);
807         // Flush errors in comment, otherwise it's invalid XML.
808         global $ErrorManager;
809         if (($errors = $ErrorManager->getPostponedErrorsAsHTML()))
810             printf("\n<!-- PHP Warnings:\n%s-->\n", AsXML($errors));
811
812         $request->finish();     // NORETURN!!!!
813     }
814
815     function channel_properties () {
816         $chann_10 = parent::channel_properties();
817         return array_merge($chann_10,
818                            array('generator' => 'PhpWiki-'.PHPWIKI_VERSION,
819                                  //<pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
820                                  //<lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
821                                  //<docs>http://blogs.law.harvard.edu/tech/rss</docs>
822                                  'copyright' => COPYRIGHTPAGE_URL
823                                  ));
824     }
825
826     // xml-rpc registerProcedure not yet implemented
827     function cloud_properties () { return false; } 
828     function cloud_properties_test () {
829         return array('protocol' => 'xml-rpc', // xml-rpc or soap or http-post
830                      'registerProcedure' => 'wiki.rssPleaseNotify',
831                      'path' => DATA_PATH.'/RPC2.php',
832                      'port' => !SERVER_PORT ? '80' : (SERVER_PROTOCOL == 'https' ? '443' : '80'),
833                      'domain' => SERVER_NAME);
834     }
835 }
836
837 /**
838  * Filter by non-empty
839  */
840 class NonDeletedRevisionIterator extends WikiDB_PageRevisionIterator
841 {
842     /** Constructor
843      *
844      * @param $revisions object a WikiDB_PageRevisionIterator.
845      */
846     function NonDeletedRevisionIterator ($revisions, $check_current_revision = true) {
847         $this->_revisions = $revisions;
848         $this->_check_current_revision = $check_current_revision;
849     }
850
851     function next () {
852         while (($rev = $this->_revisions->next())) {
853             if ($this->_check_current_revision) {
854                 $page = $rev->getPage();
855                 $check_rev = $page->getCurrentRevision();
856             }
857             else {
858                 $check_rev = $rev;
859             }
860             if (! $check_rev->hasDefaultContents())
861                 return $rev;
862         }
863         $this->free();
864         return false;
865     }
866
867 }
868
869 /**
870  * Filter by only_new.
871  * Only new created pages
872  */
873 class NewPageRevisionIterator extends WikiDB_PageRevisionIterator
874 {
875     /** Constructor
876      *
877      * @param $revisions object a WikiDB_PageRevisionIterator.
878      */
879     function NewPageRevisionIterator ($revisions) {
880         $this->_revisions = $revisions;
881     }
882
883     function next () {
884         while (($rev = $this->_revisions->next())) {
885             if ($rev->getVersion() == 1)
886                 return $rev;
887         }
888         $this->free();
889         return false;
890     }
891 }
892
893 /**
894  * Filter by author
895  */
896 class AuthorPageRevisionIterator extends WikiDB_PageRevisionIterator
897 {
898     function AuthorPageRevisionIterator ($revisions, $author) {
899         $this->_revisions = $revisions;
900         $this->_author = $author;
901     }
902
903     function next () {
904         while (($rev = $this->_revisions->next())) {
905             if ($rev->get('author_id') == $this->_author)
906                 return $rev;
907         }
908         $this->free();
909         return false;
910     }
911 }
912
913 /**
914  * Filter by owner
915  */
916 class OwnerPageRevisionIterator extends WikiDB_PageRevisionIterator
917 {
918     function OwnerPageRevisionIterator ($revisions, $owner) {
919         $this->_revisions = $revisions;
920         $this->_owner = $owner;
921     }
922
923     function next () {
924         while (($rev = $this->_revisions->next())) {
925             $page = $rev->getPage();
926             if ($page->getOwner() == $this->_owner)
927                 return $rev;
928         }
929         $this->free();
930         return false;
931     }
932 }
933
934 class WikiPlugin_RecentChanges
935 extends WikiPlugin
936 {
937     function getName () {
938         return _("RecentChanges");
939     }
940
941     function getVersion() {
942         return preg_replace("/[Revision: $]/", '',
943                             "\$Revision: 1.117 $");
944     }
945
946     function managesValidators() {
947         // Note that this is a bit of a fig.
948         // We set validators based on the most recently changed page,
949         // but this fails when the most-recent page is deleted.
950         // (Consider that the Last-Modified time will decrease
951         // when this happens.)
952
953         // We might be better off, leaving this as false (and junking
954         // the validator logic above) and just falling back to the
955         // default behavior (handled by WikiPlugin) of just using
956         // the WikiDB global timestamp as the mtime.
957
958         // Nevertheless, for now, I leave this here, mostly as an
959         // example for how to use appendValidators() and managesValidators().
960         
961         return true;
962     }
963             
964     function getDefaultArguments() {
965         return array('days'         => 2,
966                      'show_minor'   => false,
967                      'show_major'   => true,
968                      'show_all'     => false,
969                      'show_deleted' => 'sometimes',
970                      'only_new'     => false,
971                      'author'       => false,
972                      'owner'        => false,
973                      'limit'        => false,
974                      'format'       => false,
975                      'daylist'      => false,
976                      'difflinks'    => true,
977                      'historylinks' => false,
978                      'caption'      => ''
979                      );
980     }
981
982     function getArgs ($argstr, $request, $defaults = false) {
983         if (!$defaults) $defaults = $this->getDefaultArguments();
984         $args = WikiPlugin::getArgs($argstr, $request, $defaults);
985
986         $action = $request->getArg('action');
987         if ($action != 'browse' && ! $request->isActionPage($action))
988             $args['format'] = false; // default -> HTML
989
990         if ($args['format'] == 'rss' && empty($args['limit']))
991             $args['limit'] = 15; // Fix default value for RSS.
992         if ($args['format'] == 'rss2' && empty($args['limit']))
993             $args['limit'] = 15; // Fix default value for RSS2.
994
995         if ($args['format'] == 'sidebar' && empty($args['limit']))
996             $args['limit'] = 10; // Fix default value for sidebar.
997
998         return $args;
999     }
1000
1001     function getMostRecentParams (&$args) {
1002         $show_all = false; $show_minor = false; $show_major = false;
1003         $limit = false;
1004         extract($args);
1005
1006         $params = array('include_minor_revisions' => $show_minor,
1007                         'exclude_major_revisions' => !$show_major,
1008                         'include_all_revisions' => !empty($show_all));
1009         if ($limit != 0)
1010             $params['limit'] = $limit;
1011         if (!empty($args['author'])) {
1012             global $request;
1013             if ($args['author'] == '[]')
1014                 $args['author'] = $request->_user->getID();
1015             $params['author'] = $args['author'];
1016         }
1017         if (!empty($args['owner'])) {
1018             global $request;
1019             if ($args['owner'] == '[]')
1020                 $args['owner'] = $request->_user->getID();
1021             $params['owner'] = $args['owner'];
1022         }
1023         if (!empty($days)) {
1024           if ($days > 0.0)
1025             $params['since'] = time() - 24 * 3600 * $days;
1026           elseif ($days < 0.0)
1027             $params['since'] = 24 * 3600 * $days - time();
1028         }
1029
1030         return $params;
1031     }
1032
1033     function getChanges ($dbi, $args) {
1034         $changes = $dbi->mostRecent($this->getMostRecentParams($args));
1035
1036         $show_deleted = @$args['show_deleted'];
1037         $show_all = @$args['show_all'];
1038         if ($show_deleted == 'sometimes')
1039             $show_deleted = @$args['show_minor'];
1040
1041         if (!empty($args['only_new']))
1042             $changes = new NewPageRevisionIterator($changes);
1043         if (!empty($args['author']))
1044             $changes = new AuthorPageRevisionIterator($changes, $args['author']);
1045         if (!empty($args['owner']))
1046             $changes = new OwnerPageRevisionIterator($changes, $args['owner']);
1047         if (!$show_deleted)
1048             $changes = new NonDeletedRevisionIterator($changes, !$show_all);
1049
1050         return $changes;
1051     }
1052
1053     function format ($changes, $args) {
1054         global $WikiTheme;
1055         $format = $args['format'];
1056
1057         $fmt_class = $WikiTheme->getFormatter('RecentChanges', $format);
1058         if (!$fmt_class) {
1059             if ($format == 'rss')
1060                 $fmt_class = '_RecentChanges_RssFormatter';
1061             elseif ($format == 'rss2')
1062                 $fmt_class = '_RecentChanges_Rss2Formatter';
1063             elseif ($format == 'rss091') {
1064                 include_once "lib/RSSWriter091.php";
1065                 $fmt_class = '_RecentChanges_RssFormatter091';
1066             }
1067             elseif ($format == 'sidebar')
1068                 $fmt_class = '_RecentChanges_SideBarFormatter';
1069             elseif ($format == 'box')
1070                 $fmt_class = '_RecentChanges_BoxFormatter';
1071             elseif ($format == 'contribs')
1072                 $fmt_class = '_RecentChanges_UserContribsFormatter';
1073             else
1074                 $fmt_class = '_RecentChanges_HtmlFormatter';
1075         }
1076
1077         $fmt = new $fmt_class($args);
1078         return $fmt->format($changes);
1079     }
1080
1081     function run($dbi, $argstr, &$request, $basepage) {
1082         $args = $this->getArgs($argstr, $request);
1083
1084         // HACKish: fix for SF bug #622784  (1000 years of RecentChanges ought
1085         // to be enough for anyone.)
1086         $args['days'] = min($args['days'], 365000);
1087         
1088         // Hack alert: format() is a NORETURN for rss formatters.
1089         return $this->format($this->getChanges($dbi, $args), $args);
1090     }
1091
1092     // box is used to display a fixed-width, narrow version with common header.
1093     // just a numbered list of limit pagenames, without date.
1094     function box($args = false, $request = false, $basepage = false) {
1095         if (!$request) $request =& $GLOBALS['request'];
1096         if (!isset($args['limit'])) $args['limit'] = 15;
1097         $args['format'] = 'box';
1098         $args['show_minor'] = false;
1099         $args['show_major'] = true;
1100         $args['show_deleted'] = 'sometimes';
1101         $args['show_all'] = false;
1102         $args['days'] = 90;
1103         return $this->makeBox(WikiLink($this->getName(),'',
1104                                        SplitPagename($this->getName())),
1105                               $this->format
1106                               ($this->getChanges($request->_dbi, $args), $args));
1107     }
1108
1109 };
1110
1111
1112 class DayButtonBar extends HtmlElement {
1113
1114     function DayButtonBar ($plugin_args) {
1115         $this->__construct('p', array('class' => 'wiki-rc-action'));
1116
1117         // Display days selection buttons
1118         extract($plugin_args);
1119
1120         // Custom caption
1121         if (! $caption) {
1122             if ($show_minor)
1123                 $caption = _("Show minor edits for:");
1124             elseif ($show_all)
1125                 $caption = _("Show all changes for:");
1126             else
1127                 $caption = _("Show changes for:");
1128             if ($only_new)
1129                 $caption = _("All new pages since:");
1130         }
1131
1132         $this->pushContent($caption, ' ');
1133
1134         global $WikiTheme;
1135         $sep = $WikiTheme->getButtonSeparator();
1136
1137         $n = 0;
1138         foreach (explode(",", $daylist) as $days) {
1139             if ($n++)
1140                 $this->pushContent($sep);
1141             $this->pushContent($this->_makeDayButton($days));
1142         }
1143     }
1144
1145     function _makeDayButton ($days) {
1146         global $WikiTheme, $request;
1147
1148         if ($days == 1)
1149             $label = _("1 day");
1150         elseif ($days < 1)
1151             $label = "..."; //alldays
1152         else
1153             $label = sprintf(_("%s days"), abs($days));
1154
1155         $url = $request->getURLtoSelf(array('action' => $request->getArg('action'), 'days' => $days));
1156
1157         return $WikiTheme->makeButton($label, $url, 'wiki-rc-action');
1158     }
1159 }
1160
1161 // $Log: not supported by cvs2svn $
1162 // Revision 1.116  2007/05/13 18:13:41  rurban
1163 // use all filters, not just the first, ignoring the others. improve wording a bit
1164 //
1165 // Revision 1.115  2007/04/08 16:24:10  rurban
1166 // Remove redundant code in ->authorLink(): 'if_known' does the same
1167 //
1168 // Revision 1.114  2007/02/17 22:39:44  rurban
1169 // format=rss overhaul
1170 //
1171 // Revision 1.113  2007/02/17 14:15:52  rurban
1172 // new argument owner=[] for RecentChangesMyPages
1173 //
1174 // Revision 1.112  2007/01/28 20:32:07  rurban
1175 // silence empty warning
1176 //
1177 // Revision 1.111  2007/01/25 21:48:52  rurban
1178 // new argument author=[]
1179 //
1180 // Revision 1.110  2007/01/22 23:51:36  rurban
1181 // new arg: only_new
1182 //
1183 // Revision 1.109  2006/03/19 14:26:29  rurban
1184 // sf.net patch by Matt Brown: Add rel=nofollow to more actions
1185 //
1186 // Revision 1.108  2005/04/01 16:09:35  rurban
1187 // fix defaults in RecentChanges plugins: e.g. invalid pagenames for PageHistory
1188 //
1189 // Revision 1.107  2005/02/04 13:45:28  rurban
1190 // improve box layout a bit
1191 //
1192 // Revision 1.106  2005/02/02 19:39:10  rurban
1193 // honor show_all=false
1194 //
1195 // Revision 1.105  2005/01/25 03:50:54  uckelman
1196 // pre_description is a member function, so call with $this->.
1197 //
1198 // Revision 1.104  2005/01/24 23:15:16  uckelman
1199 // The extra description for RelatedChanges was appearing in RecentChanges
1200 // and PageHistory due to a bad test in _RecentChanges_HtmlFormatter. Fixed.
1201 //
1202 // Revision 1.103  2004/12/15 17:45:09  rurban
1203 // fix box method
1204 //
1205 // Revision 1.102  2004/12/06 19:29:24  rurban
1206 // simplify RSS: add RSS2 link (rss tag only, new content-type)
1207 //
1208 // Revision 1.101  2004/11/10 19:32:24  rurban
1209 // * optimize increaseHitCount, esp. for mysql.
1210 // * prepend dirs to the include_path (phpwiki_dir for faster searches)
1211 // * Pear_DB version logic (awful but needed)
1212 // * fix broken ADODB quote
1213 // * _extract_page_data simplification
1214 //
1215 // Revision 1.100  2004/06/28 16:35:12  rurban
1216 // prevent from shell commands
1217 //
1218 // Revision 1.99  2004/06/20 14:42:54  rurban
1219 // various php5 fixes (still broken at blockparser)
1220 //
1221 // Revision 1.98  2004/06/14 11:31:39  rurban
1222 // renamed global $Theme to $WikiTheme (gforge nameclash)
1223 // inherit PageList default options from PageList
1224 //   default sortby=pagename
1225 // use options in PageList_Selectable (limit, sortby, ...)
1226 // added action revert, with button at action=diff
1227 // added option regex to WikiAdminSearchReplace
1228 //
1229 // Revision 1.97  2004/06/03 18:58:27  rurban
1230 // days links requires action=RelatedChanges arg
1231 //
1232 // Revision 1.96  2004/05/18 16:23:40  rurban
1233 // rename split_pagename to SplitPagename
1234 //
1235 // Revision 1.95  2004/05/16 22:07:35  rurban
1236 // check more config-default and predefined constants
1237 // various PagePerm fixes:
1238 //   fix default PagePerms, esp. edit and view for Bogo and Password users
1239 //   implemented Creator and Owner
1240 //   BOGOUSERS renamed to BOGOUSER
1241 // fixed syntax errors in signin.tmpl
1242 //
1243 // Revision 1.94  2004/05/14 20:55:03  rurban
1244 // simplified RecentComments
1245 //
1246 // Revision 1.93  2004/05/14 17:33:07  rurban
1247 // new plugin RecentChanges
1248 //
1249 // Revision 1.92  2004/04/21 04:29:10  rurban
1250 // Two convenient RecentChanges extensions
1251 //   RelatedChanges (only links from current page)
1252 //   RecentEdits (just change the default args)
1253 //
1254 // Revision 1.91  2004/04/19 18:27:46  rurban
1255 // Prevent from some PHP5 warnings (ref args, no :: object init)
1256 //   php5 runs now through, just one wrong XmlElement object init missing
1257 // Removed unneccesary UpgradeUser lines
1258 // Changed WikiLink to omit version if current (RecentChanges)
1259 //
1260 // Revision 1.90  2004/04/18 01:11:52  rurban
1261 // more numeric pagename fixes.
1262 // fixed action=upload with merge conflict warnings.
1263 // charset changed from constant to global (dynamic utf-8 switching)
1264 //
1265 // Revision 1.89  2004/04/10 02:30:49  rurban
1266 // Fixed gettext problem with VIRTUAL_PATH scripts (Windows only probably)
1267 // Fixed "cannot setlocale..." (sf.net problem)
1268 //
1269 // Revision 1.88  2004/04/01 15:57:10  rurban
1270 // simplified Sidebar theme: table, not absolute css positioning
1271 // added the new box methods.
1272 // remaining problems: large left margin, how to override _autosplitWikiWords in Template only
1273 //
1274 // Revision 1.87  2004/03/30 02:14:03  rurban
1275 // fixed yet another Prefs bug
1276 // added generic PearDb_iter
1277 // $request->appendValidators no so strict as before
1278 // added some box plugin methods
1279 // PageList commalist for condensed output
1280 //
1281 // Revision 1.86  2004/03/12 13:31:43  rurban
1282 // enforce PagePermissions, errormsg if not Admin
1283 //
1284 // Revision 1.85  2004/02/17 12:11:36  rurban
1285 // added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...)
1286 //
1287 // Revision 1.84  2004/02/15 22:29:42  rurban
1288 // revert premature performance fix
1289 //
1290 // Revision 1.83  2004/02/15 21:34:37  rurban
1291 // PageList enhanced and improved.
1292 // fixed new WikiAdmin... plugins
1293 // editpage, Theme with exp. htmlarea framework
1294 //   (htmlarea yet committed, this is really questionable)
1295 // WikiUser... code with better session handling for prefs
1296 // enhanced UserPreferences (again)
1297 // RecentChanges for show_deleted: how should pages be deleted then?
1298 //
1299 // Revision 1.82  2004/01/25 03:58:43  rurban
1300 // use stdlib:isWikiWord()
1301 //
1302 // Revision 1.81  2003/11/28 21:06:31  carstenklapp
1303 // Enhancement: Mozilla RecentChanges sidebar now defaults to 10 changes
1304 // instead of 1. Make diff buttons smaller with css. Added description
1305 // line back in at the top.
1306 //
1307 // Revision 1.80  2003/11/27 15:17:01  carstenklapp
1308 // Theme & appearance tweaks: Converted Mozilla sidebar link into a Theme
1309 // button, to allow an image button for it to be added to Themes. Output
1310 // RSS button in small text size when theme has no button image.
1311 //
1312 // Revision 1.79  2003/04/29 14:34:20  dairiki
1313 // Bug fix: "add sidebar" link didn't work when USE_PATH_INFO was false.
1314 //
1315 // Revision 1.78  2003/03/04 01:55:05  dairiki
1316 // Fix to ensure absolute URL for logo in RSS recent changes.
1317 //
1318 // Revision 1.77  2003/02/27 23:23:38  dairiki
1319 // Fix my breakage of CSS and sidebar RecentChanges output.
1320 //
1321 // Revision 1.76  2003/02/27 22:48:44  dairiki
1322 // Fixes invalid HTML generated by PageHistory plugin.
1323 //
1324 // (<noscript> is block-level and not allowed within <p>.)
1325 //
1326 // Revision 1.75  2003/02/22 21:39:05  dairiki
1327 // Hackish fix for SF bug #622784.
1328 //
1329 // (The root of the problem is clearly a PHP bug.)
1330 //
1331 // Revision 1.74  2003/02/21 22:52:21  dairiki
1332 // Make sure to interpret relative links (like [/Subpage]) in summary
1333 // relative to correct basepage.
1334 //
1335 // Revision 1.73  2003/02/21 04:12:06  dairiki
1336 // Minor fixes for new cached markup.
1337 //
1338 // Revision 1.72  2003/02/17 02:19:01  dairiki
1339 // Fix so that PageHistory will work when the current revision
1340 // of a page has been "deleted".
1341 //
1342 // Revision 1.71  2003/02/16 20:04:48  dairiki
1343 // Refactor the HTTP validator generation/checking code.
1344 //
1345 // This also fixes a number of bugs with yesterdays validator mods.
1346 //
1347 // Revision 1.70  2003/02/16 05:09:43  dairiki
1348 // Starting to fix handling of the HTTP validator headers, Last-Modified,
1349 // and ETag.
1350 //
1351 // Last-Modified was being set incorrectly (but only when DEBUG was not
1352 // defined!)  Setting a Last-Modified without setting an appropriate
1353 // Expires: and/or Cache-Control: header results in browsers caching
1354 // the page unconditionally (for a certain period of time).
1355 // This is generally bad, since it means people don't see updated
1356 // page contents right away --- this is particularly confusing to
1357 // the people who are editing pages since their edits don't show up
1358 // next time they browse the page.
1359 //
1360 // Now, we don't allow caching of pages without revalidation
1361 // (via the If-Modified-Since and/or If-None-Match request headers.)
1362 // (You can allow caching by defining CACHE_CONTROL_MAX_AGE to an
1363 // appropriate value in index.php, but I advise against it.)
1364 //
1365 // Problems:
1366 //
1367 //   o Even when request is aborted due to the content not being
1368 //     modified, we currently still do almost all the work involved
1369 //     in producing the page.  So the only real savings from all
1370 //     this logic is in network bandwidth.
1371 //
1372 //   o Plugins which produce "dynamic" output need to be inspected
1373 //     and made to call $request->addToETag() and
1374 //     $request->setModificationTime() appropriately, otherwise the
1375 //     page can change without the change being detected.
1376 //     This leads to stale pages in cache again...
1377 //
1378 // Revision 1.69  2003/01/18 22:01:43  carstenklapp
1379 // Code cleanup:
1380 // Reformatting & tabs to spaces;
1381 // Added copyleft, getVersion, getDescription, rcs_id.
1382 //
1383
1384 // (c-file-style: "gnu")
1385 // Local Variables:
1386 // mode: php
1387 // tab-width: 8
1388 // c-basic-offset: 4
1389 // c-hanging-comment-ender-p: nil
1390 // indent-tabs-mode: nil
1391 // End:
1392 ?>