summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorCôme BERNIGAUD <come.bernigaud@laposte.net>2011-08-25 17:03:56 +0200
committerCôme BERNIGAUD <come.bernigaud@laposte.net>2011-08-25 17:03:56 +0200
commitad053d504ca0d4ce1bd15514e60fd344e8dbc293 (patch)
treefab164e6819e4faddff13e3a6fe30782b1789373 /apps
parentdf560b3d9d513e7b01c95745ae70a2151c2375fc (diff)
parente6bdd256675f86cb3335f0491a3b41b7f4bf90fd (diff)
downloadnextcloud-server-ad053d504ca0d4ce1bd15514e60fd344e8dbc293.tar.gz
nextcloud-server-ad053d504ca0d4ce1bd15514e60fd344e8dbc293.zip
Merge branch 'master' of git://anongit.kde.org/owncloud
Diffstat (limited to 'apps')
-rw-r--r--apps/bookmarks/addBm.php2
-rw-r--r--apps/bookmarks/ajax/addBookmark.php7
-rw-r--r--apps/bookmarks/ajax/delBookmark.php2
-rw-r--r--apps/bookmarks/ajax/getMeta.php2
-rw-r--r--apps/bookmarks/ajax/recordClick.php2
-rw-r--r--apps/bookmarks/ajax/updateList.php11
-rw-r--r--apps/bookmarks/bookmarksHelper.php3
-rw-r--r--apps/bookmarks/css/bookmarks.css25
-rw-r--r--apps/bookmarks/js/bookmarks.js32
-rw-r--r--apps/bookmarks/templates/list.php11
10 files changed, 80 insertions, 17 deletions
diff --git a/apps/bookmarks/addBm.php b/apps/bookmarks/addBm.php
index d308e8fe605..2dab33afb22 100644
--- a/apps/bookmarks/addBm.php
+++ b/apps/bookmarks/addBm.php
@@ -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']));
diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php
index d3d23aad267..78913f7a132 100644
--- a/apps/bookmarks/ajax/addBookmark.php
+++ b/apps/bookmarks/ajax/addBookmark.php
@@ -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
diff --git a/apps/bookmarks/ajax/delBookmark.php b/apps/bookmarks/ajax/delBookmark.php
index 99a618a7d14..bf1611fe5c1 100644
--- a/apps/bookmarks/ajax/delBookmark.php
+++ b/apps/bookmarks/ajax/delBookmark.php
@@ -36,7 +36,7 @@ if( !OC_User::isLoggedIn()){
}
$params=array(
- urldecode($_GET["url"]),
+ htmlspecialchars_decode($_GET["url"]),
OC_User::getUser()
);
diff --git a/apps/bookmarks/ajax/getMeta.php b/apps/bookmarks/ajax/getMeta.php
index dadf23afd91..e9fe0d684dc 100644
--- a/apps/bookmarks/ajax/getMeta.php
+++ b/apps/bookmarks/ajax/getMeta.php
@@ -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));
diff --git a/apps/bookmarks/ajax/recordClick.php b/apps/bookmarks/ajax/recordClick.php
index 4dcb0b4a0df..116daea8bbb 100644
--- a/apps/bookmarks/ajax/recordClick.php
+++ b/apps/bookmarks/ajax/recordClick.php
@@ -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" );
diff --git a/apps/bookmarks/ajax/updateList.php b/apps/bookmarks/ajax/updateList.php
index 9290757d0b1..ceecc5b7efa 100644
--- a/apps/bookmarks/ajax/updateList.php
+++ b/apps/bookmarks/ajax/updateList.php
@@ -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();
diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php
index be6ac098d0f..aee941a27b9 100644
--- a/apps/bookmarks/bookmarksHelper.php
+++ b/apps/bookmarks/bookmarksHelper.php
@@ -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);
diff --git a/apps/bookmarks/css/bookmarks.css b/apps/bookmarks/css/bookmarks.css
index aa28424c0b2..96559172448 100644
--- a/apps/bookmarks/css/bookmarks.css
+++ b/apps/bookmarks/css/bookmarks.css
@@ -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;
@@ -60,4 +79,8 @@
.bookmark_tags {
color: #ff3333;
-} \ No newline at end of file
+}
+
+.clear {
+ clear:both;
+}
diff --git a/apps/bookmarks/js/bookmarks.js b/apps/bookmarks/js/bookmarks.js
index ad3aefde204..ac87d967be8 100644
--- a/apps/bookmarks/js/bookmarks.js
+++ b/apps/bookmarks/js/bookmarks.js
@@ -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),
- success: function(pageinfo){
+ 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);
+}
diff --git a/apps/bookmarks/templates/list.php b/apps/bookmarks/templates/list.php
index d7d37257a8a..4f101d44f90 100644
--- a/apps/bookmarks/templates/list.php
+++ b/apps/bookmarks/templates/list.php
@@ -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"/>&nbsp;
+ <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