summaryrefslogtreecommitdiffstats
path: root/apps/bookmarks/ajax
diff options
context:
space:
mode:
authorDavid Iwanowitsch <david+git@unclouded.de>2012-01-29 19:32:33 +0100
committerRobin Appelman <icewind@owncloud.com>2012-02-01 15:40:59 +0100
commite229a6adecde57d919b6b1385729cbf8cd41fe89 (patch)
treec3d3908d6f3cc144b90bec6e1a58b6b4a32a63ed /apps/bookmarks/ajax
parent4145e3b2651312b5949de3aae4f34c1be5332eb8 (diff)
downloadnextcloud-server-e229a6adecde57d919b6b1385729cbf8cd41fe89.tar.gz
nextcloud-server-e229a6adecde57d919b6b1385729cbf8cd41fe89.zip
Added searchprovider for bookmarks, initial l10n support for bookmark plugin
moved some code from updateList.php to bookmarks.php, to make it reusable
Diffstat (limited to 'apps/bookmarks/ajax')
-rw-r--r--apps/bookmarks/ajax/updateList.php60
1 files changed, 5 insertions, 55 deletions
diff --git a/apps/bookmarks/ajax/updateList.php b/apps/bookmarks/ajax/updateList.php
index d2a5397452f..487e0d290e3 100644
--- a/apps/bookmarks/ajax/updateList.php
+++ b/apps/bookmarks/ajax/updateList.php
@@ -5,6 +5,7 @@
*
* @author Arthur Schiwon
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de
+* @copyright 2012 David Iwanowitsch <david at unclouded dot de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
@@ -30,71 +31,20 @@ require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
-$params=array(OC_User::getUser());
-$CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' );
//Filter for tag?
-$filterTag = isset($_GET['tag']) ? '%' . htmlspecialchars_decode($_GET['tag']) . '%' : false;
-if($filterTag){
- $sqlFilterTag = 'HAVING tags LIKE ?';
- $params[] = $filterTag;
- if($CONFIG_DBTYPE == 'pgsql' ) {
- $sqlFilterTag = 'HAVING array_to_string(array_agg(tag), \' \') LIKE ?';
- }
-} else {
- $sqlFilterTag = '';
-}
+$filterTag = isset($_GET['tag']) ? htmlspecialchars_decode($_GET['tag']) : false;
$offset = isset($_GET['page']) ? intval($_GET['page']) * 10 : 0;
$sort = isset($_GET['sort']) ? ($_GET['sort']) : 'bookmarks_sorting_recent';
if($sort == 'bookmarks_sorting_clicks') {
- $sqlSort = 'clickcount DESC';
+ $sqlSortColumn = 'clickcount';
} else {
- $sqlSort = 'id DESC';
+ $sqlSortColumn = 'id';
}
-if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
- $_gc_separator = ', \' \'';
-} else {
- $_gc_separator = 'SEPARATOR \' \'';
-}
-
-if($CONFIG_DBTYPE == 'pgsql' ){
- $params[] = $offset;
- $query = OC_DB::prepare('
- SELECT id, url, title, array_to_string(array_agg(tag), \' \') as tags
- FROM *PREFIX*bookmarks
- LEFT JOIN *PREFIX*bookmarks_tags ON *PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id
- WHERE
- *PREFIX*bookmarks.user_id = ?
- GROUP BY id, url, title
- '.$sqlFilterTag.'
- ORDER BY *PREFIX*bookmarks.'.$sqlSort.'
- LIMIT 10
- OFFSET ?');
-} else {
- $query = OC_DB::prepare('
- SELECT id, url, title,
- CASE WHEN *PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id
- THEN GROUP_CONCAT( tag ' .$_gc_separator. ' )
- ELSE \' \'
- END
- AS tags
- FROM *PREFIX*bookmarks
- LEFT JOIN *PREFIX*bookmarks_tags ON 1=1
- WHERE (*PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id
- OR *PREFIX*bookmarks.id NOT IN (
- SELECT *PREFIX*bookmarks_tags.bookmark_id FROM *PREFIX*bookmarks_tags
- )
- )
- AND *PREFIX*bookmarks.user_id = ?
- GROUP BY url
- '.$sqlFilterTag.'
- ORDER BY *PREFIX*bookmarks.'.$sqlSort.'
- LIMIT '.$offset.', 10');
-}
-$bookmarks = $query->execute($params)->fetchAll();
+$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $filterTag, true);
OC_JSON::success(array('data' => $bookmarks));