2 rcs_id('$Id: RecentChanges.php,v 1.112 2007-01-28 20:32:07 rurban Exp $');
4 Copyright 1999,2000,2001,2002,2007 $ThePhpWikiProgrammingTeam
6 This file is part of PhpWiki.
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.
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.
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
25 class _RecentChanges_Formatter
27 var $_absurls = false;
29 function _RecentChanges_Formatter ($rc_args) {
30 $this->_args = $rc_args;
31 $this->_diffargs = array('action' => 'diff');
33 if ($rc_args['show_minor'] || !$rc_args['show_major'])
34 $this->_diffargs['previous'] = 'minor';
36 // PageHistoryPlugin doesn't have a 'daylist' arg.
37 if (!isset($this->_args['daylist']))
38 $this->_args['daylist'] = false;
41 function include_versions_in_URLs() {
42 return (bool) $this->_args['show_all'];
45 function date ($rev) {
47 return $WikiTheme->getDay($rev->get('mtime'));
50 function time ($rev) {
52 return $WikiTheme->formatTime($rev->get('mtime'));
55 function diffURL ($rev) {
56 $args = $this->_diffargs;
57 if ($this->include_versions_in_URLs())
58 $args['version'] = $rev->getVersion();
59 $page = $rev->getPage();
60 return WikiURL($page->getName(), $args, $this->_absurls);
63 function historyURL ($rev) {
64 $page = $rev->getPage();
65 return WikiURL($page, array('action' => _("PageHistory")),
69 function pageURL ($rev) {
70 return WikiURL($this->include_versions_in_URLs() ? $rev : $rev->getPage(),
74 function authorHasPage ($author) {
75 global $WikiNameRegexp, $request;
76 $dbi = $request->getDbh();
77 return isWikiWord($author) && $dbi->isWikiPage($author);
80 function authorURL ($author) {
81 return $this->authorHasPage() ? WikiURL($author) : false;
85 function status ($rev) {
86 if ($rev->hasDefaultContents())
88 $page = $rev->getPage();
89 $prev = $page->getRevisionBefore($rev->getVersion());
90 if ($prev->hasDefaultContents())
95 function importance ($rev) {
96 return $rev->get('is_minor_edit') ? 'minor' : 'major';
99 function summary($rev) {
100 if ( ($summary = $rev->get('summary')) )
103 switch ($this->status($rev)) {
107 return _("New page");
113 function setValidators($most_recent_rev) {
114 $rev = $most_recent_rev;
115 $validators = array('RecentChanges-top' =>
116 array($rev->getPageName(), $rev->getVersion()),
117 '%mtime' => $rev->get('mtime'));
119 $request->appendValidators($validators);
123 class _RecentChanges_HtmlFormatter
124 extends _RecentChanges_Formatter
126 function diffLink ($rev) {
128 $button = $WikiTheme->makeButton(_("(diff)"), $this->diffURL($rev), 'wiki-rc-action');
129 $button->setAttr('rel', 'nofollow');
133 function historyLink ($rev) {
135 return $WikiTheme->makeButton(_("(hist)"), $this->historyURL($rev), 'wiki-rc-action');
138 function pageLink ($rev, $link_text=false) {
140 return WikiLink($this->include_versions_in_URLs() ? $rev : $rev->getPage(),'auto',$link_text);
142 $page = $rev->getPage();
144 if ($this->include_versions_in_URLs()) {
145 $version = $rev->getVersion();
146 if ($rev->isCurrent())
148 $exists = !$rev->hasDefaultContents();
152 $cur = $page->getCurrentRevision();
153 $exists = !$cur->hasDefaultContents();
156 return $WikiTheme->linkExistingWikiWord($page->getName(), $link_text, $version);
158 return $WikiTheme->linkUnknownWikiWord($page->getName(), $link_text);
162 function authorLink ($rev) {
163 $author = $rev->get('author');
164 if ( $this->authorHasPage($author) ) {
165 return WikiLink($author);
170 function summaryAsHTML ($rev) {
171 if ( !($summary = $this->summary($rev)) )
173 return HTML::strong( array('class' => 'wiki-summary'),
175 TransformLinks($summary, $rev->get('markup'), $rev->getPageName()),
179 function rss_icon () {
180 global $request, $WikiTheme;
182 $rss_url = $request->getURLtoSelf(array('format' => 'rss'));
183 return HTML::small(array('style' => 'font-weight:normal;vertical-align:middle;'),
184 $WikiTheme->makeButton("RSS", $rss_url, 'rssicon'));
186 function rss2_icon () {
187 global $request, $WikiTheme;
189 $rss_url = $request->getURLtoSelf(array('format' => 'rss2'));
190 return HTML::small(array('style' => 'font-weight:normal;vertical-align:middle;'),
191 $WikiTheme->makeButton("RSS2", $rss_url, 'rssicon'));
194 function pre_description () {
195 extract($this->_args);
196 // FIXME: say something about show_all.
197 if ($show_major && $show_minor)
200 $edits = _("major edits");
202 $edits = _("minor edits");
203 if (isset($caption) and $caption == _("Recent Comments"))
204 $edits = _("comments");
205 if (!empty($only_new)) {
206 $edits = _("created new pages");
208 if (!empty($author)) {
211 $author = $request->_user->getID();
212 $edits .= sprintf(_(" from author %s"), $author);
214 if ($timespan = $days > 0) {
215 if (intval($days) != $days)
216 $days = sprintf("%.1f", $days);
220 * Depending how this text is split up it can be tricky or
221 * impossible to translate with good grammar. So the seperate
222 * strings for 1 day and %s days are necessary in this case
223 * for translating to multiple languages, due to differing
224 * overlapping ideal word cutting points.
226 * en: day/days "The %d most recent %s [during (the past] day) are listed below."
227 * de: 1 Tag "Die %d jüngste %s [innerhalb (von des letzten] Tages) sind unten aufgelistet."
228 * de: %s days "Die %d jüngste %s [innerhalb (von] %s Tagen) sind unten aufgelistet."
230 * en: day/days "The %d most recent %s during [the past] (day) are listed below."
231 * fr: 1 jour "Les %d %s les plus récentes pendant [le dernier (d'une] jour) sont énumérées ci-dessous."
232 * fr: %s jours "Les %d %s les plus récentes pendant [les derniers (%s] jours) sont énumérées ci-dessous."
236 if (intval($days) == 1)
237 $desc = fmt("The %d most recent %s during the past day are listed below.",
240 $desc = fmt("The %d most recent %s during the past %s days are listed below.",
241 $limit, $edits, $days);
243 $desc = fmt("The %d most recent %s are listed below.",
246 elseif ($limit < 0) { //$limit < 0 means we want oldest pages
248 if (intval($days) == 1)
249 $desc = fmt("The %d oldest %s during the past day are listed below.",
252 $desc = fmt("The %d oldest %s during the past %s days are listed below.",
253 $lmt, $edits, $days);
255 $desc = fmt("The %d oldest %s are listed below.",
261 if (intval($days) == 1)
262 $desc = fmt("The most recent %s during the past day are listed below.",
265 $desc = fmt("The most recent %s during the past %s days are listed below.",
268 $desc = fmt("All %s are listed below.", $edits);
273 function description() {
274 return HTML::p(false, $this->pre_description());
279 extract($this->_args);
280 return array($show_minor ? _("RecentEdits") : _("RecentChanges"),
282 $this->rss_icon(), HTML::raw(' '), $this->rss2_icon(),
283 $this->sidebar_link());
286 function empty_message () {
287 if (isset($this->_args['caption']) and $this->_args['caption'] == _("Recent Comments"))
288 return _("No comments found");
290 return _("No changes found");
293 function sidebar_link() {
294 extract($this->_args);
295 $pagetitle = $show_minor ? _("RecentEdits") : _("RecentChanges");
298 $sidebarurl = WikiURL($pagetitle, array('format' => 'sidebar'), 'absurl');
301 "function addPanel() {\n"
302 ." window.sidebar.addPanel (\"" . sprintf("%s - %s", WIKI_NAME, $pagetitle) . "\",\n"
303 ." \"$sidebarurl\",\"\");\n"
305 $jsf = JavaScript($addsidebarjsfunc);
308 $sidebar_button = $WikiTheme->makeButton("sidebar", 'javascript:addPanel();', 'sidebaricon');
309 $addsidebarjsclick = asXML(HTML::small(array('style' => 'font-weight:normal;vertical-align:middle;'), $sidebar_button));
310 $jsc = JavaScript("if ((typeof window.sidebar == 'object') &&\n"
311 ." (typeof window.sidebar.addPanel == 'function'))\n"
313 ." document.write('$addsidebarjsclick');\n"
316 return HTML(new RawXML("\n"), $jsf, new RawXML("\n"), $jsc);
319 function format ($changes) {
320 include_once('lib/InlineParser.php');
322 $html = HTML(HTML::h2(false, $this->title()));
323 if (($desc = $this->description()))
324 $html->pushContent($desc);
326 if ($this->_args['daylist'])
327 $html->pushContent(new DayButtonBar($this->_args));
333 while ($rev = $changes->next()) {
334 if (($date = $this->date($rev)) != $last_date) {
336 $html->pushContent($lines);
337 $html->pushContent(HTML::h3($date));
342 // enforce view permission
343 if (mayAccessPage('view', $rev->_pagename)) {
344 $lines->pushContent($this->format_revision($rev));
347 $this->setValidators($rev);
352 $html->pushContent($lines);
354 $html->pushContent(HTML::p(array('class' => 'rc-empty'),
355 $this->empty_message()));
360 function format_revision ($rev) {
361 $args = &$this->_args;
363 $class = 'rc-' . $this->importance($rev);
365 $time = $this->time($rev);
366 if (! $rev->get('is_minor_edit'))
367 $time = HTML::strong(array('class' => 'pageinfo-majoredit'), $time);
369 $line = HTML::li(array('class' => $class));
372 if ($args['difflinks'])
373 $line->pushContent($this->diffLink($rev), ' ');
375 if ($args['historylinks'])
376 $line->pushContent($this->historyLink($rev), ' ');
378 $line->pushContent($this->pageLink($rev), ' ',
380 $this->summaryAsHTML($rev),
382 $this->authorLink($rev));
388 class _RecentChanges_SideBarFormatter
389 extends _RecentChanges_HtmlFormatter
391 function rss_icon () {
394 function rss2_icon () { }
396 //title click opens the normal RC or RE page in the main browser frame
397 extract($this->_args);
398 $titlelink = WikiLink($show_minor ? _("RecentEdits") : _("RecentChanges"));
399 $titlelink->setAttr('target', '_content');
400 return HTML($this->logo(), $titlelink);
403 //logo click opens the HomePage in the main browser frame
405 $img = HTML::img(array('src' => $WikiTheme->getImageURL('logo'),
408 'style' => 'height:2.5ex'
410 $linkurl = WikiLink(HOME_PAGE, false, $img);
411 $linkurl->setAttr('target', '_content');
415 function authorLink ($rev) {
416 $author = $rev->get('author');
417 if ( $this->authorHasPage($author) ) {
418 $linkurl = WikiLink($author);
419 $linkurl->setAttr('target', '_content'); // way to do this using parent::authorLink ??
425 function diffLink ($rev) {
426 $linkurl = parent::diffLink($rev);
427 $linkurl->setAttr('target', '_content');
428 $linkurl->setAttr('rel', 'nofollow');
429 // FIXME: Smelly hack to get smaller diff buttons in sidebar
430 $linkurl = new RawXML(str_replace('<img ', '<img style="height:2ex" ', asXML($linkurl)));
433 function historyLink ($rev) {
434 $linkurl = parent::historyLink($rev);
435 $linkurl->setAttr('target', '_content');
436 // FIXME: Smelly hack to get smaller history buttons in sidebar
437 $linkurl = new RawXML(str_replace('<img ', '<img style="height:2ex" ', asXML($linkurl)));
440 function pageLink ($rev) {
441 $linkurl = parent::pageLink($rev);
442 $linkurl->setAttr('target', '_content');
445 // Overriding summaryAsHTML, because there is no way yet to
446 // return summary as transformed text with
447 // links setAttr('target', '_content') in Mozilla sidebar.
448 // So for now don't create clickable links inside summary
449 // in the sidebar, or else they target the sidebar and not the
450 // main content window.
451 function summaryAsHTML ($rev) {
452 if ( !($summary = $this->summary($rev)) )
454 return HTML::strong(array('class' => 'wiki-summary'),
456 /*TransformLinks(*/$summary,/* $rev->get('markup')),*/
461 function format ($changes) {
462 $this->_args['daylist'] = false; //don't show day buttons in Mozilla sidebar
463 $html = _RecentChanges_HtmlFormatter::format ($changes);
464 $html = HTML::div(array('class' => 'wikitext'), $html);
466 $request->discardOutput();
468 printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", $GLOBALS['charset']);
469 printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"');
470 printf(' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
471 printf('<html xmlns="http://www.w3.org/1999/xhtml">');
474 extract($this->_args);
475 $title = WIKI_NAME . $show_minor ? _("RecentEdits") : _("RecentChanges");
476 printf("<title>" . $title . "</title>\n");
478 $css = $WikiTheme->getCSS();
482 printf("<body class=\"sidebar\">\n");
484 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>';
485 printf("\n</body>\n");
488 $request->finish(); // cut rest of page processing short
492 class _RecentChanges_BoxFormatter
493 extends _RecentChanges_HtmlFormatter
495 function rss_icon () {
497 function rss2_icon () {
501 function authorLink ($rev) {
503 function diffLink ($rev) {
505 function historyLink ($rev) {
507 function summaryAsHTML ($rev) {
509 function description () {
511 function format ($changes) {
512 include_once('lib/InlineParser.php');
517 $sp = HTML::Raw("\n · ");
518 while ($rev = $changes->next()) {
519 // enforce view permission
520 if (mayAccessPage('view',$rev->_pagename)) {
521 if ($link = $this->pageLink($rev)) // some entries may be empty
522 // (/Blog/.. interim pages)
523 $html->pushContent($sp, $link, HTML::br());
525 $this->setValidators($rev);
530 $html->pushContent(HTML::p(array('class' => 'rc-empty'),
531 $this->empty_message()));
536 class _RecentChanges_RssFormatter
537 extends _RecentChanges_Formatter
539 var $_absurls = true;
541 function time ($rev) {
542 return Iso8601DateTime($rev->get('mtime'));
545 function pageURI ($rev) {
546 return WikiURL($rev, '', 'absurl');
549 function format ($changes) {
551 include_once('lib/RssWriter.php');
552 $rss = new RssWriter;
554 $rss->channel($this->channel_properties());
556 if (($props = $this->image_properties()))
558 if (($props = $this->textinput_properties()))
559 $rss->textinput($props);
562 while ($rev = $changes->next()) {
563 // enforce view permission
564 if (mayAccessPage('view', $rev->_pagename)) {
565 $rss->addItem($this->item_properties($rev),
566 $this->pageURI($rev));
568 $this->setValidators($rev);
574 $request->discardOutput();
576 printf("\n<!-- Generated by PhpWiki-%s:\n%s-->\n", PHPWIKI_VERSION, $GLOBALS['RCS_IDS']);
578 // Flush errors in comment, otherwise it's invalid XML.
579 global $ErrorManager;
580 if (($errors = $ErrorManager->getPostponedErrorsAsHTML()))
581 printf("\n<!-- PHP Warnings:\n%s-->\n", AsXML($errors));
583 $request->finish(); // NORETURN!!!!
586 function image_properties () {
589 $img_url = AbsoluteURL($WikiTheme->getImageURL('logo'));
593 return array('title' => WIKI_NAME,
594 'link' => WikiURL(HOME_PAGE, false, 'absurl'),
598 function textinput_properties () {
599 return array('title' => _("Search"),
600 'description' => _("Title Search"),
602 'link' => WikiURL(_("TitleSearch"), false, 'absurl'));
605 function channel_properties () {
608 $rc_url = WikiURL($request->getArg('pagename'), false, 'absurl');
609 return array('title' => WIKI_NAME,
611 'description' => _("RecentChanges"),
612 'dc:date' => Iso8601DateTime(time()),
613 'dc:language' => $GLOBALS['LANG']);
615 /* FIXME: other things one might like in <channel>:
624 * rss091:managingEditor
626 * rss091:lastBuildDate
631 function item_properties ($rev) {
632 $page = $rev->getPage();
633 $pagename = $page->getName();
635 return array( 'title' => SplitPagename($pagename),
636 'description' => $this->summary($rev),
637 'link' => $this->pageURL($rev),
638 'dc:date' => $this->time($rev),
639 'dc:contributor' => $rev->get('author'),
640 'wiki:version' => $rev->getVersion(),
641 'wiki:importance' => $this->importance($rev),
642 'wiki:status' => $this->status($rev),
643 'wiki:diff' => $this->diffURL($rev),
644 'wiki:history' => $this->historyURL($rev)
649 /** explicit application/rss+xml Content-Type,
650 * simplified xml structure (no namespace),
651 * support for xml-rpc cloud registerProcedure (not yet)
653 class _RecentChanges_Rss2Formatter
654 extends _RecentChanges_RssFormatter {
656 function format ($changes) {
657 include_once('lib/RssWriter2.php');
658 $rss = new RssWriter2;
660 $rss->channel($this->channel_properties());
661 if (($props = $this->cloud_properties()))
663 if (($props = $this->image_properties()))
665 if (($props = $this->textinput_properties()))
666 $rss->textinput($props);
668 while ($rev = $changes->next()) {
669 // enforce view permission
670 if (mayAccessPage('view', $rev->_pagename)) {
671 $rss->addItem($this->item_properties($rev),
672 $this->pageURI($rev));
674 $this->setValidators($rev);
680 $request->discardOutput();
682 printf("\n<!-- Generated by PhpWiki-%s:\n%s-->\n", PHPWIKI_VERSION, $GLOBALS['RCS_IDS']);
683 // Flush errors in comment, otherwise it's invalid XML.
684 global $ErrorManager;
685 if (($errors = $ErrorManager->getPostponedErrorsAsHTML()))
686 printf("\n<!-- PHP Warnings:\n%s-->\n", AsXML($errors));
688 $request->finish(); // NORETURN!!!!
691 function channel_properties () {
692 $chann_10 = parent::channel_properties();
693 return array_merge($chann_10,
694 array('generator' => 'PhpWiki-'.PHPWIKI_VERSION,
695 //<pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
696 //<lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
697 //<docs>http://blogs.law.harvard.edu/tech/rss</docs>
698 'copyright' => COPYRIGHTPAGE_URL
702 // xml-rpc registerProcedure not yet implemented
703 function cloud_properties () { return false; }
704 function cloud_properties_test () {
705 return array('protocol' => 'xml-rpc', // xml-rpc or soap or http-post
706 'registerProcedure' => 'wiki.rssPleaseNotify',
707 'path' => DATA_PATH.'/RPC2.php',
708 'port' => !SERVER_PORT ? '80' : (SERVER_PROTOCOL == 'https' ? '443' : '80'),
709 'domain' => SERVER_NAME);
714 * Filter by non-empty
716 class NonDeletedRevisionIterator extends WikiDB_PageRevisionIterator
720 * @param $revisions object a WikiDB_PageRevisionIterator.
722 function NonDeletedRevisionIterator ($revisions, $check_current_revision = true) {
723 $this->_revisions = $revisions;
724 $this->_check_current_revision = $check_current_revision;
728 while (($rev = $this->_revisions->next())) {
729 if ($this->_check_current_revision) {
730 $page = $rev->getPage();
731 $check_rev = $page->getCurrentRevision();
736 if (! $check_rev->hasDefaultContents())
746 * Filter by only_new.
747 * Only new created pages
749 class NewPageRevisionIterator extends WikiDB_PageRevisionIterator
753 * @param $revisions object a WikiDB_PageRevisionIterator.
755 function NewPageRevisionIterator ($revisions) {
756 $this->_revisions = $revisions;
760 while (($rev = $this->_revisions->next())) {
761 if ($rev->getVersion() == 1)
772 class AuthorPageRevisionIterator extends WikiDB_PageRevisionIterator
774 function AuthorPageRevisionIterator ($revisions, $author) {
775 $this->_revisions = $revisions;
776 $this->_author = $author;
780 while (($rev = $this->_revisions->next())) {
781 if ($rev->get('author_id') == $this->_author)
789 class WikiPlugin_RecentChanges
792 function getName () {
793 return _("RecentChanges");
796 function getVersion() {
797 return preg_replace("/[Revision: $]/", '',
798 "\$Revision: 1.112 $");
801 function managesValidators() {
802 // Note that this is a bit of a fig.
803 // We set validators based on the most recently changed page,
804 // but this fails when the most-recent page is deleted.
805 // (Consider that the Last-Modified time will decrease
806 // when this happens.)
808 // We might be better off, leaving this as false (and junking
809 // the validator logic above) and just falling back to the
810 // default behavior (handled by WikiPlugin) of just using
811 // the WikiDB global timestamp as the mtime.
813 // Nevertheless, for now, I leave this here, mostly as an
814 // example for how to use appendValidators() and managesValidators().
819 function getDefaultArguments() {
820 return array('days' => 2,
821 'show_minor' => false,
822 'show_major' => true,
824 'show_deleted' => 'sometimes',
831 'historylinks' => false,
836 function getArgs ($argstr, $request, $defaults = false) {
837 if (!$defaults) $defaults = $this->getDefaultArguments();
838 $args = WikiPlugin::getArgs($argstr, $request, $defaults);
840 $action = $request->getArg('action');
841 if ($action != 'browse' && ! $request->isActionPage($action))
842 $args['format'] = false; // default -> HTML
844 if ($args['format'] == 'rss' && empty($args['limit']))
845 $args['limit'] = 15; // Fix default value for RSS.
846 if ($args['format'] == 'rss2' && empty($args['limit']))
847 $args['limit'] = 15; // Fix default value for RSS2.
849 if ($args['format'] == 'sidebar' && empty($args['limit']))
850 $args['limit'] = 10; // Fix default value for sidebar.
855 function getMostRecentParams (&$args) {
858 $params = array('include_minor_revisions' => $show_minor,
859 'exclude_major_revisions' => !$show_major,
860 'include_all_revisions' => !empty($show_all));
862 $params['limit'] = $limit;
863 if (!empty($args['author'])) {
865 if ($args['author'] == '[]')
866 $args['author'] = $request->_user->getID();
867 $params['author'] = $args['author'];
871 $params['since'] = time() - 24 * 3600 * $days;
873 $params['since'] = 24 * 3600 * $days - time();
878 function getChanges ($dbi, $args) {
879 $changes = $dbi->mostRecent($this->getMostRecentParams($args));
881 $show_deleted = $args['show_deleted'];
882 if ($show_deleted == 'sometimes')
883 $show_deleted = $args['show_minor'];
885 if ($args['only_new'])
886 $changes = new NewPageRevisionIterator($changes);
887 elseif ($args['author'])
888 $changes = new AuthorPageRevisionIterator($changes, $args['author']);
889 elseif (!$show_deleted)
890 $changes = new NonDeletedRevisionIterator($changes, !$args['show_all']);
895 function format ($changes, $args) {
897 $format = $args['format'];
899 $fmt_class = $WikiTheme->getFormatter('RecentChanges', $format);
901 if ($format == 'rss')
902 $fmt_class = '_RecentChanges_RssFormatter';
903 elseif ($format == 'rss2')
904 $fmt_class = '_RecentChanges_Rss2Formatter';
905 elseif ($format == 'rss091') {
906 include_once "lib/RSSWriter091.php";
907 $fmt_class = '_RecentChanges_RssFormatter091';
909 elseif ($format == 'sidebar')
910 $fmt_class = '_RecentChanges_SideBarFormatter';
911 elseif ($format == 'box')
912 $fmt_class = '_RecentChanges_BoxFormatter';
914 $fmt_class = '_RecentChanges_HtmlFormatter';
917 $fmt = new $fmt_class($args);
918 return $fmt->format($changes);
921 function run($dbi, $argstr, &$request, $basepage) {
922 $args = $this->getArgs($argstr, $request);
924 // HACKish: fix for SF bug #622784 (1000 years of RecentChanges ought
925 // to be enough for anyone.)
926 $args['days'] = min($args['days'], 365000);
928 // Hack alert: format() is a NORETURN for rss formatters.
929 return $this->format($this->getChanges($dbi, $args), $args);
932 // box is used to display a fixed-width, narrow version with common header.
933 // just a numbered list of limit pagenames, without date.
934 function box($args = false, $request = false, $basepage = false) {
935 if (!$request) $request =& $GLOBALS['request'];
936 if (!isset($args['limit'])) $args['limit'] = 15;
937 $args['format'] = 'box';
938 $args['show_minor'] = false;
939 $args['show_major'] = true;
940 $args['show_deleted'] = 'sometimes';
941 $args['show_all'] = false;
943 return $this->makeBox(WikiLink($this->getName(),'',
944 SplitPagename($this->getName())),
946 ($this->getChanges($request->_dbi, $args), $args));
952 class DayButtonBar extends HtmlElement {
954 function DayButtonBar ($plugin_args) {
955 $this->__construct('p', array('class' => 'wiki-rc-action'));
957 // Display days selection buttons
958 extract($plugin_args);
963 $caption = _("Show minor edits for:");
965 $caption = _("Show all changes for:");
967 $caption = _("Show changes for:");
969 $caption = _("All new pages since:");
972 $this->pushContent($caption, ' ');
975 $sep = $WikiTheme->getButtonSeparator();
978 foreach (explode(",", $daylist) as $days) {
980 $this->pushContent($sep);
981 $this->pushContent($this->_makeDayButton($days));
985 function _makeDayButton ($days) {
986 global $WikiTheme, $request;
991 $label = "..."; //alldays
993 $label = sprintf(_("%s days"), abs($days));
995 $url = $request->getURLtoSelf(array('action' => $request->getArg('action'), 'days' => $days));
997 return $WikiTheme->makeButton($label, $url, 'wiki-rc-action');
1001 // $Log: not supported by cvs2svn $
1002 // Revision 1.111 2007/01/25 21:48:52 rurban
1003 // new argument author=[]
1005 // Revision 1.110 2007/01/22 23:51:36 rurban
1006 // new arg: only_new
1008 // Revision 1.109 2006/03/19 14:26:29 rurban
1009 // sf.net patch by Matt Brown: Add rel=nofollow to more actions
1011 // Revision 1.108 2005/04/01 16:09:35 rurban
1012 // fix defaults in RecentChanges plugins: e.g. invalid pagenames for PageHistory
1014 // Revision 1.107 2005/02/04 13:45:28 rurban
1015 // improve box layout a bit
1017 // Revision 1.106 2005/02/02 19:39:10 rurban
1018 // honor show_all=false
1020 // Revision 1.105 2005/01/25 03:50:54 uckelman
1021 // pre_description is a member function, so call with $this->.
1023 // Revision 1.104 2005/01/24 23:15:16 uckelman
1024 // The extra description for RelatedChanges was appearing in RecentChanges
1025 // and PageHistory due to a bad test in _RecentChanges_HtmlFormatter. Fixed.
1027 // Revision 1.103 2004/12/15 17:45:09 rurban
1030 // Revision 1.102 2004/12/06 19:29:24 rurban
1031 // simplify RSS: add RSS2 link (rss tag only, new content-type)
1033 // Revision 1.101 2004/11/10 19:32:24 rurban
1034 // * optimize increaseHitCount, esp. for mysql.
1035 // * prepend dirs to the include_path (phpwiki_dir for faster searches)
1036 // * Pear_DB version logic (awful but needed)
1037 // * fix broken ADODB quote
1038 // * _extract_page_data simplification
1040 // Revision 1.100 2004/06/28 16:35:12 rurban
1041 // prevent from shell commands
1043 // Revision 1.99 2004/06/20 14:42:54 rurban
1044 // various php5 fixes (still broken at blockparser)
1046 // Revision 1.98 2004/06/14 11:31:39 rurban
1047 // renamed global $Theme to $WikiTheme (gforge nameclash)
1048 // inherit PageList default options from PageList
1049 // default sortby=pagename
1050 // use options in PageList_Selectable (limit, sortby, ...)
1051 // added action revert, with button at action=diff
1052 // added option regex to WikiAdminSearchReplace
1054 // Revision 1.97 2004/06/03 18:58:27 rurban
1055 // days links requires action=RelatedChanges arg
1057 // Revision 1.96 2004/05/18 16:23:40 rurban
1058 // rename split_pagename to SplitPagename
1060 // Revision 1.95 2004/05/16 22:07:35 rurban
1061 // check more config-default and predefined constants
1062 // various PagePerm fixes:
1063 // fix default PagePerms, esp. edit and view for Bogo and Password users
1064 // implemented Creator and Owner
1065 // BOGOUSERS renamed to BOGOUSER
1066 // fixed syntax errors in signin.tmpl
1068 // Revision 1.94 2004/05/14 20:55:03 rurban
1069 // simplified RecentComments
1071 // Revision 1.93 2004/05/14 17:33:07 rurban
1072 // new plugin RecentChanges
1074 // Revision 1.92 2004/04/21 04:29:10 rurban
1075 // Two convenient RecentChanges extensions
1076 // RelatedChanges (only links from current page)
1077 // RecentEdits (just change the default args)
1079 // Revision 1.91 2004/04/19 18:27:46 rurban
1080 // Prevent from some PHP5 warnings (ref args, no :: object init)
1081 // php5 runs now through, just one wrong XmlElement object init missing
1082 // Removed unneccesary UpgradeUser lines
1083 // Changed WikiLink to omit version if current (RecentChanges)
1085 // Revision 1.90 2004/04/18 01:11:52 rurban
1086 // more numeric pagename fixes.
1087 // fixed action=upload with merge conflict warnings.
1088 // charset changed from constant to global (dynamic utf-8 switching)
1090 // Revision 1.89 2004/04/10 02:30:49 rurban
1091 // Fixed gettext problem with VIRTUAL_PATH scripts (Windows only probably)
1092 // Fixed "cannot setlocale..." (sf.net problem)
1094 // Revision 1.88 2004/04/01 15:57:10 rurban
1095 // simplified Sidebar theme: table, not absolute css positioning
1096 // added the new box methods.
1097 // remaining problems: large left margin, how to override _autosplitWikiWords in Template only
1099 // Revision 1.87 2004/03/30 02:14:03 rurban
1100 // fixed yet another Prefs bug
1101 // added generic PearDb_iter
1102 // $request->appendValidators no so strict as before
1103 // added some box plugin methods
1104 // PageList commalist for condensed output
1106 // Revision 1.86 2004/03/12 13:31:43 rurban
1107 // enforce PagePermissions, errormsg if not Admin
1109 // Revision 1.85 2004/02/17 12:11:36 rurban
1110 // 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, ...)
1112 // Revision 1.84 2004/02/15 22:29:42 rurban
1113 // revert premature performance fix
1115 // Revision 1.83 2004/02/15 21:34:37 rurban
1116 // PageList enhanced and improved.
1117 // fixed new WikiAdmin... plugins
1118 // editpage, Theme with exp. htmlarea framework
1119 // (htmlarea yet committed, this is really questionable)
1120 // WikiUser... code with better session handling for prefs
1121 // enhanced UserPreferences (again)
1122 // RecentChanges for show_deleted: how should pages be deleted then?
1124 // Revision 1.82 2004/01/25 03:58:43 rurban
1125 // use stdlib:isWikiWord()
1127 // Revision 1.81 2003/11/28 21:06:31 carstenklapp
1128 // Enhancement: Mozilla RecentChanges sidebar now defaults to 10 changes
1129 // instead of 1. Make diff buttons smaller with css. Added description
1130 // line back in at the top.
1132 // Revision 1.80 2003/11/27 15:17:01 carstenklapp
1133 // Theme & appearance tweaks: Converted Mozilla sidebar link into a Theme
1134 // button, to allow an image button for it to be added to Themes. Output
1135 // RSS button in small text size when theme has no button image.
1137 // Revision 1.79 2003/04/29 14:34:20 dairiki
1138 // Bug fix: "add sidebar" link didn't work when USE_PATH_INFO was false.
1140 // Revision 1.78 2003/03/04 01:55:05 dairiki
1141 // Fix to ensure absolute URL for logo in RSS recent changes.
1143 // Revision 1.77 2003/02/27 23:23:38 dairiki
1144 // Fix my breakage of CSS and sidebar RecentChanges output.
1146 // Revision 1.76 2003/02/27 22:48:44 dairiki
1147 // Fixes invalid HTML generated by PageHistory plugin.
1149 // (<noscript> is block-level and not allowed within <p>.)
1151 // Revision 1.75 2003/02/22 21:39:05 dairiki
1152 // Hackish fix for SF bug #622784.
1154 // (The root of the problem is clearly a PHP bug.)
1156 // Revision 1.74 2003/02/21 22:52:21 dairiki
1157 // Make sure to interpret relative links (like [/Subpage]) in summary
1158 // relative to correct basepage.
1160 // Revision 1.73 2003/02/21 04:12:06 dairiki
1161 // Minor fixes for new cached markup.
1163 // Revision 1.72 2003/02/17 02:19:01 dairiki
1164 // Fix so that PageHistory will work when the current revision
1165 // of a page has been "deleted".
1167 // Revision 1.71 2003/02/16 20:04:48 dairiki
1168 // Refactor the HTTP validator generation/checking code.
1170 // This also fixes a number of bugs with yesterdays validator mods.
1172 // Revision 1.70 2003/02/16 05:09:43 dairiki
1173 // Starting to fix handling of the HTTP validator headers, Last-Modified,
1176 // Last-Modified was being set incorrectly (but only when DEBUG was not
1177 // defined!) Setting a Last-Modified without setting an appropriate
1178 // Expires: and/or Cache-Control: header results in browsers caching
1179 // the page unconditionally (for a certain period of time).
1180 // This is generally bad, since it means people don't see updated
1181 // page contents right away --- this is particularly confusing to
1182 // the people who are editing pages since their edits don't show up
1183 // next time they browse the page.
1185 // Now, we don't allow caching of pages without revalidation
1186 // (via the If-Modified-Since and/or If-None-Match request headers.)
1187 // (You can allow caching by defining CACHE_CONTROL_MAX_AGE to an
1188 // appropriate value in index.php, but I advise against it.)
1192 // o Even when request is aborted due to the content not being
1193 // modified, we currently still do almost all the work involved
1194 // in producing the page. So the only real savings from all
1195 // this logic is in network bandwidth.
1197 // o Plugins which produce "dynamic" output need to be inspected
1198 // and made to call $request->addToETag() and
1199 // $request->setModificationTime() appropriately, otherwise the
1200 // page can change without the change being detected.
1201 // This leads to stale pages in cache again...
1203 // Revision 1.69 2003/01/18 22:01:43 carstenklapp
1205 // Reformatting & tabs to spaces;
1206 // Added copyleft, getVersion, getDescription, rcs_id.
1209 // (c-file-style: "gnu")
1213 // c-basic-offset: 4
1214 // c-hanging-comment-ender-p: nil
1215 // indent-tabs-mode: nil