X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FFeed.php;h=512057d9371b662553f6813f6533da0735d98b18;hb=3857496fe2bda374229d0652a9cf51817cab165b;hp=0f5febd61ac0d78640ca173b3b910735a4ad6074;hpb=fb2064aed1478e80b773d611b90dd40af286eabc;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/Feed.php b/includes/Feed.php
index 0f5febd61a..512057d937 100644
--- a/includes/Feed.php
+++ b/includes/Feed.php
@@ -1,39 +1,36 @@
# 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
+# 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.
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# http://www.gnu.org/copyleft/gpl.html
/**
+ * Basic support for outputting syndication feeds in RSS, other formats.
* Contain a feed class as well as classes to build rss / atom ... feeds
* Available feeds are defined in Defines.php
- * @package MediaWiki
*/
-
/**
- * @todo document
- * @package MediaWiki
+ * A base class for basic support for outputting syndication feeds in RSS and other formats.
*/
class FeedItem {
/**#@+
* @var string
- * @access private
+ * @private
*/
var $Title = 'Wiki';
var $Description = '';
@@ -41,11 +38,12 @@ class FeedItem {
var $Date = '';
var $Author = '';
/**#@-*/
-
+
/**#@+
* @todo document
+ * @param $Url URL uniquely designating the item.
*/
- function FeedItem( $Title, $Description, $Url, $Date = '', $Author = '', $Comments = '' ) {
+ function __construct( $Title, $Description, $Url, $Date = '', $Author = '', $Comments = '' ) {
$this->Title = $Title;
$this->Description = $Description;
$this->Url = $Url;
@@ -53,7 +51,7 @@ class FeedItem {
$this->Author = $Author;
$this->Comments = $Comments;
}
-
+
/**
* @static
*/
@@ -62,7 +60,7 @@ class FeedItem {
$string = preg_replace( '/[\x00-\x08\x0b\x0c\x0e-\x1f]/', '', $string );
return htmlspecialchars( $string );
}
-
+
function getTitle() { return $this->xmlEncode( $this->Title ); }
function getUrl() { return $this->xmlEncode( $this->Url ); }
function getDescription() { return $this->xmlEncode( $this->Description ); }
@@ -77,22 +75,21 @@ class FeedItem {
}
/**
- * @todo document
- * @package MediaWiki
+ * @todo document (needs one-sentence top-level class description).
*/
class ChannelFeed extends FeedItem {
/**#@+
* Abstract function, override!
* @abstract
*/
-
+
/**
* Generate Header of the feed
*/
function outHeader() {
# print "";
}
-
+
/**
* Generate an item
* @param $item
@@ -100,7 +97,7 @@ class ChannelFeed extends FeedItem {
function outItem( $item ) {
# print "...";
}
-
+
/**
* Generate Footer of the feed
*/
@@ -108,7 +105,7 @@ class ChannelFeed extends FeedItem {
# print "";
}
/**#@-*/
-
+
/**
* Setup and send HTTP headers. Don't send any content;
* content might end up being cached and re-sent with
@@ -117,24 +114,24 @@ class ChannelFeed extends FeedItem {
* This should be called from the outHeader() method,
* but can also be called separately.
*
- * @access public
+ * @public
*/
function httpHeaders() {
global $wgOut;
-
+
# We take over from $wgOut, excepting its cache header info
$wgOut->disable();
$mimetype = $this->contentType();
header( "Content-type: $mimetype; charset=UTF-8" );
$wgOut->sendCacheControl();
-
+
}
-
+
/**
* Return an internet media type to be sent in the headers.
*
* @return string
- * @access private
+ * @private
*/
function contentType() {
global $wgRequest;
@@ -142,26 +139,25 @@ class ChannelFeed extends FeedItem {
$allowedctypes = array('application/xml','text/xml','application/rss+xml','application/atom+xml');
return (in_array($ctype, $allowedctypes) ? $ctype : 'application/xml');
}
-
+
/**
* Output the initial XML headers with a stylesheet for legibility
* if someone finds it in a browser.
- * @access private
+ * @private
*/
function outXmlHeader() {
- global $wgServer, $wgStylePath;
-
+ global $wgStylePath, $wgStyleVersion;
+
$this->httpHeaders();
echo '' . "\n";
echo '\n";
+ htmlspecialchars( wfExpandUrl( "$wgStylePath/common/feed.css?$wgStyleVersion" ) ) .
+ '"?' . ">\n";
}
}
/**
* Generate a RSS feed
- * @todo document
- * @package MediaWiki
*/
class RSSFeed extends ChannelFeed {
@@ -173,13 +169,13 @@ class RSSFeed extends ChannelFeed {
function formatTime( $ts ) {
return gmdate( 'D, d M Y H:i:s \G\M\T', wfTimestamp( TS_UNIX, $ts ) );
}
-
+
/**
* Ouput an RSS 2.0 header
*/
function outHeader() {
global $wgVersion;
-
+
$this->outXmlHeader();
?>
@@ -191,7 +187,7 @@ class RSSFeed extends ChannelFeed {
formatTime( wfTimestampNow() ) ?>
outXmlHeader();
- ?>
+ ?>getFeedId() ?>getTitle() ?>
@@ -248,34 +242,36 @@ class AtomFeed extends ChannelFeed {
formatTime( wfTimestampNow() ) ?>ZgetDescription() ?>MediaWiki
-
+
getSelfUrl();
}
-
+
/**
* Atom 1.0 requests a self-reference to the feed.
* @return string
- * @access private
+ * @private
*/
function getSelfUrl() {
global $wgRequest;
return htmlspecialchars( $wgRequest->getFullRequestURL() );
}
-
+
/**
- * @todo document
+ * Output a given item.
+ * @param $item
*/
function outItem( $item ) {
global $wgMimeType;
@@ -287,7 +283,7 @@ class AtomFeed extends ChannelFeed {
getDate() ) { ?>
formatTime( $item->getDate() ) ?>Z
-
+
getDescription() ?>
getAuthor() ) { ?>getAuthor() ?>
@@ -296,13 +292,11 @@ class AtomFeed extends ChannelFeed {
getComments() ) { ?>getComments() ?>
*/
}
-
+
/**
- * @todo document
+ * Outputs the footer for Atom 1.0 feed (basicly '\').
*/
function outFooter() {?>