diff options
-rw-r--r-- | plugins/RssWidget/RssRenderer.php | 3 | ||||
-rw-r--r-- | plugins/RssWidget/Widgets/RssChangelog.php | 27 | ||||
-rw-r--r-- | plugins/RssWidget/Widgets/RssPiwik.php | 21 |
3 files changed, 30 insertions, 21 deletions
diff --git a/plugins/RssWidget/RssRenderer.php b/plugins/RssWidget/RssRenderer.php index 51c831cd4c..8673443216 100644 --- a/plugins/RssWidget/RssRenderer.php +++ b/plugins/RssWidget/RssRenderer.php @@ -46,8 +46,7 @@ class RssRenderer $content = Http::fetchRemoteFile($this->url); $rss = simplexml_load_string($content); } catch (\Exception $e) { - echo "Error while importing feed: {$e->getMessage()}\n"; - exit; + throw new \Exception("Error while importing feed: {$e->getMessage()}\n"); } $output = '<div style="padding:10px 15px;"><ul class="rss">'; diff --git a/plugins/RssWidget/Widgets/RssChangelog.php b/plugins/RssWidget/Widgets/RssChangelog.php index 4f215fd6a6..9a58d0c367 100644 --- a/plugins/RssWidget/Widgets/RssChangelog.php +++ b/plugins/RssWidget/Widgets/RssChangelog.php @@ -20,20 +20,25 @@ class RssChangelog extends \Piwik\Widget\Widget $config->setName('Matomo Changelog'); } + private function getFeed($URL) { + $rss = new RssRenderer($URL); + $rss->setCountPosts(1); + $rss->showDescription(true); + $rss->showContent(false); + return $rss->get(); + } + public function render() - { + { try { - $rss = new RssRenderer('http://feeds.feedburner.com/PiwikReleases'); - $rss->setCountPosts(1); - $rss->showDescription(true); - $rss->showContent(false); - - return $rss->get(); - + return $this->getFeed('https://feeds.feedburner.com/PiwikReleases'); } catch (\Exception $e) { - - return $this->error($e); - } + try { + return $this->getFeed('http://feeds.feedburner.com/PiwikReleases'); + } catch (\Exception $e) { + return $this->error($e); + } + } } /** diff --git a/plugins/RssWidget/Widgets/RssPiwik.php b/plugins/RssWidget/Widgets/RssPiwik.php index 9cf78247a0..2234488c49 100644 --- a/plugins/RssWidget/Widgets/RssPiwik.php +++ b/plugins/RssWidget/Widgets/RssPiwik.php @@ -20,18 +20,23 @@ class RssPiwik extends \Piwik\Widget\Widget $config->setName('Matomo.org Blog'); } + private function getFeed($URL){ + $rss = new RssRenderer($URL); + $rss->showDescription(true); + return $rss->get(); + } + public function render() { try { - $rss = new RssRenderer('http://feeds.feedburner.com/Piwik'); - $rss->showDescription(true); - - return $rss->get(); - + return $this->getFeed('https://feeds.feedburner.com/Piwik'); } catch (\Exception $e) { - - return $this->error($e); - } + try { + return $this->getFeed('http://feeds.feedburner.com/Piwik'); + } catch (\Exception $e) { + return $this->error($e); + } + } } /** |