]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RecentChanges.php
global WikiTheme
[SourceForge/phpwiki.git] / lib / plugin / RecentChanges.php
1 <?php // -*-php-*-
2 rcs_id('$Id: RecentChanges.php,v 1.118 2007-06-02 18:24:59 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         global $WikiTheme;
413         $args = &$this->_args;
414
415         $class = 'rc-' . $this->importance($rev);
416
417         $time = $this->time($rev);
418         if (! $rev->get('is_minor_edit'))
419             $time = HTML::span(array('class' => 'pageinfo-majoredit'), $time);
420
421         $line = HTML::li(array('class' => $class));
422
423         if ($args['difflinks'])
424             $line->pushContent($this->diffLink($rev), ' ');
425
426         if ($args['historylinks'])
427             $line->pushContent($this->historyLink($rev), ' ');
428
429         if (isa($WikiTheme, 'Theme_MonoBook')) {
430             $line->pushContent(
431                                $args['historylinks'] ? '' : $this->historyLink($rev),
432                                ' . . ', $this->pageLink($rev), '; ',
433                                $time, ' . . ',
434                                $this->authorLink($rev),' ',
435                                $this->authorContribs($rev),' ',
436                                $this->summaryAsHTML($rev));
437         } else {
438             $line->pushContent($this->pageLink($rev), ' ',
439                                $time, ' ',
440                                $this->summaryAsHTML($rev),
441                                ' ... ',
442                                $this->authorLink($rev));
443         }
444         return $line;
445     }
446
447 }
448
449 /* format=contribs: no seperation into extra dates
450  * 14:41, 3 December 2006 (hist) (diff) Talk:PhpWiki (added diff link)  (top)
451  */
452 class _RecentChanges_UserContribsFormatter
453 extends _RecentChanges_HtmlFormatter
454 {
455     function title () {
456         extract($this->_args);
457         return array(_("UserContribs"),":",$author ? $author : $owner,
458                      ' ',
459                      $this->rss_icon(), 
460                      HTML::raw('&nbsp;'), $this->rss2_icon(),
461                      //HTML::raw('&nbsp;'), $this->grazr_icon(),
462                      HTML::raw('&nbsp;'), $this->atom_icon());
463     }
464
465     function format ($changes) {
466         include_once('lib/InlineParser.php');
467         
468         $html = HTML(HTML::h2(false, $this->title()));
469         $lines = HTML::ol();
470         $first = true; $count = 0;
471         while ($rev = $changes->next()) {
472             if (mayAccessPage('view', $rev->_pagename)) {
473                 $lines->pushContent($this->format_revision($rev));
474                 if ($first)
475                     $this->setValidators($rev);
476                 $first = false;
477             }
478             $count++;
479         }
480         $this->_args['limit'] = $count;
481         if (($desc = $this->description()))
482             $html->pushContent($desc);
483         if ($this->_args['daylist'])
484             $html->pushContent(new DayButtonBar($this->_args));
485         if ($first)
486             $html->pushContent(HTML::p(array('class' => 'rc-empty'),
487                                        $this->empty_message()));
488         else                               
489             $html->pushContent($lines);
490         
491         return $html;
492     }
493
494     function format_revision ($rev) {
495         $args = &$this->_args;
496         $class = 'rc-' . $this->importance($rev);
497         $time = $this->time($rev);
498         if (! $rev->get('is_minor_edit'))
499             $time = HTML::span(array('class' => 'pageinfo-majoredit'), $time);
500
501         $line = HTML::li(array('class' => $class));
502
503         $line->pushContent($this->time($rev),", ");
504         $line->pushContent($this->date($rev)," ");
505         $line->pushContent($this->diffLink($rev), ' ');
506         $line->pushContent($this->historyLink($rev), ' ');
507         $line->pushContent($this->pageLink($rev), ' ',
508                            $this->summaryAsHTML($rev));
509         return $line;
510     }
511 }
512
513 class _RecentChanges_SideBarFormatter
514 extends _RecentChanges_HtmlFormatter
515 {
516     function rss_icon () {
517         //omit rssicon
518     }
519     function rss2_icon () { }
520     function title () {
521         //title click opens the normal RC or RE page in the main browser frame
522         extract($this->_args);
523         $titlelink = WikiLink($show_minor ? _("RecentEdits") : _("RecentChanges"));
524         $titlelink->setAttr('target', '_content');
525         return HTML($this->logo(), $titlelink);
526     }
527     function logo () {
528         //logo click opens the HomePage in the main browser frame
529         global $WikiTheme;
530         $img = HTML::img(array('src' => $WikiTheme->getImageURL('logo'),
531                                'border' => 0,
532                                'align' => 'right',
533                                'style' => 'height:2.5ex'
534                                ));
535         $linkurl = WikiLink(HOME_PAGE, false, $img);
536         $linkurl->setAttr('target', '_content');
537         return $linkurl;
538     }
539
540     function authorLink ($rev) {
541         $author = $rev->get('author');
542         if ( $this->authorHasPage($author) ) {
543             $linkurl = WikiLink($author);
544             $linkurl->setAttr('target', '_content'); // way to do this using parent::authorLink ??
545             return $linkurl;
546         } else
547             return $author;
548     }
549
550     function diffLink ($rev) {
551         $linkurl = parent::diffLink($rev);
552         $linkurl->setAttr('target', '_content');
553         $linkurl->setAttr('rel', 'nofollow');
554         // FIXME: Smelly hack to get smaller diff buttons in sidebar
555         $linkurl = new RawXML(str_replace('<img ', '<img style="height:2ex" ', asXML($linkurl)));
556         return $linkurl;
557     }
558     function historyLink ($rev) {
559         $linkurl = parent::historyLink($rev);
560         $linkurl->setAttr('target', '_content');
561         // FIXME: Smelly hack to get smaller history buttons in sidebar
562         $linkurl = new RawXML(str_replace('<img ', '<img style="height:2ex" ', asXML($linkurl)));
563         return $linkurl;
564     }
565     function pageLink ($rev) {
566         $linkurl = parent::pageLink($rev);
567         $linkurl->setAttr('target', '_content');
568         return $linkurl;
569     }
570     // Overriding summaryAsHTML, because there is no way yet to
571     // return summary as transformed text with
572     // links setAttr('target', '_content') in Mozilla sidebar.
573     // So for now don't create clickable links inside summary
574     // in the sidebar, or else they target the sidebar and not the
575     // main content window.
576     function summaryAsHTML ($rev) {
577         if ( !($summary = $this->summary($rev)) )
578             return '';
579         return HTML::span(array('class' => 'wiki-summary'),
580                           "[",
581                           /*TransformLinks(*/$summary,/* $rev->get('markup')),*/
582                           "]");
583     }
584
585
586     function format ($changes) {
587         $this->_args['daylist'] = false; //don't show day buttons in Mozilla sidebar
588         $html = _RecentChanges_HtmlFormatter::format ($changes);
589         $html = HTML::div(array('class' => 'wikitext'), $html);
590         global $request;
591         $request->discardOutput();
592         
593         printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", $GLOBALS['charset']);
594         printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"');
595         printf('  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
596         printf('<html xmlns="http://www.w3.org/1999/xhtml">');
597
598         printf("<head>\n");
599         extract($this->_args);
600         $title = WIKI_NAME . $show_minor ? _("RecentEdits") : _("RecentChanges");
601         printf("<title>" . $title . "</title>\n");
602         global $WikiTheme;
603         $css = $WikiTheme->getCSS();
604         $css->PrintXML();
605         printf("</head>\n");
606
607         printf("<body class=\"sidebar\">\n");
608         $html->PrintXML();
609         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>';
610         printf("\n</body>\n");
611         printf("</html>\n");
612
613         $request->finish(); // cut rest of page processing short
614     }
615 }
616
617 class _RecentChanges_BoxFormatter
618 extends _RecentChanges_HtmlFormatter
619 {
620     function rss_icon () {
621     }
622     function rss2_icon () {
623     }
624     function title () {
625     }
626     function authorLink ($rev) {
627     }
628     function diffLink ($rev) {
629     }
630     function historyLink ($rev) {
631     }
632     function summaryAsHTML ($rev) {
633     }
634     function description () {
635     }
636     function format ($changes) {
637         include_once('lib/InlineParser.php');
638         $last_date = '';
639         $first = true;
640         $html = HTML();
641         $counter = 1;
642         $sp = HTML::Raw("\n&nbsp;&middot;&nbsp;");
643         while ($rev = $changes->next()) {
644             // enforce view permission
645             if (mayAccessPage('view',$rev->_pagename)) {
646                 if ($link = $this->pageLink($rev)) // some entries may be empty 
647                                                    // (/Blog/.. interim pages)
648                     $html->pushContent($sp, $link, HTML::br());
649                 if ($first)
650                     $this->setValidators($rev);
651                 $first = false;
652             }
653         }
654         if ($first)
655             $html->pushContent(HTML::p(array('class' => 'rc-empty'),
656                                        $this->empty_message()));
657         return $html;
658     }
659 }
660
661 class _RecentChanges_RssFormatter
662 extends _RecentChanges_Formatter
663 {
664     var $_absurls = true;
665
666     function time ($rev) {
667         return Iso8601DateTime($rev->get('mtime'));
668     }
669
670     function pageURI ($rev) {
671         return WikiURL($rev, '', 'absurl');
672     }
673
674     function format ($changes) {
675         
676         include_once('lib/RssWriter.php');
677         $rss = new RssWriter;
678
679         $rss->channel($this->channel_properties());
680
681         if (($props = $this->image_properties()))
682             $rss->image($props);
683         if (($props = $this->textinput_properties()))
684             $rss->textinput($props);
685
686         $first = true;
687         while ($rev = $changes->next()) {
688             // enforce view permission
689             if (mayAccessPage('view', $rev->_pagename)) {
690                 $rss->addItem($this->item_properties($rev),
691                               $this->pageURI($rev));
692                 if ($first)
693                     $this->setValidators($rev);
694                 $first = false;
695             }
696         }
697
698         global $request;
699         $request->discardOutput();
700         $rss->finish();
701         printf("\n<!-- Generated by PhpWiki-%s:\n%s-->\n", PHPWIKI_VERSION, $GLOBALS['RCS_IDS']);
702
703         // Flush errors in comment, otherwise it's invalid XML.
704         global $ErrorManager;
705         if (($errors = $ErrorManager->getPostponedErrorsAsHTML()))
706             printf("\n<!-- PHP Warnings:\n%s-->\n", AsXML($errors));
707
708         $request->finish();     // NORETURN!!!!
709     }
710
711     function image_properties () {
712         global $WikiTheme;
713
714         $img_url = AbsoluteURL($WikiTheme->getImageURL('logo'));
715         if (!$img_url)
716             return false;
717
718         return array('title' => WIKI_NAME,
719                      'link' => WikiURL(HOME_PAGE, false, 'absurl'),
720                      'url' => $img_url);
721     }
722
723     function textinput_properties () {
724         return array('title' => _("Search"),
725                      'description' => _("Title Search"),
726                      'name' => 's',
727                      'link' => WikiURL(_("TitleSearch"), false, 'absurl'));
728     }
729
730     function channel_properties () {
731         global $request;
732
733         $rc_url = WikiURL($request->getArg('pagename'), false, 'absurl');
734         return array('title' => WIKI_NAME,
735                      'link' => $rc_url,
736                      'description' => _("RecentChanges"),
737                      'dc:date' => Iso8601DateTime(time()),
738                      'dc:language' => $GLOBALS['LANG']);
739
740         /* FIXME: other things one might like in <channel>:
741          * sy:updateFrequency
742          * sy:updatePeriod
743          * sy:updateBase
744          * dc:subject
745          * dc:publisher
746          * dc:language
747          * dc:rights
748          * rss091:language
749          * rss091:managingEditor
750          * rss091:webmaster
751          * rss091:lastBuildDate
752          * rss091:copyright
753          */
754     }
755
756     function item_properties ($rev) {
757         $page = $rev->getPage();
758         $pagename = $page->getName();
759
760         return array( 'title'           => SplitPagename($pagename),
761                       'description'     => $this->summary($rev),
762                       'link'            => $this->pageURL($rev),
763                       'dc:date'         => $this->time($rev),
764                       'dc:contributor'  => $rev->get('author'),
765                       'wiki:version'    => $rev->getVersion(),
766                       'wiki:importance' => $this->importance($rev),
767                       'wiki:status'     => $this->status($rev),
768                       'wiki:diff'       => $this->diffURL($rev),
769                       'wiki:history'    => $this->historyURL($rev)
770                       );
771     }
772 }
773
774 /** explicit application/rss+xml Content-Type,
775  * simplified xml structure (no namespace),
776  * support for xml-rpc cloud registerProcedure (not yet)
777  */
778 class _RecentChanges_Rss2Formatter
779 extends _RecentChanges_RssFormatter {
780
781     function format ($changes) {
782         include_once('lib/RssWriter2.php');
783         $rss = new RssWriter2;
784
785         $rss->channel($this->channel_properties());
786         if (($props = $this->cloud_properties()))
787             $rss->cloud($props);
788         if (($props = $this->image_properties()))
789             $rss->image($props);
790         if (($props = $this->textinput_properties()))
791             $rss->textinput($props);
792         $first = true;
793         while ($rev = $changes->next()) {
794             // enforce view permission
795             if (mayAccessPage('view', $rev->_pagename)) {
796                 $rss->addItem($this->item_properties($rev),
797                               $this->pageURI($rev));
798                 if ($first)
799                     $this->setValidators($rev);
800                 $first = false;
801             }
802         }
803
804         global $request;
805         $request->discardOutput();
806         $rss->finish();
807         printf("\n<!-- Generated by PhpWiki-%s:\n%s-->\n", PHPWIKI_VERSION, $GLOBALS['RCS_IDS']);
808         // Flush errors in comment, otherwise it's invalid XML.
809         global $ErrorManager;
810         if (($errors = $ErrorManager->getPostponedErrorsAsHTML()))
811             printf("\n<!-- PHP Warnings:\n%s-->\n", AsXML($errors));
812
813         $request->finish();     // NORETURN!!!!
814     }
815
816     function channel_properties () {
817         $chann_10 = parent::channel_properties();
818         return array_merge($chann_10,
819                            array('generator' => 'PhpWiki-'.PHPWIKI_VERSION,
820                                  //<pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
821                                  //<lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
822                                  //<docs>http://blogs.law.harvard.edu/tech/rss</docs>
823                                  'copyright' => COPYRIGHTPAGE_URL
824                                  ));
825     }
826
827     // xml-rpc registerProcedure not yet implemented
828     function cloud_properties () { return false; } 
829     function cloud_properties_test () {
830         return array('protocol' => 'xml-rpc', // xml-rpc or soap or http-post
831                      'registerProcedure' => 'wiki.rssPleaseNotify',
832                      'path' => DATA_PATH.'/RPC2.php',
833                      'port' => !SERVER_PORT ? '80' : (SERVER_PROTOCOL == 'https' ? '443' : '80'),
834                      'domain' => SERVER_NAME);
835     }
836 }
837
838 /**
839  * Filter by non-empty
840  */
841 class NonDeletedRevisionIterator extends WikiDB_PageRevisionIterator
842 {
843     /** Constructor
844      *
845      * @param $revisions object a WikiDB_PageRevisionIterator.
846      */
847     function NonDeletedRevisionIterator ($revisions, $check_current_revision = true) {
848         $this->_revisions = $revisions;
849         $this->_check_current_revision = $check_current_revision;
850     }
851
852     function next () {
853         while (($rev = $this->_revisions->next())) {
854             if ($this->_check_current_revision) {
855                 $page = $rev->getPage();
856                 $check_rev = $page->getCurrentRevision();
857             }
858             else {
859                 $check_rev = $rev;
860             }
861             if (! $check_rev->hasDefaultContents())
862                 return $rev;
863         }
864         $this->free();
865         return false;
866     }
867
868 }
869
870 /**
871  * Filter by only_new.
872  * Only new created pages
873  */
874 class NewPageRevisionIterator extends WikiDB_PageRevisionIterator
875 {
876     /** Constructor
877      *
878      * @param $revisions object a WikiDB_PageRevisionIterator.
879      */
880     function NewPageRevisionIterator ($revisions) {
881         $this->_revisions = $revisions;
882     }
883
884     function next () {
885         while (($rev = $this->_revisions->next())) {
886             if ($rev->getVersion() == 1)
887                 return $rev;
888         }
889         $this->free();
890         return false;
891     }
892 }
893
894 /**
895  * Filter by author
896  */
897 class AuthorPageRevisionIterator extends WikiDB_PageRevisionIterator
898 {
899     function AuthorPageRevisionIterator ($revisions, $author) {
900         $this->_revisions = $revisions;
901         $this->_author = $author;
902     }
903
904     function next () {
905         while (($rev = $this->_revisions->next())) {
906             if ($rev->get('author_id') == $this->_author)
907                 return $rev;
908         }
909         $this->free();
910         return false;
911     }
912 }
913
914 /**
915  * Filter by owner
916  */
917 class OwnerPageRevisionIterator extends WikiDB_PageRevisionIterator
918 {
919     function OwnerPageRevisionIterator ($revisions, $owner) {
920         $this->_revisions = $revisions;
921         $this->_owner = $owner;
922     }
923
924     function next () {
925         while (($rev = $this->_revisions->next())) {
926             $page = $rev->getPage();
927             if ($page->getOwner() == $this->_owner)
928                 return $rev;
929         }
930         $this->free();
931         return false;
932     }
933 }
934
935 class WikiPlugin_RecentChanges
936 extends WikiPlugin
937 {
938     function getName () {
939         return _("RecentChanges");
940     }
941
942     function getVersion() {
943         return preg_replace("/[Revision: $]/", '',
944                             "\$Revision: 1.118 $");
945     }
946
947     function managesValidators() {
948         // Note that this is a bit of a fig.
949         // We set validators based on the most recently changed page,
950         // but this fails when the most-recent page is deleted.
951         // (Consider that the Last-Modified time will decrease
952         // when this happens.)
953
954         // We might be better off, leaving this as false (and junking
955         // the validator logic above) and just falling back to the
956         // default behavior (handled by WikiPlugin) of just using
957         // the WikiDB global timestamp as the mtime.
958
959         // Nevertheless, for now, I leave this here, mostly as an
960         // example for how to use appendValidators() and managesValidators().
961         
962         return true;
963     }
964             
965     function getDefaultArguments() {
966         return array('days'         => 2,
967                      'show_minor'   => false,
968                      'show_major'   => true,
969                      'show_all'     => false,
970                      'show_deleted' => 'sometimes',
971                      'only_new'     => false,
972                      'author'       => false,
973                      'owner'        => false,
974                      'limit'        => false,
975                      'format'       => false,
976                      'daylist'      => false,
977                      'difflinks'    => true,
978                      'historylinks' => false,
979                      'caption'      => ''
980                      );
981     }
982
983     function getArgs ($argstr, $request, $defaults = false) {
984         if (!$defaults) $defaults = $this->getDefaultArguments();
985         $args = WikiPlugin::getArgs($argstr, $request, $defaults);
986
987         $action = $request->getArg('action');
988         if ($action != 'browse' && ! $request->isActionPage($action))
989             $args['format'] = false; // default -> HTML
990
991         if ($args['format'] == 'rss' && empty($args['limit']))
992             $args['limit'] = 15; // Fix default value for RSS.
993         if ($args['format'] == 'rss2' && empty($args['limit']))
994             $args['limit'] = 15; // Fix default value for RSS2.
995
996         if ($args['format'] == 'sidebar' && empty($args['limit']))
997             $args['limit'] = 10; // Fix default value for sidebar.
998
999         return $args;
1000     }
1001
1002     function getMostRecentParams (&$args) {
1003         $show_all = false; $show_minor = false; $show_major = false;
1004         $limit = false;
1005         extract($args);
1006
1007         $params = array('include_minor_revisions' => $show_minor,
1008                         'exclude_major_revisions' => !$show_major,
1009                         'include_all_revisions' => !empty($show_all));
1010         if ($limit != 0)
1011             $params['limit'] = $limit;
1012         if (!empty($args['author'])) {
1013             global $request;
1014             if ($args['author'] == '[]')
1015                 $args['author'] = $request->_user->getID();
1016             $params['author'] = $args['author'];
1017         }
1018         if (!empty($args['owner'])) {
1019             global $request;
1020             if ($args['owner'] == '[]')
1021                 $args['owner'] = $request->_user->getID();
1022             $params['owner'] = $args['owner'];
1023         }
1024         if (!empty($days)) {
1025           if ($days > 0.0)
1026             $params['since'] = time() - 24 * 3600 * $days;
1027           elseif ($days < 0.0)
1028             $params['since'] = 24 * 3600 * $days - time();
1029         }
1030
1031         return $params;
1032     }
1033
1034     function getChanges ($dbi, $args) {
1035         $changes = $dbi->mostRecent($this->getMostRecentParams($args));
1036
1037         $show_deleted = @$args['show_deleted'];
1038         $show_all = @$args['show_all'];
1039         if ($show_deleted == 'sometimes')
1040             $show_deleted = @$args['show_minor'];
1041
1042         if (!empty($args['only_new']))
1043             $changes = new NewPageRevisionIterator($changes);
1044         if (!empty($args['author']))
1045             $changes = new AuthorPageRevisionIterator($changes, $args['author']);
1046         if (!empty($args['owner']))
1047             $changes = new OwnerPageRevisionIterator($changes, $args['owner']);
1048         if (!$show_deleted)
1049             $changes = new NonDeletedRevisionIterator($changes, !$show_all);
1050
1051         return $changes;
1052     }
1053
1054     function format ($changes, $args) {
1055         global $WikiTheme;
1056         $format = $args['format'];
1057
1058         $fmt_class = $WikiTheme->getFormatter('RecentChanges', $format);
1059         if (!$fmt_class) {
1060             if ($format == 'rss')
1061                 $fmt_class = '_RecentChanges_RssFormatter';
1062             elseif ($format == 'rss2')
1063                 $fmt_class = '_RecentChanges_Rss2Formatter';
1064             elseif ($format == 'rss091') {
1065                 include_once "lib/RSSWriter091.php";
1066                 $fmt_class = '_RecentChanges_RssFormatter091';
1067             }
1068             elseif ($format == 'sidebar')
1069                 $fmt_class = '_RecentChanges_SideBarFormatter';
1070             elseif ($format == 'box')
1071                 $fmt_class = '_RecentChanges_BoxFormatter';
1072             elseif ($format == 'contribs')
1073                 $fmt_class = '_RecentChanges_UserContribsFormatter';
1074             else
1075                 $fmt_class = '_RecentChanges_HtmlFormatter';
1076         }
1077
1078         $fmt = new $fmt_class($args);
1079         return $fmt->format($changes);
1080     }
1081
1082     function run($dbi, $argstr, &$request, $basepage) {
1083         $args = $this->getArgs($argstr, $request);
1084
1085         // HACKish: fix for SF bug #622784  (1000 years of RecentChanges ought
1086         // to be enough for anyone.)
1087         $args['days'] = min($args['days'], 365000);
1088         
1089         // Hack alert: format() is a NORETURN for rss formatters.
1090         return $this->format($this->getChanges($dbi, $args), $args);
1091     }
1092
1093     // box is used to display a fixed-width, narrow version with common header.
1094     // just a numbered list of limit pagenames, without date.
1095     function box($args = false, $request = false, $basepage = false) {
1096         if (!$request) $request =& $GLOBALS['request'];
1097         if (!isset($args['limit'])) $args['limit'] = 15;
1098         $args['format'] = 'box';
1099         $args['show_minor'] = false;
1100         $args['show_major'] = true;
1101         $args['show_deleted'] = 'sometimes';
1102         $args['show_all'] = false;
1103         $args['days'] = 90;
1104         return $this->makeBox(WikiLink($this->getName(),'',
1105                                        SplitPagename($this->getName())),
1106                               $this->format
1107                               ($this->getChanges($request->_dbi, $args), $args));
1108     }
1109
1110 };
1111
1112
1113 class DayButtonBar extends HtmlElement {
1114
1115     function DayButtonBar ($plugin_args) {
1116         $this->__construct('p', array('class' => 'wiki-rc-action'));
1117
1118         // Display days selection buttons
1119         extract($plugin_args);
1120
1121         // Custom caption
1122         if (! $caption) {
1123             if ($show_minor)
1124                 $caption = _("Show minor edits for:");
1125             elseif ($show_all)
1126                 $caption = _("Show all changes for:");
1127             else
1128                 $caption = _("Show changes for:");
1129             if ($only_new)
1130                 $caption = _("All new pages since:");
1131         }
1132
1133         $this->pushContent($caption, ' ');
1134
1135         global $WikiTheme;
1136         $sep = $WikiTheme->getButtonSeparator();
1137
1138         $n = 0;
1139         foreach (explode(",", $daylist) as $days) {
1140             if ($n++)
1141                 $this->pushContent($sep);
1142             $this->pushContent($this->_makeDayButton($days));
1143         }
1144     }
1145
1146     function _makeDayButton ($days) {
1147         global $WikiTheme, $request;
1148
1149         if ($days == 1)
1150             $label = _("1 day");
1151         elseif ($days < 1)
1152             $label = "..."; //alldays
1153         else
1154             $label = sprintf(_("%s days"), abs($days));
1155
1156         $url = $request->getURLtoSelf(array('action' => $request->getArg('action'), 'days' => $days));
1157
1158         return $WikiTheme->makeButton($label, $url, 'wiki-rc-action');
1159     }
1160 }
1161
1162 // $Log: not supported by cvs2svn $
1163 // Revision 1.117  2007/05/30 20:43:31  rurban
1164 // added MonoBook UserContribs
1165 //
1166 // Revision 1.116  2007/05/13 18:13:41  rurban
1167 // use all filters, not just the first, ignoring the others. improve wording a bit
1168 //
1169 // Revision 1.115  2007/04/08 16:24:10  rurban
1170 // Remove redundant code in ->authorLink(): 'if_known' does the same
1171 //
1172 // Revision 1.114  2007/02/17 22:39:44  rurban
1173 // format=rss overhaul
1174 //
1175 // Revision 1.113  2007/02/17 14:15:52  rurban
1176 // new argument owner=[] for RecentChangesMyPages
1177 //
1178 // Revision 1.112  2007/01/28 20:32:07  rurban
1179 // silence empty warning
1180 //
1181 // Revision 1.111  2007/01/25 21:48:52  rurban
1182 // new argument author=[]
1183 //
1184 // Revision 1.110  2007/01/22 23:51:36  rurban
1185 // new arg: only_new
1186 //
1187 // Revision 1.109  2006/03/19 14:26:29  rurban
1188 // sf.net patch by Matt Brown: Add rel=nofollow to more actions
1189 //
1190 // Revision 1.108  2005/04/01 16:09:35  rurban
1191 // fix defaults in RecentChanges plugins: e.g. invalid pagenames for PageHistory
1192 //
1193 // Revision 1.107  2005/02/04 13:45:28  rurban
1194 // improve box layout a bit
1195 //
1196 // Revision 1.106  2005/02/02 19:39:10  rurban
1197 // honor show_all=false
1198 //
1199 // Revision 1.105  2005/01/25 03:50:54  uckelman
1200 // pre_description is a member function, so call with $this->.
1201 //
1202 // Revision 1.104  2005/01/24 23:15:16  uckelman
1203 // The extra description for RelatedChanges was appearing in RecentChanges
1204 // and PageHistory due to a bad test in _RecentChanges_HtmlFormatter. Fixed.
1205 //
1206 // Revision 1.103  2004/12/15 17:45:09  rurban
1207 // fix box method
1208 //
1209 // Revision 1.102  2004/12/06 19:29:24  rurban
1210 // simplify RSS: add RSS2 link (rss tag only, new content-type)
1211 //
1212 // Revision 1.101  2004/11/10 19:32:24  rurban
1213 // * optimize increaseHitCount, esp. for mysql.
1214 // * prepend dirs to the include_path (phpwiki_dir for faster searches)
1215 // * Pear_DB version logic (awful but needed)
1216 // * fix broken ADODB quote
1217 // * _extract_page_data simplification
1218 //
1219 // Revision 1.100  2004/06/28 16:35:12  rurban
1220 // prevent from shell commands
1221 //
1222 // Revision 1.99  2004/06/20 14:42:54  rurban
1223 // various php5 fixes (still broken at blockparser)
1224 //
1225 // Revision 1.98  2004/06/14 11:31:39  rurban
1226 // renamed global $Theme to $WikiTheme (gforge nameclash)
1227 // inherit PageList default options from PageList
1228 //   default sortby=pagename
1229 // use options in PageList_Selectable (limit, sortby, ...)
1230 // added action revert, with button at action=diff
1231 // added option regex to WikiAdminSearchReplace
1232 //
1233 // Revision 1.97  2004/06/03 18:58:27  rurban
1234 // days links requires action=RelatedChanges arg
1235 //
1236 // Revision 1.96  2004/05/18 16:23:40  rurban
1237 // rename split_pagename to SplitPagename
1238 //
1239 // Revision 1.95  2004/05/16 22:07:35  rurban
1240 // check more config-default and predefined constants
1241 // various PagePerm fixes:
1242 //   fix default PagePerms, esp. edit and view for Bogo and Password users
1243 //   implemented Creator and Owner
1244 //   BOGOUSERS renamed to BOGOUSER
1245 // fixed syntax errors in signin.tmpl
1246 //
1247 // Revision 1.94  2004/05/14 20:55:03  rurban
1248 // simplified RecentComments
1249 //
1250 // Revision 1.93  2004/05/14 17:33:07  rurban
1251 // new plugin RecentChanges
1252 //
1253 // Revision 1.92  2004/04/21 04:29:10  rurban
1254 // Two convenient RecentChanges extensions
1255 //   RelatedChanges (only links from current page)
1256 //   RecentEdits (just change the default args)
1257 //
1258 // Revision 1.91  2004/04/19 18:27:46  rurban
1259 // Prevent from some PHP5 warnings (ref args, no :: object init)
1260 //   php5 runs now through, just one wrong XmlElement object init missing
1261 // Removed unneccesary UpgradeUser lines
1262 // Changed WikiLink to omit version if current (RecentChanges)
1263 //
1264 // Revision 1.90  2004/04/18 01:11:52  rurban
1265 // more numeric pagename fixes.
1266 // fixed action=upload with merge conflict warnings.
1267 // charset changed from constant to global (dynamic utf-8 switching)
1268 //
1269 // Revision 1.89  2004/04/10 02:30:49  rurban
1270 // Fixed gettext problem with VIRTUAL_PATH scripts (Windows only probably)
1271 // Fixed "cannot setlocale..." (sf.net problem)
1272 //
1273 // Revision 1.88  2004/04/01 15:57:10  rurban
1274 // simplified Sidebar theme: table, not absolute css positioning
1275 // added the new box methods.
1276 // remaining problems: large left margin, how to override _autosplitWikiWords in Template only
1277 //
1278 // Revision 1.87  2004/03/30 02:14:03  rurban
1279 // fixed yet another Prefs bug
1280 // added generic PearDb_iter
1281 // $request->appendValidators no so strict as before
1282 // added some box plugin methods
1283 // PageList commalist for condensed output
1284 //
1285 // Revision 1.86  2004/03/12 13:31:43  rurban
1286 // enforce PagePermissions, errormsg if not Admin
1287 //
1288 // Revision 1.85  2004/02/17 12:11:36  rurban
1289 // 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, ...)
1290 //
1291 // Revision 1.84  2004/02/15 22:29:42  rurban
1292 // revert premature performance fix
1293 //
1294 // Revision 1.83  2004/02/15 21:34:37  rurban
1295 // PageList enhanced and improved.
1296 // fixed new WikiAdmin... plugins
1297 // editpage, Theme with exp. htmlarea framework
1298 //   (htmlarea yet committed, this is really questionable)
1299 // WikiUser... code with better session handling for prefs
1300 // enhanced UserPreferences (again)
1301 // RecentChanges for show_deleted: how should pages be deleted then?
1302 //
1303 // Revision 1.82  2004/01/25 03:58:43  rurban
1304 // use stdlib:isWikiWord()
1305 //
1306 // Revision 1.81  2003/11/28 21:06:31  carstenklapp
1307 // Enhancement: Mozilla RecentChanges sidebar now defaults to 10 changes
1308 // instead of 1. Make diff buttons smaller with css. Added description
1309 // line back in at the top.
1310 //
1311 // Revision 1.80  2003/11/27 15:17:01  carstenklapp
1312 // Theme & appearance tweaks: Converted Mozilla sidebar link into a Theme
1313 // button, to allow an image button for it to be added to Themes. Output
1314 // RSS button in small text size when theme has no button image.
1315 //
1316 // Revision 1.79  2003/04/29 14:34:20  dairiki
1317 // Bug fix: "add sidebar" link didn't work when USE_PATH_INFO was false.
1318 //
1319 // Revision 1.78  2003/03/04 01:55:05  dairiki
1320 // Fix to ensure absolute URL for logo in RSS recent changes.
1321 //
1322 // Revision 1.77  2003/02/27 23:23:38  dairiki
1323 // Fix my breakage of CSS and sidebar RecentChanges output.
1324 //
1325 // Revision 1.76  2003/02/27 22:48:44  dairiki
1326 // Fixes invalid HTML generated by PageHistory plugin.
1327 //
1328 // (<noscript> is block-level and not allowed within <p>.)
1329 //
1330 // Revision 1.75  2003/02/22 21:39:05  dairiki
1331 // Hackish fix for SF bug #622784.
1332 //
1333 // (The root of the problem is clearly a PHP bug.)
1334 //
1335 // Revision 1.74  2003/02/21 22:52:21  dairiki
1336 // Make sure to interpret relative links (like [/Subpage]) in summary
1337 // relative to correct basepage.
1338 //
1339 // Revision 1.73  2003/02/21 04:12:06  dairiki
1340 // Minor fixes for new cached markup.
1341 //
1342 // Revision 1.72  2003/02/17 02:19:01  dairiki
1343 // Fix so that PageHistory will work when the current revision
1344 // of a page has been "deleted".
1345 //
1346 // Revision 1.71  2003/02/16 20:04:48  dairiki
1347 // Refactor the HTTP validator generation/checking code.
1348 //
1349 // This also fixes a number of bugs with yesterdays validator mods.
1350 //
1351 // Revision 1.70  2003/02/16 05:09:43  dairiki
1352 // Starting to fix handling of the HTTP validator headers, Last-Modified,
1353 // and ETag.
1354 //
1355 // Last-Modified was being set incorrectly (but only when DEBUG was not
1356 // defined!)  Setting a Last-Modified without setting an appropriate
1357 // Expires: and/or Cache-Control: header results in browsers caching
1358 // the page unconditionally (for a certain period of time).
1359 // This is generally bad, since it means people don't see updated
1360 // page contents right away --- this is particularly confusing to
1361 // the people who are editing pages since their edits don't show up
1362 // next time they browse the page.
1363 //
1364 // Now, we don't allow caching of pages without revalidation
1365 // (via the If-Modified-Since and/or If-None-Match request headers.)
1366 // (You can allow caching by defining CACHE_CONTROL_MAX_AGE to an
1367 // appropriate value in index.php, but I advise against it.)
1368 //
1369 // Problems:
1370 //
1371 //   o Even when request is aborted due to the content not being
1372 //     modified, we currently still do almost all the work involved
1373 //     in producing the page.  So the only real savings from all
1374 //     this logic is in network bandwidth.
1375 //
1376 //   o Plugins which produce "dynamic" output need to be inspected
1377 //     and made to call $request->addToETag() and
1378 //     $request->setModificationTime() appropriately, otherwise the
1379 //     page can change without the change being detected.
1380 //     This leads to stale pages in cache again...
1381 //
1382 // Revision 1.69  2003/01/18 22:01:43  carstenklapp
1383 // Code cleanup:
1384 // Reformatting & tabs to spaces;
1385 // Added copyleft, getVersion, getDescription, rcs_id.
1386 //
1387
1388 // (c-file-style: "gnu")
1389 // Local Variables:
1390 // mode: php
1391 // tab-width: 8
1392 // c-basic-offset: 4
1393 // c-hanging-comment-ender-p: nil
1394 // indent-tabs-mode: nil
1395 // End:
1396 ?>