2009-10-03 21:52:30 +00:00
|
|
|
<?php
|
2010-03-28 18:09:59 +00:00
|
|
|
/**
|
|
|
|
* Export own bookmarks in CSV format in order to allow the import
|
|
|
|
* into a spreadsheet tool like Excel
|
|
|
|
*
|
|
|
|
* PHP version 5.
|
|
|
|
*
|
|
|
|
* @category Bookmarking
|
|
|
|
* @package SemanticScuttle
|
|
|
|
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
|
|
|
|
* @author Christian Weiske <cweiske@cweiske.de>
|
|
|
|
* @author Eric Dane <ericdane@users.sourceforge.net>
|
|
|
|
* @license GPL http://www.gnu.org/licenses/gpl.html
|
|
|
|
* @link http://sourceforge.net/projects/semanticscuttle
|
|
|
|
*/
|
2009-10-03 21:52:30 +00:00
|
|
|
|
2009-05-05 13:27:07 +00:00
|
|
|
// Force HTTP authentication first!
|
2010-03-17 20:11:21 +00:00
|
|
|
$httpContentType = 'application/csv-tab-delimited-table';
|
|
|
|
require_once 'httpauth.inc.php';
|
|
|
|
header("Content-disposition: filename=exportBookmarks.csv");
|
2009-10-03 21:52:30 +00:00
|
|
|
|
|
|
|
/* Service creation: only useful services are created */
|
2011-01-24 07:04:08 +00:00
|
|
|
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
|
2009-10-03 21:52:30 +00:00
|
|
|
|
|
|
|
// Check to see if a tag was specified.
|
2010-03-28 18:08:38 +00: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 21:52:30 +00:00
|
|
|
|
|
|
|
// Get the posts relevant to the passed-in variables.
|
2010-03-28 18:08:38 +00:00
|
|
|
$bookmarks = $bookmarkservice->getBookmarks(
|
|
|
|
0, null, $userservice->getCurrentUserId(),
|
|
|
|
$tag, null, getSortOrder()
|
|
|
|
);
|
2009-10-03 21:52:30 +00:00
|
|
|
|
2009-05-05 13:27:07 +00:00
|
|
|
//columns titles
|
2009-05-19 13:37:40 +00:00
|
|
|
echo 'url;title;tags;description';
|
2009-10-03 21:52:30 +00:00
|
|
|
echo "\n";
|
|
|
|
|
2011-01-24 07:04:08 +00:00
|
|
|
foreach ($bookmarks['bookmarks'] as $row) {
|
|
|
|
if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) {
|
2009-10-03 21:52:30 +00:00
|
|
|
$description = '';
|
2011-01-24 07:04:08 +00:00
|
|
|
} else {
|
|
|
|
$description = filter(
|
|
|
|
str_replace(array("\r\n", "\n", "\r"), "", $row['bDescription']), 'xml'
|
|
|
|
);
|
|
|
|
}
|
2009-10-03 21:52:30 +00:00
|
|
|
|
|
|
|
$taglist = '';
|
|
|
|
if (count($row['tags']) > 0) {
|
2011-01-24 07:04:08 +00:00
|
|
|
foreach ($row['tags'] as $tag) {
|
2009-10-03 21:52:30 +00:00
|
|
|
$taglist .= convertTag($tag) .',';
|
2011-01-24 07:04:08 +00:00
|
|
|
}
|
2009-10-03 21:52:30 +00:00
|
|
|
$taglist = substr($taglist, 0, -1);
|
|
|
|
} else {
|
|
|
|
$taglist = 'system:unfiled';
|
|
|
|
}
|
|
|
|
|
2011-01-24 07:04:08 +00:00
|
|
|
echo '"'.filter($row['bAddress'], 'xml') .'";"'. filter($row['bTitle'], 'xml') .
|
|
|
|
'";"'. filter($taglist, 'xml') .'";"'. $description .'"';
|
2009-10-03 21:52:30 +00:00
|
|
|
echo "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|