. * * @category Bookmark * @package StatusNet * @author Evan Prodromou * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ if (!defined('STATUSNET')) { // This check helps protect against security problems; // your code file can't be executed directly from the web. exit(1); } /** * Importer class for Delicious bookmarks * * @category Bookmark * @package StatusNet * @author Evan Prodromou * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ class DeliciousBookmarkImporter extends QueueHandler { /** * Return the transport for this queue handler * * @return string 'dlcsbkmk' */ function transport() { return 'dlcsbkmk'; } /** * Handle the data * * @param array $data array of user, dt, dd * * @return boolean success value */ function handle($data) { list($user, $dt, $dd) = $data; $as = $dt->getElementsByTagName('a'); if ($as->length == 0) { throw new ClientException(_("No tag in a
.")); } $a = $as->item(0); $private = $a->getAttribute('private'); if ($private != 0) { throw new ClientException(_('Skipping private bookmark.')); } if (!empty($dd)) { $description = $dd->nodeValue; } else { $description = null; } $title = $a->nodeValue; $url = $a->getAttribute('href'); $tags = $a->getAttribute('tags'); $addDate = $a->getAttribute('add_date'); $created = common_sql_date(intval($addDate)); try { $saved = Bookmark::saveNew($user->getProfile(), $title, $url, $tags, $description, array('created' => $created, 'distribute' => false)); } catch (ClientException $e) { // Most likely a duplicate -- continue on with the rest! common_log(LOG_ERR, "Error importing delicious bookmark to $url: " . $e->getMessage()); return true; } return true; } }