From c3d67c16be0ff84d5502827e4095c213e655515a Mon Sep 17 00:00:00 2001 From: mensonge Date: Tue, 5 May 2009 13:27:07 +0000 Subject: New Feature: export user's bookmarks into CSV format for import into spreadsheet tools git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@316 b3834d28-1941-0410-a4f8-b48e95affb8f --- api/.htaccess | 1 + api/export_csv.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 api/export_csv.php (limited to 'api') diff --git a/api/.htaccess b/api/.htaccess index 9553254..dc20db5 100644 --- a/api/.htaccess +++ b/api/.htaccess @@ -13,6 +13,7 @@ RewriteRule ^posts/update posts_update.php RewriteRule ^posts/add posts_add.php RewriteRule ^posts/delete posts_delete.php RewriteRule ^export/html export_html.php +RewriteRule ^export/csv export_csv.php RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L] diff --git a/api/export_csv.php b/api/export_csv.php new file mode 100644 index 0000000..d9d824b --- /dev/null +++ b/api/export_csv.php @@ -0,0 +1,47 @@ +getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag, NULL, getSortOrder()); + +header("Content-Type: application/csv-tab-delimited-table"); +header("Content-disposition: filename=exportBookmarks.csv"); + +//columns titles +echo 'url,title,tags,description'; +echo "\n"; + +foreach($bookmarks['bookmarks'] as $row) { + if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) + $description = ''; + else + $description = filter($row['bDescription'], 'xml'); + + $taglist = ''; + if (count($row['tags']) > 0) { + foreach($row['tags'] as $tag) + $taglist .= convertTag($tag) .','; + $taglist = substr($taglist, 0, -1); + } else { + $taglist = 'system:unfiled'; + } + + echo '"'.filter($row['bAddress'], 'xml') .'","'. filter($row['bTitle'], 'xml') .'","'. filter($taglist, 'xml') .'","'. $description .'"'; + echo "\n"; +} + + +?> -- cgit v1.2.3