diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-04 16:54:26 -0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-04 16:54:26 -0400 |
commit | fcd843bc0c2ef3163d1ecc6b036e46726a61239a (patch) | |
tree | f2ce5d1117be95e2b24a16b59e83238a15ef910b /lib | |
parent | 69480001986cd83852ee6351fbd5d68718eb829c (diff) |
shows articles in accordion view
Diffstat (limited to 'lib')
-rw-r--r-- | lib/item.php | 11 | ||||
-rw-r--r-- | lib/itemmapper.php | 18 | ||||
-rw-r--r-- | lib/utils.php | 3 |
3 files changed, 25 insertions, 7 deletions
diff --git a/lib/item.php b/lib/item.php index bd695d8bd..ff3655e04 100644 --- a/lib/item.php +++ b/lib/item.php @@ -31,10 +31,11 @@ class OC_News_Item { private $status; //a bit-field set with status flags private $id; //id of the item in the database table - public function __construct($url, $title, $guid, $id = null){ + public function __construct($url, $title, $guid, $body, $id = null){ $this->title = $title; $this->url = $url; $this->guid = $guid; + $this->body = $body; $this->status |= StatusFlag::Unread; } @@ -105,4 +106,12 @@ class OC_News_Item { public function setUrl($url){ $this->url = $url; } + + public function getBody(){ + return $this->body; + } + + public function setBody($body){ + $this->body = $body; + } } diff --git a/lib/itemmapper.php b/lib/itemmapper.php index 81be77e21..b08dcd86b 100644 --- a/lib/itemmapper.php +++ b/lib/itemmapper.php @@ -32,7 +32,8 @@ class OC_News_ItemMapper { $title = $row['title']; $guid = $row['guid']; $status = $row['status']; - $item = new OC_News_Item($url, $title, $guid); + $body = $row['body']; + $item = new OC_News_Item($url, $title, $guid, $body); $item->setStatus($status); $items[] = $item; } @@ -62,16 +63,17 @@ class OC_News_ItemMapper { public function save(OC_News_Item $item, $feedid){ $guid = $item->getGuid(); $status = $item->getStatus(); - + $itemid = $this->findIdFromGuid($guid, $feedid); if ($itemid == null){ $title = $item->getTitle(); - + $body = $item->getBody(); + $stmt = OCP\DB::prepare(' INSERT INTO ' . self::tableName . - '(url, title, guid, feed_id, status) - VALUES (?, ?, ?, ?, ?) + '(url, title, body, guid, feed_id, status) + VALUES (?, ?, ?, ?, ?, ?) '); if(empty($title)) { @@ -79,9 +81,15 @@ class OC_News_ItemMapper { $title = $l->t('no title'); } + if(empty($body)) { + $l = OC_L10N::get('news'); + $body = $l->t('no body'); + } + $params=array( htmlspecialchars_decode($item->getUrl()), htmlspecialchars_decode($title), + $body, $guid, $feedid, $status diff --git a/lib/utils.php b/lib/utils.php index 16f39f413..e42e304bb 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -36,7 +36,8 @@ class OC_News_Utils { $itemUrl = $spitem->get_permalink(); $itemTitle = $spitem->get_title(); $itemGUID = $spitem->get_id(); - $items[] = new OC_News_Item($itemUrl, $itemTitle, $itemGUID); + $itemBody = $spitem->get_content(); + $items[] = new OC_News_Item($itemUrl, $itemTitle, $itemGUID, $itemBody); } $feed = new OC_News_Feed($url, $title, $items); |