2007-12-12 17:29:16 +01:00
|
|
|
<?php
|
2010-01-16 11:08:25 +01:00
|
|
|
/**
|
|
|
|
* Implements the del.icio.us API request for a user's recent posts,
|
|
|
|
* optionally filtered by tag and/or number of posts
|
|
|
|
* (default 15, max 100, just like del.icio.us).
|
|
|
|
*
|
|
|
|
* SemanticScuttle - your social bookmark manager.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2007-12-12 17:29:16 +01:00
|
|
|
|
|
|
|
// Set default and max number of posts
|
|
|
|
$countDefault = 15;
|
2010-01-16 11:08:25 +01:00
|
|
|
$countMax = 100;
|
2007-12-12 17:29:16 +01:00
|
|
|
|
|
|
|
// Force HTTP authentication first!
|
2010-03-17 21:11:21 +01:00
|
|
|
$httpContentType = 'text/xml';
|
2010-01-16 11:08:25 +01:00
|
|
|
require_once 'httpauth.inc.php';
|
2007-12-12 17:29:16 +01:00
|
|
|
|
2008-12-05 08:25:04 +01:00
|
|
|
/* Service creation: only useful services are created */
|
2010-01-16 11:08:25 +01:00
|
|
|
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
|
2008-12-05 08:25:04 +01:00
|
|
|
|
2007-12-12 17:29:16 +01:00
|
|
|
|
|
|
|
// Check to see if a tag was specified.
|
2010-01-16 11:08:25 +01:00
|
|
|
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != '')) {
|
2007-12-12 17:29:16 +01:00
|
|
|
$tag = trim($_REQUEST['tag']);
|
2010-01-16 11:08:25 +01:00
|
|
|
} else {
|
|
|
|
$tag = null;
|
|
|
|
}
|
2007-12-12 17:29:16 +01:00
|
|
|
|
|
|
|
// Check to see if the number of items was specified.
|
2010-01-16 11:08:25 +01:00
|
|
|
if (isset($_REQUEST['count']) && (intval($_REQUEST['count']) != 0)) {
|
2007-12-12 17:29:16 +01:00
|
|
|
$count = intval($_REQUEST['count']);
|
2010-01-16 11:08:25 +01:00
|
|
|
if ($count > $countMax) {
|
2007-12-12 17:29:16 +01:00
|
|
|
$count = $countMax;
|
2010-01-16 11:08:25 +01:00
|
|
|
} else if ($count < 0) {
|
2007-12-12 17:29:16 +01:00
|
|
|
$count = 0;
|
2010-01-16 11:08:25 +01:00
|
|
|
}
|
2007-12-12 17:29:16 +01:00
|
|
|
} else {
|
|
|
|
$count = $countDefault;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the posts relevant to the passed-in variables.
|
2010-01-16 11:08:25 +01:00
|
|
|
$bookmarks = $bookmarkservice->getBookmarks(
|
|
|
|
0, $count, $userservice->getCurrentUserId(), $tag
|
|
|
|
);
|
2007-12-12 17:29:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
// Set up the XML file and output all the tags.
|
|
|
|
echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
|
2008-12-05 08:25:04 +01:00
|
|
|
echo '<posts tag="'. (is_null($tag) ? '' : filter($tag, 'xml')) .'" user="'. filter($currentUser->getUsername(), 'xml') ."\">\r\n";
|
2007-12-12 17:29:16 +01:00
|
|
|
|
2010-01-16 11:08:25 +01:00
|
|
|
foreach ($bookmarks['bookmarks'] as $row) {
|
|
|
|
if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) {
|
2007-12-12 17:29:16 +01:00
|
|
|
$description = '';
|
2010-01-16 11:08:25 +01:00
|
|
|
} else {
|
2007-12-12 17:29:16 +01:00
|
|
|
$description = 'extended="'. filter($row['bDescription'], 'xml') .'" ';
|
2010-01-16 11:08:25 +01:00
|
|
|
}
|
2007-12-12 17:29:16 +01:00
|
|
|
|
|
|
|
$taglist = '';
|
|
|
|
if (count($row['tags']) > 0) {
|
2010-01-16 11:08:25 +01:00
|
|
|
foreach ($row['tags'] as $tag) {
|
2007-12-12 17:29:16 +01:00
|
|
|
$taglist .= convertTag($tag) .' ';
|
2010-01-16 11:08:25 +01:00
|
|
|
}
|
2007-12-12 17:29:16 +01:00
|
|
|
$taglist = substr($taglist, 0, -1);
|
|
|
|
} else {
|
|
|
|
$taglist = 'system:unfiled';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "\t<post href=\"". filter($row['bAddress'], 'xml') .'" description="'. filter($row['bTitle'], 'xml') .'" '. $description .'hash="'. $row['bHash'] .'" tag="'. filter($taglist, 'xml') .'" time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />\r\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '</posts>';
|
|
|
|
?>
|