1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2024-11-29 04:24:11 +01:00

Bookmark: Fetch title for bookmark added from interface ref #145

This commit is contained in:
Brice Maron 2012-11-05 20:34:09 +00:00
parent 0404b8c5ef
commit eefac414f5
3 changed files with 16 additions and 6 deletions

View File

@ -26,20 +26,27 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck(); OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('bookmarks'); OCP\JSON::checkAppEnabled('bookmarks');
require_once OC_App::getAppPath('bookmarks').'/bookmarksHelper.php';
// If we go the dialog form submit // If we go the dialog form submit
if(isset($_POST['url'])) { if(isset($_POST['url'])) {
$title = '';
$tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array(); $tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array();
$pub = isset($_POST['is_public']) ? true : false; $pub = isset($_POST['is_public']) ? true : false;
if(isset($_POST['record_id']) && is_numeric($_POST['record_id']) ) { //EDIT if(isset($_POST['record_id']) && is_numeric($_POST['record_id']) ) { //EDIT
$bm = $_POST['record_id']; $bm = $_POST['record_id'];
OC_Bookmarks_Bookmarks::editBookmark($bm, $_POST['url'], $_POST['title'], $tags, $_POST['description'], $pub); OC_Bookmarks_Bookmarks::editBookmark($bm, $_POST['url'], $_POST['title'], $tags, $_POST['description'], $pub);
$title = $_POST['title'];
} }
else { else {
$bm = OC_Bookmarks_Bookmarks::addBookmark($_POST['url'], $_POST['title'], $tags, $_POST['description'], $pub); if(isset($_POST['from_own'])) {
$datas = getURLMetadata($_POST['url']);
if(isset($datas['title'])) $title = $datas['title'];
} }
OCP\JSON::success(array('id'=>$bm)); $bm = OC_Bookmarks_Bookmarks::addBookmark($_POST['url'], $title, $tags, $_POST['description'], $pub);
}
OCP\JSON::success(array('id'=>$bm,'title'=>$title));
exit(); exit();
} }
OC_JSON::error(); OC_JSON::error();

View File

@ -153,10 +153,11 @@ function getBookmarks() {
for(var i in bookmarks.data) { for(var i in bookmarks.data) {
updateBookmarksList(bookmarks.data[i]); updateBookmarksList(bookmarks.data[i]);
$("#firstrun").hide();
} }
if($('.bookmarks_list').is(':empty')) { if($('.bookmarks_list').is(':empty')) {
$("#firstrun").show(); $("#firstrun").show();
} else {
$("#firstrun").hide();
} }
$('.bookmark_link').click(recordClick); $('.bookmark_link').click(recordClick);
@ -196,7 +197,7 @@ function addBookmark(event) {
event.preventDefault(); event.preventDefault();
url = $('#add_url').val(); url = $('#add_url').val();
$('#add_url').val(''); $('#add_url').val('');
bookmark = { url: url, description:'', title:''}; bookmark = { url: url, description:'', title:'', from_own: '1'};
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: OC.filePath('bookmarks', 'ajax', 'editBookmark.php'), url: OC.filePath('bookmarks', 'ajax', 'editBookmark.php'),
@ -204,6 +205,7 @@ function addBookmark(event) {
success: function(data){ success: function(data){
if (data.status == 'success') { if (data.status == 'success') {
bookmark.id = data.id; bookmark.id = data.id;
bookmark.title = data.title
bookmark.added_date = new Date(); bookmark.added_date = new Date();
updateBookmarksList(bookmark, 'prepend'); updateBookmarksList(bookmark, 'prepend');
} }

View File

@ -9,7 +9,8 @@
?> ?>
<input type="hidden" id="bookmarkFilterTag" value="<?php echo $_['req_tag']; ?>" /> <input type="hidden" id="bookmarkFilterTag" value="<?php echo $_['req_tag']; ?>" />
<div id="controls"> <div id="controls">
<form id="add_form"><input type="text" id="add_url" value="" placeholder="<?php echo $l->t('Address'); ?>"/> <form id="add_form">
<input type="text" id="add_url" value="" placeholder="<?php echo $l->t('Address'); ?>"/>
<input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" /> <input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" />
</form> </form>
<div id="view_type"> <div id="view_type">