Skip to content

Commit

Permalink
[MAINTENANCE] Improvements regarding TYPO3 12 update (#1368)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Meyer <[email protected]>
  • Loading branch information
markusweigelt and sebastian-meyer authored Nov 5, 2024
1 parent f0b6815 commit dc570d6
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
uses: php-actions/composer@v6
with:
command: update
php_version: "7.4"

- name: PHPStan Static Analysis
uses: php-actions/phpstan@v3
with:
configuration: ./.github/phpstan.neon
path: ''
9 changes: 5 additions & 4 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Pagination\PaginationInterface;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Pagination\PaginatorInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;

/**
Expand Down Expand Up @@ -108,9 +108,10 @@ public function injectDocumentRepository(DocumentRepository $documentRepository)
*/
protected function initialize(RequestInterface $request): void
{
// replace with $this->request->getQueryParams() when dropping support for Typo3 v11, see Deprecation-100596
$this->requestData = GeneralUtility::_GPmerged('tx_dlf');
$this->pageUid = (int) GeneralUtility::_GET('id');
/** @var Request $request */
$this->requestData = $request->getQueryParams()['tx_dlf'] ?? [];
$this->pageUid = (int) ($this->requestData['id'] ?? 0);
$this->requestData['page'] = $this->requestData['page'] ?? 1;

// Sanitize user input to prevent XSS attacks.
$this->sanitizeRequestData();
Expand Down
8 changes: 5 additions & 3 deletions Classes/Controller/TableOfContentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,23 +264,25 @@ private function resolveMenuEntry(array $entry): array
private function getAllLogicalUnits(): void
{
$physicalStructure = $this->document->getCurrentDocument()->physicalStructure;

if (isset($this->requestData['page']) &&
!empty($this->requestData['page'])
&& !empty($physicalStructure)
) {
$page = $this->requestData['page'];
$structureMapLinks = $this->document->getCurrentDocument()->smLinks;

$this->activeEntries = array_merge(
(array) $structureMapLinks['p2l'][$physicalStructure[0]],
(array) $structureMapLinks['p2l'][$physicalStructure[$page]]
(array) ($structureMapLinks['p2l'][$physicalStructure[0]] ?? []),
(array) ($structureMapLinks['p2l'][$physicalStructure[$page]] ?? [])
);
if (
!empty($this->requestData['double'])
&& $page < $this->document->getCurrentDocument()->numPages
) {
$this->activeEntries = array_merge(
$this->activeEntries,
(array) $structureMapLinks['p2l'][$physicalStructure[$page + 1]]
(array) ($structureMapLinks['p2l'][$physicalStructure[$page + 1]] ?? [])
);
}
}
Expand Down
8 changes: 5 additions & 3 deletions Classes/Controller/ToolboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ private function renderModelDownloadTool(): void

$this->setPage();

$this->view->assign('modelDownload', $this->getFile($this->requestData['page'], GeneralUtility::trimExplode(',', $this->settings['fileGrpsModelDownload'])));
if (isset($this->requestData['page'])) {
$this->view->assign('modelDownload', $this->getFile($this->requestData['page'], GeneralUtility::trimExplode(',', $this->settings['fileGrpsModelDownload'])));
}
}

/**
Expand Down Expand Up @@ -417,7 +419,7 @@ private function getPageLink(): array
$fileGrpsDownload = GeneralUtility::trimExplode(',', $this->extConf['files']['fileGrpDownload']);
// Get image link.
while ($fileGrpDownload = array_shift($fileGrpsDownload)) {
$firstFileGroupDownload = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$pageNumber]]['files'][$fileGrpDownload];
$firstFileGroupDownload = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$pageNumber]]['files'][$fileGrpDownload] ?? [];
if (!empty($firstFileGroupDownload)) {
$firstPageLink = $this->currentDocument->getFileLocation($firstFileGroupDownload);
// Get second page, too, if double page view is activated.
Expand Down Expand Up @@ -461,7 +463,7 @@ private function getWorkLink(): string
$fileGrpsDownload = GeneralUtility::trimExplode(',', $this->extConf['files']['fileGrpDownload']);
// Get work link.
while ($fileGrpDownload = array_shift($fileGrpsDownload)) {
$fileGroupDownload = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[0]]['files'][$fileGrpDownload];
$fileGroupDownload = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[0]]['files'][$fileGrpDownload] ?? [];
if (!empty($fileGroupDownload)) {
$workLink = $this->currentDocument->getFileLocation($fileGroupDownload);
break;
Expand Down
3 changes: 2 additions & 1 deletion Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ function($arguments, $cPid)
&& !$this->isIiifManifestWithNewspaperRelatedType($metadata['type'][0])) {
$type = $metadata['type'][0];
}

return $type;
});
}
Expand All @@ -162,6 +161,7 @@ protected function loadDocument(array $requestData, int $pid): void
if (!empty($requestData['id'])) {
$this->initializeRepositories($pid);
$doc = null;
$this->document = null;
if (MathUtility::canBeInterpretedAsInteger($requestData['id'])) {
// find document from repository by uid
$this->document = $this->documentRepository->findOneByIdAndSettings((int) $requestData['id'], ['storagePid' => $pid]);
Expand All @@ -172,6 +172,7 @@ protected function loadDocument(array $requestData, int $pid): void
}
} elseif (GeneralUtility::isValidUrl($requestData['id'])) {
$doc = AbstractDocument::getInstance($requestData['id'], ['storagePid' => $pid], true);

if ($doc !== null) {
if ($doc->recordId) {
$this->document = $this->documentRepository->findOneByRecordId($doc->recordId);
Expand Down
3 changes: 2 additions & 1 deletion Classes/Middleware/Embedded3dViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Exception;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Log\LogManager;
Expand Down Expand Up @@ -210,7 +211,7 @@ public function renderDefaultViewer($model): HtmlResponse
{
/** @var ResourceFactory $resourceFactory */
$resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
$html = $resourceFactory->retrieveFileOrFolderObject('EXT:dlf/Resources/Private/Templates/Embedded3dViewer/Standalone.html')->getContents();
$html = $resourceFactory->retrieveFileOrFolderObject('EXT:dlf/Resources/Public/Html/Embedded3dViewerStandalone.html')->getContents();
$file = $resourceFactory->retrieveFileOrFolderObject('EXT:dlf/Resources/Public/JavaScript/Embedded3dViewer/model-viewer-3.5.0.min.js');
$html = str_replace('{{modelViewerJS}}', $file->getPublicUrl(), $html);
$html = str_replace("{{modelUrl}}", $model, $html);
Expand Down
11 changes: 10 additions & 1 deletion Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,19 @@ page {
kitodo-pageView-searchInDocument = EXT:dlf/Resources/Public/JavaScript/PageView/SearchInDocument.js
kitodo-pageView-pageView = EXT:dlf/Resources/Public/JavaScript/PageView/PageView.js
kitodo-search-suggest = EXT:dlf/Resources/Public/JavaScript/Search/Suggester.js

}
}

[typo3.branch=="11.5"]
page.inlineSettings {
dlfAssets = /typo3conf/ext/dlf/Resources/Public/
}
[else]
page.inlineSettings {
dlfAssets = /_assets/007831ab53eafe3f6be2b9b1baf2a8d6/
}
[end]

[request && like(traverse(request.getQueryParams(), 'tx_dlf/multiview'), '1')]
page.includeJSFooter {
# Gridstack
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/WildWebMidi/wildwebmidi.js

Large diffs are not rendered by default.

0 comments on commit dc570d6

Please sign in to comment.