2009-10-03 23:52:30 +02:00
|
|
|
<?php
|
|
|
|
// Export in CSV format in order to allow the import into a spreadsheet tool like Excel
|
|
|
|
|
2009-05-05 15:27:07 +02:00
|
|
|
// Force HTTP authentication first!
|
2010-03-17 21:11:21 +01:00
|
|
|
$httpContentType = 'application/csv-tab-delimited-table';
|
|
|
|
require_once 'httpauth.inc.php';
|
|
|
|
header("Content-disposition: filename=exportBookmarks.csv");
|
2009-10-03 23:52:30 +02:00
|
|
|
|
|
|
|
/* Service creation: only useful services are created */
|
2009-10-23 19:13:16 +02:00
|
|
|
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
|
2009-10-03 23:52:30 +02:00
|
|
|
|
|
|
|
// Check to see if a tag was specified.
|
2010-03-28 20:08:38 +02:00
|
|
|
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != '')) {
|
|
|
|
//$_GET vars have + replaced to " " automatically
|
|
|
|
$tag = str_replace(' ', '+', trim($_REQUEST['tag']));
|
|
|
|
} else {
|
|
|
|
$tag = null;
|
|
|
|
}
|
2009-10-03 23:52:30 +02:00
|
|
|
|
|
|
|
// Get the posts relevant to the passed-in variables.
|
2010-03-28 20:08:38 +02:00
|
|
|
$bookmarks = $bookmarkservice->getBookmarks(
|
|
|
|
0, null, $userservice->getCurrentUserId(),
|
|
|
|
$tag, null, getSortOrder()
|
|
|
|
);
|
2009-10-03 23:52:30 +02:00
|
|
|
|
2009-05-05 15:27:07 +02:00
|
|
|
//columns titles
|
2009-05-19 15:37:40 +02:00
|
|
|
echo 'url;title;tags;description';
|
2009-10-03 23:52:30 +02:00
|
|
|
echo "\n";
|
|
|
|
|
|
|
|
foreach($bookmarks['bookmarks'] as $row) {
|
|
|
|
if (is_null($row['bDescription']) || (trim($row['bDescription']) == ''))
|
|
|
|
$description = '';
|
|
|
|
else
|
|
|
|
$description = filter(str_replace(array("\r\n", "\n", "\r"),"", $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';
|
|
|
|
}
|
|
|
|
|
2009-05-19 15:37:40 +02:00
|
|
|
echo '"'.filter($row['bAddress'], 'xml') .'";"'. filter($row['bTitle'], 'xml') .'";"'. filter($taglist, 'xml') .'";"'. $description .'"';
|
2009-10-03 23:52:30 +02:00
|
|
|
echo "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|