mirror of
https://github.com/wallabag/wallabag.git
synced 2024-09-27 14:00:15 +00:00
Fix bad date format in Browser import
This commit is contained in:
parent
f0fd82d039
commit
27acc6ddb8
5 changed files with 31 additions and 62 deletions
|
@ -193,6 +193,29 @@ abstract class BrowserImport extends AbstractImport
|
||||||
return $entry;
|
return $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function prepareEntry($entry = [])
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'title' => $entry['name'],
|
||||||
|
'html' => '',
|
||||||
|
'url' => $entry['url'],
|
||||||
|
'is_archived' => $this->markAsRead,
|
||||||
|
'tags' => '',
|
||||||
|
// date are in format like "13118829474385693"
|
||||||
|
// and it'll be devided by 1000 in AbstractImport
|
||||||
|
'created_at' => (int) ceil($entry['date_added'] / 10000),
|
||||||
|
];
|
||||||
|
|
||||||
|
if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
|
||||||
|
$data['tags'] = $entry['tags'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,35 +29,4 @@ class ChromeImport extends BrowserImport
|
||||||
{
|
{
|
||||||
return 'import.chrome.description';
|
return 'import.chrome.description';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function prepareEntry($entry = [])
|
|
||||||
{
|
|
||||||
$data = [
|
|
||||||
'title' => $entry['name'],
|
|
||||||
'html' => '',
|
|
||||||
'url' => $entry['url'],
|
|
||||||
'is_archived' => $this->markAsRead,
|
|
||||||
'tags' => '',
|
|
||||||
'created_at' => $entry['date_added'],
|
|
||||||
];
|
|
||||||
|
|
||||||
if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
|
|
||||||
$data['tags'] = $entry['tags'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function setEntryAsRead(array $importedEntry)
|
|
||||||
{
|
|
||||||
$importedEntry['is_archived'] = 1;
|
|
||||||
|
|
||||||
return $importedEntry;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,35 +29,4 @@ class FirefoxImport extends BrowserImport
|
||||||
{
|
{
|
||||||
return 'import.firefox.description';
|
return 'import.firefox.description';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function prepareEntry($entry = [])
|
|
||||||
{
|
|
||||||
$data = [
|
|
||||||
'title' => $entry['name'],
|
|
||||||
'html' => '',
|
|
||||||
'url' => $entry['url'],
|
|
||||||
'is_archived' => $this->markAsRead,
|
|
||||||
'tags' => '',
|
|
||||||
'created_at' => $entry['date_added'],
|
|
||||||
];
|
|
||||||
|
|
||||||
if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
|
|
||||||
$data['tags'] = $entry['tags'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function setEntryAsRead(array $importedEntry)
|
|
||||||
{
|
|
||||||
$importedEntry['is_archived'] = 1;
|
|
||||||
|
|
||||||
return $importedEntry;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,6 +120,10 @@ class ChromeControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertNotEmpty($content->getPreviewPicture());
|
$this->assertNotEmpty($content->getPreviewPicture());
|
||||||
$this->assertNotEmpty($content->getLanguage());
|
$this->assertNotEmpty($content->getLanguage());
|
||||||
$this->assertEquals(0, count($content->getTags()));
|
$this->assertEquals(0, count($content->getTags()));
|
||||||
|
|
||||||
|
$createdAt = $content->getCreatedAt();
|
||||||
|
$this->assertEquals('2011', $createdAt->format('Y'));
|
||||||
|
$this->assertEquals('07', $createdAt->format('m'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithEmptyFile()
|
public function testImportWallabagWithEmptyFile()
|
||||||
|
|
|
@ -133,6 +133,10 @@ class FirefoxControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertNotEmpty($content->getMimetype());
|
$this->assertNotEmpty($content->getMimetype());
|
||||||
$this->assertNotEmpty($content->getPreviewPicture());
|
$this->assertNotEmpty($content->getPreviewPicture());
|
||||||
$this->assertEmpty($content->getLanguage());
|
$this->assertEmpty($content->getLanguage());
|
||||||
|
|
||||||
|
$createdAt = $content->getCreatedAt();
|
||||||
|
$this->assertEquals('2011', $createdAt->format('Y'));
|
||||||
|
$this->assertEquals('07', $createdAt->format('m'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithEmptyFile()
|
public function testImportWallabagWithEmptyFile()
|
||||||
|
|
Loading…
Reference in a new issue