3 namespace BookStack\Exports;
5 use BookStack\App\Model;
6 use BookStack\Exports\ZipExportModels\ZipExportAttachment;
7 use BookStack\Exports\ZipExportModels\ZipExportPage;
9 class ZipExportReferences
11 /** @var ZipExportPage[] */
12 protected array $pages = [];
13 protected array $books = [];
14 protected array $chapters = [];
16 /** @var ZipExportAttachment[] */
17 protected array $attachments = [];
19 public function __construct(
20 protected ZipReferenceParser $parser,
24 public function addPage(ZipExportPage $page): void
27 $this->pages[$page->id] = $page;
30 foreach ($page->attachments as $attachment) {
31 if ($attachment->id) {
32 $this->attachments[$attachment->id] = $attachment;
37 public function buildReferences(): void
39 // TODO - References to images, attachments, other entities
41 // TODO - Parse page MD & HTML
42 foreach ($this->pages as $page) {
43 $page->html = $this->parser->parse($page->html ?? '', function (Model $model): ?string {
44 // TODO - Handle found link to $model
45 // - Validate we can see/access $model, or/and that it's
46 // part of the export in progress.
48 // TODO - Add images after the above to files
55 // TODO - Parse chapter desc html
56 // TODO - Parse book desc html