From 912374165b89b0e6aae71d6fd0930176da259fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20T=C3=A4tzner?= Date: Sat, 21 Jul 2012 16:45:37 +0200 Subject: Add feed fallback icon and set a relative width on the feed list items. --- lib/utils.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/utils.php b/lib/utils.php index a9f1488b1..cddfcaaa3 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -4,10 +4,10 @@ * * @author Alessandro Cosentino * Copyright (c) 2012 - Alessandro Cosentino -* +* * This file is licensed under the Affero General Public License version 3 or later. * See the COPYING-README file -* +* */ // load SimplePie library @@ -18,8 +18,8 @@ class OC_News_Utils { /** * @brief Fetch a feed from remote - * @param url remote url of the feed - * @returns + * @param url remote url of the feed + * @returns */ public static function fetch($url){ //TODO: handle the case where fetching of the feed fails @@ -29,7 +29,7 @@ class OC_News_Utils { $spfeed->init(); $spfeed->handle_content_type(); $title = $spfeed->get_title(); - + $spitems = $spfeed->get_items(); $items = array(); foreach($spitems as $spitem) { //FIXME: maybe we can avoid this loop @@ -37,18 +37,19 @@ class OC_News_Utils { $itemTitle = $spitem->get_title(); $itemGUID = $spitem->get_id(); $itemBody = $spitem->get_content(); - $items[] = new OC_News_Item($itemUrl, $itemTitle, $itemGUID, $itemBody); + $items[] = new OC_News_Item($itemUrl, $itemTitle, $itemGUID, $itemBody); } $feed = new OC_News_Feed($url, $title, $items); - + $favicon = $spfeed->get_image_url(); if ($favicon == null) { - $favicon = $url . "favicon.ico"; + // fallback icon + $favicon = OCP\Util::imagePath('news', 'rss.svg'); //check if this file exists } $feed->setFavicon($favicon); - + return $feed; } } \ No newline at end of file -- cgit v1.2.3