Merge "API: Improve handling of interwiki redirects when resolving"
[lhc/web/wiklou.git] / includes / Feed.php
index 1b99519..2fdfa42 100644 (file)
  * @ingroup Feed
  */
 class FeedItem {
-       /**
-        * @var Title
-        */
-       var $title;
+       /** @var Title */
+       public $title;
+
+       public $description;
+
+       public $url;
+
+       public $date;
+
+       public $author;
 
-       var $description;
-       var $url;
-       var $date;
-       var $author;
-       var $uniqueId;
-       var $comments;
-       var $rssIsPermalink = false;
+       public $uniqueId;
+
+       public $comments;
+
+       public $rssIsPermalink = false;
 
        /**
         * Constructor
@@ -93,7 +97,7 @@ class FeedItem {
        }
 
        /**
-        * set the unique id of an item
+        * Set the unique id of an item
         *
         * @param string $uniqueId Unique id for the item
         * @param bool $rssIsPermalink Set to true if the guid (unique id) is a permalink (RSS feeds only)
@@ -141,7 +145,7 @@ class FeedItem {
        }
 
        /**
-        * Get the title of this item
+        * Get the date of this item
         *
         * @return string
         */
@@ -170,7 +174,7 @@ class FeedItem {
        /**
         * Quickie hack... strip out wikilinks to more legible form from the comment.
         *
-        * @param string $text wikitext
+        * @param string $text Wikitext
         * @return string
         */
        public static function stripComment( $text ) {
@@ -238,28 +242,27 @@ abstract class ChannelFeed extends FeedItem {
         * Return an internet media type to be sent in the headers.
         *
         * @return string
-        * @private
         */
-       function contentType() {
+       private function contentType() {
                global $wgRequest;
+
                $ctype = $wgRequest->getVal( 'ctype', 'application/xml' );
-               $allowedctypes = array( 'application/xml', 'text/xml', 'application/rss+xml', 'application/atom+xml' );
+               $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.
-        * @private
+        * Output the initial XML headers.
         */
-       function outXmlHeader() {
-               global $wgStylePath, $wgStyleVersion;
-
+       protected function outXmlHeader() {
                $this->httpHeaders();
                echo '<?xml version="1.0"?>' . "\n";
-               echo '<?xml-stylesheet type="text/css" href="' .
-                       htmlspecialchars( wfExpandUrl( "$wgStylePath/common/feed.css?$wgStyleVersion", PROTO_CURRENT ) ) .
-                       '"?' . ">\n";
        }
 }
 
@@ -303,6 +306,7 @@ class RSSFeed extends ChannelFeed {
         * @param FeedItem $item Item to be output
         */
        function outItem( $item ) {
+               // @codingStandardsIgnoreStart Ignore long lines and formatting issues.
        ?>
                <item>
                        <title><?php print $item->getTitle(); ?></title>
@@ -314,6 +318,7 @@ class RSSFeed extends ChannelFeed {
                        <?php if ( $item->getComments() ) { ?><comments><?php print wfExpandUrl( $item->getComments(), PROTO_CURRENT ); ?></comments><?php }?>
                </item>
 <?php
+               // @codingStandardsIgnoreEnd
        }
 
        /**
@@ -334,6 +339,7 @@ class RSSFeed extends ChannelFeed {
 class AtomFeed extends ChannelFeed {
        /**
         * @todo document
+        * @param string|int $ts
         * @return string
         */
        function formatTime( $ts ) {
@@ -348,6 +354,7 @@ class AtomFeed extends ChannelFeed {
                global $wgVersion;
 
                $this->outXmlHeader();
+               // @codingStandardsIgnoreStart Ignore long lines and formatting issues.
                ?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="<?php print $this->getLanguage() ?>">
                <id><?php print $this->getFeedId() ?></id>
                <title><?php print $this->getTitle() ?></title>
@@ -358,6 +365,7 @@ class AtomFeed extends ChannelFeed {
                <generator>MediaWiki <?php print $wgVersion ?></generator>
 
 <?php
+               // @codingStandardsIgnoreEnd
        }
 
        /**
@@ -367,18 +375,16 @@ class AtomFeed extends ChannelFeed {
         * have to change the id? Maybe? Maybe not.
         *
         * @return string
-        * @private
         */
-       function getFeedId() {
+       private function getFeedId() {
                return $this->getSelfUrl();
        }
 
        /**
         * Atom 1.0 requests a self-reference to the feed.
         * @return string
-        * @private
         */
-       function getSelfUrl() {
+       private function getSelfUrl() {
                global $wgRequest;
                return htmlspecialchars( $wgRequest->getFullRequestURL() );
        }
@@ -389,6 +395,7 @@ class AtomFeed extends ChannelFeed {
         */
        function outItem( $item ) {
                global $wgMimeType;
+               // @codingStandardsIgnoreStart Ignore long lines and formatting issues.
        ?>
        <entry>
                <id><?php print $item->getUniqueId(); ?></id>
@@ -412,5 +419,6 @@ class AtomFeed extends ChannelFeed {
         */
        function outFooter() {?>
        </feed><?php
+               // @codingStandardsIgnoreEnd
        }
 }