}
}
+ 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
{
$instance = new self();
public function metadataOnly(): void
{
- $this->description_html = $this->priority = null;
+ $this->description_html = null;
foreach ($this->pages as $page) {
$page->metadataOnly();
}
}
+ public function children(): array
+ {
+ return $this->pages;
+ }
+
public static function fromModel(Chapter $model, ZipExportFiles $files): self
{
$instance = new self();
public function metadataOnly(): void
{
- $this->html = $this->markdown = $this->priority = null;
+ $this->html = $this->markdown = null;
foreach ($this->attachments as $attachment) {
$attachment->metadataOnly();
use BookStack\Exceptions\ZipExportException;
use BookStack\Exports\ZipExports\Models\ZipExportBook;
use BookStack\Exports\ZipExports\Models\ZipExportChapter;
-use BookStack\Exports\ZipExports\Models\ZipExportModel;
use BookStack\Exports\ZipExports\Models\ZipExportPage;
use BookStack\Util\WebSafeMimeSniffer;
use ZipArchive;
<span>@icon('tag'){{ count($model->tags) }}</span>
@endif
</div>
- @foreach($model->chapters ?? [] as $chapter)
- @include('exports.parts.import-item', ['type' => 'chapter', 'model' => $chapter])
- @endforeach
- @foreach($model->pages ?? [] as $page)
- @include('exports.parts.import-item', ['type' => 'page', 'model' => $page])
- @endforeach
+ @if(method_exists($model, 'children'))
+ @foreach($model->children() as $child)
+ @include('exports.parts.import-item', [
+ 'type' => ($child instanceof \BookStack\Exports\ZipExports\Models\ZipExportPage) ? 'page' : 'chapter',
+ 'model' => $child
+ ])
+ @endforeach
+ @endif
</div>
</div>
\ No newline at end of file