зеркало из https://github.com/nextcloud/news.git
starts implementing updateitem
This commit is contained in:
Родитель
e4b145726f
Коммит
5754af967c
|
@ -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!'))));
|
||||
|
|
@ -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;}
|
||||
|
|
18
js/news.js
18
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();
|
||||
|
|
|
@ -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>';
|
||||
|
|
Загрузка…
Ссылка в новой задаче