_args = $rc_args; $this->_diffargs = array('action' => 'diff'); if ($rc_args['show_minor'] || !$rc_args['show_major']) $this->_diffargs['previous'] = 'minor'; // PageHistoryPlugin doesn't have a 'daylist' arg. if (!isset($this->_args['daylist'])) $this->_args['daylist'] = false; } function include_versions_in_URLs() { return (bool) $this->_args['show_all']; } function date ($rev) { global $Theme; return $Theme->getDay($rev->get('mtime')); } function time ($rev) { global $Theme; return $Theme->formatTime($rev->get('mtime')); } function diffURL ($rev) { $args = $this->_diffargs; if ($this->include_versions_in_URLs()) $args['version'] = $rev->getVersion(); $page = $rev->getPage(); return WikiURL($page->getName(), $args, $this->_absurls); } function historyURL ($rev) { $page = $rev->getPage(); return WikiURL($page, array('action' => _("PageHistory")), $this->_absurls); } function pageURL ($rev) { return WikiURL($this->include_versions_in_URLs() ? $rev : $rev->getPage(), '', $this->_absurls); } function authorHasPage ($author) { global $WikiNameRegexp, $request; $dbi = $request->getDbh(); return preg_match("/^$WikiNameRegexp\$/", $author) && $dbi->isWikiPage($author); } function authorURL ($author) { return $this->authorHasPage() ? WikiURL($author) : false; } function status ($rev) { if ($rev->hasDefaultContents()) return 'deleted'; $page = $rev->getPage(); $prev = $page->getRevisionBefore($rev->getVersion()); if ($prev->hasDefaultContents()) return 'new'; return 'updated'; } function importance ($rev) { return $rev->get('is_minor_edit') ? 'minor' : 'major'; } function summary($rev) { if ( ($summary = $rev->get('summary')) ) return $summary; switch ($this->status($rev)) { case 'deleted': return _("Deleted."); case 'new': return _("New page."); default: return ''; } } function http_lastmodified_header($mtime) { static $mostrecentlymodified = false; if (! $mostrecentlymodified) { // set http header to date of most recently modified page $mostrecentlymodified = $mtime; //$rev->get('mtime'); header("Last-Modified: " . Rfc2822DateTime($mostrecentlymodified)); } } } class _RecentChanges_HtmlFormatter extends _RecentChanges_Formatter { function diffLink ($rev) { global $Theme; return $Theme->makeButton(_("(diff)"), $this->diffURL($rev), 'wiki-rc-action'); } function historyLink ($rev) { global $Theme; return $Theme->makeButton(_("(hist)"), $this->historyURL($rev), 'wiki-rc-action'); } function pageLink ($rev) { $page = $rev->getPage(); global $Theme; if ($this->include_versions_in_URLs()) { $version = $rev->getVersion(); $exists = !$rev->hasDefaultContents(); } else { $version = false; $cur = $page->getCurrentRevision(); $exists = !$cur->hasDefaultContents(); } if ($exists) return $Theme->linkExistingWikiWord($page->getName(), false, $version); else return $Theme->linkUnknownWikiWord($page->getName(), false, $version); } function authorLink ($rev) { $author = $rev->get('author'); if ( $this->authorHasPage($author) ) { return WikiLink($author); } else return $author; } function summaryAsHTML ($rev) { if ( !($summary = $this->summary($rev)) ) return ''; return HTML::strong( array('class' => 'wiki-summary'), "[", TransformLinks($summary, $rev->get('markup')), "]"); } function rss_icon () { global $request, $Theme; $rss_url = $request->getURLtoSelf(array('format' => 'rss')); return $Theme->makeButton("RSS", $rss_url, 'rssicon'); } function description () { extract($this->_args); // FIXME: say something about show_all. if ($show_major && $show_minor) $edits = _("edits"); elseif ($show_major) $edits = _("major edits"); else $edits = _("minor edits"); if ($timespan = $days > 0) { if (intval($days) != $days) $days = sprintf("%.1f", $days); } $lmt = abs($limit); /** * Depending how this text is split up it can be tricky or * impossible to translate with good grammar. So the seperate * strings for 1 day and %s days are necessary in this case * for translating to multiple languages, due to differing * overlapping ideal word cutting points. * * en: day/days "The %d most recent %s [during (the past] day) are listed below." * de: 1 Tag "Die %d jüngste %s [innerhalb (von des letzten] Tages) sind unten aufgelistet." * de: %s days "Die %d jüngste %s [innerhalb (von] %s Tagen) sind unten aufgelistet." * * en: day/days "The %d most recent %s during [the past] (day) are listed below." * fr: 1 jour "Les %d %s les plus récentes pendant [le dernier (d'une] jour) sont énumérées ci-dessous." * fr: %s jours "Les %d %s les plus récentes pendant [les derniers (%s] jours) sont énumérées ci-dessous." */ if ($limit > 0) { if ($timespan) { if (intval($days) == 1) $desc = fmt("The %d most recent %s during the past day are listed below.", $limit, $edits); else $desc = fmt("The %d most recent %s during the past %s days are listed below.", $limit, $edits, $days); } else $desc = fmt("The %d most recent %s are listed below.", $limit, $edits); } elseif ($limit < 0) { //$limit < 0 means we want oldest pages if ($timespan) { if (intval($days) == 1) $desc = fmt("The %d oldest %s during the past day are listed below.", $lmt, $edits); else $desc = fmt("The %d oldest %s during the past %s days are listed below.", $lmt, $edits, $days); } else $desc = fmt("The %d oldest %s are listed below.", $lmt, $edits); } else { if ($timespan) { if (intval($days) == 1) $desc = fmt("The most recent %s during the past day are listed below.", $edits); else $desc = fmt("The most recent %s during the past %s days are listed below.", $edits, $days); } else $desc = fmt("All %s are listed below.", $edits); } return $desc; } function title () { extract($this->_args); return array($show_minor ? _("RecentEdits") : _("RecentChanges"), ' ', $this->rss_icon(), $this->sidebar_link()); } function sidebar_link() { extract($this->_args); $pagetitle = $show_minor ? _("RecentEdits") : _("RecentChanges"); global $request; $sidebarurl = WikiURL($pagetitle, false, 'absurl') . "?format=sidebar"; $addsidebarjsfunc = "function addPanel() {\n" ." window.sidebar.addPanel (\"" . sprintf("%s - %s", WIKI_NAME, $pagetitle) . "\",\n" ." \"$sidebarurl\",\"\");\n" ."}\n"; $jsf = $this->_javascript($addsidebarjsfunc); $addsidebarjsclick = " " . "sidebar"; $jsc = $this->_javascript("if ((typeof window.sidebar == 'object') &&\n" ." (typeof window.sidebar.addPanel == 'function'))\n" ." {\n" ." document.write('$addsidebarjsclick');\n" ." }\n" ); return HTML(new RawXML("\n"), $jsf, new RawXML("\n"), $jsc); } function _javascript($script) { return HTML::script(array('language' => 'JavaScript', 'type' => 'text/javascript'), new RawXml("")); } function format ($changes) { $html = HTML(HTML::h2(false, $this->title())); if (($desc = $this->description())) $html->pushContent(HTML::p(false, $desc)); if ($this->_args['daylist']) $html->pushContent(new DayButtonBar($this->_args)); $last_date = ''; $lines = false; while ($rev = $changes->next()) { if (($date = $this->date($rev)) != $last_date) { if ($lines) $html->pushContent($lines); $html->pushContent(HTML::h3($date)); $lines = HTML::ul(); $last_date = $date; } $this->http_lastmodified_header($rev->get('mtime')); $lines->pushContent($this->format_revision($rev)); } if ($lines) $html->pushContent($lines); return $html; } function format_revision ($rev) { $args = &$this->_args; $class = 'rc-' . $this->importance($rev); $time = $this->time($rev); if (! $rev->get('is_minor_edit')) $time = HTML::strong(array('class' => 'pageinfo-majoredit'), $time); $line = HTML::li(array('class' => $class)); if ($args['difflinks']) $line->pushContent($this->diffLink($rev), ' '); if ($args['historylinks']) $line->pushContent($this->historyLink($rev), ' '); $line->pushContent($this->pageLink($rev), ' ', $time, ' ', $this->summaryAsHTML($rev), ' ... ', $this->authorLink($rev)); return $line; } } class _RecentChanges_SideBarFormatter extends _RecentChanges_HtmlFormatter { function description () { //omit description } function rss_icon () { //omit rssicon } function title () { //title click opens the normal RC or RE page in the main browser frame extract($this->_args); $titlelink = WikiLink($show_minor ? _("RecentEdits") : _("RecentChanges")); $titlelink->setAttr('target', '_content'); return HTML($this->logo(), $titlelink); } function logo () { //logo click opens the HomePage in the main browser frame global $Theme; $img = HTML::img(array('src' => $Theme->getImageURL('logo'), 'border' => 0, 'align' => 'right', 'width' => 32 )); $linkurl = WikiLink(HOME_PAGE, false, $img); $linkurl->setAttr('target', '_content'); return $linkurl; } function authorLink ($rev) { $author = $rev->get('author'); if ( $this->authorHasPage($author) ) { $linkurl = WikiLink($author); $linkurl->setAttr('target', '_content'); // way to do this using parent::authorLink ?? return $linkurl; } else return $author; } function diffLink ($rev) { $linkurl = parent::diffLink($rev); $linkurl->setAttr('target', '_content'); return $linkurl; } function historyLink ($rev) { $linkurl = parent::historyLink($rev); $linkurl->setAttr('target', '_content'); return $linkurl; } function pageLink ($rev) { $linkurl = parent::pageLink($rev); $linkurl->setAttr('target', '_content'); return $linkurl; } // Overriding summaryAsHTML, because there is no way yet to // return summary as transformed text with // links setAttr('target', '_content') in Mozilla sidebar. // So for now don't create clickable links inside summary // in the sidebar, or else they target the sidebar and not the // main content window. function summaryAsHTML ($rev) { if ( !($summary = $this->summary($rev)) ) return ''; return HTML::strong(array('class' => 'wiki-summary'), "[", /*TransformLinks(*/$summary,/* $rev->get('markup')),*/ "]"); } function format ($changes) { $this->_args['daylist'] = false; //only 1 day for Mozilla sidebar $html = _RecentChanges_HtmlFormatter::format ($changes); $html = HTML::div(array('class' => 'wikitext'), $html); printf("\n", CHARSET); printf(''); printf(''); printf("
\n"); extract($this->_args); $title = WIKI_NAME . $show_minor ? _("RecentEdits") : _("RecentChanges"); printf("