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 | |
parent | 69480001986cd83852ee6351fbd5d68718eb829c (diff) |
shows articles in accordion view
-rw-r--r-- | css/news.css | 2 | ||||
-rw-r--r-- | index.php | 10 | ||||
-rw-r--r-- | js/news.js | 5 | ||||
-rw-r--r-- | lib/item.php | 11 | ||||
-rw-r--r-- | lib/itemmapper.php | 18 | ||||
-rw-r--r-- | lib/utils.php | 3 | ||||
-rw-r--r-- | templates/part.items.php | 5 |
7 files changed, 44 insertions, 10 deletions
diff --git a/css/news.css b/css/news.css index 0c75af7c4..8f89ef378 100644 --- a/css/news.css +++ b/css/news.css @@ -9,3 +9,5 @@ .news_input { float:left; font-size:12px; padding:4px 2px; border:solid 1px #aacfe4; width:200px; } ul.controls li { float: left; } + +.accordion .title { background: #DCDCDC; font-size: 12px; border-bottom:1px solid #ccc; font-weight:bold;} @@ -24,7 +24,15 @@ $foldermapper = new OC_News_FolderMapper(OCP\USER::getUser()); $allfeeds = $foldermapper->root(); -$feedid = isset( $_GET['feedid'] ) ? $_GET['feedid'] : null; +if ($allfeeds) { + $feedid = isset( $_GET['feedid'] ) ? $_GET['feedid'] : null; + if ($feedid == null) { + + } +} +else { + $feedid = 0; +} $tmpl = new OCP\Template( 'news', 'main', 'user' ); $tmpl->assign('allfeeds', $allfeeds); diff --git a/js/news.js b/js/news.js index 71000fdda..699b8ce2f 100644 --- a/js/news.js +++ b/js/news.js @@ -77,5 +77,10 @@ $(document).ready(function(){ $(this).parent().children().toggle(); $(this).toggle(); }); + + $('.accordion .title').click(function() { + $(this).next().toggle(); + return false; + }).next().hide(); });
\ No newline at end of file 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); diff --git a/templates/part.items.php b/templates/part.items.php index 93b7e213c..d109d6d34 100644 --- a/templates/part.items.php +++ b/templates/part.items.php @@ -6,8 +6,9 @@ $itemmapper = new OC_News_ItemMapper(); $items = $itemmapper->findAll($feedid); -echo '<ul>'; +echo '<ul class="accordion">'; foreach($items as $item) { - echo '<li>' . $item->getTitle() . '</li>'; + echo '<li><div class="title">' . $item->getTitle() . '</div>'; + echo '<div class="body">' . $item->getBody() . '</div></li>'; } echo '</ul>'; |