1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2025-02-18 15:54:28 +01:00

First version of export file

This commit is contained in:
Brice Maron 2012-09-18 20:27:24 +00:00
parent f61dc7cf43
commit a29afef606
2 changed files with 39 additions and 5 deletions

32
export.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* Copyright (c) 2012 Brice Maron < brice __At__ bmaron dot net >
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
// Check if we are a user
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('bookmarks');
$file = <<<EOT
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
EOT;
$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks(0, 'id', array(), true,-1);
foreach($bookmarks as $bm) {
$file .= '<DT><A HREF="'.$bm['url'].'" TAGS="'.implode(',',$bm['tags']).'">'.htmlspecialchars($bm['title'], ENT_QUOTES, 'UTF-8').'</A>';
if($bm['description'])
$file .= '<DD>'.htmlspecialchars($bm['description'], ENT_QUOTES, 'UTF-8');
}
echo $file;

View File

@ -54,13 +54,13 @@ class OC_Bookmarks_Bookmarks{
* @param sqlSortColumn sort result with this column
* @param filters can be: empty -> no filter, a string -> filter this, a string array -> filter for all strings
* @param filterTagOnly if true, filter affects only tags, else filter affects url, title and tags
* @param limit number of item to return (default 10) if -1 or false then all item are returned
* @return void
*/
public static function findBookmarks($offset, $sqlSortColumn, $filters, $filterTagOnly) {
public static function findBookmarks($offset, $sqlSortColumn, $filters, $filterTagOnly, $limit = 10) {
$CONFIG_DBTYPE = OCP\Config::getSystemValue( 'dbtype', 'sqlite' );
if(is_string($filters)) $filters = array($filters);
$limit = 10;
$params=array(OCP\USER::getUser());
if($CONFIG_DBTYPE == 'pgsql') {
@ -82,9 +82,11 @@ class OC_Bookmarks_Bookmarks{
$params[] = '%' . strtolower($filter) . '%';
}
}
$sql .= " ORDER BY ".$sqlSortColumn." DESC
LIMIT $limit
OFFSET $offset";
$sql .= " ORDER BY ".$sqlSortColumn." DESC ";
if($limit != -1 && $limit !== false) {
$sql .= " LIMIT $limit ";
$sql .= " OFFSET $offset";
}
$query = OCP\DB::prepare($sql);
$results = $query->execute($params)->fetchAll();