MediaWiki fundraising/REL1_35
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 public function __construct(
60 $title, $description, $url, $date = '', $author = '', $comments = ''
61 ) {
62 $this->title = $title;
63 $this->description = $description;
64 $this->url = $url;
65 $this->uniqueId = $url;
66 $this->date = $date;
67 $this->author = $author;
68 $this->comments = $comments;
69 }
70
77 public function xmlEncode( $string ) {
78 $string = str_replace( "\r\n", "\n", $string );
79 $string = preg_replace( '/[\x00-\x08\x0b\x0c\x0e-\x1f]/', '', $string );
80 return htmlspecialchars( $string );
81 }
82
87 public function getUniqueID() {
88 $id = $this->getUniqueIdUnescaped();
89 if ( $id ) {
90 return $this->xmlEncode( $id );
91 }
92 }
93
98 public function getUniqueIdUnescaped() {
99 if ( $this->uniqueId ) {
100 return wfExpandUrl( $this->uniqueId, PROTO_CURRENT );
101 }
102 }
103
110 public function setUniqueId( $uniqueId, $rssIsPermalink = false ) {
111 $this->uniqueId = $uniqueId;
112 $this->rssIsPermalink = $rssIsPermalink;
113 }
114
120 public function getTitle() {
121 return $this->xmlEncode( $this->title );
122 }
123
129 public function getUrl() {
130 return $this->xmlEncode( $this->url );
131 }
132
137 public function getUrlUnescaped() {
138 return $this->url;
139 }
140
146 public function getDescription() {
147 return $this->xmlEncode( $this->description );
148 }
149
155 public function getDescriptionUnescaped() {
156 return $this->description;
157 }
158
164 public function getLanguage() {
165 global $wgLanguageCode;
166 return LanguageCode::bcp47( $wgLanguageCode );
167 }
168
174 public function getDate() {
175 return $this->date;
176 }
177
183 public function getAuthor() {
184 return $this->xmlEncode( $this->author );
185 }
186
192 public function getAuthorUnescaped() {
193 return $this->author;
194 }
195
201 public function getComments() {
202 return $this->xmlEncode( $this->comments );
203 }
204
210 public function getCommentsUnescaped() {
211 return $this->comments;
212 }
213
220 public static function stripComment( $text ) {
221 return preg_replace( '/\[\[([^]]*\|)?([^]]+)\]\]/', '\2', $text );
222 }
223
225}
$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:164
setUniqueId( $uniqueId, $rssIsPermalink=false)
Set the unique id of an item.
Definition FeedItem.php:110
getDescription()
Get the description of this item; already xml-encoded.
Definition FeedItem.php:146
$rssIsPermalink
Definition FeedItem.php:49
getDescriptionUnescaped()
Get the description of this item without any escaping.
Definition FeedItem.php:155
getCommentsUnescaped()
Get the comment of this item without any escaping.
Definition FeedItem.php:210
getTitle()
Get the title of this item; already xml-encoded.
Definition FeedItem.php:120
getDate()
Get the date of this item.
Definition FeedItem.php:174
getUniqueIdUnescaped()
Get the unique id of this item, without any escaping.
Definition FeedItem.php:98
Title $title
Definition FeedItem.php:35
static stripComment( $text)
Quickie hack... strip out wikilinks to more legible form from the comment.
Definition FeedItem.php:220
getAuthor()
Get the author of this item; already xml-encoded.
Definition FeedItem.php:183
xmlEncode( $string)
Encode $string so that it can be safely embedded in a XML document.
Definition FeedItem.php:77
getComments()
Get the comment of this item; already xml-encoded.
Definition FeedItem.php:201
getAuthorUnescaped()
Get the author of this item without any escaping.
Definition FeedItem.php:192
getUrlUnescaped()
Get the URL of this item without any escaping.
Definition FeedItem.php:137
__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:87
getUrl()
Get the URL of this item; already xml-encoded.
Definition FeedItem.php:129
Represents a title within MediaWiki.
Definition Title.php:42
const PROTO_CURRENT
Definition Defines.php:212