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