From: Brion Vibber Date: Fri, 19 Mar 2004 05:31:18 +0000 (+0000) Subject: Some more RSS syndication work. tags now included; Special:Newpages X-Git-Tag: 1.3.0beta1~774 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=9729a6d8deb543f7326a4d0579c96167be6ddde4;p=lhc%2Fweb%2Fwiklou.git Some more RSS syndication work. tags now included; Special:Newpages includes page text (incomplete); preliminary feed support for Recentchanges; added RSS feed link next to printable link (incomplete). --- diff --git a/includes/Feed.php b/includes/Feed.php index 248ba620e7..c7dd64cfec 100644 --- a/includes/Feed.php +++ b/includes/Feed.php @@ -1,4 +1,23 @@ +# 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", @@ -10,12 +29,14 @@ class FeedItem { 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... */ @@ -43,6 +64,9 @@ class FeedItem { function getDate() { return $this->Date; } + function getAuthor() { + return $this->xmlEncode( $this->Author ); + } } class ChannelFeed extends FeedItem { @@ -66,6 +90,7 @@ class RSSFeed extends ChannelFeed { function outHeader() { global $wgVersion; + header( "Content-type: application/xml; charset=UTF-8" ); print '<' . '?xml version="1.0" encoding="utf-8"?' . ">\n"; ?> @@ -85,6 +110,7 @@ class RSSFeed extends ChannelFeed { getUrl() ?> getDescription() ?> getDate() ) { ?>formatTime( $item->getDate() ) ?> + getAuthor() ) { ?>getAuthor() ?> 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; } diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 62c5c7f1a8..93a13bf17d 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -42,14 +42,14 @@ class QueryPage { # 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; @@ -141,23 +141,39 @@ class QueryPage { $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 = "

" . htmlspecialchars( wfMsg( "summary" ) ) . ": " . $text . "

\n
\n
" . + nl2br( $row->cur_text ) . "
";; + } + 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(); diff --git a/includes/Skin.php b/includes/Skin.php index cd338b7abb..ffb671f9bb 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1,4 +1,7 @@ printableLink(); if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ; @@ -476,17 +479,22 @@ class Skin { 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 = "" . wfMsg( "printableversion" ) . ""; + if( $wgOut->isSyndicated() ) { + foreach( $wgFeedClasses as $format => $class ) { + $s .= " | {$format}"; + } + } return $s; } diff --git a/includes/SpecialNewpages.php b/includes/SpecialNewpages.php index f142a20f8d..86f46d46fa 100644 --- a/includes/SpecialNewpages.php +++ b/includes/SpecialNewpages.php @@ -14,7 +14,7 @@ class NewPagesPage extends QueryPage { 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}"; } diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index 732115addf..46a57071a4 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -1,11 +1,17 @@ getVal( "feed" ); + $feeding = ( $feedFormat == "rss" ); + if( $par ) { $bits = preg_split( '/\s*,\s*/', trim( $par ) ); if( in_array( "hidebots", $bits ) ) $hidebots = 1; @@ -119,22 +125,43 @@ function wfSpecialRecentchanges( $par ) $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="" ) diff --git a/languages/Language.php b/languages/Language.php index c580b14a23..ba4c587d31 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -406,7 +406,8 @@ $wgLanguageNamesEn =& $wgLanguageNames; "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( @@ -1405,9 +1406,14 @@ amusement.", # Thumbnails "thumbnail-more" => "Enlarge", -"missingimage" => "Missing image
$1\n" - - +"missingimage" => "Missing image
$1\n", + +# Special:Import +"import" => "Import pages", +"importtext" => "Blah blah blah", +"importfailed" => "Import failed: $1", +"importnotext" => "Empty or no text", +"importsuccess" => "Import succeeded!", ); #--------------------------------------------------------------------------