mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-12 13:33:46 +08:00
ZIP Imports: Added book content ordering to import preview
This commit is contained in:
parent
59cfc087e1
commit
c0dff6d4a6
|
@ -36,6 +36,20 @@ class ZipExportBook extends ZipExportModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function children(): array
|
||||||
|
{
|
||||||
|
$children = [
|
||||||
|
...$this->pages,
|
||||||
|
...$this->chapters,
|
||||||
|
];
|
||||||
|
|
||||||
|
usort($children, function ($a, $b) {
|
||||||
|
return ($a->priority ?? 0) - ($b->priority ?? 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $children;
|
||||||
|
}
|
||||||
|
|
||||||
public static function fromModel(Book $model, ZipExportFiles $files): self
|
public static function fromModel(Book $model, ZipExportFiles $files): self
|
||||||
{
|
{
|
||||||
$instance = new self();
|
$instance = new self();
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ZipExportChapter extends ZipExportModel
|
||||||
|
|
||||||
public function metadataOnly(): void
|
public function metadataOnly(): void
|
||||||
{
|
{
|
||||||
$this->description_html = $this->priority = null;
|
$this->description_html = null;
|
||||||
|
|
||||||
foreach ($this->pages as $page) {
|
foreach ($this->pages as $page) {
|
||||||
$page->metadataOnly();
|
$page->metadataOnly();
|
||||||
|
@ -30,6 +30,11 @@ class ZipExportChapter extends ZipExportModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function children(): array
|
||||||
|
{
|
||||||
|
return $this->pages;
|
||||||
|
}
|
||||||
|
|
||||||
public static function fromModel(Chapter $model, ZipExportFiles $files): self
|
public static function fromModel(Chapter $model, ZipExportFiles $files): self
|
||||||
{
|
{
|
||||||
$instance = new self();
|
$instance = new self();
|
||||||
|
|
|
@ -23,7 +23,7 @@ class ZipExportPage extends ZipExportModel
|
||||||
|
|
||||||
public function metadataOnly(): void
|
public function metadataOnly(): void
|
||||||
{
|
{
|
||||||
$this->html = $this->markdown = $this->priority = null;
|
$this->html = $this->markdown = null;
|
||||||
|
|
||||||
foreach ($this->attachments as $attachment) {
|
foreach ($this->attachments as $attachment) {
|
||||||
$attachment->metadataOnly();
|
$attachment->metadataOnly();
|
||||||
|
|
|
@ -5,7 +5,6 @@ namespace BookStack\Exports\ZipExports;
|
||||||
use BookStack\Exceptions\ZipExportException;
|
use BookStack\Exceptions\ZipExportException;
|
||||||
use BookStack\Exports\ZipExports\Models\ZipExportBook;
|
use BookStack\Exports\ZipExports\Models\ZipExportBook;
|
||||||
use BookStack\Exports\ZipExports\Models\ZipExportChapter;
|
use BookStack\Exports\ZipExports\Models\ZipExportChapter;
|
||||||
use BookStack\Exports\ZipExports\Models\ZipExportModel;
|
|
||||||
use BookStack\Exports\ZipExports\Models\ZipExportPage;
|
use BookStack\Exports\ZipExports\Models\ZipExportPage;
|
||||||
use BookStack\Util\WebSafeMimeSniffer;
|
use BookStack\Util\WebSafeMimeSniffer;
|
||||||
use ZipArchive;
|
use ZipArchive;
|
||||||
|
|
|
@ -16,11 +16,13 @@ $model - object
|
||||||
<span>@icon('tag'){{ count($model->tags) }}</span>
|
<span>@icon('tag'){{ count($model->tags) }}</span>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@foreach($model->chapters ?? [] as $chapter)
|
@if(method_exists($model, 'children'))
|
||||||
@include('exports.parts.import-item', ['type' => 'chapter', 'model' => $chapter])
|
@foreach($model->children() as $child)
|
||||||
@endforeach
|
@include('exports.parts.import-item', [
|
||||||
@foreach($model->pages ?? [] as $page)
|
'type' => ($child instanceof \BookStack\Exports\ZipExports\Models\ZipExportPage) ? 'page' : 'chapter',
|
||||||
@include('exports.parts.import-item', ['type' => 'page', 'model' => $page])
|
'model' => $child
|
||||||
|
])
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
Loading…
Reference in New Issue
Block a user