MediaWiki REL1_34
FeedItem.php
Go to the documentation of this file.
1<?php
33class FeedItem {
35 public $title;
36
38
39 public $url;
40
41 public $date;
42
43 public $author;
44
45 public $uniqueId;
46
47 public $comments;
48
49 public $rssIsPermalink = false;
50
59 function __construct( $title, $description, $url, $date = '', $author = '', $comments = '' ) {
60 $this->title = $title;
61 $this->description = $description;
62 $this->url = $url;
63 $this->uniqueId = $url;
64 $this->date = $date;
65 $this->author = $author;
66 $this->comments = $comments;
67 }
68
75 public function xmlEncode( $string ) {
76 $string = str_replace( "\r\n", "\n", $string );
77 $string = preg_replace( '/[\x00-\x08\x0b\x0c\x0e-\x1f]/', '', $string );
78 return htmlspecialchars( $string );
79 }
80
85 public function getUniqueID() {
86 $id = $this->getUniqueIdUnescaped();
87 if ( $id ) {
88 return $this->xmlEncode( $id );
89 }
90 }
91
96 public function getUniqueIdUnescaped() {
97 if ( $this->uniqueId ) {
98 return wfExpandUrl( $this->uniqueId, PROTO_CURRENT );
99 }
100 }
101
108 public function setUniqueId( $uniqueId, $rssIsPermalink = false ) {
109 $this->uniqueId = $uniqueId;
110 $this->rssIsPermalink = $rssIsPermalink;
111 }
112
118 public function getTitle() {
119 return $this->xmlEncode( $this->title );
120 }
121
127 public function getUrl() {
128 return $this->xmlEncode( $this->url );
129 }
130
135 public function getUrlUnescaped() {
136 return $this->url;
137 }
138
144 public function getDescription() {
145 return $this->xmlEncode( $this->description );
146 }
147
153 public function getDescriptionUnescaped() {
154 return $this->description;
155 }
156
162 public function getLanguage() {
163 global $wgLanguageCode;
164 return LanguageCode::bcp47( $wgLanguageCode );
165 }
166
172 public function getDate() {
173 return $this->date;
174 }
175
181 public function getAuthor() {
182 return $this->xmlEncode( $this->author );
183 }
184
190 public function getAuthorUnescaped() {
191 return $this->author;
192 }
193
199 public function getComments() {
200 return $this->xmlEncode( $this->comments );
201 }
202
208 public function getCommentsUnescaped() {
209 return $this->comments;
210 }
211
218 public static function stripComment( $text ) {
219 return preg_replace( '/\[\[([^]]*\|)?([^]]+)\]\]/', '\2', $text );
220 }
222}
$wgLanguageCode
Site language code.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
A base class for outputting syndication feeds (e.g.
Definition FeedItem.php:33
getLanguage()
Get the language of this item.
Definition FeedItem.php:162
setUniqueId( $uniqueId, $rssIsPermalink=false)
Set the unique id of an item.
Definition FeedItem.php:108
getDescription()
Get the description of this item; already xml-encoded.
Definition FeedItem.php:144
$rssIsPermalink
Definition FeedItem.php:49
getDescriptionUnescaped()
Get the description of this item without any escaping.
Definition FeedItem.php:153
getCommentsUnescaped()
Get the comment of this item without any escaping.
Definition FeedItem.php:208
getTitle()
Get the title of this item; already xml-encoded.
Definition FeedItem.php:118
getDate()
Get the date of this item.
Definition FeedItem.php:172
getUniqueIdUnescaped()
Get the unique id of this item, without any escaping.
Definition FeedItem.php:96
Title $title
Definition FeedItem.php:35
static stripComment( $text)
Quickie hack... strip out wikilinks to more legible form from the comment.
Definition FeedItem.php:218
getAuthor()
Get the author of this item; already xml-encoded.
Definition FeedItem.php:181
xmlEncode( $string)
Encode $string so that it can be safely embedded in a XML document.
Definition FeedItem.php:75
getComments()
Get the comment of this item; already xml-encoded.
Definition FeedItem.php:199
getAuthorUnescaped()
Get the author of this item without any escaping.
Definition FeedItem.php:190
getUrlUnescaped()
Get the URL of this item without any escaping.
Definition FeedItem.php:135
__construct( $title, $description, $url, $date='', $author='', $comments='')
Definition FeedItem.php:59
getUniqueID()
Get the unique id of this item; already xml-encoded.
Definition FeedItem.php:85
getUrl()
Get the URL of this item; already xml-encoded.
Definition FeedItem.php:127
Represents a title within MediaWiki.
Definition Title.php:42
const PROTO_CURRENT
Definition Defines.php:211