Removed redundant code.

This commit is contained in:
Marvin Thomas Rabe 2012-02-22 16:04:17 +01:00
parent e2d6bf4c63
commit fd72f2bd29
12 changed files with 22 additions and 109 deletions

View File

@ -27,8 +27,6 @@ require_once('../../lib/base.php');
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('bookmarks');
require_once('bookmarksHelper.php');
OC_App::setActiveNavigationEntry( 'bookmarks_index' );
OC_Util::addScript('bookmarks','addBm');
@ -37,10 +35,6 @@ OC_Util::addStyle('bookmarks', 'bookmarks');
$tmpl = new OC_Template( 'bookmarks', 'addBm', 'user' );
$url = isset($_GET['url']) ? urldecode($_GET['url']) : '';
$metadata = getURLMetadata($url);
$tmpl->assign('URL', htmlentities($metadata['url'],ENT_COMPAT,'utf-8'));
$title = isset($metadata['title']) ? $metadata['title'] : (isset($_GET['title']) ? $_GET['title'] : '');
$tmpl->assign('TITLE', htmlentities($title,ENT_COMPAT,'utf-8'));
$tmpl->assign('URL', htmlentities($url,ENT_COMPAT,'utf-8'));
$tmpl->printPage();

View File

@ -45,8 +45,13 @@ $query = OC_DB::prepare("
(url, title, user_id, public, added, lastmodified)
VALUES (?, ?, ?, 0, $_ut, $_ut)
");
if(empty($_GET["title"])) {
require_once('../bookmarksHelper.php');
$metadata = getURLMetadata($_GET["url"]);
$_GET["title"] = $metadata['title'];
}
$params=array(
htmlspecialchars_decode($_GET["url"]),
htmlspecialchars_decode($_GET["title"]),
@ -56,7 +61,6 @@ $query->execute($params);
$b_id = OC_DB::insertid('*PREFIX*bookmarks');
if($b_id !== false) {
$query = OC_DB::prepare("
INSERT INTO *PREFIX*bookmarks_tags
@ -76,4 +80,3 @@ if($b_id !== false) {
OC_JSON::success(array('data' => $b_id));
}

View File

@ -1,39 +0,0 @@
<?php
/**
* ownCloud - bookmarks plugin
*
* @author Arthur Schiwon
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
//no apps or filesystem
$RUNTIME_NOSETUPFS=true;
require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
// $metadata = array();
require '../bookmarksHelper.php';
$metadata = getURLMetadata(htmlspecialchars_decode($_GET["url"]));
OC_JSON::success(array('data' => $metadata));

View File

@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* Copyright (c) 2011 Arthur Schiwon <blizzz@arthur-schiwon.de>
* This file is licensed under the Affero General Public License version 3 or
* later.

View File

@ -75,14 +75,6 @@
<sorting>descending</sorting>
</field>
</index>
<!-- <index>
<name>url</name>
<unique>true</unique>
<field>
<name>url</name>
<sorting>ascending</sorting>
</field>
</index>-->
</declaration>
</table>

View File

@ -3,8 +3,8 @@
<id>bookmarks</id>
<name>Bookmarks</name>
<description>Bookmark manager for ownCloud</description>
<version>0.1</version>
<version>0.2</version>
<licence>AGPL</licence>
<author>Arthur Schiwon</author>
<author>Arthur Schiwon, Marvin Thomas Rabe</author>
<require>2</require>
</info>

View File

@ -4,11 +4,10 @@ $(document).ready(function() {
function addBookmark(event) {
var url = $('#bookmark_add_url').val();
var title = $('#bookmark_add_title').val();
var tags = $('#bookmark_add_tags').val();
$.ajax({
url: 'ajax/addBookmark.php',
data: 'url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&tags=' + encodeURI(tags),
data: 'url=' + encodeURI(url) + '&tags=' + encodeURI(tags),
success: function(data){
window.close();
}

View File

@ -11,8 +11,6 @@ $(document).ready(function() {
$('#bookmark_add_submit').click(addOrEditBookmark);
$(window).scroll(updateOnBottom);
$('#bookmark_add_url').focusout(getMetadata);
$('.bookmarks_list').empty();
getBookmarks();
@ -47,20 +45,6 @@ function getBookmarks() {
});
}
function getMetadata() {
var url = encodeEntities($('#bookmark_add_url').val());
$('.loading_meta').css('display','inline');
$.ajax({
url: 'ajax/getMeta.php',
data: 'url=' + encodeURIComponent(url),
success: function(pageinfo){
$('#bookmark_add_url').val(pageinfo.data.url);
$('#bookmark_add_title').val(pageinfo.data.title);
$('.loading_meta').css('display','none');
}
});
}
// function addBookmark() {
// Instead of creating editBookmark() function, Converted the one above to
// addOrEditBookmark() to make .js file more compact.
@ -86,21 +70,9 @@ function addOrEditBookmark(event) {
var bookmark_id = response.data;
$('.bookmarks_add').slideToggle();
$('.bookmarks_add').children('p').children('.bookmarks_input').val('');
$('.bookmarks_list').prepend(
'<div class="bookmark_single" data-id="' + bookmark_id + '" >' +
'<p class="bookmark_actions">' +
'<span class="bookmark_delete">' +
'<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' +
'</span>&nbsp;' +
'<span class="bookmark_edit">' +
'<img class="svg" src="'+OC.imagePath('core', 'actions/rename')+'" title="Edit">' +
'</span>' +
'</p>' +
'<p class="bookmark_title"><a href="' + url + '" target="_blank" class="bookmark_link">' + title + '</a></p>' +
'<p class="bookmark_tags">' + tagshtml + '</p>' +
'<p class="bookmark_url">' + url + '</p>' +
'</div>'
);
$('.bookmarks_list').empty();
bookmarks_page = 0;
getBookmarks();
}
});
}
@ -112,15 +84,9 @@ function addOrEditBookmark(event) {
$('.bookmarks_add').slideToggle();
$('.bookmarks_add').children('p').children('.bookmarks_input').val('');
$('#bookmark_add_id').val('0');
var record = $('.bookmark_single[data-id = "' + id + '"]');
record.children('.bookmark_url:first').text(url);
var record_title = record.children('.bookmark_title:first').children('a:first');
record_title.attr('href', url);
record_title.text(title);
record.children('.bookmark_tags:first').html(tagshtml);
$('.bookmarks_list').empty();
bookmarks_page = 0;
getBookmarks();
}
});
}
@ -162,6 +128,7 @@ function updateBookmarksList(bookmark) {
if(!hasProtocol(bookmark.url)) {
bookmark.url = 'http://' + bookmark.url;
}
if(bookmark.title == '') bookmark.title = bookmark.url;
$('.bookmarks_list').append(
'<div class="bookmark_single" data-id="' + bookmark.id +'" >' +
'<p class="bookmark_actions">' +

View File

@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
@ -8,6 +8,4 @@
$tmpl = new OC_Template( 'bookmarks', 'settings');
//OC_Util::addScript('bookmarks','settings');
return $tmpl->fetchPage();

View File

@ -1,6 +1,5 @@
<div class="bookmarks_addBm">
<p><label class="bookmarks_label"><?php echo $l->t('Address'); ?></label><input type="text" id="bookmark_add_url" class="bookmarks_input" value="<?php echo $_['URL']; ?>"/></p>
<p><label class="bookmarks_label"><?php echo $l->t('Title'); ?></label><input type="text" id="bookmark_add_title" class="bookmarks_input" value="<?php echo $_['TITLE']; ?>" /></p>
<p><label class="bookmarks_label"><?php echo $l->t('Tags'); ?></label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p>
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint"><?php echo $l->t('Hint: Use space to separate tags.'); ?></label></p>
<p><label class="bookmarks_label"></label><input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" /></p>

View File

@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* Copyright (c) 2011 Arthur Schiwon <blizzz@arthur-schiwon.de>
* This file is licensed under the Affero General Public License version 3 or
* later.

View File

@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.