2024-10-21 02:56:56 +08:00
|
|
|
<?php
|
|
|
|
|
2024-10-23 17:48:26 +08:00
|
|
|
namespace BookStack\Exports\ZipExports\Models;
|
2024-10-21 02:56:56 +08:00
|
|
|
|
|
|
|
use BookStack\Entities\Models\Page;
|
|
|
|
use BookStack\Entities\Tools\PageContent;
|
2024-10-23 17:48:26 +08:00
|
|
|
use BookStack\Exports\ZipExports\ZipExportFiles;
|
2024-10-21 02:56:56 +08:00
|
|
|
|
2024-10-21 19:13:41 +08:00
|
|
|
class ZipExportPage extends ZipExportModel
|
2024-10-21 02:56:56 +08:00
|
|
|
{
|
|
|
|
public ?int $id = null;
|
|
|
|
public string $name;
|
|
|
|
public ?string $html = null;
|
|
|
|
public ?string $markdown = null;
|
|
|
|
public ?int $priority = null;
|
|
|
|
/** @var ZipExportAttachment[] */
|
|
|
|
public array $attachments = [];
|
|
|
|
/** @var ZipExportImage[] */
|
|
|
|
public array $images = [];
|
|
|
|
/** @var ZipExportTag[] */
|
|
|
|
public array $tags = [];
|
|
|
|
|
|
|
|
public static function fromModel(Page $model, ZipExportFiles $files): self
|
|
|
|
{
|
|
|
|
$instance = new self();
|
|
|
|
$instance->id = $model->id;
|
|
|
|
$instance->name = $model->name;
|
|
|
|
$instance->html = (new PageContent($model))->render();
|
|
|
|
|
|
|
|
if (!empty($model->markdown)) {
|
|
|
|
$instance->markdown = $model->markdown;
|
|
|
|
}
|
|
|
|
|
|
|
|
$instance->tags = ZipExportTag::fromModelArray($model->tags()->get()->all());
|
|
|
|
$instance->attachments = ZipExportAttachment::fromModelArray($model->attachments()->get()->all(), $files);
|
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
}
|