From c378e972a12ba41d252d74e509f88ea7bec2544d Mon Sep 17 00:00:00 2001 From: Alessandro Cosentino Date: Tue, 17 Jul 2012 17:37:54 -0400 Subject: adds favicon; needs css polishing --- appinfo/database.xml | 6 ++++++ appinfo/info.xml | 2 +- css/news.css | 2 +- lib/feed.php | 10 ++++++++++ lib/feedmapper.php | 12 ++++++++---- lib/foldermapper.php | 2 +- lib/utils.php | 8 ++++++++ templates/part.feeds.php | 3 ++- 8 files changed, 37 insertions(+), 8 deletions(-) diff --git a/appinfo/database.xml b/appinfo/database.xml index 3f5f6c44a..dc3a2b606 100644 --- a/appinfo/database.xml +++ b/appinfo/database.xml @@ -75,6 +75,12 @@ true 100 + + favicon_link + text + false + 100 + added integer diff --git a/appinfo/info.xml b/appinfo/info.xml index 0ada6e75c..1e5215550 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -3,7 +3,7 @@ news News An RSS/Atom feed reader - 5.5 + 6.1 AGPL Alessandro Cosentino 4 diff --git a/css/news.css b/css/news.css index d85c8e48b..37b73334c 100644 --- a/css/news.css +++ b/css/news.css @@ -44,7 +44,7 @@ ul#feedfoldermenu { position:fixed; margin-left: 0; bottom: 2.8em; border-left:1 li { padding: 0px !important; } li.menuItem { margin-left:0.7em; margin-right:0.7em; float: none !important; text-align: left; } -li.feeds_list { margin-left: 20px !important; text-align: right; } +li.feeds_list { text-align: right; padding-left: 20px; } li.folder_list:hover { color: rgb(0, 0, 0) !important; background: none !important; } li.feeds_list:hover { background: none repeat scroll 0% 0% rgb(221, 221, 221) !important; } diff --git a/lib/feed.php b/lib/feed.php index bbed8d598..59db6f7cc 100644 --- a/lib/feed.php +++ b/lib/feed.php @@ -18,6 +18,7 @@ class OC_News_Feed extends OC_News_Collection { private $url; private $spfeed; //encapsulate a SimplePie_Core object private $items; //array that contains all the items of the feed + private $favicon; public function __construct($url, $title, $items, $id = null){ $this->url = $url; @@ -36,6 +37,14 @@ class OC_News_Feed extends OC_News_Collection { return $this->title; } + public function getFavicon(){ + return $this->favicon; + } + + public function setFavicon($favicon){ + $this->favicon = $favicon; + } + public function setItems($items){ $this->items = $items; } @@ -43,4 +52,5 @@ class OC_News_Feed extends OC_News_Collection { public function getItems(){ return $this->items; } + } diff --git a/lib/feedmapper.php b/lib/feedmapper.php index 73afa0e86..c43ff47a5 100644 --- a/lib/feedmapper.php +++ b/lib/feedmapper.php @@ -46,6 +46,8 @@ class OC_News_FeedMapper { $title = $row['title']; $id = $row['id']; $feed = new OC_News_Feed($url, $title, null, $id); + $favicon = $row['favicon_link']; + $feed->setFavicon($favicon); $feeds[] = $feed; } return $feeds; @@ -64,7 +66,8 @@ class OC_News_FeedMapper { $url = $row['url']; $title = $row['title']; $feed = new OC_News_Feed($url, $title, null,$id); - + $favicon = $row['favicon_link']; + $feed->setFavicon($favicon); $itemMapper = new OC_News_ItemMapper(); $items = $itemMapper->findAll($id); $feed->setItems($items); @@ -118,16 +121,17 @@ class OC_News_FeedMapper { if ($feedid == null){ $query = OCP\DB::prepare(' INSERT INTO ' . self::tableName . - '(url, title, folder_id, added, lastmodified) - VALUES (?, ?, ?, ?, ?) + '(url, title, favicon_link, folder_id, added, lastmodified) + VALUES (?, ?, ?, ?, ?, ?) '); $params=array( $url, htmlspecialchars_decode($title), + $feed->getFavicon(), $folderid, $_ut, - $_ut + $_ut, ); $query->execute($params); diff --git a/lib/foldermapper.php b/lib/foldermapper.php index 45dc53c42..01dce13d7 100644 --- a/lib/foldermapper.php +++ b/lib/foldermapper.php @@ -40,7 +40,7 @@ class OC_News_FolderMapper { $result = $stmt->execute(array($this->userid, $id)); while( $row = $result->fetchRow()){ - $child = OC_News_FolderMapper::populate($row['name'], $row['id']); + $child = self::populate($row['name'], $row['id']); $root->addChild($child); } diff --git a/lib/utils.php b/lib/utils.php index 959a102ee..a9f1488b1 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -41,6 +41,14 @@ class OC_News_Utils { } $feed = new OC_News_Feed($url, $title, $items); + + $favicon = $spfeed->get_image_url(); + if ($favicon == null) { + $favicon = $url . "favicon.ico"; + //check if this file exists + } + $feed->setFavicon($favicon); + return $feed; } } \ No newline at end of file diff --git a/templates/part.feeds.php b/templates/part.feeds.php index 5874f1bc1..d8e4a6b01 100644 --- a/templates/part.feeds.php +++ b/templates/part.feeds.php @@ -14,7 +14,8 @@ print_folder($child, $depth+1); } elseif ($child instanceOf OC_News_Feed) { //onhover $(element).attr('id', 'newID'); - echo '
  • ' . $child->getTitle() .''; + $favicon = $child->getFavicon(); + echo '
  • ' . $child->getTitle() .''; countUnreadItems($child->getId()); echo ''; echo ''; -- cgit v1.2.3