From 17814509754fa405d1f7be716cbeca1cd08deda8 Mon Sep 17 00:00:00 2001 From: Alessandro Cosentino Date: Mon, 15 Oct 2012 00:36:44 -0400 Subject: specifies name of the blog when showing items --- appinfo/app.php | 1 + controllers/news.controller.php | 4 ---- lib/item.php | 9 +++++++++ lib/itemmapper.php | 4 +++- templates/part.items.php | 6 +++++- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/appinfo/app.php b/appinfo/app.php index ed51748da..6c2aca9ef 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -15,6 +15,7 @@ OC::$CLASSPATH['OCA\News\Item'] = 'apps/news/lib/item.php'; OC::$CLASSPATH['OCA\News\Collection'] = 'apps/news/lib/collection.php'; OC::$CLASSPATH['OCA\News\Feed'] = 'apps/news/lib/feed.php'; OC::$CLASSPATH['OCA\News\Folder'] = 'apps/news/lib/folder.php'; +OC::$CLASSPATH['OCA\News\FeedType'] = 'apps/news/lib/feedtypes.php'; OC::$CLASSPATH['OCA\News\FeedMapper'] = 'apps/news/lib/feedmapper.php'; OC::$CLASSPATH['OCA\News\ItemMapper'] = 'apps/news/lib/itemmapper.php'; diff --git a/controllers/news.controller.php b/controllers/news.controller.php index 4f498b944..814f90d10 100644 --- a/controllers/news.controller.php +++ b/controllers/news.controller.php @@ -12,12 +12,8 @@ namespace OCA\News; -require_once(\OC_App::getAppPath('news') . '/lib/feedtypes.php'); - - class NewsController extends Controller { - /** * Decides wether to show the feedpage or the firstrun page */ diff --git a/lib/item.php b/lib/item.php index f2d4fbd63..95a64859c 100644 --- a/lib/item.php +++ b/lib/item.php @@ -34,6 +34,7 @@ class Item { private $id; //id of the item in the database table private $author; private $date; //date is stored in the Unix format + private $feedTitle; public function __construct($url, $title, $guid, $body, $id = null) { $this->title = $title; @@ -119,6 +120,14 @@ class Item { public function setTitle($title) { $this->title = $title; } + + public function getFeedTitle() { + return $this->feedTitle; + } + + public function setFeedTitle($feedtitle) { + $this->feedTitle = $feedtitle; + } public function getUrl() { return $this->url; diff --git a/lib/itemmapper.php b/lib/itemmapper.php index 58894cce8..92a3928d7 100644 --- a/lib/itemmapper.php +++ b/lib/itemmapper.php @@ -57,10 +57,12 @@ class ItemMapper { public function findByFeedId($feedid) { $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE feed_id = ? ORDER BY pub_date DESC'); $result = $stmt->execute(array($feedid)); - + $feedmapper = new FeedMapper($this->userid); + $feed = $feedmapper->findById($feedid); $items = array(); while ($row = $result->fetchRow()) { $item = $this->fromRow($row); + $item->setFeedTitle($feed->getTitle()); $items[] = $item; } diff --git a/templates/part.items.php b/templates/part.items.php index 174a96e5e..d331f5172 100644 --- a/templates/part.items.php +++ b/templates/part.items.php @@ -31,7 +31,11 @@ foreach($items as $item) { echo ''; echo '

' . htmlspecialchars($item->getTitle(), ENT_QUOTES, 'UTF-8') . '

'; - + +// if ($lastViewedFeedType !== OCA\News\FeedType::FEED) { + echo '
' . $l->t('from') . ' ' . $item->getFeedTitle() . '
'; +// } + if(($item->getAuthor() !== null) && (trim($item->getAuthor()) != '')) { echo '

'. $l->t('by') . ' ' . htmlspecialchars($item->getAuthor(), ENT_QUOTES, 'UTF-8') . '

'; } -- cgit v1.2.3