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::checkAppEnabled('bookmarks');
require_once OC_App::getAppPath('bookmarks').'/bookmarksHelper.php';
// If we go the dialog form submit
if(isset($_POST['url'])) {
$title = '';
$tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array();
$pub = isset($_POST['is_public']) ? true : false;
if(isset($_POST['record_id']) && is_numeric($_POST['record_id']) ) { //EDIT
$bm = $_POST['record_id'];
OC_Bookmarks_Bookmarks::editBookmark($bm, $_POST['url'], $_POST['title'], $tags, $_POST['description'], $pub);
$title = $_POST['title'];
}
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();
}
OC_JSON::error();

View File

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

View File

@ -9,7 +9,8 @@
?>
<input type="hidden" id="bookmarkFilterTag" value="<?php echo $_['req_tag']; ?>" />
<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" />
</form>
<div id="view_type">