Merge branch 'master' of git://anongit.kde.org/owncloud
This commit is contained in:
commit
ad053d504c
|
@ -41,7 +41,7 @@ $tmpl = new OC_Template( 'bookmarks', 'addBm', 'user' );
|
|||
$url = isset($_GET['url']) ? urldecode($_GET['url']) : '';
|
||||
$metadata = getURLMetadata($url);
|
||||
|
||||
$tmpl->assign('URL', htmlentities($url));
|
||||
$tmpl->assign('URL', htmlentities($metadata['url']));
|
||||
$tmpl->assign('TITLE', htmlentities($metadata['title']));
|
||||
$tmpl->assign('DESCRIPTION', htmlentities($metadata['description']));
|
||||
|
||||
|
|
|
@ -51,15 +51,14 @@ $query = OC_DB::prepare("
|
|||
|
||||
|
||||
$params=array(
|
||||
urldecode($_GET["url"]),
|
||||
urldecode($_GET["title"]),
|
||||
urldecode($_GET["description"]),
|
||||
htmlspecialchars_decode($_GET["url"]),
|
||||
htmlspecialchars_decode($_GET["title"]),
|
||||
htmlspecialchars_decode($_GET["description"]),
|
||||
OC_User::getUser()
|
||||
);
|
||||
$query->execute($params);
|
||||
$b_id = OC_DB::insertid();
|
||||
|
||||
|
||||
if($b_id !== false) {
|
||||
$query = OC_DB::prepare("
|
||||
INSERT INTO *PREFIX*bookmarks_tags
|
||||
|
|
|
@ -36,7 +36,7 @@ if( !OC_User::isLoggedIn()){
|
|||
}
|
||||
|
||||
$params=array(
|
||||
urldecode($_GET["url"]),
|
||||
htmlspecialchars_decode($_GET["url"]),
|
||||
OC_User::getUser()
|
||||
);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ if( !OC_User::isLoggedIn()){
|
|||
// $metadata = array();
|
||||
|
||||
require '../bookmarksHelper.php';
|
||||
$metadata = getURLMetadata(htmlspecialchars_decode($_GET["url"]));
|
||||
|
||||
$metadata = getURLMetadata(urldecode($_GET["url"]));
|
||||
|
||||
echo json_encode( array( 'status' => 'success', 'data' => $metadata));
|
||||
|
|
|
@ -40,7 +40,7 @@ $query = OC_DB::prepare("
|
|||
AND url LIKE ?
|
||||
");
|
||||
|
||||
$params=array(OC_User::getUser(), urldecode($_GET["url"]));
|
||||
$params=array(OC_User::getUser(), htmlspecialchars_decode($_GET["url"]));
|
||||
$bookmarks = $query->execute($params);
|
||||
|
||||
header( "HTTP/1.1 204 No Content" );
|
||||
|
|
|
@ -39,7 +39,7 @@ $params=array(OC_User::getUser());
|
|||
$CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' );
|
||||
|
||||
//Filter for tag?
|
||||
$filterTag = isset($_GET['tag']) ? '%' . urldecode($_GET['tag']) . '%' : false;
|
||||
$filterTag = isset($_GET['tag']) ? '%' . htmlspecialchars_decode($_GET['tag']) . '%' : false;
|
||||
if($filterTag){
|
||||
$sqlFilterTag = 'HAVING tags LIKE ?';
|
||||
$params[] = $filterTag;
|
||||
|
@ -50,6 +50,13 @@ if($filterTag){
|
|||
$offset = isset($_GET['page']) ? intval($_GET['page']) * 10 : 0;
|
||||
$params[] = $offset;
|
||||
|
||||
$sort = isset($_GET['sort']) ? ($_GET['sort']) : 'bookmarks_sorting_recent';
|
||||
if($sort == 'bookmarks_sorting_clicks') {
|
||||
$sqlSort = 'clickcount DESC';
|
||||
} else {
|
||||
$sqlSort = 'id DESC';
|
||||
}
|
||||
|
||||
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
|
||||
$_gc_separator = ', \' \'';
|
||||
} else {
|
||||
|
@ -72,7 +79,7 @@ $query = OC_DB::prepare('
|
|||
AND *PREFIX*bookmarks.user_id = ?
|
||||
GROUP BY url
|
||||
'.$sqlFilterTag.'
|
||||
ORDER BY *PREFIX*bookmarks.id DESC
|
||||
ORDER BY *PREFIX*bookmarks.'.$sqlSort.'
|
||||
LIMIT ?, 10');
|
||||
|
||||
$bookmarks = $query->execute($params)->fetchAll();
|
||||
|
|
|
@ -7,10 +7,11 @@ function getURLMetadata($url) {
|
|||
if(preg_match($protocols, $url) == 0) {
|
||||
$url = 'http://' . $url;
|
||||
}
|
||||
$metadata['url'] = $url;
|
||||
|
||||
$page = file_get_contents($url);
|
||||
@preg_match( "/<title>(.*)<\/title>/si", $page, $match );
|
||||
$metadata['title'] = htmlentities(strip_tags(@$match[1]));
|
||||
$metadata['title'] = htmlspecialchars_decode(@$match[1]);
|
||||
|
||||
$meta = get_meta_tags($url);
|
||||
|
||||
|
|
|
@ -23,10 +23,29 @@
|
|||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.bookmarks_sorting {
|
||||
float: left;
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
.bookmarks_sorting li {
|
||||
padding: 1ex 1em;
|
||||
border: 1px solid gray;
|
||||
-moz-border-radius:1em; -webkit-border-radius:1em; border-radius:1em;
|
||||
}
|
||||
|
||||
.bookmarks_sorting_active {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.bookmarks_add {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bookmarks_addBml {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.bookmarks_label {
|
||||
width: 7em;
|
||||
display: inline-block;
|
||||
|
@ -61,3 +80,7 @@
|
|||
.bookmark_tags {
|
||||
color: #ff3333;
|
||||
}
|
||||
|
||||
.clear {
|
||||
clear:both;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
var bookmarks_page = 0;
|
||||
var bookmarks_loading = false;
|
||||
|
||||
var bookmarks_sorting = 'bookmarks_sorting_recent';
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.bookmarks_addBtn').click(function(event){
|
||||
$('.bookmarks_add').slideToggle();
|
||||
|
@ -10,6 +12,9 @@ $(document).ready(function() {
|
|||
$(window).scroll(updateOnBottom);
|
||||
|
||||
$('#bookmark_add_url').focusout(getMetadata);
|
||||
$('.' + bookmarks_sorting).addClass('bookmarks_sorting_active');
|
||||
|
||||
$('.bookmarks_sorting li').click(function(event){changeSorting(this)});
|
||||
|
||||
$('.bookmarks_list').empty();
|
||||
getBookmarks();
|
||||
|
@ -20,9 +25,10 @@ function getBookmarks() {
|
|||
//have patience :)
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: 'ajax/updateList.php',
|
||||
data: 'tag=' + encodeURI($('#bookmarkFilterTag').val()) + '&page=' + bookmarks_page,
|
||||
data: 'tag=' + encodeURI($('#bookmarkFilterTag').val()) + '&page=' + bookmarks_page + '&sort=' + bookmarks_sorting,
|
||||
success: function(bookmarks){
|
||||
bookmarks_page += 1;
|
||||
$('.bookmark_link').unbind('click', recordClick);
|
||||
|
@ -42,14 +48,26 @@ function getMetadata() {
|
|||
var url = encodeEntities($('#bookmark_add_url').val())
|
||||
$.ajax({
|
||||
url: 'ajax/getMeta.php',
|
||||
data: 'url=' + encodeURI(url),
|
||||
data: 'url=' + encodeURIComponent(url),
|
||||
success: function(pageinfo){
|
||||
$('#bookmark_add_url').val(pageinfo.data.url);
|
||||
$('#bookmark_add_description').val(pageinfo.data.description);
|
||||
$('#bookmark_add_title').val(pageinfo.data.title);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function changeSorting(sortEl) {
|
||||
$('.' + bookmarks_sorting).removeClass('bookmarks_sorting_active');
|
||||
bookmarks_sorting = sortEl.className;
|
||||
$('.' + bookmarks_sorting).addClass('bookmarks_sorting_active');
|
||||
|
||||
$('.bookmarks_list').empty();
|
||||
bookmarks_page = 0;
|
||||
bookmarks_loading = false;
|
||||
getBookmarks();
|
||||
}
|
||||
|
||||
function addBookmark(event) {
|
||||
var url = encodeEntities($('#bookmark_add_url').val())
|
||||
var title = encodeEntities($('#bookmark_add_title').val())
|
||||
|
@ -94,6 +112,9 @@ function updateBookmarksList(bookmark) {
|
|||
for ( var i=0, len=tags.length; i<len; ++i ){
|
||||
taglist = taglist + '<a class="bookmark_tags" href="?tag=' + encodeURI(tags[i]) + '">' + tags[i] + '</a> ';
|
||||
}
|
||||
if(!hasProtocol(bookmark.url)) {
|
||||
bookmark.url = 'http://' + bookmark.url;
|
||||
}
|
||||
$('.bookmarks_list').append(
|
||||
'<div class="bookmark_single">' +
|
||||
'<p class="bookmark_title"><a href="' + encodeEntities(bookmark.url) + '" target="_new" class="bookmark_link">' + encodeEntities(bookmark.title) + '</a></p>' +
|
||||
|
@ -127,3 +148,8 @@ function encodeEntities(s){
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function hasProtocol(url) {
|
||||
var regexp = /(ftp|http|https|sftp)/;
|
||||
return regexp.test(url);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<input type="hidden" id="bookmarkFilterTag" value="<?php if(isset($_GET['tag'])) echo htmlentities($_GET['tag']); ?>" />
|
||||
<h2 class="bookmarks_headline"><?php echo isset($_GET["tag"]) ? 'Bookmarks with tag: ' . urldecode($_GET["tag"]) : 'All bookmarks'; ?></h2>
|
||||
<div class="bookmarks_menu">
|
||||
<input type="button" class="bookmarks_addBtn" value="Add Bookmark" />
|
||||
<a type="button" class="bookmarks_addBml" href="javascript:var url = encodeURI(location.href);window.open('<?php echo (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . OC_Helper::linkTo('bookmarks', 'addBm.php'); ?>?url='+url, 'owncloud-bookmarks');" title="Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.">Bookmarklet</a>
|
||||
<input type="button" class="bookmarks_addBtn" value="Add Bookmark"/>
|
||||
<a class="bookmarks_addBml" href="javascript:var url = encodeURIComponent(location.href);window.open('<?php echo (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . OC_Helper::linkTo('bookmarks', 'addBm.php'); ?>?url='+url, 'owncloud-bookmarks');" title="Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.">Add page to ownCloud</a>
|
||||
</div>
|
||||
<div class="bookmarks_add">
|
||||
<p><label class="bookmarks_label">Address</label><input type="text" id="bookmark_add_url" class="bookmarks_input" /></p>
|
||||
|
@ -12,6 +12,13 @@
|
|||
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint">Hint: Use space to separate tags.</label></p>
|
||||
<p><label class="bookmarks_label"></label><input type="submit" id="bookmark_add_submit" /></p>
|
||||
</div>
|
||||
<div class="bookmarks_sorting pager">
|
||||
<ul>
|
||||
<li class="bookmarks_sorting_recent">Recent Bookmarks</li>
|
||||
<li class="bookmarks_sorting_clicks">Most clicks</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div class="bookmarks_list">
|
||||
<noscript>
|
||||
JavaScript is needed to display your Bookmarks
|
||||
|
|
Loading…
Reference in New Issue