<?php
+# Basic support for outputting syndication feeds in RSS, other formats
+#
+# Copyright (C) 2004 Brion Vibber <brion@pobox.com>
+# http://www.mediawiki.org/
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# http://www.gnu.org/copyleft/gpl.html
$wgFeedClasses = array(
"rss" => "RSSFeed",
var $Description = "";
var $Url = "";
var $Date = "";
+ var $Author = "";
- function FeedItem( $Title, $Description, $Url, $Date = "" ) {
+ function FeedItem( $Title, $Description, $Url, $Date = "", $Author = "" ) {
$this->Title = $Title;
$this->Description = $Description;
$this->Url = $Url;
$this->Date = $Date;
+ $this->Author = $Author;
}
/* Static... */
function getDate() {
return $this->Date;
}
+ function getAuthor() {
+ return $this->xmlEncode( $this->Author );
+ }
}
class ChannelFeed extends FeedItem {
function outHeader() {
global $wgVersion;
+ header( "Content-type: application/xml; charset=UTF-8" );
print '<' . '?xml version="1.0" encoding="utf-8"?' . ">\n";
?><rss version="2.0">
<channel>
<link><?php print $item->getUrl() ?></link>
<description><?php print $item->getDescription() ?></description>
<?php if( $item->getDate() ) { ?><pubDate><?php print $this->formatTime( $item->getDate() ) ?></pubDate><?php } ?>
+ <?php if( $item->getAuthor() ) { ?><author><?php print $item->getAuthor() ?></author><?php }?>
</item>
<?php
var $mContainsOldMagic, $mContainsNewMagic;
var $mIsArticleRelated;
var $mParserOptions;
+ var $mShowFeedLinks = false;
function OutputPage()
{
function isArticle() { return $this->mIsarticle; }
function setPrintable() { $this->mPrintable = true; }
function isPrintable() { return $this->mPrintable; }
+ function setSyndicated( $show = true ) { $this->mShowFeedLinks = $show; }
+ function isSyndicated() { return $this->mShowFeedLinks; }
function setOnloadHandler( $js ) { $this->mOnloadHandler = $js; }
function getOnloadHandler() { return $this->mOnloadHandler; }
function disable() { $this->mDoNothing = true; }
# real, honest-to-gosh query page.
function doQuery( $offset, $limit ) {
-
global $wgUser, $wgOut, $wgLang, $wgMiserMode;
$sname = $this->getName();
$fname = get_class($this) . "::doQuery";
+ $wgOut->setSyndicated( true );
+
if ( $this->isExpensive( ) ) {
-
$vsp = $wgLang->getValidSpecialPages();
$logpage = new LogPage( "!" . $vsp[$sname] );
$logpage->mUpdateRecentChanges = false;
$title->getText(),
$this->feedItemDesc( $row ),
$title->getFullURL(),
- $date);
+ $date,
+ $this->feedItemAuthor( $row ) );
} else {
return NULL;
}
}
function feedItemDesc( $row ) {
+ $text = "";
if( isset( $row->cur_comment ) ) {
- return $row->cur_comment;
+ $text = $row->cur_comment;
} elseif( isset( $row->old_comment ) ) {
- return $row->old_comment;
+ $text = $row->old_comment;
} elseif( isset( $row->rc_comment ) ) {
- return $row->rc_comment;
+ $text = $row->rc_comment;
+ }
+ $text = htmlspecialchars( $text );
+
+ if( isset( $row->cur_text ) ) {
+ $text = "<p>" . htmlspecialchars( wfMsg( "summary" ) ) . ": " . $text . "</p>\n<hr />\n<div>" .
+ nl2br( $row->cur_text ) . "</div>";;
+ }
+ return $text;
+ }
+
+ function feedItemAuthor( $row ) {
+ $fields = array( "cur_user_text", "old_user_text", "rc_user_text" );
+ foreach( $fields as $field ) {
+ if( isset( $row->$field ) ) return $row->field;
}
return "";
}
-
+
function feedTitle() {
global $wgLanguageCode, $wgSitename, $wgLang;
$pages = $wgLang->getValidSpecialPages();
<?php
+
+include_once( "Feed.php" );
+
# See skin.doc
# These are the INTERNAL names, which get mapped
function pageTitleLinks()
{
- global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang, $wgUseApproval ;
+ global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang, $wgUseApproval;
$s = $this->printableLink();
if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
function printableLink()
{
- global $wgOut, $wgTitle, $oldid, $action;
+ global $wgOut, $wgFeedClasses;
- $q = "";
- foreach( $_GET as $var => $val ) {
- if( $var != "title" && $var != "printable" )
- $q .= urlencode( $var ) . "=" . urlencode( $val );
+ $baseurl = $_SERVER['REQUEST_URI'];
+ if( strpos( "?", $baseurl ) == false ) {
+ $baseurl .= "?";
+ } else {
+ $baseurl .= "&";
}
- if( !empty( $q ) ) $q .= "&";
+ $baseurl = htmlspecialchars( $baseurl );
- $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
- WfMsg( "printableversion" ), "{$q}printable=yes" );
+ $s = "<a href=\"{$baseurl}printable=yes\">" . wfMsg( "printableversion" ) . "</a>";
+ if( $wgOut->isSyndicated() ) {
+ foreach( $wgFeedClasses as $format => $class ) {
+ $s .= " | <a href=\"{$baseurl}feed={$format}\">{$format}</a>";
+ }
+ }
return $s;
}
function getSQL( $offset, $limit ) {
return "SELECT rc_namespace AS cur_namespace, rc_title AS cur_title,rc_user AS cur_user,rc_user_text AS cur_user_text,rc_comment as cur_comment," .
- "rc_timestamp AS cur_timestamp,length(cur_text) as cur_length FROM recentchanges,cur " .
+ "rc_timestamp AS cur_timestamp,length(cur_text) as cur_length,cur_text FROM recentchanges,cur " .
"WHERE rc_cur_id=cur_id AND rc_new=1 AND rc_namespace=0 AND cur_is_redirect=0 " .
"ORDER BY rc_timestamp DESC LIMIT {$offset}, {$limit}";
}
<?php
+include_once( "Feed.php" );
+
function wfSpecialRecentchanges( $par )
{
global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname;
+ global $wgRequest, $wgSitename, $wgLanguageCode;
global $days, $hideminor, $from, $hidebots, $hideliu; # From query string
$fname = "wfSpecialRecentchanges";
-
+
+ $feedFormat = $wgRequest->getVal( "feed" );
+ $feeding = ( $feedFormat == "rss" );
+
if( $par ) {
$bits = preg_split( '/\s*,\s*/', trim( $par ) );
if( in_array( "hidebots", $bits ) ) $hidebots = 1;
$wgOut->addHTML( "{$note}\n" );
- $s = $sk->beginRecentChangesList();
- foreach( $rows as $obj ){
- if( $limit == 0) {
- break;
+ if( $feeding ) {
+ $wgOut->disable();
+
+ $feed = new RSSFeed(
+ $wgSitename . " - " . wfMsg( "recentchanges" ) . " [" . $wgLanguageCode . "]",
+ htmlspecialchars( wfMsg( "recentchangestext" ) ),
+ $wgTitle->getFullUrl() );
+ $feed->outHeader();
+ foreach( $rows as $obj ) {
+ $title = Title::makeTitle( $obj->rc_namespace, $obj->rc_title );
+ $item = new FeedItem(
+ $title->getPrefixedText(),
+ htmlspecialchars( $obj->rc_comment ),
+ $title->getFullURL(),
+ $obj->rc_timestamp,
+ $obj->rc_user_text );
+ $feed->outItem( $item );
}
-
- if ( ! ( $hideminor && $obj->rc_minor ) ) {
- $rc = RecentChange::newFromRow( $obj );
- $s .= $sk->recentChangesLine( $rc, !empty( $obj->wl_user ) );
- --$limit;
+ $feed->outFooter();
+ } else {
+ $wgOut->setSyndicated( true );
+ $s = $sk->beginRecentChangesList();
+ foreach( $rows as $obj ){
+ if( $limit == 0) {
+ break;
+ }
+
+ if ( ! ( $hideminor && $obj->rc_minor ) ) {
+ $rc = RecentChange::newFromRow( $obj );
+ $s .= $sk->recentChangesLine( $rc, !empty( $obj->wl_user ) );
+ --$limit;
+ }
}
+ $s .= $sk->endRecentChangesList();
+ $wgOut->addHTML( $s );
}
- $s .= $sk->endRecentChangesList();
-
wfFreeResult( $res );
- $wgOut->addHTML( $s );
}
function rcCountLink( $lim, $d, $page="Recentchanges", $more="" )
"Asksql" => "Query the database",
"Allmessages" => "All system messages",
"Undelete" => "Restore deleted pages",
- "Makesysop" => "Turn a user into a sysop"
+ "Makesysop" => "Turn a user into a sysop",
+ "Import" => "Import a page with history",
);
/* private */ $wgDeveloperSpecialPagesEn = array(
# Thumbnails
"thumbnail-more" => "Enlarge",
-"missingimage" => "<b>Missing image</b><br><i>$1</i>\n"
-
-
+"missingimage" => "<b>Missing image</b><br><i>$1</i>\n",
+
+# Special:Import
+"import" => "Import pages",
+"importtext" => "Blah blah blah",
+"importfailed" => "Import failed: $1",
+"importnotext" => "Empty or no text",
+"importsuccess" => "Import succeeded!",
);
#--------------------------------------------------------------------------