Skip to content

Commit

Permalink
[MAINTENANCE] Cleanup and improvements regarding TYPO3 12 update (#1362)
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 Oct 21, 2024
1 parent 6dfff36 commit 5c4c903
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 144 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
/var/
/vendor/
.DS_Store
_build
venv
2 changes: 0 additions & 2 deletions Build/Documentation/.gitignore

This file was deleted.

35 changes: 0 additions & 35 deletions Build/Documentation/conf.py

This file was deleted.

1 change: 0 additions & 1 deletion Build/Documentation/dbdocs/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;

/**
Expand Down
55 changes: 0 additions & 55 deletions Build/Documentation/sphinx.sh

This file was deleted.

7 changes: 3 additions & 4 deletions Classes/Common/MetsDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -845,9 +845,8 @@ private function setDefaultMetadataValue(array $resArray, array &$metadata): voi
private function setSortableMetadataValue(array $resArray, DOMXPath $domXPath, DOMElement $domNode, array &$metadata): void
{
$indexName = $resArray['index_name'];
$currentMetadata = $metadata[$indexName][0];

if (!empty($metadata[$indexName]) && $resArray['is_sortable']) {
$currentMetadata = $metadata[$indexName][0];
if ($resArray['format'] > 0 && !empty($resArray['xpath_sorting'])) {
$values = $domXPath->evaluate($resArray['xpath_sorting'], $domNode);
if ($values instanceof DOMNodeList && $values->length > 0) {
Expand Down Expand Up @@ -1338,15 +1337,15 @@ protected function magicGetFileGrps(): array
// Get configured USE attributes.
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey, 'files');
$useGrps = GeneralUtility::trimExplode(',', $extConf['fileGrpImages']);

$configKeys = [
'fileGrpThumbs',
'fileGrpDownload',
'fileGrpFulltext',
'fileGrpAudio',
'fileGrpScore'
];

foreach ($configKeys as $key) {
if (!empty($extConf[$key])) {
$useGrps = array_merge($useGrps, GeneralUtility::trimExplode(',', $extConf[$key]));
Expand Down
13 changes: 8 additions & 5 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,12 @@ protected function setDefaultPage(): void
// Set default values if not set.
// $this->requestData['page'] may be integer or string (physical structure @ID)
if (
(int) $this->requestData['page'] > 0
|| empty($this->requestData['page'])
|| is_array($this->requestData['docPage'])
isset($this->requestData['page'])
&& (
(int) $this->requestData['page'] > 0
|| empty($this->requestData['page'])
|| is_array($this->requestData['docPage'])
)
) {
if (isset($this->settings['multiViewType']) && $this->document->getCurrentDocument()->tableOfContents[0]['type'] === $this->settings['multiViewType']) {
$i = 0;
Expand Down Expand Up @@ -471,7 +474,7 @@ protected function buildSimplePagination(PaginationInterface $pagination, Pagina
// array with label as screen/pagination page number
// and startRecordNumber for correct structure of the link
//<f:link.action action="{action}"
// addQueryString="true"
// addQueryString="untrusted"
// argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[page]'}"
// additionalParams="{'tx_dlf[page]': page.startRecordNumber}"
// arguments="{searchParameter: lastSearch}">{page.label}</f:link.action>
Expand Down Expand Up @@ -581,7 +584,7 @@ protected function getDocumentByUrl(string $documentId)
} else {
$this->documentArray[] = $doc;
}
if ($this->requestData['multipleSource'] && is_array($this->requestData['multipleSource'])) {
if (isset($this->requestData['multipleSource']) && is_array($this->requestData['multipleSource'])) {
$i = 0;
foreach ($this->requestData['multipleSource'] as $location) {
$document = AbstractDocument::getInstance($location, $this->settings, true);
Expand Down
20 changes: 11 additions & 9 deletions Classes/Controller/AudioPlayerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@ public function mainAction(): ResponseInterface
// Check if there are any audio files available.
$fileGrpsAudio = GeneralUtility::trimExplode(',', $this->extConf['files']['fileGrpAudio']);
while ($fileGrpAudio = array_shift($fileGrpsAudio)) {
$physicalStructureInfo = $this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$this->requestData['page']]];
$fileId = $physicalStructureInfo['files'][$fileGrpAudio];
if (!empty($fileId)) {
// Get audio data.
$file = $this->document->getCurrentDocument()->getFileInfo($fileId);
$this->audio['url'] = $file['location'];
$this->audio['label'] = $physicalStructureInfo['label'];
$this->audio['mimetype'] = $file['mimeType'];
break;
$physicalStructureInfo = $this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$this->requestData['page'] ?? 0]];
if (array_key_exists($fileGrpAudio, $physicalStructureInfo['files'])) {
$fileId = $physicalStructureInfo['files'][$fileGrpAudio];
if (!empty($fileId)) {
// Get audio data.
$file = $this->document->getCurrentDocument()->getFileInfo($fileId);
$this->audio['url'] = $file['location'];
$this->audio['label'] = $physicalStructureInfo['label'];
$this->audio['mimetype'] = $file['mimeType'];
break;
}
}
}

Expand Down
12 changes: 7 additions & 5 deletions Classes/Controller/MetadataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,13 @@ private function getMetadata(): array
if ($this->settings['rootline'] < 2) {
// Get current structure's @ID.
$ids = [];
$page = $this->currentDocument->physicalStructure[$this->requestData['page']];
if (!empty($page) && !empty($this->currentDocument->smLinks['p2l'][$page])) {
foreach ($this->currentDocument->smLinks['p2l'][$page] as $logId) {
$count = $this->currentDocument->getStructureDepth($logId);
$ids[$count][] = $logId;
if (isset($this->requestData['page'])) {
$page = $this->currentDocument->physicalStructure[$this->requestData['page']];
if (!empty($page) && !empty($this->currentDocument->smLinks['p2l'][$page])) {
foreach ($this->currentDocument->smLinks['p2l'][$page] as $logId) {
$count = $this->currentDocument->getStructureDepth($logId);
$ids[$count][] = $logId;
}
}
}
ksort($ids);
Expand Down
28 changes: 15 additions & 13 deletions Classes/Controller/PageViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,20 @@ public function mainAction(): ResponseInterface

$this->setPage();

$page = $this->requestData['page'] ?? 0;

// Get image data.
$this->images[0] = $this->getImage($this->requestData['page']);
$this->fulltexts[0] = $this->getFulltext($this->requestData['page']);
$this->annotationContainers[0] = $this->getAnnotationContainers($this->requestData['page']);
if ($this->requestData['double'] && $this->requestData['page'] < $this->document->getCurrentDocument()->numPages) {
$this->images[1] = $this->getImage($this->requestData['page'] + 1);
$this->fulltexts[1] = $this->getFulltext($this->requestData['page'] + 1);
$this->annotationContainers[1] = $this->getAnnotationContainers($this->requestData['page'] + 1);
$this->images[0] = $this->getImage($page);
$this->fulltexts[0] = $this->getFulltext($page);
$this->annotationContainers[0] = $this->getAnnotationContainers($page);
if ($this->requestData['double'] && $page < $this->document->getCurrentDocument()->numPages) {
$this->images[1] = $this->getImage($page + 1);
$this->fulltexts[1] = $this->getFulltext($page + 1);
$this->annotationContainers[1] = $this->getAnnotationContainers($page + 1);
}

$this->scores = $this->getScore($this->requestData['page']);
$this->measures = $this->getMeasures($this->requestData['page']);
$this->scores = $this->getScore($page);
$this->measures = $this->getMeasures($page);

// Get the controls for the map.
$this->controls = explode(',', $this->settings['features']);
Expand All @@ -154,7 +156,7 @@ public function mainAction(): ResponseInterface

$this->view->assign('images', $this->images);
$this->view->assign('docId', $this->requestData['id']);
$this->view->assign('page', $this->requestData['page']);
$this->view->assign('page', $page);

return $this->htmlResponse();
}
Expand Down Expand Up @@ -280,7 +282,7 @@ public function addDocumentAction(FormAddDocument $formAddDocument): ResponseInt
{
if (GeneralUtility::isValidUrl($formAddDocument->getLocation())) {
$nextMultipleSourceKey = 0;
if ($this->requestData['multipleSource']) {
if (isset($this->requestData['multipleSource']) && is_array($this->requestData['multipleSource'])) {
$nextMultipleSourceKey = max(array_keys($this->requestData['multipleSource'])) + 1;
}
$params = array_merge(
Expand Down Expand Up @@ -527,7 +529,7 @@ protected function addViewerJS(): void
});';
} else {
$currentMeasureId = '';
$docPage = $this->requestData['page'];
$docPage = $this->requestData['page'] ?? 0;

$docMeasures = $this->getMeasures($docPage);
if ($this->requestData['measure'] ?? false) {
Expand All @@ -537,7 +539,7 @@ protected function addViewerJS(): void
$viewer = [
'controls' => $this->controls,
'div' => $this->settings['elementId'],
'progressElementId' => $this->settings['progressElementId'],
'progressElementId' => $this->settings['progressElementId'] ?? 'tx-dlf-page-progress',
'images' => $this->images,
'fulltexts' => $this->fulltexts,
'score' => $this->scores,
Expand Down
6 changes: 3 additions & 3 deletions Classes/Controller/TableOfContentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ private function resolveMenuEntry(array $entry): array
*/
private function getAllLogicalUnits(): void
{
$page = $this->requestData['page'];
$physicalStructure = $this->document->getCurrentDocument()->physicalStructure;
if (
!empty($page)
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]],
Expand Down
15 changes: 9 additions & 6 deletions Classes/Controller/ToolboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,17 @@ private function renderImageDownloadTool(): void
}

