SourceForge logo
SourceForge logo
Menu

phpwiki-checkins

From: Geoffrey T. D. <da...@us...> - 2001年12月14日 20:24:28
Update of /cvsroot/phpwiki/phpwiki/lib/plugin
In directory usw-pr-cvs1:/tmp/cvs-serv11289/lib/plugin
Modified Files:
	RecentChanges.php 
Log Message:
Big refactor/cleanup in part to allow for code sharing with the
(forthcoming) PageHistory plugin.
Index: RecentChanges.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/RecentChanges.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** RecentChanges.php	2001年12月11日 22:45:39	1.5
--- RecentChanges.php	2001年12月14日 20:24:25	1.6
***************
*** 3,134 ****
 /**
 */
- define('RSS_ENCODING', 'ISO-8859-1');
 
! class WikiPlugin_RecentChanges
! extends WikiPlugin
 {
! var $name = 'RecentChanges';
 
! function getDefaultArguments() {
! return array('days'		=> 2,
! 'show_minor'	=> false,
! 'show_major'	=> true,
! 'show_all'		=> false,
! 'limit'		=> false,
! 'format'		=> false);
 }
 
! function run($dbi, $argstr, $request) {
! $args = $this->getArgs($argstr, $request);
! extract($args);
! $params = array('include_minor_revisions' => $show_minor,
! 'exclude_major_revisions' => !$show_major,
! 'include_all_revisions' => $show_all);
 
! if ($days > 0.0)
! $params['since'] = time() - 24 * 3600 * $days;
! 
! $changes = $dbi->mostRecent($params);
 
! if ($request->getArg('action') != 'browse')
! $format = false; // default -> HTML
! switch ($format) {
! case 'rss':
! if (!$args['limit'])
! $args['limit'] = 15;
 
! header("Content-Type: application/xml; charset=" . RSS_ENCODING);
! 
! $xml = $this->__format_as_rss($changes, $args, $request);
! printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", RSS_ENCODING);
! printf("<!-- Generated by PhpWiki:\n%s-->\n", $GLOBALS['RCS_IDS']);
! echo $xml;
! ExitWiki();
! break;
 default:
! return $this->__format_as_html($changes, $args, $request);
! break;
 }
 }
 
! function __format_as_html($changes, $args, $request) {
 
! global $dateformat;
! global $WikiNameRegexp;
! 
! $last_date = '';
! $lines = array();
 
! $diffargs = array('action' => 'diff');
 
- // FIXME: add XML icon (and link) to title?
 $rss_url = $request->getURLtoSelf(array('format' => 'rss'));
! $rss_icon = Element('a', array('href' => $rss_url),
! Element('img', array('src' => DataURL('images/rss.png'),
! 'alt' => 'RSS available',
! 'class' => 'linkicon')));
! 
! $html = Element('h3', htmlspecialchars(_("RecentChanges")) . " $rss_icon");
 
! $limit = $args['limit'];
 while ($rev = $changes->next()) {
! $created = $rev->get('mtime');
! $date = strftime($dateformat, $created);
! $time = strftime("%l:%M %p", $created); // Make configurable.
! if ($date != $last_date) {
 if ($lines) {
! $html .= Element('ul', join("\n", $lines));
 $lines = array();
 }
! $html .= Element('p',QElement('b', $date));
 $last_date = $date;
 }
 
! $page = $rev->getPage();
! $pagename = $page->getName();
 
- if ($args['show_all']) {
- // FIXME: should set previous, too, if showing only minor or major revs.
- // or maybe difftype.
- $diffargs['version'] = $rev->getVersion();
- }
- 
- $diff = QElement('a',
- array('href' => WikiURL($pagename, $diffargs)),
- "(diff)");
- 
- $wikipage = LinkWikiWord($page->getName());
 
- $author = $rev->get('author');
- if (preg_match("/^$WikiNameRegexp\$/", $author))
- $author = LinkWikiWord($author);
- else
- $author = htmlspecialchars($author);
 
! $summary = $rev->get('summary');
! if ($summary)
! $summary = QElement('b', "[$summary]");
! 
! $lines[] = Element('li',
! "$diff $wikipage $time $summary ... $author");
 
! if ($limit && --$limit <= 0)
! break;
! }
! if ($lines)
! $html .= Element('ul', join("\n", $lines));
! 
! return $html;
 }
 
! function __format_as_rss($changes, $args, $request) {
 include_once('lib/RssWriter.php');
 $rss = new RssWriter;
 $rc_url = WikiURL($request->getArg('pagename'), false, 'absurl');
 
! $chan = array('title' => WIKI_NAME,
! 'dc:description' => _("RecentChanges"),
! 'link' => $rc_url,
! 'dc:date' => Iso8601DateTime(time()));
 
 /* FIXME: other things one might like in <channel>: 
--- 3,259 ----
 /**
 */
 
! 
! 
! class _RecentChanges_Formatter
 {
! var $_absurls = false;
 
! function _RecentChanges_Formatter ($rc_args) {
! $this->_args = $rc_args;
! $this->_diffargs = array('action' => 'diff');
! 
! if ($rc_args['show_major'] && !$rc_args['show_minor'])
! $this->_diffargs['previous'] = 'major';
 }
 
! function include_versions_in_URLs() {
! return (bool) $this->args['show_all'];
! }
! 
! function date ($rev) {
! return strftime($GLOBALS['dateformat'], $rev->get('mtime'));
! }
 
! function time ($rev) {
! // FIXME: Make configurable.
! return strftime("%l:%M %p", $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 pageURL ($rev) {
! $params = array();
! if ($this->include_versions_in_URLs())
! $params['version'] = $rev->getVersion();
! $page = $rev->getPage();
! return WikiURL($page->getName(), $params, $this->_absurls);
! }
! 
! function authorURL($author) {
! global $WikiNameRegexp, $dbi;
! 
! if (preg_match("/^$WikiNameRegexp\$/", $author) && $dbi->isWikiPage($author))
! return WikiURL($author);
! return 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 '';
 }
 }
+ }
 
! class _RecentChanges_HtmlFormatter
! extends _RecentChanges_Formatter
! {
! function diffLink ($rev) {
! return QElement('a', array('href' => $this->diffURL($rev)),
! _("(diff)"));
! }
 
! function pageLink ($rev) {
! $page = $rev->getPage();
! return QElement('a', array('href' => $this->pageURL($rev), 'class' => 'wiki'),
! $page->getName());
! }
! 
! function authorLink ($rev) {
! $author = $rev->get('author');
! if ( ($url = $this->authorURL($author)) )
! return QElement('a', array('href' => $url, 'class' => 'wiki'), $author);
! else
! return htmlspecialchars($author);
! }
! 
 
! function rss_icon () {
! global $request;
 
 $rss_url = $request->getURLtoSelf(array('format' => 'rss'));
! return Element('a', array('href' => $rss_url),
! Element('img', array('src' => DataURL('images/rss.png'),
! 'alt' => _("RSS available"),
! 'class' => '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 ($limit > 0) {
! if ($days > 0)
! $desc = sprintf(_("The %d most recent %s during the past %.1f days are listed below."),
! $limit, $edits, $days);
! else
! $desc = sprintf(_("The %d most recent %s are listed below."),
! $limit, $edits);
! }
! else {
! if ($days > 0)
! $desc = sprintf(_("The most recent %s during the past %.1f days are listed below."),
! $edits, $days);
! else
! $desc = sprintf(_("All %s are listed below."), $edits);
! }
! return htmlspecialchars($desc);
! }
 
! 
! function title () {
! return htmlspecialchars(_("RecentChanges")) . "\n" . $this->rss_icon();
! }
! 
! function format ($changes) {
! $html[] = Element('h2', $this->title());
! if (($desc = $this->description()))
! $html[] = Element('p', $desc);
! 
! $last_date = '';
! $lines = array();
! 
 while ($rev = $changes->next()) {
! if (($date = $this->date($rev)) != $last_date) {
 if ($lines) {
! $html[] = Element('ul', join("\n", $lines));
 $lines = array();
 }
! $html[] = QElement('h3', $date);
 $last_date = $date;
 }
 
! $lines[] = $this->format_revision($rev);
! }
! if ($lines)
! $html[] = Element('ul', join("\n", $lines));
! return join("\n", $html) . "\n";
! }
! 
! function format_revision ($rev) {
! if ( ($summary = $this->summary($rev)) )
! $summary = QElement('b', "[$summary]");
! 
! $class = 'rc-' . $this->importance($rev);
! 
! return Element('li', array('class' => $class),
! implode(' ', array( $this->diffLink($rev),
! $this->pageLink($rev),
! $this->time($rev),
! $summary,
! '...',
! $this->authorLink($rev) )));
! }
! }
 
 
 
! class _RecentChanges_RssFormatter
! extends _RecentChanges_Formatter
! {
! var $_absurls = true;
 
! function time ($rev) {
! return Iso8601DateTime($rev->get('mtime'));
 }
 
! function pageURI ($rev) {
! $page = $rev->getPage();
! return WikiURL($page->getName(),
! array('version' => $rev->getVersion()),
! 'absurl');
! }
! 
! function format ($changes) {
 include_once('lib/RssWriter.php');
 $rss = new RssWriter;
+ 
+ 
+ $rss->channel($this->channel_properties());
+ 
+ if (($props = $this->image_properties()))
+ $rss->image($props);
+ if (($props = $this->textinput_properties()))
+ $rss->textinput($props);
+ 
+ while ($rev = $changes->next()) {
+ $rss->addItem($this->item_properties($rev),
+ $this->pageURI($rev));
+ }
+ 
+ $rss->finish();
+ printf("\n<!-- Generated by PhpWiki:\n%s-->\n", $GLOBALS['RCS_IDS']);
+ ExitWiki(); // NORETURN!!!!
+ }
+ 
+ function image_properties () {
+ return array('title' => WIKI_NAME,
+ 'link' => WikiURL(_("HomePage"), false, 'absurl'),
+ 'url' => DataURL($GLOBALS['logo']));
+ }
+ 
+ function textinput_properties () {
+ return array('title' => _("Search"),
+ 'description' => _("Title Search"),
+ 'name' => 's',
+ 'link' => WikiURL(_("TitleSearch"), false, 'absurl'));
+ }
+ 
+ function channel_properties () {
+ global $request;
+ 
 $rc_url = WikiURL($request->getArg('pagename'), false, 'absurl');
 
! return array('title' => WIKI_NAME,
! 'dc:description' => _("RecentChanges"),
! 'link' => $rc_url,
! 'dc:date' => Iso8601DateTime(time()));
 
 /* FIXME: other things one might like in <channel>: 
***************
*** 146,201 ****
 * rss091:copyright
 */
 
! $rss->channel($chan, $rc_url);
 
! $rss->image(array('title' => 'PhpWiki', // FIXME: this should be a config define
! 'link' => WikiURL(_("HomePage"), false, 'absurl'),
! 'url' => DataURL($GLOBALS['logo'])));
! 
! $rss->textinput(array('title' => _("Search"),
! 'description' => _("Title Search"),
! 'name' => 's',
! 'link' => WikiURL(_("TitleSearch"), false, 'absurl')));
 
! $limit = $args['limit'];
! while ($rev = $changes->next()) {
! $page = $rev->getPage();
 
! $urlargs = array();
! if ($args['show_all']) {
! // FIXME: should set previous, too, if showing only minor or major revs.
! // or maybe difftype.
! $urlargs['version'] = $rev->getVersion();
! }
! 
! $pagename = $page->getName();
! 
! $item = array('title' => split_pagename($pagename),
! 'description' => $rev->get('summary'),
! 'link' => WikiURL($pagename, $urlargs, 'absurl'),
! 'dc:date' => Iso8601DateTime($rev->get('mtime')),
! 'dc:contributor' => $rev->get('author'),
! 'wiki:version' => $rev->getVersion(),
! 'wiki:importance' => $rev->get('is_minor_edit') ? 'minor' : 'major',
! // wiki:status = 'new' | 'updated' | 'deleted'
! 'wiki:diff' => WikiURL($pagename,
! array_merge($urlargs,
! array('action' => 'diff',
! 'previous' => 'major')),
! 'absurl'),
! 'wiki:history' => WikiURL($pagename,
! array('action' => 'info'),
! 'absurl')
! );
 
 
! $uri = WikiURL($pagename, array('version' => $rev->getVersion()), 'absurl');
! $rss->addItem($item, $uri);
 
! if ($limit && --$limit <= 0)
! break;
! }
 
! return $rss->asXML();
 }
 };
--- 271,358 ----
 * rss091:copyright
 */
+ }
+ 
+ 
+ 
+ 
+ function item_properties ($rev) {
+ $page = $rev->getPage();
+ $pagename = $page->getName();
+ 
+ return array( 'title'		=> split_pagename($pagename),
+ 'description'	=> $this->summary($rev),
+ 'link'		=> $this->pageURL($rev),
+ 'dc:date'		=> $this->time($rev),
+ 'dc:contributor'	=> $rev->get('author'),
+ 'wiki:version'	=> $rev->getVersion(),
+ 'wiki:importance' => $this->importance($rev),
+ 'wiki:status'	=> $this->status($rev),
+ 'wiki:diff'	=> $this->diffURL($rev),
+ 'wiki:history'	=> WikiURL($pagename,
+ array('action' => 'info'),
+ 'absurl')
+ );
+ }
+ }
+ 
+ class WikiPlugin_RecentChanges
+ extends WikiPlugin
+ {
+ var $name = 'RecentChanges';
+ 
+ function getDefaultArguments() {
+ return array('days'		=> 2,
+ 'show_minor'	=> false,
+ 'show_major'	=> true,
+ 'show_all'		=> false,
+ 'limit'		=> false,
+ 'format'		=> false);
+ }
 
! function getArgs ($argstr, $request, $defaults = false) {
! $args = WikiPlugin::getArgs($argstr, $request, $defaults);
 
! if ($request->getArg('action') != 'browse')
! $args['format'] = false; // default -> HTML
! 
! if ($args['format'] == 'rss' && empty($args['limit']))
! $args['limit'] = 15; // Fix default value for RSS.
 
! return $args;
! }
! 
! function getMostRecentParams ($args) {
! extract($args);
 
! $params = array('include_minor_revisions' => $show_minor,
! 'exclude_major_revisions' => !$show_major,
! 'include_all_revisions' => !empty($show_all));
 
+ if ($limit > 0)
+ $params['limit'] = $limit;
 
! if ($days > 0.0)
! $params['since'] = time() - 24 * 3600 * $days;
 
! return $params;
! }
! 
! function getChanges ($dbi, $args) {
! return $dbi->mostRecent($this->getMostRecentParams($args));
! }
 
! function format ($changes, $args) {
! if ($args['format'] == 'rss')
! $fmt = new _RecentChanges_RssFormatter($args);
! else
! $fmt = new _RecentChanges_HtmlFormatter($args);
! return $fmt->format($changes);
! }
! 
! 
! function run ($dbi, $argstr, $request) {
! $args = $this->getArgs($argstr, $request);
! // Hack alert: format() is a NORETURN for rss formatters.
! return $this->format($this->getChanges($dbi, $args), $args);
 }
 };
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /