+
+ protected function handleModelReference(Model $model, ZipExportModel $exportModel, ZipExportFiles $files): ?string
+ {
+ // TODO - References to other entities
+
+ // Handle attachment references
+ // No permission check needed here since they would only already exist in this
+ // reference context if already allowed via their entity access.
+ if ($model instanceof Attachment) {
+ if (isset($this->attachments[$model->id])) {
+ return "[[bsexport:attachment:{$model->id}]]";
+ }
+ return null;
+ }
+
+ // Handle image references
+ if ($model instanceof Image) {
+ // Only handle gallery and drawio images
+ if ($model->type !== 'gallery' && $model->type !== 'drawio') {
+ return null;
+ }
+
+ // We don't expect images to be part of book/chapter content
+ if (!($exportModel instanceof ZipExportPage)) {
+ return null;
+ }
+
+ $page = $model->getPage();
+ if ($page && userCan('view', $page)) {
+ if (!isset($this->images[$model->id])) {
+ $exportImage = ZipExportImage::fromModel($model, $files);
+ $this->images[$model->id] = $exportImage;
+ $exportModel->images[] = $exportImage;
+ }
+ return "[[bsexport:image:{$model->id}]]";
+ }
+ return null;
+ }
+
+ return null;
+ }