Fix import and export

This commit is contained in:
Marcel Klehr 2020-04-07 19:00:54 +02:00
parent 71583d39c3
commit 796d6c8a26
3 changed files with 18 additions and 23 deletions

View File

@ -659,6 +659,8 @@ class BookmarkController extends ApiController {
return new JSONResponse(['status' => 'error', 'data' => $result['errors']]);
}
$folder = $this->toInternalFolderId($folder);
try {
$result = $this->htmlImporter->importFile($this->userId, $file, $folder);
} catch (UnauthorizedAccessError $e) {
@ -690,7 +692,7 @@ class BookmarkController extends ApiController {
*/
public function exportBookmark() {
try {
$data = $this->htmlExporter->exportFolder($this->userId, -1);
$data = $this->htmlExporter->exportFolder($this->userId, $this->_getRootFolderId());
} catch (UnauthorizedAccessError $e) {
// Will probably never happen
return new JSONResponse(['status' => 'error', 'data' => 'Unauthorized access']);

View File

@ -61,7 +61,7 @@ class HtmlExporter {
* @throws DoesNotExistException
* @throws MultipleObjectsReturnedException
*/
public function exportFolder($userId, int $folderId = -1): string {
public function exportFolder($userId, int $folderId): string {
$file = '<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>';
@ -74,23 +74,16 @@ class HtmlExporter {
/**
* @param int $userId
* @param int $id
* @param bool $recurse
* @return string
* @throws UnauthorizedAccessError
* @throws DoesNotExistException
* @throws MultipleObjectsReturnedException
* @throws UnauthorizedAccessError
*/
protected function serializeFolder($userId, int $id): string {
if ($id !== -1) {
$folder = $this->folderMapper->find($id);
if ($folder->getUserId() !== $userId) {
throw new UnauthorizedAccessError('Insufficient permissions for folder ' . $id);
}
$output = '<DT><h3>' . htmlspecialchars($folder->getTitle()) . '</h3>' . "\n"
. '<DL><p>';
} else {
$output = '<H1>Bookmarks</h1>' . "\n"
. '<DL><p>';
}
$folder = $this->folderMapper->find($id);
$output = '<DT><h3>' . htmlspecialchars($folder->getTitle()) . '</h3>' . "\n"
. '<DL><p>';
$childBookmarks = $this->treeMapper->findChildren(TreeMapper::TYPE_BOOKMARK, $id);
foreach ($childBookmarks as $bookmark) {

View File

@ -86,16 +86,16 @@
bookmark: {
type: Object,
required: true,
},
},
},
data() {
return { title: this.bookmark.title, renaming: false, selected: false }
},
computed: {
apiUrl() {
if (this.isPublic) {
return generateUrl('/apps/bookmarks/public/rest/v2')
}
data() {
return { title: this.bookmark.title, renaming: false, selected: false }
},
computed: {
apiUrl() {
if (this.isPublic) {
return generateUrl('/apps/bookmarks/public/rest/v2')
}
return generateUrl('/apps/bookmarks')
},
iconUrl() {