Merged revisions 56170 via svnmerge from
svn://svn.silverstripe.com/silverstripe/modules/blog/branches/trunk-dnc ........ r56170 | ischommer | 2008-06-13 11:25:35 +1200 (Fri, 13 Jun 2008) | 1 line BUGFIX Adding getAbsoluteRssURL() to RSSWidget to avoid SimplePie confusion on relative URLs (causes timeouts) ........
This commit is contained in:
parent
b039275eae
commit
4df0def63b
|
@ -14,6 +14,23 @@ class RSSWidget extends Widget {
|
||||||
static $cmsTitle = "RSS Feed";
|
static $cmsTitle = "RSS Feed";
|
||||||
static $description = "Shows the latest entries of a RSS feed.";
|
static $description = "Shows the latest entries of a RSS feed.";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the RssUrl is relative, convert it to absolute with the
|
||||||
|
* current baseURL to avoid confusing simplepie.
|
||||||
|
* Passing relative URLs to simplepie will result
|
||||||
|
* in strange DNS lookups and request timeouts.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getAbsoluteRssUrl() {
|
||||||
|
$urlParts = parse_url($this->RssUrl);
|
||||||
|
if(!isset($urlParts['host']) || !$urlParts['host']) {
|
||||||
|
return Director::absoluteBaseURL() . $this->RssUrl;
|
||||||
|
} else {
|
||||||
|
return $this->RssUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
return new FieldSet(
|
return new FieldSet(
|
||||||
new TextField("RSSTitle", _t('RSSWidget.CT', "Custom title for the feed")),
|
new TextField("RSSTitle", _t('RSSWidget.CT', "Custom title for the feed")),
|
||||||
|
@ -27,7 +44,7 @@ class RSSWidget extends Widget {
|
||||||
|
|
||||||
function FeedItems() {
|
function FeedItems() {
|
||||||
$output = new DataObjectSet();
|
$output = new DataObjectSet();
|
||||||
$this->feed = new SimplePie($this->RssUrl);
|
$this->feed = new SimplePie($this->AbsoluteRssUrl);
|
||||||
$this->feed->init();
|
$this->feed->init();
|
||||||
if($items = $this->feed->get_items(0, $this->NumberToShow)) {
|
if($items = $this->feed->get_items(0, $this->NumberToShow)) {
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
|
|
Loading…
Reference in New Issue