$this->setPage();
$page = $this->requestData['page'] ?? 0;

$imageArray = [];
// Get left or single page download.
$image = $this->getImage($this->requestData['page']);
$image = $this->getImage($page);
if (Helper::filterFilesByMimeType($image, ['image'])) {
$imageArray[0] = $image;
}

if ($this->requestData['double'] == 1) {
$image = $this->getImage($this->requestData['page'] + 1);
$image = $this->getImage($page + 1);
if (Helper::filterFilesByMimeType($image, ['image'])) {
$imageArray[1] = $image;
}
Expand Down Expand Up @@ -412,7 +413,7 @@ private function getPageLink(): array
$firstPageLink = '';
$secondPageLink = '';
$pageLinkArray = [];
$pageNumber = $this->requestData['page'];
$pageNumber = $this->requestData['page'] ?? 0;
$fileGrpsDownload = GeneralUtility::trimExplode(',', $this->extConf['files']['fileGrpDownload']);
// Get image link.
while ($fileGrpDownload = array_shift($fileGrpsDownload)) {
Expand Down Expand Up @@ -587,9 +588,11 @@ private function isFullTextEmpty(): bool
{
$fileGrpsFulltext = GeneralUtility::trimExplode(',', $this->extConf['files']['fileGrpFulltext']);
while ($fileGrpFulltext = array_shift($fileGrpsFulltext)) {
$files = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$this->requestData['page']]]['files'];
if (!empty($files[$fileGrpFulltext])) {
return false;
if (isset($this->requestData['page'])) {
$files = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$this->requestData['page']]]['files'];
if (!empty($files[$fileGrpFulltext])) {
return false;
}
}
}
return true;
Expand Down
10 changes: 5 additions & 5 deletions Resources/Private/Partials/Lists/Pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<f:if condition="{pagination.previousPageNumberG} && {pagination.previousPageNumberG} >= {pagination.firstPageNumber}">
<f:then>
<li class="first">
<f:link.action action="{action}" addQueryString="true" argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[page]'}" additionalParams="{'tx_dlf[page]': 1, 'tx_dlf[id]': docUid}" arguments="{searchParameter: lastSearch}" title="1">1</f:link.action>
<f:link.action action="{action}" addQueryString="untrusted" argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[page]'}" additionalParams="{'tx_dlf[page]': 1, 'tx_dlf[id]': docUid}" arguments="{searchParameter: lastSearch}" title="1">1</f:link.action>
</li>
<li class="previous">
<f:link.action action="{action}" addQueryString="true" argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[page]'}" additionalParams="{'tx_dlf[page]': pagination.previousPageNumber, 'tx_dlf[id]': docUid}" arguments="{searchParameter: lastSearch}" title="{f:translate(key: 'pagination.previous')}">{f:translate(key: 'prevPage')}</f:link.action>
<f:link.action action="{action}" addQueryString="untrusted" argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[page]'}" additionalParams="{'tx_dlf[page]': pagination.previousPageNumber, 'tx_dlf[id]': docUid}" arguments="{searchParameter: lastSearch}" title="{f:translate(key: 'pagination.previous')}">{f:translate(key: 'prevPage')}</f:link.action>
</li>
</f:then>
<f:else>
Expand Down Expand Up @@ -43,7 +43,7 @@
</f:case>
<f:defaultCase>
<li class="{f:if(condition: '{page.label} == {paginator.currentPageNumber}', then:'current')}">
<f:link.action action="{action}" addQueryString="true" argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[page]'}" additionalParams="{'tx_dlf[page]': page.startRecordNumber, 'tx_dlf[id]': docUid}" arguments="{searchParameter: lastSearch}">{page.label}</f:link.action>
<f:link.action action="{action}" addQueryString="untrusted" argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[page]'}" additionalParams="{'tx_dlf[page]': page.startRecordNumber, 'tx_dlf[id]': docUid}" arguments="{searchParameter: lastSearch}">{page.label}</f:link.action>
</li>
</f:defaultCase>
</f:switch>
Expand All @@ -53,10 +53,10 @@
<f:if condition="{pagination.nextPageNumberG} && {pagination.nextPageNumberG} <= {pagination.lastPageNumber}">
<f:then>
<li class="next">
<f:link.action action="{action}" addQueryString="true" argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[page]'}" additionalParams="{'tx_dlf[page]': pagination.nextPageNumber, 'tx_dlf[id]': docUid}" arguments="{searchParameter: lastSearch}" title="{f:translate(key: 'nextPage')}">{f:translate(key: 'nextPage')}</f:link.action>
<f:link.action action="{action}" addQueryString="untrusted" argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[page]'}" additionalParams="{'tx_dlf[page]': pagination.nextPageNumber, 'tx_dlf[id]': docUid}" arguments="{searchParameter: lastSearch}" title="{f:translate(key: 'nextPage')}">{f:translate(key: 'nextPage')}</f:link.action>
</li>
<li class="last">
<f:link.action action="{action}" addQueryString="true" argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[page]'}" additionalParams="{'tx_dlf[page]': pagination.lastPageNumberG, 'tx_dlf[id]': docUid}" arguments="{searchParameter: lastSearch}" title="{pagination.lastPageNumber}">{pagination.lastPageNumber}</f:link.action>
<f:link.action action="{action}" addQueryString="untrusted" argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[page]'}" additionalParams="{'tx_dlf[page]': pagination.lastPageNumberG, 'tx_dlf[id]': docUid}" arguments="{searchParameter: lastSearch}" title="{pagination.lastPageNumber}">{pagination.lastPageNumber}</f:link.action>
</li>
</f:then>
<f:else>
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Templates/Feeds/Main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<channel>
<title>{settings.title}</title>
<description>{settings.description}</description>
<link><f:uri.action addQueryString="1" absolute="1" /></link>
<link><f:uri.action addQueryString="untrusted" absolute="1" /></link>
<f:if condition="{feedMeta.copyright}">
<copyright>{feedMeta.copyright}</copyright>
</f:if>
Expand Down

0 comments on commit 5c4c903

Please sign in to comment.