From c8ec2f131e194c1d86386f05ac1a3ddd80b6fa0b Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Mon, 3 Apr 2023 17:58:46 +0200 Subject: [PATCH] Remove initDoc to avoid redundancy between Document and PageView controllers Logically the document should not be displayed if its controller is not loaded --- Classes/Controller/PageViewController.php | 16 ---------------- Resources/Public/JavaScript/PageView/PageView.js | 14 +++----------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/Classes/Controller/PageViewController.php b/Classes/Controller/PageViewController.php index 8ca6d56dbe..dabf9e0333 100644 --- a/Classes/Controller/PageViewController.php +++ b/Classes/Controller/PageViewController.php @@ -137,21 +137,6 @@ protected function getFulltext(int $page): array */ protected function addViewerJS(): void { - // TODO(client-side): Avoid redundancy to DocumentController - $imageFileGroups = array_reverse(GeneralUtility::trimExplode(',', $this->extConf['fileGrpImages'])); - $fulltextFileGroups = GeneralUtility::trimExplode(',', $this->extConf['fileGrpFulltext']); - $config = [ - 'forceAbsoluteUrl' => !empty($this->settings['forceAbsoluteUrl']), - 'proxyFileGroups' => !empty($this->settings['useInternalProxy']) - ? array_merge($imageFileGroups, $fulltextFileGroups) - : [], - // toArray uses closed interval [minPage, maxPage] - 'minPage' => $this->requestData['page'], - 'maxPage' => $this->requestData['page'] + $this->requestData['double'] - ]; - - $initDoc = $this->document->getCurrentDocument()->toArray($this->uriBuilder, $config); - // Viewer configuration. $viewerConfiguration = ' (function () { @@ -175,7 +160,6 @@ protected function addViewerJS(): void fulltexts: ' . json_encode($this->fulltexts) . ', annotationContainers: ' . json_encode($this->annotationContainers) . ', useInternalProxy: ' . ($this->settings['useInternalProxy'] ? 1 : 0) . ', - initDoc: ' . json_encode($initDoc) . ', }); tx_dlf_viewer.setDocController(docController); } diff --git a/Resources/Public/JavaScript/PageView/PageView.js b/Resources/Public/JavaScript/PageView/PageView.js index a020c3a10f..0b2f39b3da 100644 --- a/Resources/Public/JavaScript/PageView/PageView.js +++ b/Resources/Public/JavaScript/PageView/PageView.js @@ -22,7 +22,6 @@ * images?: dlf.ImageDesc[] | []; * fulltexts?: dlf.FulltextDesc[] | []; * controls?: ('OverviewMap' | 'ZoomPanel')[]; - * initDoc: dlf.Document; * }} DlfViewerConfig * * @typedef {any} DlfDocument @@ -196,11 +195,6 @@ var dlfViewer = function(settings){ */ this.layersCache = {}; - /** - * @private - */ - this.initDoc = settings.initDoc; - /** * @type {dlfController | null} * @private @@ -653,10 +647,9 @@ dlfViewer.prototype.init = function(controlNames) { dlfViewer.prototype.getVisiblePages = function () { if (this.docController === null) { - return this.initDoc.pages.map( (page, i) => ({ - pageNo: this.initDoc.query.minPage + i, - pageObj: page - })); + /* eslint no-console: ["error", { allow: ["warn", "error"] }] */ + console.error("No document controller found"); + return; } else { return this.docController.getVisiblePages(); } @@ -762,7 +755,6 @@ dlfViewer.prototype.initLayer = function (imageSourceObjs) { */ dlfViewer.prototype.initLoadFulltexts = function (visiblePages) { if (this.docController === null) { - // TODO(client-side): Make it work then docController === null return; }