* @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
}
/**
- * 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)
}
/**
- * Get the title of this item
+ * Get the date of this item
*
* @return string
*/
/**
* 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 ) {
* 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";
}
}
* @param FeedItem $item Item to be output
*/
function outItem( $item ) {
+ // @codingStandardsIgnoreStart Ignore long lines and formatting issues.
?>
<item>
<title><?php print $item->getTitle(); ?></title>
<?php if ( $item->getComments() ) { ?><comments><?php print wfExpandUrl( $item->getComments(), PROTO_CURRENT ); ?></comments><?php }?>
</item>
<?php
+ // @codingStandardsIgnoreEnd
}
/**
class AtomFeed extends ChannelFeed {
/**
* @todo document
+ * @param string|int $ts
* @return string
*/
function formatTime( $ts ) {
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>
<generator>MediaWiki <?php print $wgVersion ?></generator>
<?php
+ // @codingStandardsIgnoreEnd
}
/**
* 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() );
}
*/
function outItem( $item ) {
global $wgMimeType;
+ // @codingStandardsIgnoreStart Ignore long lines and formatting issues.
?>
<entry>
<id><?php print $item->getUniqueId(); ?></id>
*/
function outFooter() {?>
</feed><?php
+ // @codingStandardsIgnoreEnd
}
}