summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajax/deletefeed.php35
-rw-r--r--css/news.css2
-rw-r--r--js/news.js49
-rw-r--r--templates/part.feeds.php8
4 files changed, 90 insertions, 4 deletions
diff --git a/ajax/deletefeed.php b/ajax/deletefeed.php
new file mode 100644
index 000000000..b54620d48
--- /dev/null
+++ b/ajax/deletefeed.php
@@ -0,0 +1,35 @@
+<?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();
+
+$userid = OCP\USER::getUser();
+
+$feedurl = trim($_POST['feedurl']);
+
+$feed = OC_News_Utils::fetch($feedurl);
+$feedmapper = new OC_News_FeedMapper();
+$feedid = $feedmapper->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 8f89ef378..cbfef64c2 100644
--- a/css/news.css
+++ b/css/news.css
@@ -3,6 +3,8 @@
#feeds { background: #fff; width: 20em; left: 12.5em; top: 3.7em; bottom:3em; position: fixed; overflow: auto; padding: 0; margin: 0; }
#feeds a { height: 23px; display: block; margin: 0 0 0 0; padding: 0 0 0 25px; }
#bottomcontrols { padding: 0; bottom:0px; height:2.8em; width: 20em; margin:0; background:#eee; border-top:1px solid #ccc; position:fixed; -moz-box-shadow: 0 -3px 3px -3px #000; -webkit-box-shadow: 0 -3px 3px -3px #000; box-shadow: 0 -3px 3px -3px #000;}
+#feeds_delete { position:relative; float:right; background:url('%webroot%/core/img/actions/delete.svg') no-repeat center; }
+#feeds_edit { position:relative; float:right; background:url('%webroot%/core/img/actions/rename.svg') no-repeat center; }
.svg { border: inherit; background: inherit; }
diff --git a/js/news.js b/js/news.js
index 699b8ce2f..3675fb0db 100644
--- a/js/news.js
+++ b/js/news.js
@@ -64,6 +64,50 @@ News={
OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
}
});
+ },
+ doDelete:function() {
+ $('#feeds_delete').tipsy('hide');
+ OC.dialogs.confirm(t('news', 'Are you sure you want to delete this feed?'), t('news', 'Warning'), function(answer) {
+ if(answer == true) {
+ $.post(OC.filePath('contacts', 'ajax', 'deletefeed.php'),{'id':Contacts.UI.Card.id},function(jsondata){
+ if(jsondata.status == 'success'){
+ var newid = '';
+ var curlistitem = $('#leftcontent [data-id="'+jsondata.data.id+'"]');
+ var newlistitem = curlistitem.prev();
+ if(newlistitem == undefined) {
+ newlistitem = curlistitem.next();
+ }
+ curlistitem.remove();
+ if(newlistitem != undefined) {
+ newid = newlistitem.data('id');
+ }
+ $('#rightcontent').data('id',newid);
+ this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = '';
+ this.data = undefined;
+
+ if($('#contacts li').length > 0) { // Load first in list.
+ Contacts.UI.Card.update(newid);
+ } else {
+ // load intro page
+ $.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
+ if(jsondata.status == 'success'){
+ id = '';
+ $('#rightcontent').data('id','');
+ $('#rightcontent').html(jsondata.data.page);
+ }
+ else{
+ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
+ }
+ });
+ }
+ }
+ else{
+ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
+ }
+ });
+ }
+ });
+ return false;
}
}
}
@@ -71,7 +115,6 @@ News={
$(document).ready(function(){
$('#addfeedfolder').click(News.UI.overview);
- $('#addfeedfolder').keydown(News.UI.overview);
$('.collapsable').click(function(){
$(this).parent().children().toggle();
@@ -82,5 +125,7 @@ $(document).ready(function(){
$(this).next().toggle();
return false;
}).next().hide();
-
+
+ $('#feeds_delete').click( function() { News.Feed.doDelete(); return false;} );
+
}); \ No newline at end of file
diff --git a/templates/part.feeds.php b/templates/part.feeds.php
index 52716c804..5adb70d1c 100644
--- a/templates/part.feeds.php
+++ b/templates/part.feeds.php
@@ -1,6 +1,7 @@
<?php
-
function print_folder(OC_News_Folder $folder, $depth){
+ $l = new OC_l10n('news');
+
echo '<ul style="margin-left:' . 10*$depth . 'px;"> <li style="background-image:url(' .
OC_Helper::imagePath('core', 'filetypes/folder.png') . '); background-repeat:no-repeat; background-position:0px 8px; padding-left: 20px; ">' .
'<span class="collapsable">' . $folder->getName() .'</span><ul>';
@@ -10,7 +11,10 @@
print_folder($child, $depth+1);
}
elseif ($child instanceOf OC_News_Feed) {
- echo '<li><a href="' . OCP\Util::linkTo('news', 'index.php'). '?feedid=' . $child->getId() . '">' . $child->getTitle() .'</a></li>';
+ echo '<li><a href="' . OCP\Util::linkTo('news', 'index.php'). '?feedid=' . $child->getId() . '">' . $child->getTitle() .'</a>';
+ echo '<button class="svg action" id="feeds_delete" title="' . $l->t('Delete feed') . '"></button>';
+ echo '<button class="svg action" id="feeds_edit" title="' . $l->t('Edit feed') . '"></button>';
+ echo '</li>';
}
else {
//TODO:handle error in this case