2009-10-03 23:52:30 +02:00
< ? php
2010-01-16 11:01:37 +01:00
/**
* Implements the del . icio . us API request for all a user ' s posts ,
* optionally filtered by tag .
*
* 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
*/
2009-10-03 23:52:30 +02:00
// del.icio.us behavior:
// - doesn't include the filtered tag as an attribute on the root element (we do)
2008-04-18 09:08:17 +02:00
// Force HTTP authentication first!
2010-01-16 11:01:37 +01:00
require_once 'httpauth.inc.php' ;
2009-10-03 23:52:30 +02:00
/* Service creation: only useful services are created */
2010-01-16 11:01:37 +01:00
$bookmarkservice = SemanticScuttle_Service_Factory :: get ( 'Bookmark' );
2009-10-03 23:52:30 +02:00
// Check to see if a tag was specified.
2010-01-16 11:01:37 +01:00
if ( isset ( $_REQUEST [ 'tag' ]) && ( trim ( $_REQUEST [ 'tag' ]) != '' )) {
2009-10-03 23:52:30 +02:00
$tag = trim ( $_REQUEST [ 'tag' ]);
2010-01-16 11:01:37 +01:00
} else {
$tag = null ;
}
2009-10-03 23:52:30 +02:00
// Get the posts relevant to the passed-in variables.
2010-01-16 11:01:37 +01:00
$bookmarks = $bookmarkservice -> getBookmarks (
0 , null , $userservice -> getCurrentUserId (),
$tag , null , getSortOrder ()
);
2009-10-03 23:52:30 +02:00
// Set up the XML file and output all the posts.
2008-04-18 09:08:17 +02:00
echo '<!DOCTYPE NETSCAPE-Bookmark-file-1>' . " \r \n " ;
2010-01-16 11:01:37 +01:00
echo '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" />' ;
2009-10-03 23:52:30 +02:00
echo '<!-- This is an automatically generated file. -->' . " \r \n " ;
echo '<TITLE>Bookmarks</TITLE>' . " \r \n " ;
echo '<H1 LAST_MODIFIED="' . date ( 'U' ) . '">Bookmarks for ' . htmlspecialchars ( $currentUser -> getUsername ()) . '' . ( is_null ( $tag ) ? '' : ' tag="' . htmlspecialchars ( $tag ) . '"' ) . " from " . $sitename . " </H1> \r \n " ;
echo '<DL><p>' . " \r \n " ;
2010-01-16 11:01:37 +01:00
foreach ( $bookmarks [ 'bookmarks' ] as $row ) {
if ( is_null ( $row [ 'bDescription' ]) || ( trim ( $row [ 'bDescription' ]) == '' )) {
2009-10-03 23:52:30 +02:00
$description = '' ;
2010-01-16 11:01:37 +01:00
} else {
2009-10-03 23:52:30 +02:00
$description = 'description="' . filter ( $row [ 'bDescription' ], 'xml' ) . '" ' ;
2010-01-16 11:01:37 +01:00
}
2009-10-03 23:52:30 +02:00
$taglist = '' ;
if ( count ( $row [ 'tags' ]) > 0 ) {
2010-01-16 11:01:37 +01:00
foreach ( $row [ 'tags' ] as $tag ) {
2009-10-03 23:52:30 +02:00
$taglist .= convertTag ( $tag ) . ',' ;
2010-01-16 11:01:37 +01:00
}
2009-10-03 23:52:30 +02:00
$taglist = substr ( $taglist , 0 , - 1 );
} else {
$taglist = 'system:unfiled' ;
}
echo " \t <dt><a href= \" " . filter ( $row [ 'bAddress' ], 'xml' ) . '" ' . $description . ' hash="' . md5 ( $row [ 'bAddress' ]) . '" tags="' . filter ( $taglist , 'xml' ) . '" ADD_DATE="' . date ( 'U' , strtotime ( $row [ 'bDatetime' ])) . " \" > " . filter ( $row [ 'bTitle' ], 'xml' ) . " </a> \r \n " ;
}
echo '</DL><p>' ;
?>