summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajax/markitem.php34
-rw-r--r--css/news.css3
-rw-r--r--js/news.js18
-rw-r--r--templates/part.items.php9
4 files changed, 61 insertions, 3 deletions
diff --git a/ajax/markitem.php b/ajax/markitem.php
new file mode 100644
index 000000000..ea54d79e3
--- /dev/null
+++ b/ajax/markitem.php
@@ -0,0 +1,34 @@
+<?php
+/**
+* ownCloud - News app
+*
+* @author Alessandro Cosentino
+* Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
+*
+* This file is licensed under the Affero General Public License version 3 or later.
+* See the COPYING-README file
+*
+*/
+
+// Check if we are a user
+OCP\JSON::checkLoggedIn();
+OCP\JSON::checkAppEnabled('news');
+OCP\JSON::callCheck();
+
+$itemid = trim($_POST['itemid']);
+
+$itemmapper = new OC_News_ItemMapper();
+$item = $itemmapper->find($itemid);
+$feedid = $itemmapper->save($feed, 0);
+
+$l = OC_L10N::get('news');
+
+if(!$feedid) {
+ OCP\JSON::error(array('data' => array('message' => $l->t('Error adding folder.'))));
+ OCP\Util::writeLog('news','ajax/newfeed.php: Error adding feed: '.$_POST['feedurl'], OCP\Util::ERROR);
+ exit();
+}
+
+//TODO: replace the following with a real success case. see contact/ajax/createaddressbook.php for inspirations
+OCP\JSON::success(array('data' => array('message' => $l->t('Feed added!'))));
+
diff --git a/css/news.css b/css/news.css
index 7e7256849..f36304531 100644
--- a/css/news.css
+++ b/css/news.css
@@ -12,4 +12,5 @@
ul.controls li { float: left; }
-.accordion .title { background: #DCDCDC; font-size: 12px; border-bottom:1px solid #ccc; font-weight:bold;}
+.accordion .title_unread { background: #DCDCDC; font-size: 12px; border-bottom:1px solid #ccc; font-weight:bold;}
+.accordion .title_read { background: #DCDCDC; font-size: 12px; border-bottom:1px solid #ccc;}
diff --git a/js/news.js b/js/news.js
index b940a3f69..25a6d6f34 100644
--- a/js/news.js
+++ b/js/news.js
@@ -97,6 +97,16 @@ News={
}
});
return false;
+ },
+ markItem:function(itemid) {
+ $.post(OC.filePath('news', 'ajax', 'markitem.php'),{'itemid':itemid},function(jsondata){
+ if(jsondata.status == 'success'){
+
+ }
+ else{
+ OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
+ }
+ });
}
}
}
@@ -110,10 +120,16 @@ $(document).ready(function(){
$(this).toggle();
});
- $('.accordion .title').click(function() {
+ $('.accordion .title_unread').click(function() {
$(this).next().toggle();
return false;
}).next().hide();
+
+ $('.accordion .title_read').click(function() {
+ $(this).next().toggle();
+ return false;
+ }).next().hide();
+
$('.feeds_list').hover(function() {
$(this).find('#feeds_delete').toggle();
diff --git a/templates/part.items.php b/templates/part.items.php
index d109d6d34..d1336b838 100644
--- a/templates/part.items.php
+++ b/templates/part.items.php
@@ -8,7 +8,14 @@ $items = $itemmapper->findAll($feedid);
echo '<ul class="accordion">';
foreach($items as $item) {
- echo '<li><div class="title">' . $item->getTitle() . '</div>';
+ $title = $item->getTitle();
+ echo '<li>';
+ if ($item->isRead()) {
+ echo '<div class="title_read">' . $title . '</div>';
+ }
+ else {
+ echo '<div class="title_unread" onClick="News.Feed.markItem(' . $item->getId() . ')">' . $title . '</div>';
+ }
echo '<div class="body">' . $item->getBody() . '</div></li>';
}
echo '</ul>';