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]
</IfModule>
--- /dev/null
+<?php\r
+// Export in CSV format in order to allow the import into a spreadsheet tool like Excel\r
+\r
+// Force HTTP authentication first!
+require_once('httpauth.inc.php');\r
+require_once('../header.inc.php');\r
+
+/* Service creation: only useful services are created */\r
+$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');\r
+\r
+// Check to see if a tag was specified.\r
+if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))\r
+ $tag = trim($_REQUEST['tag']);\r
+else\r
+ $tag = NULL;\r
+\r
+// Get the posts relevant to the passed-in variables.\r
+$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag, NULL, getSortOrder());\r
+\r
+header("Content-Type: application/csv-tab-delimited-table");
+header("Content-disposition: filename=exportBookmarks.csv");\r
+\r
+//columns titles
+echo 'url,title,tags,description';
+echo "\n";\r
+\r
+foreach($bookmarks['bookmarks'] as $row) {\r
+ if (is_null($row['bDescription']) || (trim($row['bDescription']) == ''))\r
+ $description = '';\r
+ else\r
+ $description = filter($row['bDescription'], 'xml');\r
+\r
+ $taglist = '';\r
+ if (count($row['tags']) > 0) {\r
+ foreach($row['tags'] as $tag)\r
+ $taglist .= convertTag($tag) .',';\r
+ $taglist = substr($taglist, 0, -1);\r
+ } else {\r
+ $taglist = 'system:unfiled';\r
+ }\r
+\r
+ echo '"'.filter($row['bAddress'], 'xml') .'","'. filter($row['bTitle'], 'xml') .'","'. filter($taglist, 'xml') .'","'. $description .'"';
+ echo "\n";\r
+}\r
+\r
+\r
+?>\r