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