]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Bookmark/deliciousbookmarkimporter.php
SubMirror: add mirrored feeds count & management link to stats section when showing...
[quix0rs-gnu-social.git] / plugins / Bookmark / deliciousbookmarkimporter.php
index 061572d95a034ae10fa3a32dd082aceb8ce62956..018239f49d6be341edc6cbfd065820c64fcf463a 100644 (file)
@@ -61,48 +61,29 @@ class DeliciousBookmarkImporter extends QueueHandler
     /**
      * Handle the data
      * 
-     * @param array $data array of user, dt, dd
+     * @param array $data associative array of user & bookmark info from DeliciousBackupImporter::importBookmark()
      *
      * @return boolean success value
      */
 
     function handle($data)
     {
-        list($user, $dt, $dd) = $data;
+        $profile = Profile::staticGet('id', $data['profile_id']);
 
-        $as = $dt->getElementsByTagName('a');
-
-        if ($as->length == 0) {
-            throw new ClientException(_("No <A> tag in a <DT>."));
-        }
-
-        $a = $as->item(0);
-                    
-        $private = $a->getAttribute('private');
-
-        if ($private != 0) {
-            throw new ClientException(_('Skipping private bookmark.'));
+        try {
+            $saved = Bookmark::saveNew($profile,
+                                       $data['title'],
+                                       $data['url'],
+                                       $data['tags'],
+                                       $data['description'],
+                                       array('created' => $data['created'],
+                                             'distribute' => false));
+        } catch (ClientException $e) {
+            // Most likely a duplicate -- continue on with the rest!
+            common_log(LOG_ERR, "Error importing delicious bookmark to $data[url]: " . $e->getMessage());
+            return true;
         }
 
-        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));
-
-        $saved = Bookmark::saveNew($user->getProfile(),
-                                          $title,
-                                          $url,
-                                          $tags,
-                                          $description,
-                                          array('created' => $created));
-
         return true;
     }
 }