X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FImportBundle%2FImport%2FBrowserImport.php;h=2ca1683b1688b33ff7c9e203e635b0bb83b09f7a;hb=5601b4536cea2a4c5ebdd39251cc16ec92c01b1d;hp=68fa8bf83877c98354f662613e56973a6912440c;hpb=12d93e6896f2d99b6329b7979ee7b6d11e457c3a;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php index 68fa8bf8..2ca1683b 100644 --- a/src/Wallabag/ImportBundle/Import/BrowserImport.php +++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php @@ -45,6 +45,8 @@ abstract class BrowserImport extends AbstractImport $data = json_decode(file_get_contents($this->filepath), true); if (empty($data)) { + $this->logger->error('Wallabag Browser: no entries in imported file'); + return false; } @@ -137,12 +139,24 @@ abstract class BrowserImport extends AbstractImport public function parseEntry(array $importedEntry) { if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) { + if ($this->producer) { + $this->parseEntriesForProducer($importedEntry); + + return; + } + $this->parseEntries($importedEntry); return; } if (array_key_exists('children', $importedEntry)) { + if ($this->producer) { + $this->parseEntriesForProducer($importedEntry['children']); + + return; + } + $this->parseEntries($importedEntry['children']); return; @@ -193,41 +207,6 @@ abstract class BrowserImport extends AbstractImport return $entry; } - /** - * {@inheritdoc} - */ - protected function prepareEntry(array $entry = []) - { - $url = array_key_exists('uri', $entry) ? $entry['uri'] : $entry['url']; - $date = array_key_exists('date_added', $entry) ? $entry['date_added'] : $entry['dateAdded']; - $title = array_key_exists('name', $entry) ? $entry['name'] : $entry['title']; - - if (16 === strlen($date)) { - // firefox ... - $date = (int) ceil($date / 1000000); - } else if (17 === strlen($date)) { - // chrome ... - $date = (int) ceil($date / 10000000); - } else { - $date = ''; - } - - $data = [ - 'title' => $title, - 'html' => '', - 'url' => $url, - 'is_archived' => $this->markAsRead, - 'tags' => '', - 'created_at' => $date, - ]; - - if (array_key_exists('tags', $entry) && $entry['tags'] != '') { - $data['tags'] = $entry['tags']; - } - - return $data; - } - /** * {@inheritdoc} */