2010-11-04 23:19:00 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-06 00:05:34 +00:00
|
|
|
namespace MediaWiki\Extension\RSS;
|
|
|
|
|
|
|
|
use DOMDocument;
|
2020-02-07 03:52:27 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2024-06-10 18:17:47 +00:00
|
|
|
use MediaWiki\Parser\Parser;
|
2024-01-05 20:23:30 +00:00
|
|
|
use MediaWiki\Parser\Sanitizer;
|
|
|
|
use MediaWiki\Status\Status;
|
2023-08-19 04:18:50 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2022-04-06 00:05:34 +00:00
|
|
|
use MWHttpRequest;
|
2022-12-27 12:16:31 +00:00
|
|
|
use ParserFactory;
|
2022-04-06 00:05:34 +00:00
|
|
|
use PPFrame;
|
|
|
|
use TextContent;
|
|
|
|
use WANObjectCache;
|
2022-02-24 21:17:28 +00:00
|
|
|
use Wikimedia\AtEase\AtEase;
|
2020-02-07 03:52:27 +00:00
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
class RSSParser {
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var int */
|
2010-11-04 23:19:00 +00:00
|
|
|
protected $maxheads = 32;
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var string */
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
protected $date = "Y-m-d H:i:s";
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var int */
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
protected $ItemMaxLength = 200;
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var bool */
|
2010-11-04 23:19:00 +00:00
|
|
|
protected $reversed = false;
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var string[] */
|
2017-05-20 21:41:06 +00:00
|
|
|
protected $highlight = [];
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var string[] */
|
2017-05-20 21:41:06 +00:00
|
|
|
protected $filter = [];
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var string[] */
|
2017-05-20 21:41:06 +00:00
|
|
|
protected $filterOut = [];
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var string */
|
2010-11-04 23:19:00 +00:00
|
|
|
protected $itemTemplate;
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var string */
|
2010-11-04 23:19:00 +00:00
|
|
|
protected $url;
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var string */
|
2010-11-04 23:19:00 +00:00
|
|
|
protected $etag;
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var int */
|
2010-11-04 23:19:00 +00:00
|
|
|
protected $lastModified;
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var DOMDocument */
|
2010-11-04 23:19:00 +00:00
|
|
|
protected $xml;
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var string[] */
|
2017-05-20 21:41:06 +00:00
|
|
|
protected $displayFields = [ 'author', 'title', 'encodedContent', 'description' ];
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var string[] */
|
2015-06-01 23:15:49 +00:00
|
|
|
protected $stripItems;
|
2024-08-20 20:15:24 +00:00
|
|
|
/** @var string */
|
2015-06-01 23:15:49 +00:00
|
|
|
protected $markerString;
|
|
|
|
|
2020-02-07 03:52:27 +00:00
|
|
|
/**
|
|
|
|
* @var WANObjectCache
|
|
|
|
*/
|
|
|
|
private $cache;
|
|
|
|
|
2022-12-27 12:16:31 +00:00
|
|
|
/**
|
|
|
|
* @var ParserFactory
|
|
|
|
*/
|
|
|
|
private $parserFactory;
|
|
|
|
|
2012-01-28 17:05:20 +00:00
|
|
|
/**
|
|
|
|
* @var RSSData
|
|
|
|
*/
|
|
|
|
public $rss;
|
|
|
|
|
2012-10-07 10:11:49 +00:00
|
|
|
/**
|
2022-02-12 00:20:00 +00:00
|
|
|
* @var MWHttpRequest
|
2012-10-07 10:11:49 +00:00
|
|
|
*/
|
2010-11-04 23:19:00 +00:00
|
|
|
public $client;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience function that takes a space-separated string and returns an array of words
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param string $str list of words
|
|
|
|
* @return array words found
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
|
|
|
private static function explodeOnSpaces( $str ) {
|
|
|
|
$found = preg_split( '# +#', $str );
|
2017-05-20 21:41:06 +00:00
|
|
|
return is_array( $found ) ? $found : [];
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Take a bit of WikiText that looks like
|
|
|
|
* <rss max=5>http://example.com/</rss>
|
|
|
|
* and return an object that can produce rendered output.
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param string $url
|
|
|
|
* @param array $args
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
2018-11-02 10:23:45 +00:00
|
|
|
public function __construct( $url, $args ) {
|
2024-03-11 21:44:41 +00:00
|
|
|
global $wgRSSDateDefaultFormat, $wgRSSItemMaxLength;
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
$this->url = $url;
|
|
|
|
|
2022-04-28 12:01:18 +00:00
|
|
|
// Quote marks to prevent XSS (T307028)
|
|
|
|
$this->markerString = "'\"" . wfRandomString( 32 );
|
2017-05-20 21:41:06 +00:00
|
|
|
$this->stripItems = [];
|
2020-02-07 03:52:27 +00:00
|
|
|
$this->cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
|
2022-12-27 12:16:31 +00:00
|
|
|
$this->parserFactory = MediaWikiServices::getInstance()->getParserFactory();
|
2015-06-01 23:15:49 +00:00
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
# Get max number of headlines from argument-array
|
|
|
|
if ( isset( $args['max'] ) ) {
|
|
|
|
$this->maxheads = $args['max'];
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get reverse flag from argument array
|
|
|
|
if ( isset( $args['reverse'] ) ) {
|
|
|
|
$this->reversed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get date format from argument array
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
# or use a default value
|
2012-10-07 10:11:49 +00:00
|
|
|
# @todo FIXME: not used yet
|
2012-02-18 07:35:23 +00:00
|
|
|
if ( isset( $args['date'] ) ) {
|
2010-11-04 23:19:00 +00:00
|
|
|
$this->date = $args['date'];
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
} elseif ( isset( $wgRSSDateDefaultFormat ) ) {
|
|
|
|
$this->date = $wgRSSDateDefaultFormat;
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
Revert r111347, r111348, r111350, r111351, r111515, r111816, r112243, r112251, r112308, r112314, r112315, r112465, r112467, r112709, r113297, r113508, r113510, r113524, r113546, r114168. Unreviewed revisions in the RSS extension and their dependencies.
All of these revisions are tagged with 'gerritmigration' and will be resubmitted into Gerrit after the Gerrit switchover. See also http://lists.wikimedia.org/pipermail/wikitech-l/2012-March/059124.html
2012-03-21 18:40:06 +00:00
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
# Get highlight terms from argument array
|
|
|
|
if ( isset( $args['highlight'] ) ) {
|
|
|
|
# mapping to lowercase here so the regex can be case insensitive below.
|
|
|
|
$this->highlight = self::explodeOnSpaces( $args['highlight'] );
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get filter terms from argument array
|
|
|
|
if ( isset( $args['filter'] ) ) {
|
|
|
|
$this->filter = self::explodeOnSpaces( $args['filter'] );
|
|
|
|
}
|
|
|
|
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
# Get a maximal length for item texts
|
|
|
|
if ( isset( $args['item-max-length'] ) ) {
|
|
|
|
$this->ItemMaxLength = $args['item-max-length'];
|
|
|
|
} elseif ( is_numeric( $wgRSSItemMaxLength ) ) {
|
|
|
|
$this->ItemMaxLength = $wgRSSItemMaxLength;
|
|
|
|
}
|
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
if ( isset( $args['filterout'] ) ) {
|
|
|
|
$this->filterOut = self::explodeOnSpaces( $args['filterout'] );
|
|
|
|
}
|
|
|
|
|
2011-08-15 21:52:08 +00:00
|
|
|
// 'template' is the pagename of a user's itemTemplate including
|
|
|
|
// a further pagename for the feedTemplate
|
|
|
|
// In that way everything is handled via these two pages
|
|
|
|
// and no default pages or templates are used.
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
2011-08-15 21:52:08 +00:00
|
|
|
// 'templatename' is an optional pagename of a user's feedTemplate
|
|
|
|
// In that way it substitutes $1 (default: RSSPost) in MediaWiki:Rss-item
|
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
if ( isset( $args['template'] ) ) {
|
2011-08-15 21:52:08 +00:00
|
|
|
$itemTemplateTitleObject = Title::newFromText( $args['template'], NS_TEMPLATE );
|
2016-09-19 17:43:21 +00:00
|
|
|
|
|
|
|
if ( $itemTemplateTitleObject->exists() ) {
|
2021-12-16 21:09:09 +00:00
|
|
|
$itemTemplatePageObject = MediaWikiServices::getInstance()
|
|
|
|
->getWikiPageFactory()
|
|
|
|
->newFromTitle( $itemTemplateTitleObject );
|
2016-09-19 17:43:21 +00:00
|
|
|
$itemTemplateContentObject = $itemTemplatePageObject->getContent();
|
|
|
|
|
|
|
|
if ( $itemTemplateContentObject instanceof TextContent ) {
|
2019-03-27 14:55:23 +00:00
|
|
|
$this->itemTemplate = $itemTemplateContentObject->getText();
|
2016-09-19 17:43:21 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-04 23:19:00 +00:00
|
|
|
} else {
|
2011-08-15 21:52:08 +00:00
|
|
|
if ( isset( $args['templatename'] ) ) {
|
|
|
|
$feedTemplatePagename = $args['templatename'];
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// compatibility patch for rss extension
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
2012-01-20 21:46:31 +00:00
|
|
|
$feedTemplatePagename = 'RSSPost';
|
2011-08-15 21:52:08 +00:00
|
|
|
$feedTemplateTitleObject = Title::newFromText( $feedTemplatePagename, NS_TEMPLATE );
|
|
|
|
|
|
|
|
if ( !$feedTemplateTitleObject->exists() ) {
|
|
|
|
$feedTemplatePagename = Title::makeTitleSafe( NS_MEDIAWIKI, 'Rss-feed' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MediaWiki:Rss-item = {{ feedTemplatePagename | title = {{{title}}} | ... }}
|
|
|
|
|
|
|
|
// if the attribute parameter templatename= is not present
|
|
|
|
// then it defaults to
|
2017-05-20 21:41:06 +00:00
|
|
|
// {{ Template:RSSPost | title = {{{title}}} | ... }}
|
2017-06-20 07:20:13 +00:00
|
|
|
// - if Template:RSSPost exists from pre-1.9 versions
|
2017-05-20 21:41:06 +00:00
|
|
|
// {{ MediaWiki:Rss-feed | title = {{{title}}} | ... }}
|
2017-06-20 07:20:13 +00:00
|
|
|
// - otherwise
|
2011-08-15 21:52:08 +00:00
|
|
|
|
2012-10-07 10:11:49 +00:00
|
|
|
$this->itemTemplate = wfMessage( 'rss-item', $feedTemplatePagename )->plain();
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-02 10:23:45 +00:00
|
|
|
private function insertStripItem( $item ) {
|
2015-06-01 23:15:49 +00:00
|
|
|
$this->stripItems[] = $item;
|
|
|
|
$itemIndex = count( $this->stripItems ) - 1;
|
|
|
|
return "{$this->markerString}-{$itemIndex}-{$this->markerString}";
|
|
|
|
}
|
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
/**
|
2010-11-05 00:59:28 +00:00
|
|
|
* Return RSS object for the given URL, maintaining caching.
|
|
|
|
*
|
|
|
|
* NOTES ON RETRIEVING REMOTE FILES:
|
|
|
|
* No attempt will be made to fetch remote files if there is something in cache.
|
|
|
|
*
|
|
|
|
* NOTES ON FAILED REQUESTS:
|
|
|
|
* If there is an HTTP error while fetching an RSS object, the cached version
|
2010-11-16 23:21:36 +00:00
|
|
|
* will be returned, if it exists.
|
2010-11-05 00:59:28 +00:00
|
|
|
*
|
2011-01-08 01:33:42 +00:00
|
|
|
* @return Status object
|
2010-11-05 00:59:28 +00:00
|
|
|
*/
|
2018-11-02 10:23:45 +00:00
|
|
|
public function fetch() {
|
2010-11-04 23:19:00 +00:00
|
|
|
if ( !isset( $this->url ) ) {
|
|
|
|
return Status::newFatal( 'rss-fetch-nourl' );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Flow
|
|
|
|
// 1. check cache
|
|
|
|
// 2. if there is a hit, make sure its fresh
|
|
|
|
// 3. if cached obj fails freshness check, fetch remote
|
|
|
|
// 4. if remote fails, return stale object, or error
|
2020-02-07 03:52:27 +00:00
|
|
|
$key = $this->cache->makeKey( 'rss-fetch', $this->url );
|
2010-11-04 23:19:00 +00:00
|
|
|
$cachedFeed = $this->loadFromCache( $key );
|
|
|
|
if ( $cachedFeed !== false ) {
|
|
|
|
wfDebugLog( 'RSS', 'Outputting cached feed for ' . $this->url );
|
|
|
|
return Status::newGood();
|
|
|
|
}
|
2010-11-05 00:59:28 +00:00
|
|
|
wfDebugLog( 'RSS', 'Cache Failed, fetching ' . $this->url . ' from remote.' );
|
2010-11-04 23:19:00 +00:00
|
|
|
|
2022-04-06 00:05:34 +00:00
|
|
|
return $this->fetchRemote( $key );
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the URL from the cache
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param string $key lookup key to associate with this item
|
2017-07-26 21:02:17 +00:00
|
|
|
* @return bool
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
|
|
|
protected function loadFromCache( $key ) {
|
2020-02-07 03:52:27 +00:00
|
|
|
global $wgRSSCacheCompare;
|
2010-11-04 23:19:00 +00:00
|
|
|
|
2020-02-07 03:52:27 +00:00
|
|
|
$data = $this->cache->get( $key );
|
2010-11-13 19:16:39 +00:00
|
|
|
if ( !is_array( $data ) ) {
|
2010-11-04 23:19:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-03-11 21:44:41 +00:00
|
|
|
[ $etag, $lastModified, $rss ] = $data;
|
2010-11-04 23:19:00 +00:00
|
|
|
if ( !isset( $rss->items ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
wfDebugLog( 'RSS', "Got '$key' from cache" );
|
|
|
|
|
|
|
|
# Now that we've verified that we got useful data, keep it around.
|
|
|
|
$this->rss = $rss;
|
|
|
|
$this->etag = $etag;
|
|
|
|
$this->lastModified = $lastModified;
|
|
|
|
|
|
|
|
// We only care if $wgRSSCacheCompare is > 0
|
|
|
|
if ( $wgRSSCacheCompare && time() - $wgRSSCacheCompare > $lastModified ) {
|
2010-11-05 00:59:28 +00:00
|
|
|
wfDebugLog( 'RSS', 'Content is old enough that we need to check cached content' );
|
2010-11-04 23:19:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-11-13 19:16:39 +00:00
|
|
|
* Store these objects (i.e. etag, lastModified, and RSS) in the cache.
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param string $key lookup key to associate with this item
|
2017-07-26 21:02:17 +00:00
|
|
|
* @return bool
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
|
|
|
protected function storeInCache( $key ) {
|
2020-02-07 03:52:27 +00:00
|
|
|
global $wgRSSCacheAge;
|
2010-11-04 23:19:00 +00:00
|
|
|
|
|
|
|
if ( !isset( $this->rss ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-02-07 03:52:27 +00:00
|
|
|
|
|
|
|
$this->cache->set(
|
|
|
|
$key,
|
2017-05-20 21:41:06 +00:00
|
|
|
[ $this->etag, $this->lastModified, $this->rss ],
|
2020-02-07 03:52:27 +00:00
|
|
|
$wgRSSCacheAge
|
|
|
|
);
|
|
|
|
|
|
|
|
wfDebugLog( 'RSS', "Stored '$key' as in cache" );
|
2010-11-04 23:19:00 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve a feed.
|
2020-02-07 03:52:27 +00:00
|
|
|
* @param string $key Cache key
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param array $headers headers to send along with the request
|
2010-11-04 23:19:00 +00:00
|
|
|
* @return Status object
|
|
|
|
*/
|
2017-05-20 21:41:06 +00:00
|
|
|
protected function fetchRemote( $key, array $headers = [] ) {
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
global $wgRSSFetchTimeout, $wgRSSUserAgent, $wgRSSProxy,
|
|
|
|
$wgRSSUrlNumberOfAllowedRedirects;
|
2010-11-04 23:19:00 +00:00
|
|
|
|
|
|
|
if ( $this->etag ) {
|
|
|
|
wfDebugLog( 'RSS', 'Used etag: ' . $this->etag );
|
|
|
|
$headers['If-None-Match'] = $this->etag;
|
|
|
|
}
|
|
|
|
if ( $this->lastModified ) {
|
2019-01-08 17:35:47 +00:00
|
|
|
$lastModified = gmdate( 'r', $this->lastModified );
|
|
|
|
wfDebugLog( 'RSS', "Used last modified: $lastModified" );
|
|
|
|
$headers['If-Modified-Since'] = $lastModified;
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
|
|
|
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
/**
|
|
|
|
* 'noProxy' can conditionally be set as shown in the commented
|
|
|
|
* example below; in HttpRequest 'noProxy' takes precedence over
|
|
|
|
* any value of 'proxy' and disables the use of a proxy.
|
|
|
|
*
|
|
|
|
* This is useful if you run the wiki in an intranet and need to
|
|
|
|
* access external feed urls through a proxy but internal feed
|
|
|
|
* urls must be accessed without a proxy.
|
|
|
|
*
|
|
|
|
* The general handling of such cases will be subject of a
|
|
|
|
* forthcoming version.
|
|
|
|
*/
|
|
|
|
|
2017-05-20 21:41:06 +00:00
|
|
|
$url = $this->url;
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
$noProxy = !isset( $wgRSSProxy );
|
|
|
|
|
|
|
|
// Example for disabling proxy use for certain urls
|
|
|
|
// $noProxy = preg_match( '!\.internal\.example\.com$!i', parse_url( $url, PHP_URL_HOST ) );
|
|
|
|
|
|
|
|
if ( isset( $wgRSSUrlNumberOfAllowedRedirects )
|
|
|
|
&& is_numeric( $wgRSSUrlNumberOfAllowedRedirects ) ) {
|
|
|
|
$maxRedirects = $wgRSSUrlNumberOfAllowedRedirects;
|
|
|
|
} else {
|
|
|
|
$maxRedirects = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we set followRedirects intentionally to true to see error messages
|
|
|
|
// in cases where the maximum number of redirects is reached
|
2020-06-07 10:33:40 +00:00
|
|
|
$client = MediaWikiServices::getInstance()->getHttpRequestFactory()->create( $url,
|
2017-05-20 21:41:06 +00:00
|
|
|
[
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
'timeout' => $wgRSSFetchTimeout,
|
|
|
|
'followRedirects' => true,
|
|
|
|
'maxRedirects' => $maxRedirects,
|
|
|
|
'proxy' => $wgRSSProxy,
|
|
|
|
'noProxy' => $noProxy,
|
|
|
|
'userAgent' => $wgRSSUserAgent,
|
2020-06-07 10:33:40 +00:00
|
|
|
],
|
|
|
|
__METHOD__
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
);
|
2010-11-25 12:38:25 +00:00
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
foreach ( $headers as $header => $value ) {
|
|
|
|
$client->setHeader( $header, $value );
|
|
|
|
}
|
|
|
|
|
|
|
|
$fetch = $client->execute();
|
|
|
|
$this->client = $client;
|
|
|
|
|
|
|
|
if ( !$fetch->isGood() ) {
|
2018-05-07 18:09:56 +00:00
|
|
|
wfDebug( 'RSS', 'Request Failed: ' . Status::wrap( $fetch )->getWikitext() );
|
2010-11-04 23:19:00 +00:00
|
|
|
return $fetch;
|
|
|
|
}
|
|
|
|
|
2022-04-06 00:05:34 +00:00
|
|
|
return $this->responseToXML( $key );
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
|
|
|
|
2013-09-03 04:55:09 +00:00
|
|
|
/**
|
|
|
|
* @see https://bugzilla.wikimedia.org/show_bug.cgi?id=34763
|
|
|
|
* @param string $wikiText
|
|
|
|
* @param Parser $origParser
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function sandboxParse( $wikiText, $origParser ) {
|
2022-12-27 12:16:31 +00:00
|
|
|
$myParser = $this->parserFactory->getInstance();
|
2013-09-03 04:55:09 +00:00
|
|
|
$result = $myParser->parse(
|
|
|
|
$wikiText,
|
|
|
|
$origParser->getTitle(),
|
|
|
|
$origParser->getOptions()
|
|
|
|
);
|
2015-06-01 23:15:49 +00:00
|
|
|
|
|
|
|
$stripItems = $this->stripItems;
|
2022-04-06 00:05:34 +00:00
|
|
|
return preg_replace_callback(
|
2015-06-01 23:15:49 +00:00
|
|
|
"/{$this->markerString}-(\d+)-{$this->markerString}/",
|
2021-05-13 00:43:27 +00:00
|
|
|
static function ( array $matches ) use ( $stripItems ) {
|
2017-06-20 07:20:13 +00:00
|
|
|
$markerIndex = (int)$matches[1];
|
2015-06-01 23:15:49 +00:00
|
|
|
return $stripItems[$markerIndex];
|
|
|
|
},
|
|
|
|
$result->getText()
|
|
|
|
);
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
/**
|
|
|
|
* Render the entire feed so that each item is passed to the
|
|
|
|
* template which the MediaWiki then displays.
|
|
|
|
*
|
2012-10-07 10:11:49 +00:00
|
|
|
* @param Parser $parser
|
2018-04-07 09:22:17 +00:00
|
|
|
* @param PPFrame $frame The frame param to pass to recursiveTagParse()
|
2012-10-07 10:11:49 +00:00
|
|
|
* @return string
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
2018-11-02 10:23:45 +00:00
|
|
|
public function renderFeed( $parser, $frame ) {
|
2011-08-15 21:52:08 +00:00
|
|
|
$renderedFeed = '';
|
2024-09-19 05:43:52 +00:00
|
|
|
$wikitextFeed = '';
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
2011-08-15 21:52:08 +00:00
|
|
|
if ( isset( $this->itemTemplate ) && isset( $parser ) && isset( $frame ) ) {
|
2010-11-04 23:19:00 +00:00
|
|
|
$headcnt = 0;
|
|
|
|
if ( $this->reversed ) {
|
|
|
|
$this->rss->items = array_reverse( $this->rss->items );
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ( $this->rss->items as $item ) {
|
|
|
|
if ( $this->maxheads > 0 && $headcnt >= $this->maxheads ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $this->canDisplay( $item ) ) {
|
2024-09-19 05:43:52 +00:00
|
|
|
$wikitextFeed .= $this->renderItem( $item, $parser ) . "\n";
|
2010-11-04 23:19:00 +00:00
|
|
|
$headcnt++;
|
|
|
|
}
|
|
|
|
}
|
2011-08-15 21:52:08 +00:00
|
|
|
|
2024-09-19 05:43:52 +00:00
|
|
|
$renderedFeed = $this->sandboxParse( $wikitextFeed, $parser );
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$parser->addTrackingCategory( 'rss-tracking-category' );
|
|
|
|
|
2011-08-15 21:52:08 +00:00
|
|
|
return $renderedFeed;
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-11-05 00:59:28 +00:00
|
|
|
* Render each item, filtering it out if necessary, applying any highlighting.
|
|
|
|
*
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param array $item an array produced by RSSData where keys are the names of the RSS elements
|
|
|
|
* @param Parser $parser
|
2012-10-07 10:11:49 +00:00
|
|
|
* @return mixed
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
protected function renderItem( $item, $parser ) {
|
2011-08-15 21:52:08 +00:00
|
|
|
$renderedItem = $this->itemTemplate;
|
2010-11-19 21:02:01 +00:00
|
|
|
|
2011-08-15 21:52:08 +00:00
|
|
|
// $info will only be an XML element name, so we're safe using it.
|
|
|
|
// $item[$info] is handled by the XML parser --
|
|
|
|
// and that means bad RSS with stuff like
|
|
|
|
// <description><script>alert("hi")</script></description> will find its
|
|
|
|
// rogue <script> tags neutered.
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
// use the overloaded multi byte wrapper functions in GlobalFunctions.php
|
2011-08-15 21:52:08 +00:00
|
|
|
|
|
|
|
foreach ( array_keys( $item ) as $info ) {
|
2013-10-17 21:37:46 +00:00
|
|
|
if ( $item[$info] != "" ) {
|
|
|
|
switch ( $info ) {
|
2024-03-11 21:44:41 +00:00
|
|
|
// ATOM <id> elements and RSS <link> elements are item link urls
|
|
|
|
case 'id':
|
|
|
|
$txt = $this->sanitizeUrl( $item['id'] );
|
|
|
|
$renderedItem = str_replace( '{{{link}}}', $txt, $renderedItem );
|
|
|
|
break;
|
|
|
|
case 'link':
|
|
|
|
$txt = $this->sanitizeUrl( $item['link'] );
|
|
|
|
$renderedItem = str_replace( '{{{link}}}', $txt, $renderedItem );
|
|
|
|
break;
|
|
|
|
case 'date':
|
|
|
|
$tempTimezone = date_default_timezone_get();
|
|
|
|
date_default_timezone_set( 'UTC' );
|
|
|
|
$txt = date( $this->date,
|
|
|
|
strtotime( $this->escapeTemplateParameter( $item['date'] ) ) );
|
|
|
|
date_default_timezone_set( $tempTimezone );
|
|
|
|
$renderedItem = str_replace( '{{{date}}}', $txt, $renderedItem );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$str = $this->escapeTemplateParameter( $item[$info] );
|
|
|
|
$str = $parser->getTargetLanguage()->truncateForVisual( $str, $this->ItemMaxLength );
|
|
|
|
$str = $this->highlightTerms( $str );
|
|
|
|
$renderedItem = str_replace( '{{{' . $info . '}}}',
|
|
|
|
$this->insertStripItem( $str ), $renderedItem );
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
}
|
2011-08-15 21:52:08 +00:00
|
|
|
}
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
2011-08-15 21:52:08 +00:00
|
|
|
|
|
|
|
// nullify all remaining info items in the template
|
|
|
|
// without a corresponding info in the current feed item
|
|
|
|
|
2022-04-06 00:05:34 +00:00
|
|
|
return preg_replace( "!{{{[^}]+}}}!U", "", $renderedItem );
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
|
|
|
|
2010-11-23 02:16:05 +00:00
|
|
|
/**
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
* Sanitize a URL for inclusion in wikitext. Escapes characters that have
|
2010-11-23 02:16:05 +00:00
|
|
|
* a special meaning in wikitext, replacing them with URL escape codes, so
|
|
|
|
* that arbitrary input can be included as a free or bracketed external
|
|
|
|
* link and both work and be safe.
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param string $url
|
|
|
|
* @return string
|
2010-11-23 02:16:05 +00:00
|
|
|
*/
|
|
|
|
protected function sanitizeUrl( $url ) {
|
|
|
|
# Remove control characters
|
2013-06-09 07:12:33 +00:00
|
|
|
$url = preg_replace( '/[\000-\037\177]/', '', trim( $url ) );
|
2010-11-23 02:16:05 +00:00
|
|
|
# Escape other problematic characters
|
|
|
|
$out = '';
|
2017-05-20 21:41:06 +00:00
|
|
|
for ( $i = 0, $len = strlen( $url ); $i < $len; $i++ ) {
|
2010-11-23 02:16:05 +00:00
|
|
|
$boringLength = strcspn( $url, '<>"[|]\ {', $i );
|
|
|
|
if ( $boringLength ) {
|
|
|
|
$out .= substr( $url, $i, $boringLength );
|
|
|
|
$i += $boringLength;
|
|
|
|
}
|
2017-05-20 21:41:06 +00:00
|
|
|
if ( $i < $len ) {
|
2010-11-23 02:16:05 +00:00
|
|
|
$out .= rawurlencode( $url[$i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sanitize user input for inclusion as a template parameter.
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
*
|
2010-11-23 02:16:05 +00:00
|
|
|
* Unlike in wfEscapeWikiText() as of r77127, this escapes }} in addition
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
* to the other kinds of markup, to avoid user input ending a template
|
2010-11-23 02:16:05 +00:00
|
|
|
* invocation.
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
*
|
|
|
|
* If you want to allow clickable link Urls (HTML <a> tag) in RSS feeds:
|
|
|
|
* $wgRSSAllowLinkTag = true;
|
|
|
|
*
|
|
|
|
* If you want to allow images (HTML <img> tag) in RSS feeds:
|
2013-02-26 08:04:11 +00:00
|
|
|
* $wgRSSAllowImageTag = true;
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param string $text
|
|
|
|
* @return string
|
2010-11-23 02:16:05 +00:00
|
|
|
*/
|
|
|
|
protected function escapeTemplateParameter( $text ) {
|
2013-02-26 08:04:11 +00:00
|
|
|
global $wgRSSAllowLinkTag, $wgRSSAllowImageTag;
|
|
|
|
|
2017-05-20 21:41:06 +00:00
|
|
|
$extraInclude = [];
|
|
|
|
$extraExclude = [ "iframe" ];
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
2022-04-06 00:05:34 +00:00
|
|
|
if ( $wgRSSAllowLinkTag ) {
|
2013-02-26 08:04:11 +00:00
|
|
|
$extraInclude[] = "a";
|
|
|
|
} else {
|
|
|
|
$extraExclude[] = "a";
|
|
|
|
}
|
|
|
|
|
2022-04-06 00:05:34 +00:00
|
|
|
if ( $wgRSSAllowImageTag ) {
|
2013-02-26 08:04:11 +00:00
|
|
|
$extraInclude[] = "img";
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
} else {
|
2013-02-26 08:04:11 +00:00
|
|
|
$extraExclude[] = "img";
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 00:05:34 +00:00
|
|
|
if ( $wgRSSAllowLinkTag || $wgRSSAllowImageTag ) {
|
2022-03-04 19:26:41 +00:00
|
|
|
$ret = Sanitizer::removeSomeTags( $text, [
|
|
|
|
'extraTags' => $extraInclude,
|
|
|
|
'removeTags' => $extraExclude,
|
|
|
|
] );
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
2019-01-07 18:33:26 +00:00
|
|
|
} else {
|
|
|
|
// use the old escape method for a while
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
|
|
|
|
$text = str_replace(
|
2017-05-20 21:41:06 +00:00
|
|
|
[
|
2024-03-11 21:44:41 +00:00
|
|
|
'[', '|', ']', '\'', 'ISBN ',
|
|
|
|
'RFC ', '://', "\n=", '{{', '}}',
|
2017-05-20 21:41:06 +00:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'[', '|', ']', ''', 'ISBN ',
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
'RFC ', '://', "\n=", '{{', '}}',
|
2017-05-20 21:41:06 +00:00
|
|
|
],
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
htmlspecialchars( str_replace( "\n", "", $text ) )
|
|
|
|
);
|
|
|
|
|
|
|
|
// keep some basic layout tags
|
|
|
|
$ret = str_replace(
|
2017-05-20 21:41:06 +00:00
|
|
|
[
|
|
|
|
'<p>', '</p>',
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
'<br/>', '<br>', '</br>',
|
|
|
|
'<b>', '</b>',
|
|
|
|
'<i>', '</i>',
|
|
|
|
'<u>', '</u>',
|
|
|
|
'<s>', '</s>',
|
2017-05-20 21:41:06 +00:00
|
|
|
],
|
|
|
|
[
|
|
|
|
"", "<br/>",
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
"<br/>", "<br/>", "<br/>",
|
|
|
|
"'''", "'''",
|
|
|
|
"''", "''",
|
|
|
|
"<u>", "</u>",
|
|
|
|
"<s>", "</s>",
|
2017-05-20 21:41:06 +00:00
|
|
|
],
|
version 2.18 + squashed commit RSS changes fromSVN
bump version number from 2.17 to 2.18 for the releas version
removed 4 white spaces tabs.
followed the advices of the code reviewer. removed an unwanted switch(true) structure
removed switch case by an assoc array, removed unneeded http factory comments Wikinaut 2013-01-04
removed unneeded INSTALL text file
new version 2.17 incl. code cosmetics. rebased on master bea4447d24ad33c115e64385ef8fc5a308b58188 2012-12-22
bear with me ! It's my first real-life commit to gerrit. Wikinaut, 2012-12-30
Catrope squashed these together per Wikinaut's request. List of commit
summaries:
adding the long-wanted date format attribute.
implemented a date format equalising function,
so that dates of RSS feeds are rendered in a common format.
follow-up r111347 : adding escapeTemplateParameter around the user supplied optional date attribute
fix for bug30377 : add a new parameter to limit the number of characters when rendering the channel item <description>
follow-up r111350 . check if optional parameter isset and is_numeric, otherwise limit to the built-in default (30000)
removed a wrong comment regarding PHP 5.3 function date_create_from_format,
which is not suited to auto-detect a time string in any formats - only strtotime() can do it.
follow-up r111350 r111351 . switch replaced by if elseif construct.
name and behaviour change of wgRSSAllowedFeeds towgRSSUrlWhitelist.
The wgRSSUrlWhitelist is _now_ empty by default which was not the case until this version.
Admins who want to allow their users to insert arbitrary feed urls must now denote this expressly
with an asterisk in quotes as whitelist array element.
This is harmonised to the same method as recently introduced in E:EtherpadLite.
The RELEASE NOTES file has been updated, updates to the MediaWiki manual page will follow soon.
increased wgRSSFetchTimeout default from 5 to 15 seconds - many sites are too slow.
v2.00 can parse ATOM feeds, at least some.
This is a major improvement over pre-2.00 versions which only could read and parse RSS feeds but no ATOM feeds.
Version 2.00 begins to keep care of namespaces in the XML.
The parser still leaves room for further improvements.
At least, E:RSS can now read E:WikiArticleFeeds generated RSS _and_ ATOM feeds.
v2.01 fixed ATOM summary element was forgotten to be parsed.
Added handling of basic HTML layout tags (p br b u i s) in feed descriptions,
they are preserved in the wiki output after sanitizing.
improved code legibility function namespacePrefixedQuery
fix for ultra bug 30028 .
The RSS extension can parse RSS and ATOM feeds of different flavours.
The php xml dom xpath query uses now a namespace-safe method to find all elements like item (RSS, RDF)
or entry (ATOM).
Further fixed a hidden problem when the feed url was redirecting,
this threw the Cannot parse RSS for XML error, which is now history.
Introduced a new parameter wgRSSUrlNumberOfAllowedRedirects which defaults to zero,
i.e. no redirects are allowed by default. See Manual page
removed superfluous code for setting userAgent since r112466
function name typo correction. Version number update
fix for bug34763 'RSS feed items (HTML) are not rendered as HTML but htmlescaped';
tolerated controlled regression bug30377 'feed item length limitation',
because this now becomes very tricky when we allow some tags in order to close bug 34763.
add tracking category feature (enabled by default). Each page using this extensions gets
automatically the tracking category with MediaWiki:Rss-tracking-category name (= RSS).
Tracking-Cat-Feature can be disabled, or a different MediaWiki message text can be assigned.
Documentation of the switch is inline and follows on MediaWiki.
follow up r113508 : escaped html tag brackets to make translaters happy
beautifying the tracking category name
adding casts. better ?
removed the redundant code for handling tracking categories.
By using '-' for the message text rss-tracking-category , this can be disabled easily.
+ Patchset 11
rebased on master
+ Patchset 12
wrapped commit message text lines
version number bumped to 2.18
+ Patchset 13
improved and updated README
added history of the present version 2.18
+ Patchset 14
white space fixes
version number fixes
Change-Id: I2d9724314f94c216650370071b31390c5c2c97fc
2012-02-13 01:39:24 +00:00
|
|
|
$text
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $ret;
|
2010-11-23 02:16:05 +00:00
|
|
|
}
|
|
|
|
|
2010-11-04 23:19:00 +00:00
|
|
|
/**
|
|
|
|
* Parse an HTTP response object into an array of relevant RSS data
|
2010-11-05 00:59:28 +00:00
|
|
|
*
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param string $key the key to use to store the parsed response in the cache
|
2020-02-07 03:52:27 +00:00
|
|
|
* @return Status parsed RSS object (see RSSParse) or false
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
|
|
|
protected function responseToXML( $key ) {
|
2010-11-05 00:59:28 +00:00
|
|
|
wfDebugLog( 'RSS', "Got '" . $this->client->getStatus() . "', updating cache for $key" );
|
2010-11-04 23:19:00 +00:00
|
|
|
if ( $this->client->getStatus() === 304 ) {
|
|
|
|
# Not modified, update cache
|
|
|
|
wfDebugLog( 'RSS', "Got 304, updating cache for $key" );
|
|
|
|
$this->storeInCache( $key );
|
|
|
|
} else {
|
|
|
|
$this->xml = new DOMDocument;
|
2019-01-08 17:35:47 +00:00
|
|
|
$rawXML = $this->client->getContent();
|
2010-11-04 23:19:00 +00:00
|
|
|
|
2019-01-08 17:35:47 +00:00
|
|
|
if ( $rawXML == '' ) {
|
2010-11-05 00:59:28 +00:00
|
|
|
return Status::newFatal( 'rss-parse-error', 'No XML content' );
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
|
|
|
|
2022-02-24 21:17:28 +00:00
|
|
|
AtEase::suppressWarnings();
|
2020-12-27 16:29:56 +00:00
|
|
|
|
|
|
|
$oldDisable = false;
|
|
|
|
if ( LIBXML_VERSION < 20900 ) {
|
|
|
|
// Prevent loading external entities when parsing the XML (bug 46932)
|
|
|
|
$oldDisable = libxml_disable_entity_loader( true );
|
|
|
|
}
|
2019-01-08 17:35:47 +00:00
|
|
|
$this->xml->loadXML( $rawXML );
|
2020-12-27 16:29:56 +00:00
|
|
|
if ( LIBXML_VERSION < 20900 ) {
|
|
|
|
libxml_disable_entity_loader( $oldDisable );
|
|
|
|
}
|
|
|
|
|
2022-02-24 21:17:28 +00:00
|
|
|
AtEase::restoreWarnings();
|
2010-11-04 23:19:00 +00:00
|
|
|
|
|
|
|
$this->rss = new RSSData( $this->xml );
|
|
|
|
|
|
|
|
// if RSS parsed successfully
|
2010-11-13 19:11:28 +00:00
|
|
|
if ( $this->rss && !$this->rss->error ) {
|
2010-11-04 23:19:00 +00:00
|
|
|
$this->etag = $this->client->getResponseHeader( 'Etag' );
|
|
|
|
$this->lastModified =
|
|
|
|
strtotime( $this->client->getResponseHeader( 'Last-Modified' ) );
|
|
|
|
|
|
|
|
wfDebugLog( 'RSS', 'Stored etag (' . $this->etag . ') and Last-Modified (' .
|
|
|
|
$this->client->getResponseHeader( 'Last-Modified' ) . ') and items (' .
|
|
|
|
count( $this->rss->items ) . ')!' );
|
|
|
|
$this->storeInCache( $key );
|
|
|
|
} else {
|
2010-11-13 19:11:28 +00:00
|
|
|
return Status::newFatal( 'rss-parse-error', $this->rss->error );
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return Status::newGood();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a given item should or should not be displayed
|
2010-11-05 00:59:28 +00:00
|
|
|
*
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param array $item associative array that RSSData produced for an <item>
|
2017-07-26 21:02:17 +00:00
|
|
|
* @return bool
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
|
|
|
protected function canDisplay( array $item ) {
|
2010-11-05 00:59:28 +00:00
|
|
|
$check = '';
|
2010-11-04 23:19:00 +00:00
|
|
|
|
|
|
|
/* We're only going to check the displayable fields */
|
|
|
|
foreach ( $this->displayFields as $field ) {
|
|
|
|
if ( isset( $item[$field] ) ) {
|
|
|
|
$check .= $item[$field];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $this->filter( $check, 'filterOut' ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ( $this->filter( $check, 'filter' ) ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters items in or out if the match a string we're looking for.
|
2010-11-05 00:59:28 +00:00
|
|
|
*
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param string $text the text to examine
|
|
|
|
* @param string $filterType "filterOut" to check for matches in the filterOut member list.
|
|
|
|
* Otherwise, uses the filter member list.
|
2017-07-26 21:02:17 +00:00
|
|
|
* @return bool Decision to filter or not.
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
|
|
|
protected function filter( $text, $filterType ) {
|
|
|
|
if ( $filterType === 'filterOut' ) {
|
|
|
|
$filter = $this->filterOut;
|
|
|
|
} else {
|
|
|
|
$filter = $this->filter;
|
|
|
|
}
|
|
|
|
|
2010-11-05 00:59:28 +00:00
|
|
|
if ( count( $filter ) == 0 ) {
|
|
|
|
return $filterType !== 'filterOut';
|
|
|
|
}
|
2010-11-04 23:19:00 +00:00
|
|
|
|
|
|
|
/* Using : for delimiter here since it'll be quoted automatically. */
|
2017-05-20 21:41:06 +00:00
|
|
|
$match = preg_match( ':(' . implode( '|',
|
|
|
|
array_map( 'preg_quote', $filter ) ) . '):i', $text );
|
2010-11-04 23:19:00 +00:00
|
|
|
if ( $match ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Highlight the words we're supposed to be looking for
|
2010-11-05 00:59:28 +00:00
|
|
|
*
|
2017-10-14 15:23:24 +00:00
|
|
|
* @param string $text the text to look in.
|
|
|
|
* @return string with matched text highlighted in a <span> element
|
2010-11-04 23:19:00 +00:00
|
|
|
*/
|
|
|
|
protected function highlightTerms( $text ) {
|
|
|
|
if ( count( $this->highlight ) === 0 ) {
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
2015-01-31 22:18:19 +00:00
|
|
|
$terms = array_flip( array_map( 'strtolower', $this->highlight ) );
|
2017-05-20 21:41:06 +00:00
|
|
|
$highlight = ':' . implode( '|',
|
|
|
|
array_map( 'preg_quote', array_values( $this->highlight ) ) ) . ':i';
|
2021-05-13 00:43:27 +00:00
|
|
|
return preg_replace_callback( $highlight, static function ( $match ) use ( $terms ) {
|
2017-05-20 21:41:06 +00:00
|
|
|
$styleStart = "<span style='font-weight: bold; " .
|
|
|
|
"background: none repeat scroll 0%% 0%% rgb(%s); color: %s;'>";
|
|
|
|
$styleEnd = '</span>';
|
2015-01-31 22:18:19 +00:00
|
|
|
|
|
|
|
# bg colors cribbed from Google's highlighting of search terms
|
2017-05-20 21:41:06 +00:00
|
|
|
$bgcolor = [ '255, 255, 102', '160, 255, 255', '153, 255, 153',
|
2015-01-31 22:18:19 +00:00
|
|
|
'255, 153, 153', '255, 102, 255', '136, 0, 0', '0, 170, 0', '136, 104, 0',
|
2017-05-20 21:41:06 +00:00
|
|
|
'0, 70, 153', '153, 0, 153' ];
|
2015-01-31 22:18:19 +00:00
|
|
|
# Spelling out the fg colors instead of using processing time to create this list
|
2017-05-20 21:41:06 +00:00
|
|
|
$color = [ 'black', 'black', 'black', 'black', 'black',
|
|
|
|
'white', 'white', 'white', 'white', 'white' ];
|
2015-01-31 22:18:19 +00:00
|
|
|
|
|
|
|
$index = $terms[strtolower( $match[0] )] % count( $bgcolor );
|
|
|
|
|
|
|
|
return sprintf( $styleStart, $bgcolor[$index], $color[$index] ) . $match[0] . $styleEnd;
|
|
|
|
}, $text );
|
2010-11-04 23:19:00 +00:00
|
|
|
}
|
|
|
|
}
|