]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Add Tags on Import 1008/head
authorkaffeeringe <kontakt@kaffeeringe.de>
Sun, 18 Jan 2015 20:49:05 +0000 (21:49 +0100)
committerkaffeeringe <kontakt@kaffeeringe.de>
Sun, 18 Jan 2015 20:49:05 +0000 (21:49 +0100)
I fixed it! And it works for me.

But: I am not too good with programming. So better check the code ;-)

inc/poche/Poche.class.php

index 16235474bf601a4cc321bf1513b7d9e59326c1a1..01f919d9eb4eef65c04d18ce33c2e9f74e691bd9 100755 (executable)
@@ -192,6 +192,7 @@ class Poche
                 } else {
                   Tools::redirect('?view=home&closewin=true');
                 }
+                return $last_id;
                 break;
             case 'delete':
                 $msg = 'delete link #' . $id;
@@ -625,7 +626,18 @@ class Poche
                         $urlsInserted[] = $url; //add
                         if (isset($record['tags']) && trim($record['tags'])) {
 
-                            // @TODO: set tags
+                            $tags = explode(' ', $record['tags']);                                                                                                             
+                                                       foreach($tags as $tag) {
+                                                               $entry_id = $id;
+                                                               $tag_id = $this->store->retrieveTagByValue($tag);
+                                                               if ($tag_id) {
+                                                                       $this->store->setTagToEntry($tag_id['id'], $entry_id);                                                                  
+                                                               } else {
+                                                                       $this->store->createTag($tag);
+                                                                       $tag_id = $this->store->retrieveTagByValue($tag);
+                                                                       $this->store->setTagToEntry($tag_id['id'], $entry_id);
+                                                               }
+                                                       }
 
                         }
                     }