Skip to content

Commit

Permalink
Remove initDoc to avoid redundancy between Document and PageView cont…
Browse files Browse the repository at this point in the history
…rollers

Logically the document should not be displayed if its controller is not loaded
  • Loading branch information
beatrycze-volk committed Oct 25, 2023
1 parent b12ca3e commit c8ec2f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
16 changes: 0 additions & 16 deletions Classes/Controller/PageViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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);
}
Expand Down
14 changes: 3 additions & 11 deletions Resources/Public/JavaScript/PageView/PageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* images?: dlf.ImageDesc[] | [];
* fulltexts?: dlf.FulltextDesc[] | [];
* controls?: ('OverviewMap' | 'ZoomPanel')[];
* initDoc: dlf.Document;
* }} DlfViewerConfig
*
* @typedef {any} DlfDocument
Expand Down Expand Up @@ -196,11 +195,6 @@ var dlfViewer = function(settings){
*/
this.layersCache = {};

/**
* @private
*/
this.initDoc = settings.initDoc;

/**
* @type {dlfController | null}
* @private
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit c8ec2f1

Please sign in to comment.