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