From 9583e9208752c284921e9f3884d9ac2fcab9980a Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Thu, 28 Sep 2023 16:21:19 +0200 Subject: [PATCH 01/76] [FEATURE] Use getFileInfo function for getting file url and mime type (#1008) Co-authored-by: Sebastian Meyer --- Classes/Common/AbstractDocument.php | 22 +++++++ Classes/Common/IiifManifest.php | 17 ++++++ Classes/Common/MetsDocument.php | 64 +++++++++----------- Classes/Controller/AudioPlayerController.php | 12 ++-- Classes/Controller/PageViewController.php | 22 ++++--- Classes/Controller/ToolboxController.php | 7 ++- 6 files changed, 93 insertions(+), 51 deletions(-) diff --git a/Classes/Common/AbstractDocument.php b/Classes/Common/AbstractDocument.php index 6007ec5e7..9d18becdb 100644 --- a/Classes/Common/AbstractDocument.php +++ b/Classes/Common/AbstractDocument.php @@ -29,6 +29,7 @@ * @subpackage dlf * @access public * @property int $cPid This holds the PID for the configuration + * @property-read array $fileInfos Additional information about files (e.g., ADMID), indexed by ID. * @property-read bool $hasFulltext Are there any fulltext files available? * @property-read array $metadataArray This holds the documents' parsed metadata array * @property-read int $numPages The holds the total number of pages @@ -71,6 +72,14 @@ abstract class AbstractDocument */ public static $extKey = 'dlf'; + /** + * Additional information about files (e.g., ADMID), indexed by ID. + * + * @var array + * @access protected + */ + protected $fileInfos = []; + /** * This holds the configuration for all supported metadata encodings * @see loadFormats() @@ -365,6 +374,19 @@ protected abstract function getDocument(); */ public abstract function getDownloadLocation($id); + /** + * This gets all file information stored in single array. + * + * @access public + * + * @abstract + * + * @param string $id The "@ID" attribute of the file node (METS) or the "@id" property of the IIIF resource + * + * @return array|null The set of file information + */ + public abstract function getFileInfo($id); + /** * This gets the location of a file representing a physical page or track * diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index c31cd439d..ee50d480d 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -383,6 +383,23 @@ public function getDownloadLocation($id) return $fileLocation; } + /** + * {@inheritDoc} + * @see AbstractDocument::getFileInfo() + */ + public function getFileInfo($id) + { + if (empty($this->fileInfos[$id]['location'])) { + $this->fileInfos[$id]['location'] = $this->getFileLocation($id); + } + + if (empty($this->fileInfos[$id]['mimeType'])) { + $this->fileInfos[$id]['mimeType'] = $this->getFileMimeType($id); + } + + return $this->fileInfos[$id]; + } + /** * {@inheritDoc} * @see AbstractDocument::getFileLocation() diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index f05b706ae..f25f665ba 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -32,7 +32,6 @@ * @property-read array $mdSec Associative array of METS metadata sections indexed by their IDs. * @property-read array $dmdSec Subset of `$mdSec` storing only the dmdSec entries; kept for compatibility. * @property-read array $fileGrps This holds the file ID -> USE concordance - * @property-read array $fileInfos Additional information about files (e.g., ADMID), indexed by ID. * @property-read bool $hasFulltext Are there any fulltext files available? * @property-read array $metadataArray This holds the documents' parsed metadata array * @property-read \SimpleXMLElement $mets This holds the XML file's METS part as \SimpleXMLElement object @@ -131,16 +130,6 @@ final class MetsDocument extends AbstractDocument */ protected $fileGrpsLoaded = false; - /** - * Additional information about files (e.g., ADMID), indexed by ID. - * TODO: Consider using this for `getFileMimeType()` and `getFileLocation()`. - * @see _getFileInfos() - * - * @var array - * @access protected - */ - protected $fileInfos = []; - /** * This holds the XML file's METS part as \SimpleXMLElement object * @@ -214,24 +203,42 @@ protected function establishRecordId($pid) */ public function getDownloadLocation($id) { - $fileMimeType = $this->getFileMimeType($id); - $fileLocation = $this->getFileLocation($id); - if ($fileMimeType === 'application/vnd.kitodo.iiif') { - $fileLocation = (strrpos($fileLocation, 'info.json') === strlen($fileLocation) - 9) ? $fileLocation : (strrpos($fileLocation, '/') === strlen($fileLocation) ? $fileLocation . 'info.json' : $fileLocation . '/info.json'); + $file = $this->getFileInfo($id); + if ($file['mimeType'] === 'application/vnd.kitodo.iiif') { + $file['location'] = (strrpos($file['location'], 'info.json') === strlen($file['location']) - 9) ? $file['location'] : (strrpos($file['location'], '/') === strlen($file['location']) ? $file['location'] . 'info.json' : $file['location'] . '/info.json'); $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); IiifHelper::setUrlReader(IiifUrlReader::getInstance()); IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']); IiifHelper::setMaxThumbnailWidth($conf['iiifThumbnailWidth']); - $service = IiifHelper::loadIiifResource($fileLocation); + $service = IiifHelper::loadIiifResource($file['location']); if ($service !== null && $service instanceof AbstractImageService) { return $service->getImageUrl(); } - } elseif ($fileMimeType === 'application/vnd.netfpx') { - $baseURL = $fileLocation . (strpos($fileLocation, '?') === false ? '?' : ''); + } elseif ($file['mimeType'] === 'application/vnd.netfpx') { + $baseURL = $file['location'] . (strpos($file['location'], '?') === false ? '?' : ''); // TODO CVT is an optional IIP server capability; in theory, capabilities should be determined in the object request with '&obj=IIP-server' return $baseURL . '&CVT=jpeg'; } - return $fileLocation; + return $file['location']; + } + + /** + * {@inheritDoc} + * @see AbstractDocument::getFileInfo() + */ + public function getFileInfo($id) + { + $this->_getFileGrps(); + + if (isset($this->fileInfos[$id]) && empty($this->fileInfos[$id]['location'])) { + $this->fileInfos[$id]['location'] = $this->getFileLocation($id); + } + + if (isset($this->fileInfos[$id]) && empty($this->fileInfos[$id]['mimeType'])) { + $this->fileInfos[$id]['mimeType'] = $this->getFileMimeType($id); + } + + return $this->fileInfos[$id]; } /** @@ -658,7 +665,7 @@ protected function getMetadataIds($id) { // Load amdSecChildIds concordance $this->_getMdSec(); - $this->_getFileInfos(); + $fileInfo = $this->getFileInfo($id); // Get DMDID and ADMID of logical structure node if (!empty($this->logicalUnits[$id])) { @@ -669,9 +676,9 @@ protected function getMetadataIds($id) if ($mdSec) { $dmdIds = (string) $mdSec->attributes()->DMDID; $admIds = (string) $mdSec->attributes()->ADMID; - } else if (isset($this->fileInfos[$id])) { - $dmdIds = $this->fileInfos[$id]['dmdId']; - $admIds = $this->fileInfos[$id]['admId']; + } else if (isset($fileInfo)) { + $dmdIds = $fileInfo['dmdId']; + $admIds = $fileInfo['admId']; } else { $dmdIds = ''; $admIds = ''; @@ -961,17 +968,6 @@ protected function _getFileGrps() return $this->fileGrps; } - /** - * - * @access protected - * @return array - */ - protected function _getFileInfos() - { - $this->_getFileGrps(); - return $this->fileInfos; - } - /** * {@inheritDoc} * @see AbstractDocument::prepareMetadataArray() diff --git a/Classes/Controller/AudioPlayerController.php b/Classes/Controller/AudioPlayerController.php index 078cc7157..ae11d2b16 100644 --- a/Classes/Controller/AudioPlayerController.php +++ b/Classes/Controller/AudioPlayerController.php @@ -85,12 +85,14 @@ public function mainAction() // Check if there are any audio files available. $fileGrpsAudio = GeneralUtility::trimExplode(',', $this->extConf['fileGrpAudio']); while ($fileGrpAudio = array_shift($fileGrpsAudio)) { - $fileGroupAudio = $this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$this->requestData['page']]]['files'][$fileGrpAudio]; - if (!empty($fileGroupAudio)) { + $physicalStructureInfo = $this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$this->requestData['page']]]; + $fileId = $physicalStructureInfo['files'][$fileGrpAudio]; + if (!empty($fileId)) { // Get audio data. - $this->audio['url'] = $this->document->getCurrentDocument()->getFileLocation($fileGroupAudio); - $this->audio['label'] = $this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$this->requestData['page']]]['label']; - $this->audio['mimetype'] = $this->document->getCurrentDocument()->getFileMimeType($fileGroupAudio); + $file = $this->document->getCurrentDocument()->getFileInfo($fileId); + $this->audio['url'] = $file['location']; + $this->audio['label'] = $physicalStructureInfo['label']; + $this->audio['mimetype'] = $file['mimeType']; break; } } diff --git a/Classes/Controller/PageViewController.php b/Classes/Controller/PageViewController.php index a11cc61e8..ededffc3c 100644 --- a/Classes/Controller/PageViewController.php +++ b/Classes/Controller/PageViewController.php @@ -112,13 +112,15 @@ protected function getFulltext($page) // Get fulltext link. $fileGrpsFulltext = GeneralUtility::trimExplode(',', $this->extConf['fileGrpFulltext']); while ($fileGrpFulltext = array_shift($fileGrpsFulltext)) { - $fileGroupFulltext = $this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$page]]['files'][$fileGrpFulltext]; - if (!empty($fileGroupFulltext)) { - $fulltext['url'] = $this->document->getCurrentDocument()->getFileLocation($fileGroupFulltext); + $physicalStructureInfo = $this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$page]]; + $fileId = $physicalStructureInfo['files'][$fileGrpFulltext]; + if (!empty($fileId)) { + $file = $this->document->getCurrentDocument()->getFileLocation($fileId); + $fulltext['url'] = $file['location']; if ($this->settings['useInternalProxy']) { $this->configureProxyUrl($fulltext['url']); } - $fulltext['mimetype'] = $this->document->getCurrentDocument()->getFileMimeType($fileGroupFulltext); + $fulltext['mimetype'] = $file['mimeType']; break; } else { $this->logger->notice('No full-text file found for page "' . $page . '" in fileGrp "' . $fileGrpFulltext . '"'); @@ -229,13 +231,15 @@ protected function getImage($page) $fileGrpsImages = GeneralUtility::trimExplode(',', $this->extConf['fileGrpImages']); while ($fileGrpImages = array_pop($fileGrpsImages)) { // Get image link. - $fileGroupImage = $this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$page]]['files'][$fileGrpImages]; - if (!empty($fileGroupImage)) { - $image['url'] = $this->document->getCurrentDocument()->getFileLocation($fileGroupImage); - $image['mimetype'] = $this->document->getCurrentDocument()->getFileMimeType($fileGroupImage); + $physicalStructureInfo = $this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$page]]; + $fileId = $physicalStructureInfo['files'][$fileGrpImages]; + if (!empty($fileId)) { + $file = $this->document->getCurrentDocument()->getFileInfo($fileId); + $image['url'] = $file['location']; + $image['mimetype'] = $file['mimeType']; // Only deliver static images via the internal PageViewProxy. - // (For IIP and IIIF, the viewer needs to build and access a separate metadata URL, see `getMetdadataURL` in `OLSources.js`.) + // (For IIP and IIIF, the viewer needs to build and access a separate metadata URL, see `getMetadataURL` in `OLSources.js`.) if ($this->settings['useInternalProxy'] && !str_contains(strtolower($image['mimetype']), 'application')) { $this->configureProxyUrl($image['url']); } diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index b38b60af6..a41c7a52d 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -231,10 +231,11 @@ private function getImage($page) $fileGrps = GeneralUtility::trimExplode(',', $this->settings['fileGrpsImageDownload']); while ($fileGrp = @array_pop($fileGrps)) { // Get image link. - $fileGroup = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrp]; + $physicalStructureInfo = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]; + $fileId = $physicalStructureInfo['files'][$fileGrp]; if (!empty($fileGroup)) { - $image['url'] = $this->doc->getDownloadLocation($fileGroup); - $image['mimetype'] = $this->doc->getFileMimeType($fileGroup); + $image['url'] = $this->doc->getDownloadLocation($fileId); + $image['mimetype'] = $this->doc->getFileMimeType($fileId); switch ($image['mimetype']) { case 'image/jpeg': $image['mimetypeLabel'] = ' (JPG)'; From 72e96355887db4d094a59fc985c6f94b230a3ef7 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Thu, 28 Sep 2023 16:32:45 +0200 Subject: [PATCH 02/76] Display and index hyphenated words as normal words (#1009) Co-authored-by: Sebastian Meyer --- Classes/Format/Alto.php | 22 ++++++++++- .../Public/JavaScript/PageView/AltoParser.js | 37 +++++++++++++------ .../JavaScript/PageView/FulltextControl.js | 5 ++- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/Classes/Format/Alto.php b/Classes/Format/Alto.php index b3895f5e5..7297b51b2 100644 --- a/Classes/Format/Alto.php +++ b/Classes/Format/Alto.php @@ -38,8 +38,20 @@ public function getRawText(\SimpleXMLElement $xml) $rawText = ''; $xml->registerXPathNamespace('alto', 'http://www.loc.gov/standards/alto/ns-v2#'); // Get all (presumed) words of the text. - $words = $xml->xpath('./alto:Layout/alto:Page/alto:PrintSpace//alto:TextBlock/alto:TextLine/alto:String/@CONTENT'); - if (!empty($words)) { + $strings = $xml->xpath('./alto:Layout/alto:Page/alto:PrintSpace//alto:TextBlock/alto:TextLine/alto:String'); + $words = []; + if (!empty($strings)) { + for ($i = 0; $i < count($strings); $i++) { + $attributes = $strings[$i]->attributes(); + if (isset($attributes['SUBS_TYPE'])) { + if ($attributes['SUBS_TYPE'] == 'HypPart1') { + $i++; + $words[] = $attributes['SUBS_CONTENT']; + } + } else { + $words[] = $attributes['CONTENT']; + } + } $rawText = implode(' ', $words); } return $rawText; @@ -101,6 +113,12 @@ public function getTextAsMiniOcr(\SimpleXMLElement $xml) */ private function getWord($attributes) { + if (!empty($attributes['SUBS_CONTENT'])) { + if ($attributes['SUBS_TYPE'] == 'HypPart1') { + return htmlspecialchars((string) $attributes['SUBS_CONTENT']); + } + return ' '; + } return htmlspecialchars((string) $attributes['CONTENT']) . ' '; } diff --git a/Resources/Public/JavaScript/PageView/AltoParser.js b/Resources/Public/JavaScript/PageView/AltoParser.js index 99e8a56b0..2762eb561 100644 --- a/Resources/Public/JavaScript/PageView/AltoParser.js +++ b/Resources/Public/JavaScript/PageView/AltoParser.js @@ -323,36 +323,51 @@ dlfAltoParser.prototype.parseTextLineFeatures_ = function(node) { * @private */ dlfAltoParser.prototype.parseContentFeatures_ = function(node) { - var textlineContentElements = $(node).children(), - textlineContentFeatures = []; + var textLineContentElements = $(node).children(), + textLineContentFeatures = []; - for (var i = 0; i < textlineContentElements.length; i++) { - var feature = this.parseFeatureWithGeometry_(textlineContentElements[i]), + for (var i = 0; i < textLineContentElements.length; i++) { + var feature = this.parseFeatureWithGeometry_(textLineContentElements[i]), fulltext = ''; - // parse fulltexts - switch (textlineContentElements[i].nodeName.toLowerCase()) { + // parse full texts + switch (textLineContentElements[i].nodeName.toLowerCase()) { case 'string': - fulltext = textlineContentElements[i].getAttribute('CONTENT'); + fulltext = this.parseString_(textLineContentElements[i]); break; case 'sp': fulltext = ' '; break; case 'hyp': - fulltext = '-'; + fulltext = ''; break; default: fulltext = ''; }; feature.setProperties({fulltext}); - textlineContentFeatures.push(feature); + textLineContentFeatures.push(feature); }; - return textlineContentFeatures; + return textLineContentFeatures; }; - +/** + * + * @param {Element} + * @return {string} + * @private + */ +dlfAltoParser.prototype.parseString_ = function(textLineContentElement) { + var hyphen = textLineContentElement.getAttribute('SUBS_TYPE') + if (typeof(hyphen) != 'undefined' && hyphen != null) { + if (hyphen == 'HypPart1') { + return textLineContentElement.getAttribute('SUBS_CONTENT'); + } + return ''; + }; + return textLineContentElement.getAttribute('CONTENT'); +}; /** * diff --git a/Resources/Public/JavaScript/PageView/FulltextControl.js b/Resources/Public/JavaScript/PageView/FulltextControl.js index a9e303849..a78b7d5b7 100644 --- a/Resources/Public/JavaScript/PageView/FulltextControl.js +++ b/Resources/Public/JavaScript/PageView/FulltextControl.js @@ -595,7 +595,10 @@ dlfViewerFullTextControl.prototype.getTextLineSpan = function(textLine) { textLineSpan.append(this.getItemForTextLineSpan(item)); } - textLineSpan.append(dlfTmplFulltext.space.cloneNode()); + // clone space only if last element is not a hyphen + if (content[content.length - 1].get('type') != 'hyp') { + textLineSpan.append(dlfTmplFulltext.space.cloneNode()); + } return textLineSpan; }; From 5ba47e8bd0f255be125cadb837e067885d4ca623 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Thu, 28 Sep 2023 20:32:47 +0200 Subject: [PATCH 03/76] [MAINTENANCE] Consistently use namespace declaration and avoid namespaces in code (#1010) Co-authored-by: Sebastian Meyer --- Classes/Command/BaseCommand.php | 6 +++--- Classes/Common/Helper.php | 11 ++++++----- Classes/Common/IiifManifest.php | 2 +- Classes/Common/IiifUrlReader.php | 2 +- Classes/Common/Indexer.php | 14 ++++++++------ Classes/Common/KitodoFlashMessageRenderer.php | 3 ++- Classes/Common/Solr/Solr.php | 11 +++++++---- Classes/Controller/AbstractController.php | 5 +++-- Classes/Controller/BasketController.php | 6 ++++-- Classes/Controller/CollectionController.php | 5 +++-- Classes/Controller/FeedsController.php | 3 ++- Classes/Controller/NavigationController.php | 5 +++-- Classes/Controller/OaiPmhController.php | 2 +- Classes/Controller/ToolboxController.php | 3 ++- Classes/Domain/Model/ActionLog.php | 4 +++- Classes/Domain/Model/Basket.php | 5 +++-- Classes/Domain/Model/Collection.php | 4 +++- Classes/Domain/Model/Document.php | 11 ++++++----- Classes/Domain/Model/Format.php | 4 +++- Classes/Domain/Model/Library.php | 4 +++- Classes/Domain/Model/Mail.php | 4 +++- Classes/Domain/Model/Metadata.php | 11 ++++++----- Classes/Domain/Model/MetadataFormat.php | 10 ++++++---- Classes/Domain/Model/PageSelectForm.php | 4 +++- Classes/Domain/Model/Printer.php | 4 +++- Classes/Domain/Model/SolrCore.php | 4 +++- Classes/Domain/Model/Structure.php | 8 +++++--- Classes/Domain/Model/Token.php | 4 +++- .../Domain/Repository/ActionLogRepository.php | 4 +++- Classes/Domain/Repository/BasketRepository.php | 4 +++- .../Domain/Repository/CollectionRepository.php | 8 +++++--- .../Domain/Repository/DocumentRepository.php | 17 ++++++++++------- Classes/Domain/Repository/FormatRepository.php | 4 +++- Classes/Domain/Repository/LibraryRepository.php | 4 +++- Classes/Domain/Repository/MailRepository.php | 3 ++- .../Repository/MetadataFormatRepository.php | 6 ++++-- .../Domain/Repository/MetadataRepository.php | 8 ++++---- Classes/Domain/Repository/PrinterRepository.php | 4 +++- .../Domain/Repository/SolrCoreRepository.php | 6 ++++-- .../Domain/Repository/StructureRepository.php | 6 ++++-- Classes/Domain/Repository/TokenRepository.php | 5 ++--- .../DocumentTypeFunctionProvider.php | 7 +++---- .../ExpressionLanguage/DocumentTypeProvider.php | 1 - Classes/Format/AudioVideoMD.php | 4 +++- Classes/Format/Mods.php | 3 ++- Classes/Format/TeiHeader.php | 4 +++- Classes/Hooks/ConfigurationForm.php | 11 +++-------- .../EditInProductionWarning.php | 3 ++- .../Form/FieldInformation/SolrCoreStatus.php | 5 +++-- Classes/Hooks/ItemsProcFunc.php | 7 ++++--- Classes/Updates/MigrateSettings.php | 1 - 51 files changed, 172 insertions(+), 112 deletions(-) diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index 56497519d..02f5cd3d2 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -29,7 +29,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; -use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; /** @@ -68,7 +68,7 @@ class BaseCommand extends Command protected $storagePid; /** - * @var \Kitodo\Dlf\Domain\Model\Library + * @var Library */ protected $owner; @@ -110,7 +110,7 @@ public function __construct(CollectionRepository $collectionRepository, protected function initializeRepositories($storagePid) { if (MathUtility::canBeInterpretedAsInteger($storagePid)) { - $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); + $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $frameworkConfiguration['persistence']['storagePid'] = MathUtility::forceIntegerInRange((int) $storagePid, 0); $this->configurationManager->setConfiguration($frameworkConfiguration); diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index 371980800..7c3659be2 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -18,16 +18,18 @@ use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; +use TYPO3\CMS\Core\Messaging\FlashMessageQueue; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; +use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Core\Domain\Repository\PageRepository; - /** * Helper class for the 'dlf' extension * @@ -84,14 +86,13 @@ class Helper * @param bool $session: Should the message be saved in the user's session? * @param string $queue: The queue's unique identifier * - * @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue The queue the message was added to + * @return FlashMessageQueue The queue the message was added to */ public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages') { $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); - $flashMessage = GeneralUtility::makeInstance( - \TYPO3\CMS\Core\Messaging\FlashMessage::class, + $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $message, $title, $severity, @@ -650,7 +651,7 @@ public static function renderFlashMessages($queue = 'kitodo.default.flashMessage $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); $flashMessages = $flashMessageQueue->getAllMessagesAndFlush(); - $content = GeneralUtility::makeInstance(\Kitodo\Dlf\Common\KitodoFlashMessageRenderer::class) + $content = GeneralUtility::makeInstance(KitodoFlashMessageRenderer::class) ->render($flashMessages); return $content; } diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index ee50d480d..ee71215eb 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -99,7 +99,7 @@ final class IiifManifest extends AbstractDocument protected $originalMetadataArray = []; /** - * Holds the mime types of linked resources in the manifest (extreacted during parsing) for later use. + * Holds the mime types of linked resources in the manifest (extracted during parsing) for later use. * @var array * @access protected */ diff --git a/Classes/Common/IiifUrlReader.php b/Classes/Common/IiifUrlReader.php index 3ca97a260..cbdd28ef5 100644 --- a/Classes/Common/IiifUrlReader.php +++ b/Classes/Common/IiifUrlReader.php @@ -38,7 +38,7 @@ class IiifUrlReader implements UrlReaderInterface /** * * {@inheritDoc} - * @see \Ubl\Iiif\Tools\UrlReaderInterface::getContent() + * @see UrlReaderInterface::getContent() */ public function getContent($url) { diff --git a/Classes/Common/Indexer.php b/Classes/Common/Indexer.php index 0fccb452f..fd2ae7a38 100644 --- a/Classes/Common/Indexer.php +++ b/Classes/Common/Indexer.php @@ -15,6 +15,8 @@ use Kitodo\Dlf\Common\Solr\Solr; use Kitodo\Dlf\Domain\Repository\DocumentRepository; use Kitodo\Dlf\Domain\Model\Document; +use Solarium\Core\Query\DocumentInterface; +use Solarium\QueryType\Update\Query\Query; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Messaging\FlashMessage; @@ -87,7 +89,7 @@ class Indexer * * @access public * - * @param \Kitodo\Dlf\Domain\Model\Document $document: The document to add + * @param Document $document: The document to add * * @return bool true on success or false on failure */ @@ -296,7 +298,7 @@ protected static function loadIndexConf($pid) * * @access protected * - * @param \Kitodo\Dlf\Domain\Model\Document $document: The METS document + * @param Document $document: The METS document * @param array $logicalUnit: Array of the logical unit to process * * @return bool true on success or false on failure @@ -425,7 +427,7 @@ protected static function processLogical(Document $document, array $logicalUnit) * * @access protected * - * @param \Kitodo\Dlf\Domain\Model\Document $document: The METS document + * @param Document $document: The METS document * @param int $page: The page number * @param array $physicalUnit: Array of the physical unit to process * @@ -541,12 +543,12 @@ protected static function solrConnect($core, $pid = 0) * * @access private * - * @param \Solarium\QueryType\Update\Query\Query $updateQuery solarium query - * @param \Kitodo\Dlf\Domain\Model\Document $document: The METS document + * @param Query $updateQuery solarium query + * @param Document $document: The METS document * @param array $unit: Array of the logical or physical unit to process * @param string $fullText: Text containing full text for indexing * - * @return \Solarium\Core\Query\DocumentInterface + * @return DocumentInterface */ private static function getSolrDocument($updateQuery, $document, $unit, $fullText = '') { $solrDoc = $updateQuery->createDocument(); diff --git a/Classes/Common/KitodoFlashMessageRenderer.php b/Classes/Common/KitodoFlashMessageRenderer.php index 46ddc27ac..ea4d69ce3 100644 --- a/Classes/Common/KitodoFlashMessageRenderer.php +++ b/Classes/Common/KitodoFlashMessageRenderer.php @@ -13,6 +13,7 @@ namespace Kitodo\Dlf\Common; use TYPO3\CMS\Core\Messaging\FlashMessage; +use TYPO3\CMS\Core\Messaging\Renderer\FlashMessageRendererInterface; /** * A class representing a bootstrap flash messages. @@ -21,7 +22,7 @@ * The created output contains all classes which are required for * the TYPO3 backend. Any kind of message contains also a nice icon. */ -class KitodoFlashMessageRenderer implements \TYPO3\CMS\Core\Messaging\Renderer\FlashMessageRendererInterface +class KitodoFlashMessageRenderer implements FlashMessageRendererInterface { /** * @var string The message severity class names diff --git a/Classes/Common/Solr/Solr.php b/Classes/Common/Solr/Solr.php index 7c4b64486..99a6924e7 100644 --- a/Classes/Common/Solr/Solr.php +++ b/Classes/Common/Solr/Solr.php @@ -15,6 +15,9 @@ use Kitodo\Dlf\Common\Helper; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; +use Solarium\Client; +use Solarium\Core\Client\Adapter\Http; +use Solarium\QueryType\Server\CoreAdmin\Result\StatusResult; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Database\ConnectionPool; @@ -298,7 +301,7 @@ public static function getFields() * * @param mixed $core: Name or UID of the core to load or null to get core admin endpoint * - * @return \Kitodo\Dlf\Common\Solr\Solr Instance of this class + * @return Solr Instance of this class */ public static function getInstance($core = null) { @@ -601,7 +604,7 @@ protected function __construct($core) // Get Solr connection parameters from configuration. $this->loadSolrConnectionInfo(); // Configure connection adapter. - $adapter = GeneralUtility::makeInstance(\Solarium\Core\Client\Adapter\Http::class); + $adapter = GeneralUtility::makeInstance(Http::class); // Todo: When updating to TYPO3 >=10.x and Solarium >=6.x // the timeout must be set with the adapter instead of the // endpoint (see below). @@ -627,7 +630,7 @@ protected function __construct($core) ] ]; // Instantiate Solarium\Client class. - $this->service = GeneralUtility::makeInstance(\Solarium\Client::class, $config); + $this->service = GeneralUtility::makeInstance(Client::class, $config); $this->service->setAdapter($adapter); // Todo: When updating to TYPO3 >=10.x and Solarium >=6.x // $adapter and $eventDispatcher are mandatory arguments @@ -647,7 +650,7 @@ protected function __construct($core) if ($core !== null) { $result = $response->getStatusResult(); if ( - $result instanceof \Solarium\QueryType\Server\CoreAdmin\Result\StatusResult + $result instanceof StatusResult && $result->getUptime() > 0 ) { // Set core name. diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 4ab2100b7..2a69ed7e8 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -23,6 +23,7 @@ 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; /** * Abstract controller class for most of the plugin controller. @@ -32,7 +33,7 @@ * @subpackage dlf * @access public */ -abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController implements LoggerAwareInterface +abstract class AbstractController extends ActionController implements LoggerAwareInterface { use LoggerAwareTrait; @@ -52,7 +53,7 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) /** * This holds the current document * - * @var \Kitodo\Dlf\Domain\Model\Document + * @var Document * @access protected */ protected $document; diff --git a/Classes/Controller/BasketController.php b/Classes/Controller/BasketController.php index b4155ca29..b009df004 100644 --- a/Classes/Controller/BasketController.php +++ b/Classes/Controller/BasketController.php @@ -19,7 +19,9 @@ use Kitodo\Dlf\Domain\Repository\MailRepository; use Kitodo\Dlf\Domain\Repository\BasketRepository; use Kitodo\Dlf\Domain\Repository\PrinterRepository; +use TYPO3\CMS\Core\Mail\MailMessage; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\MailUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Core\Context\Context; @@ -544,9 +546,9 @@ protected function sendMail() $mailBody = $hookObj->customizeMailBody($mailText, $pdfUrl); } } - $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom(); + $from = MailUtility::getSystemFrom(); // send mail - $mail = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class); + $mail = GeneralUtility::makeInstance(MailMessage::class); // Prepare and send the message $mail // subject diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index 3fa41d016..d4e103fa7 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -12,6 +12,7 @@ namespace Kitodo\Dlf\Controller; use Kitodo\Dlf\Common\Solr\Solr; +use Kitodo\Dlf\Domain\Model\Collection; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; use Kitodo\Dlf\Domain\Repository\CollectionRepository; @@ -144,11 +145,11 @@ public function listAction() * * @access protected * - * @param \Kitodo\Dlf\Domain\Model\Collection $collection: The collection object + * @param Collection $collection: The collection object * * @return void */ - public function showAction(\Kitodo\Dlf\Domain\Model\Collection $collection) + public function showAction(Collection $collection) { $searchParams = $this->getParametersSafely('searchParameter'); diff --git a/Classes/Controller/FeedsController.php b/Classes/Controller/FeedsController.php index 684f842d2..fae8ab06c 100644 --- a/Classes/Controller/FeedsController.php +++ b/Classes/Controller/FeedsController.php @@ -12,6 +12,7 @@ namespace Kitodo\Dlf\Controller; use Kitodo\Dlf\Common\AbstractDocument; +use Kitodo\Dlf\Domain\Model\Library; use Kitodo\Dlf\Domain\Repository\LibraryRepository; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -62,7 +63,7 @@ public function mainAction() $requestData = $this->request->getArguments(); // get library information - /** @var \Kitodo\Dlf\Domain\Model\Library|null $library */ + /** @var Library|null $library */ $library = $this->libraryRepository->findByUid($this->settings['library']); $feedMeta = []; diff --git a/Classes/Controller/NavigationController.php b/Classes/Controller/NavigationController.php index 8718e72fb..3b1a15a79 100644 --- a/Classes/Controller/NavigationController.php +++ b/Classes/Controller/NavigationController.php @@ -11,6 +11,7 @@ namespace Kitodo\Dlf\Controller; +use Kitodo\Dlf\Domain\Model\PageSelectForm; use TYPO3\CMS\Core\Utility\MathUtility; /** @@ -25,10 +26,10 @@ class NavigationController extends AbstractController { /** * Method to get the page select values and use them with chash - * @param \Kitodo\Dlf\Domain\Model\PageSelectForm|NULL $pageSelectForm + * @param PageSelectForm|NULL $pageSelectForm * @return void */ - public function pageSelectAction(\Kitodo\Dlf\Domain\Model\PageSelectForm $pageSelectForm = NULL) { + public function pageSelectAction(PageSelectForm $pageSelectForm = NULL) { if ($pageSelectForm) { $uri = $this->uriBuilder->reset() ->setArguments( diff --git a/Classes/Controller/OaiPmhController.php b/Classes/Controller/OaiPmhController.php index 224ecbbdb..0164684ae 100644 --- a/Classes/Controller/OaiPmhController.php +++ b/Classes/Controller/OaiPmhController.php @@ -449,7 +449,7 @@ protected function verbListIdentifiers() $this->error = 'idDoesNotExist'; return; } - // create new and empty documentlist + // create new and empty document list $resultSet = []; if (is_array($documentSet)) { $resultSet['elements'] = $documentSet; diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index a41c7a52d..239014ebc 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -11,6 +11,7 @@ namespace Kitodo\Dlf\Controller; +use Kitodo\Dlf\Common\AbstractDocument; use Kitodo\Dlf\Common\Helper; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -29,7 +30,7 @@ class ToolboxController extends AbstractController /** * This holds the current document * - * @var \Kitodo\Dlf\Common\AbstractDocument + * @var AbstractDocument * @access private */ private $doc; diff --git a/Classes/Domain/Model/ActionLog.php b/Classes/Domain/Model/ActionLog.php index bb107670c..325874c12 100644 --- a/Classes/Domain/Model/ActionLog.php +++ b/Classes/Domain/Model/ActionLog.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** * (Basket Plugin) Action log for mails and printouts. * @@ -19,7 +21,7 @@ * @subpackage dlf * @access public */ -class ActionLog extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class ActionLog extends AbstractEntity { /** * @var int diff --git a/Classes/Domain/Model/Basket.php b/Classes/Domain/Model/Basket.php index 3c9728682..1f79073ff 100644 --- a/Classes/Domain/Model/Basket.php +++ b/Classes/Domain/Model/Basket.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** * (Basket Plugin) A basket that is bound to a frontend session. * @@ -19,7 +21,7 @@ * @subpackage dlf * @access public */ -class Basket extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class Basket extends AbstractEntity { /** * @var string|null @@ -41,7 +43,6 @@ class Basket extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity */ protected $sessionId; - /** * @return string|null */ diff --git a/Classes/Domain/Model/Collection.php b/Classes/Domain/Model/Collection.php index 36f26f3a2..0b3c5b0ce 100644 --- a/Classes/Domain/Model/Collection.php +++ b/Classes/Domain/Model/Collection.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** * Domain model of the 'Collection'. * @@ -19,7 +21,7 @@ * @subpackage dlf * @access public */ -class Collection extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class Collection extends AbstractEntity { /** * @var int diff --git a/Classes/Domain/Model/Document.php b/Classes/Domain/Model/Document.php index 72a38208e..19f941b26 100644 --- a/Classes/Domain/Model/Document.php +++ b/Classes/Domain/Model/Document.php @@ -14,6 +14,7 @@ use Kitodo\Dlf\Common\AbstractDocument; use TYPO3\CMS\Extbase\Annotation as Extbase; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; @@ -24,7 +25,7 @@ * @subpackage dlf * @access public */ -class Document extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class Document extends AbstractEntity { /** * @var \DateTime @@ -431,7 +432,7 @@ public function setThumbnail(string $thumbnail): void /** * @return \Kitodo\Dlf\Domain\Model\Structure */ - public function getStructure(): Structure + public function getStructure(): \Kitodo\Dlf\Domain\Model\Structure { return $this->structure; } @@ -439,7 +440,7 @@ public function getStructure(): Structure /** * @param \Kitodo\Dlf\Domain\Model\Structure $structure */ - public function setStructure(Structure $structure): void + public function setStructure(\Kitodo\Dlf\Domain\Model\Structure $structure): void { $this->structure = $structure; } @@ -596,7 +597,7 @@ public function setCollections(?ObjectStorage $collections): void * * @param \Kitodo\Dlf\Domain\Model\Collection $collection */ - public function addCollection(Collection $collection): void + public function addCollection(\Kitodo\Dlf\Domain\Model\Collection $collection): void { $this->collections->attach($collection); } @@ -658,7 +659,7 @@ public function getOwner(): ?Library /** * @param \Kitodo\Dlf\Domain\Model\Library $owner */ - public function setOwner(Library $owner): void + public function setOwner(\Kitodo\Dlf\Domain\Model\Library $owner): void { $this->owner = $owner; } diff --git a/Classes/Domain/Model/Format.php b/Classes/Domain/Model/Format.php index 92844505d..3b8884a97 100644 --- a/Classes/Domain/Model/Format.php +++ b/Classes/Domain/Model/Format.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** * Configured data formats and namespaces like MODS, ALTO, IIIF etc. * They are referenced by ``tx_dlf_metadataformat.encoded``. @@ -25,7 +27,7 @@ * @subpackage dlf * @access public */ -class Format extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class Format extends AbstractEntity { /** * Name of the type that is used to reference it. diff --git a/Classes/Domain/Model/Library.php b/Classes/Domain/Model/Library.php index 668917a41..6ee1bee4d 100644 --- a/Classes/Domain/Model/Library.php +++ b/Classes/Domain/Model/Library.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** * A library institution with the following use cases: * @@ -26,7 +28,7 @@ * @subpackage dlf * @access public */ -class Library extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class Library extends AbstractEntity { /** * @var string diff --git a/Classes/Domain/Model/Mail.php b/Classes/Domain/Model/Mail.php index 740e8ba66..685389803 100644 --- a/Classes/Domain/Model/Mail.php +++ b/Classes/Domain/Model/Mail.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** * (Basket Plugin) Recipient mail addresses for sending documents. * @@ -19,7 +21,7 @@ * @subpackage dlf * @access public */ -class Mail extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class Mail extends AbstractEntity { /** * @var string diff --git a/Classes/Domain/Model/Metadata.php b/Classes/Domain/Model/Metadata.php index ba03376a6..4dd8322e3 100644 --- a/Classes/Domain/Model/Metadata.php +++ b/Classes/Domain/Model/Metadata.php @@ -13,6 +13,7 @@ namespace Kitodo\Dlf\Domain\Model; use TYPO3\CMS\Extbase\Annotation as Extbase; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; /** @@ -22,7 +23,7 @@ * @subpackage dlf * @access public */ -class Metadata extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class Metadata extends AbstractEntity { /** * @var \Kitodo\Dlf\Domain\Model\Metadata @@ -47,7 +48,7 @@ class Metadata extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity protected $indexName; /** - * The formats that encode this metadatum (local IRRE field to ``tx_dlf_metadataformat``). + * The formats that encode this metadata (local IRRE field to ``tx_dlf_metadataformat``). * * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Kitodo\Dlf\Domain\Model\MetadataFormat> * @Extbase\ORM\Lazy @@ -125,7 +126,7 @@ protected function initStorageObjects() } /** - * @return \Kitodo\Dlf\Domain\Model\Metadata + * @return Metadata */ public function getL18nParent(): Metadata { @@ -211,7 +212,7 @@ public function setFormat(ObjectStorage $format): void * * @return void */ - public function addFormat(MetadataFormat $format) + public function addFormat(\Kitodo\Dlf\Domain\Model\MetadataFormat $format) { $this->format->attach($format); } @@ -223,7 +224,7 @@ public function addFormat(MetadataFormat $format) * * @return void */ - public function removeFormat(MetadataFormat $formatToRemove) + public function removeFormat(\Kitodo\Dlf\Domain\Model\MetadataFormat $formatToRemove) { $this->format->detach($formatToRemove); } diff --git a/Classes/Domain/Model/MetadataFormat.php b/Classes/Domain/Model/MetadataFormat.php index e280289a9..c3c678ef6 100644 --- a/Classes/Domain/Model/MetadataFormat.php +++ b/Classes/Domain/Model/MetadataFormat.php @@ -12,8 +12,10 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** - * This specifies a way how a metadatum (``tx_dlf_metadata``) may be encoded in a specific data format (``tx_dlf_format``). + * This specifies a way how a metadata (``tx_dlf_metadata``) may be encoded in a specific data format (``tx_dlf_format``). * * For instance, the title of a document may be obtained from either the MODS * title field, or from the TEIHDR caption. This is modeled as two ``tx_dlf_metadaformat`` @@ -25,7 +27,7 @@ * @subpackage dlf * @access public */ -class MetadataFormat extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class MetadataFormat extends AbstractEntity { /** * UID of the ``tx_dlf_metadata`` that is encoded by this metadata entry. @@ -42,14 +44,14 @@ class MetadataFormat extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity protected $encoded; /** - * XPath/JSONPath expression to extract the metadatum (relative to the data format root). + * XPath/JSONPath expression to extract the metadata (relative to the data format root). * * @var string */ protected $xpath; /** - * XPath/JSONPath expression to extract sorting variant (suffixed ``_sorting``) of the metadatum. + * XPath/JSONPath expression to extract sorting variant (suffixed ``_sorting``) of the metadata. * * @var string */ diff --git a/Classes/Domain/Model/PageSelectForm.php b/Classes/Domain/Model/PageSelectForm.php index cfbe16ad5..ba29b917a 100644 --- a/Classes/Domain/Model/PageSelectForm.php +++ b/Classes/Domain/Model/PageSelectForm.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** * (Basket Plugin) A basket that is bound to a frontend session. * @@ -19,7 +21,7 @@ * @subpackage dlf * @access public */ -class PageSelectForm extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class PageSelectForm extends AbstractEntity { /** * @var integer diff --git a/Classes/Domain/Model/Printer.php b/Classes/Domain/Model/Printer.php index 1c277e85b..c0b2e855f 100644 --- a/Classes/Domain/Model/Printer.php +++ b/Classes/Domain/Model/Printer.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** * (Basket Plugin) External printers for sending documents. * @@ -19,7 +21,7 @@ * @subpackage dlf * @access public */ -class Printer extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class Printer extends AbstractEntity { /** * @var string diff --git a/Classes/Domain/Model/SolrCore.php b/Classes/Domain/Model/SolrCore.php index 006980aba..84f94cf27 100644 --- a/Classes/Domain/Model/SolrCore.php +++ b/Classes/Domain/Model/SolrCore.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** * Cores on the application-wide Solr instance that are available for indexing. * They may be used, for example, as a parameter to the CLI indexing commands, and are referenced by ``tx_dlf_document.solrcore``. @@ -21,7 +23,7 @@ * @subpackage dlf * @access public */ -class SolrCore extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class SolrCore extends AbstractEntity { /** * @var int diff --git a/Classes/Domain/Model/Structure.php b/Classes/Domain/Model/Structure.php index cc5b0499a..46d241078 100644 --- a/Classes/Domain/Model/Structure.php +++ b/Classes/Domain/Model/Structure.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** * Domain model of 'Structure'. * @@ -19,10 +21,10 @@ * @subpackage dlf * @access public */ -class Structure extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class Structure extends AbstractEntity { /** - * @var \Kitodo\Dlf\Domain\Model\Structure + * @var Structure */ protected $l18nParent; @@ -57,7 +59,7 @@ class Structure extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity protected $status; /** - * @return \Kitodo\Dlf\Domain\Model\Structure + * @return Structure */ public function getL18nParent(): Structure { diff --git a/Classes/Domain/Model/Token.php b/Classes/Domain/Model/Token.php index f8091a91d..95d8ed4e9 100644 --- a/Classes/Domain/Model/Token.php +++ b/Classes/Domain/Model/Token.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; + /** * Resumption tokens for OAI-PMH interface. * @@ -19,7 +21,7 @@ * @subpackage dlf * @access public */ -class Token extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +class Token extends AbstractEntity { /** * The resumption token string. diff --git a/Classes/Domain/Repository/ActionLogRepository.php b/Classes/Domain/Repository/ActionLogRepository.php index b420e1acc..e83557a01 100644 --- a/Classes/Domain/Repository/ActionLogRepository.php +++ b/Classes/Domain/Repository/ActionLogRepository.php @@ -12,7 +12,9 @@ namespace Kitodo\Dlf\Domain\Repository; -class ActionLogRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +use TYPO3\CMS\Extbase\Persistence\Repository; + +class ActionLogRepository extends Repository { } diff --git a/Classes/Domain/Repository/BasketRepository.php b/Classes/Domain/Repository/BasketRepository.php index c0a41ce12..da28f4737 100644 --- a/Classes/Domain/Repository/BasketRepository.php +++ b/Classes/Domain/Repository/BasketRepository.php @@ -12,7 +12,9 @@ namespace Kitodo\Dlf\Domain\Repository; -class BasketRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +use TYPO3\CMS\Extbase\Persistence\Repository; + +class BasketRepository extends Repository { } diff --git a/Classes/Domain/Repository/CollectionRepository.php b/Classes/Domain/Repository/CollectionRepository.php index 260defcd6..16cbedec9 100644 --- a/Classes/Domain/Repository/CollectionRepository.php +++ b/Classes/Domain/Repository/CollectionRepository.php @@ -15,9 +15,11 @@ use Kitodo\Dlf\Common\Helper; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\QueryInterface; +use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; -class CollectionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +class CollectionRepository extends Repository { /** * Set the default ordering. This is applied to findAll(), too. @@ -33,7 +35,7 @@ class CollectionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository * * @param string $uids separated by comma * - * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface + * @return QueryResultInterface */ public function findAllByUids($uids) { @@ -64,7 +66,7 @@ public function getCollectionForMetadata($pages) * * @param array $settings * - * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface + * @return array|QueryResultInterface */ public function findCollectionsBySettings($settings = []) { diff --git a/Classes/Domain/Repository/DocumentRepository.php b/Classes/Domain/Repository/DocumentRepository.php index ed7b588e6..e47f53072 100644 --- a/Classes/Domain/Repository/DocumentRepository.php +++ b/Classes/Domain/Repository/DocumentRepository.php @@ -12,19 +12,22 @@ namespace Kitodo\Dlf\Domain\Repository; +use Doctrine\DBAL\ForwardCompatibility\Result; use Kitodo\Dlf\Common\AbstractDocument; use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\Solr\SolrSearch; use Kitodo\Dlf\Domain\Model\Collection; use Kitodo\Dlf\Domain\Model\Document; +use Kitodo\Dlf\Domain\Model\Structure; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; -use TYPO3\CMS\Extbase\Persistence\QueryInterface; use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult; +use TYPO3\CMS\Extbase\Persistence\Repository; +use TYPO3\CMS\Extbase\Persistence\QueryInterface; -class DocumentRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +class DocumentRepository extends Repository { /** * The controller settings passed to the repository for some special actions. @@ -106,8 +109,8 @@ public function findOldestDocument() /** * @param int $partOf - * @param \Kitodo\Dlf\Domain\Model\Structure $structure - * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface + * @param Structure $structure + * @return array|QueryResultInterface */ public function getChildrenOfYearAnchor($partOf, $structure) { @@ -143,7 +146,7 @@ public function findOneByIdAndSettings($uid, $settings = []) * * @param array $settings * - * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface + * @return array|QueryResultInterface */ public function findDocumentsBySettings($settings = []) { @@ -174,7 +177,7 @@ public function findDocumentsBySettings($settings = []) * @param array $collections * @param int $limit * - * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface + * @return array|QueryResultInterface */ public function findAllByCollectionsLimited($collections, $limit = 50) { @@ -347,7 +350,7 @@ public function getStatisticsForSelectedCollection($settings) * @param int $pid * @param array $settings * - * @return \Doctrine\DBAL\ForwardCompatibility\Result + * @return Result */ public function getTableOfContentsFromDb($uid, $pid, $settings) { diff --git a/Classes/Domain/Repository/FormatRepository.php b/Classes/Domain/Repository/FormatRepository.php index dfec62397..4ec3948dc 100644 --- a/Classes/Domain/Repository/FormatRepository.php +++ b/Classes/Domain/Repository/FormatRepository.php @@ -12,7 +12,9 @@ namespace Kitodo\Dlf\Domain\Repository; -class FormatRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +use TYPO3\CMS\Extbase\Persistence\Repository; + +class FormatRepository extends Repository { } diff --git a/Classes/Domain/Repository/LibraryRepository.php b/Classes/Domain/Repository/LibraryRepository.php index 2fdd5576f..dba73b830 100644 --- a/Classes/Domain/Repository/LibraryRepository.php +++ b/Classes/Domain/Repository/LibraryRepository.php @@ -12,7 +12,9 @@ namespace Kitodo\Dlf\Domain\Repository; -class LibraryRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +use TYPO3\CMS\Extbase\Persistence\Repository; + +class LibraryRepository extends Repository { } diff --git a/Classes/Domain/Repository/MailRepository.php b/Classes/Domain/Repository/MailRepository.php index fa0876621..412ab06e7 100644 --- a/Classes/Domain/Repository/MailRepository.php +++ b/Classes/Domain/Repository/MailRepository.php @@ -14,8 +14,9 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; +use TYPO3\CMS\Extbase\Persistence\Repository; -class MailRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +class MailRepository extends Repository { public function findAllWithPid($pid) diff --git a/Classes/Domain/Repository/MetadataFormatRepository.php b/Classes/Domain/Repository/MetadataFormatRepository.php index c258c734c..c7b724f0a 100644 --- a/Classes/Domain/Repository/MetadataFormatRepository.php +++ b/Classes/Domain/Repository/MetadataFormatRepository.php @@ -12,7 +12,9 @@ namespace Kitodo\Dlf\Domain\Repository; -class MetadataFormatRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +use TYPO3\CMS\Extbase\Persistence\Repository; + +class MetadataFormatRepository extends Repository { -} \ No newline at end of file +} diff --git a/Classes/Domain/Repository/MetadataRepository.php b/Classes/Domain/Repository/MetadataRepository.php index 3be96f894..d8c4b79f4 100644 --- a/Classes/Domain/Repository/MetadataRepository.php +++ b/Classes/Domain/Repository/MetadataRepository.php @@ -12,18 +12,18 @@ namespace Kitodo\Dlf\Domain\Repository; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\QueryInterface; +use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; -class MetadataRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +class MetadataRepository extends Repository { /** * Finds all collection for the given settings * * @param array $settings * - * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface + * @return array|QueryResultInterface */ public function findBySettings($settings = []) { diff --git a/Classes/Domain/Repository/PrinterRepository.php b/Classes/Domain/Repository/PrinterRepository.php index ba8bf605d..5433b390a 100644 --- a/Classes/Domain/Repository/PrinterRepository.php +++ b/Classes/Domain/Repository/PrinterRepository.php @@ -12,7 +12,9 @@ namespace Kitodo\Dlf\Domain\Repository; -class PrinterRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +use TYPO3\CMS\Extbase\Persistence\Repository; + +class PrinterRepository extends Repository { } diff --git a/Classes/Domain/Repository/SolrCoreRepository.php b/Classes/Domain/Repository/SolrCoreRepository.php index 586ce722c..9cb250ea5 100644 --- a/Classes/Domain/Repository/SolrCoreRepository.php +++ b/Classes/Domain/Repository/SolrCoreRepository.php @@ -12,7 +12,9 @@ namespace Kitodo\Dlf\Domain\Repository; -class SolrCoreRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +use TYPO3\CMS\Extbase\Persistence\Repository; + +class SolrCoreRepository extends Repository { -} \ No newline at end of file +} diff --git a/Classes/Domain/Repository/StructureRepository.php b/Classes/Domain/Repository/StructureRepository.php index 3b9287a0e..906076b2d 100644 --- a/Classes/Domain/Repository/StructureRepository.php +++ b/Classes/Domain/Repository/StructureRepository.php @@ -12,7 +12,9 @@ namespace Kitodo\Dlf\Domain\Repository; -class StructureRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +use TYPO3\CMS\Extbase\Persistence\Repository; + +class StructureRepository extends Repository { -} \ No newline at end of file +} diff --git a/Classes/Domain/Repository/TokenRepository.php b/Classes/Domain/Repository/TokenRepository.php index 88527c89c..25b83f3fc 100644 --- a/Classes/Domain/Repository/TokenRepository.php +++ b/Classes/Domain/Repository/TokenRepository.php @@ -12,11 +12,10 @@ namespace Kitodo\Dlf\Domain\Repository; -use TYPO3\CMS\Core\Database\ConnectionPool; -use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Persistence\Repository; -class TokenRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +class TokenRepository extends Repository { /** * Delete all expired token diff --git a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php index 8d498eb31..a2fbd3b71 100644 --- a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php +++ b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php @@ -13,7 +13,6 @@ namespace Kitodo\Dlf\ExpressionLanguage; use Kitodo\Dlf\Common\AbstractDocument; -use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\IiifManifest; use Kitodo\Dlf\Domain\Model\Document; use Kitodo\Dlf\Domain\Repository\DocumentRepository; @@ -51,7 +50,7 @@ public function getFunctions() /** * This holds the current document * - * @var \Kitodo\Dlf\Domain\Model\Document + * @var Document * @access protected */ protected $document; @@ -87,7 +86,7 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) */ protected function initializeRepositories($storagePid) { - $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); + $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $frameworkConfiguration['persistence']['storagePid'] = MathUtility::forceIntegerInRange((int) $storagePid, 0); $this->configurationManager->setConfiguration($frameworkConfiguration); @@ -98,7 +97,7 @@ protected function initializeRepositories($storagePid) /** * Shortcut function to access field values * - * @return \Symfony\Component\ExpressionLanguage\ExpressionFunction + * @return ExpressionFunction */ protected function getDocumentTypeFunction(): ExpressionFunction { diff --git a/Classes/ExpressionLanguage/DocumentTypeProvider.php b/Classes/ExpressionLanguage/DocumentTypeProvider.php index 8a2acf0a6..44b35aa72 100644 --- a/Classes/ExpressionLanguage/DocumentTypeProvider.php +++ b/Classes/ExpressionLanguage/DocumentTypeProvider.php @@ -13,7 +13,6 @@ namespace Kitodo\Dlf\ExpressionLanguage; use TYPO3\CMS\Core\ExpressionLanguage\AbstractProvider; -use TYPO3\CMS\Core\ExpressionLanguage\FunctionsProvider\Typo3ConditionFunctionsProvider; /** * Wrapper class to provide variables and functions for the ExpressionLanguage. diff --git a/Classes/Format/AudioVideoMD.php b/Classes/Format/AudioVideoMD.php index 5c65677b7..ede534833 100644 --- a/Classes/Format/AudioVideoMD.php +++ b/Classes/Format/AudioVideoMD.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Format; +use Kitodo\Dlf\Common\MetadataInterface; + /** * Process AudioMD and VideoMD metadata. * @@ -23,7 +25,7 @@ * @subpackage dlf * @access public */ -class AudioVideoMD implements \Kitodo\Dlf\Common\MetadataInterface +class AudioVideoMD implements MetadataInterface { /** * Extract some essential AudioMD/VideoMD metadata. diff --git a/Classes/Format/Mods.php b/Classes/Format/Mods.php index 4ed9a5c62..a8c038789 100644 --- a/Classes/Format/Mods.php +++ b/Classes/Format/Mods.php @@ -14,6 +14,7 @@ use Kitodo\Dlf\Api\Orcid\Profile as OrcidProfile; use Kitodo\Dlf\Api\Viaf\Profile as ViafProfile; +use Kitodo\Dlf\Common\MetadataInterface; /** * Metadata MODS format class for the 'dlf' extension @@ -23,7 +24,7 @@ * @subpackage dlf * @access public */ -class Mods implements \Kitodo\Dlf\Common\MetadataInterface +class Mods implements MetadataInterface { /** * The metadata XML diff --git a/Classes/Format/TeiHeader.php b/Classes/Format/TeiHeader.php index 6c2aeaf12..bab6aacd7 100644 --- a/Classes/Format/TeiHeader.php +++ b/Classes/Format/TeiHeader.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Format; +use Kitodo\Dlf\Common\MetadataInterface; + /** * Metadata TEI-Header format class for the 'dlf' extension * @@ -20,7 +22,7 @@ * @subpackage dlf * @access public */ -class TeiHeader implements \Kitodo\Dlf\Common\MetadataInterface +class TeiHeader implements MetadataInterface { /** * This extracts the essential TEIHDR metadata from XML diff --git a/Classes/Hooks/ConfigurationForm.php b/Classes/Hooks/ConfigurationForm.php index 6556d6d99..9861335db 100644 --- a/Classes/Hooks/ConfigurationForm.php +++ b/Classes/Hooks/ConfigurationForm.php @@ -14,12 +14,7 @@ use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\Solr\Solr; -use TYPO3\CMS\Core\Core\Bootstrap; -use TYPO3\CMS\Core\Database\ConnectionPool; -use TYPO3\CMS\Core\Localization\LanguageService; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; -use TYPO3\CMS\Core\Utility\VersionNumberUtility; +use TYPO3\CMS\Core\Messaging\FlashMessage; /** * Hooks and helper for \TYPO3\CMS\Core\TypoScript\ConfigurationForm @@ -46,13 +41,13 @@ public function checkSolrConnection() Helper::addMessage( Helper::getLanguageService()->getLL('solr.status'), Helper::getLanguageService()->getLL('solr.connected'), - \TYPO3\CMS\Core\Messaging\FlashMessage::OK + FlashMessage::OK ); } else { Helper::addMessage( Helper::getLanguageService()->getLL('solr.error'), Helper::getLanguageService()->getLL('solr.notConnected'), - \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING + FlashMessage::WARNING ); } return Helper::renderFlashMessages(); diff --git a/Classes/Hooks/Form/FieldInformation/EditInProductionWarning.php b/Classes/Hooks/Form/FieldInformation/EditInProductionWarning.php index a21845d66..26ae12bd0 100644 --- a/Classes/Hooks/Form/FieldInformation/EditInProductionWarning.php +++ b/Classes/Hooks/Form/FieldInformation/EditInProductionWarning.php @@ -14,6 +14,7 @@ use Kitodo\Dlf\Common\Helper; use TYPO3\CMS\Backend\Form\AbstractNode; +use TYPO3\CMS\Core\Messaging\FlashMessage; /** * FieldInformation renderType for TYPO3 FormEngine @@ -43,7 +44,7 @@ public function render(): array Helper::addMessage( htmlspecialchars(Helper::getLanguageService()->getLL('flash.editInProductionWarning')), '', // We must not set a title/header, because

isn't allowed in FieldInformation. - \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING + FlashMessage::WARNING ); // Add message to result array. $result['html'] = Helper::renderFlashMessages(); diff --git a/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php b/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php index dff2574e2..66f497412 100644 --- a/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php +++ b/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php @@ -15,6 +15,7 @@ use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\Solr\Solr; use TYPO3\CMS\Backend\Form\AbstractNode; +use TYPO3\CMS\Core\Messaging\FlashMessage; /** * FieldInformation renderType for TYPO3 FormEngine @@ -63,7 +64,7 @@ public function render(): array Helper::addMessage( sprintf(Helper::getLanguageService()->getLL('flash.coreStatus'), $startTime, $uptime, $lastModified, $numDocuments), '', // We must not set a title/header, because

isn't allowed in FieldInformation. - \TYPO3\CMS\Core\Messaging\FlashMessage::INFO + FlashMessage::INFO ); } } else { @@ -71,7 +72,7 @@ public function render(): array Helper::addMessage( Helper::getLanguageService()->getLL('solr.error'), '', // We must not set a title/header, because

isn't allowed in FieldInformation. - \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR + FlashMessage::ERROR ); } // Add message to result array. diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php index b94ce252d..aa58e62b7 100644 --- a/Classes/Hooks/ItemsProcFunc.php +++ b/Classes/Hooks/ItemsProcFunc.php @@ -15,9 +15,10 @@ use Kitodo\Dlf\Common\Helper; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; +use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\TypoScript\TemplateService; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; use TYPO3\CMS\Extbase\Object\ObjectManager; /** @@ -65,7 +66,7 @@ public function toolList(&$params) public function getTyposcriptConfigFromPluginSiteRoot($params) { $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $pid = $params['flexParentDatabaseRow']['pid']; - $rootline = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($pid); + $rootline = BackendUtility::BEgetRootLine($pid); $siterootRow = []; foreach ($rootline as $_row) { if ($_row['is_siteroot'] == '1') { @@ -75,7 +76,7 @@ public function getTyposcriptConfigFromPluginSiteRoot($params) { } try { - $ts = $objectManager->get(\TYPO3\CMS\Core\TypoScript\TemplateService::class, [$siterootRow['uid']]); + $ts = $objectManager->get(TemplateService::class, [$siterootRow['uid']]); $ts->rootLine = $rootline; $ts->runThroughTemplates($rootline, 0); $ts->generateConfig(); diff --git a/Classes/Updates/MigrateSettings.php b/Classes/Updates/MigrateSettings.php index 22b939fed..a2bd0d027 100644 --- a/Classes/Updates/MigrateSettings.php +++ b/Classes/Updates/MigrateSettings.php @@ -13,7 +13,6 @@ namespace Kitodo\Dlf\Updates; use TYPO3\CMS\Core\Database\ConnectionPool; -use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; From 6fff5d5008c675dea36b582a3084f4c0ecf2aacf Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Thu, 28 Sep 2023 20:42:44 +0200 Subject: [PATCH 04/76] [MAINTENANCE] Remove {@inheritdoc} from functions (#1011) Co-authored-by: Sebastian Meyer --- Classes/Common/IiifManifest.php | 17 ----------------- Classes/Common/IiifUrlReader.php | 2 -- Classes/Common/MetsDocument.php | 30 ++++++++++-------------------- 3 files changed, 10 insertions(+), 39 deletions(-) diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index ee71215eb..13621dec9 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -115,7 +115,6 @@ final class IiifManifest extends AbstractDocument public static $extKey = 'dlf'; /** - * {@inheritDoc} * @see AbstractDocument::establishRecordId() */ protected function establishRecordId($pid) @@ -171,7 +170,6 @@ protected function establishRecordId($pid) } /** - * {@inheritDoc} * @see AbstractDocument::getDocument() */ protected function getDocument() @@ -256,7 +254,6 @@ protected function getUseGroups($use) } /** - * {@inheritDoc} * @see AbstractDocument::_getPhysicalStructure() */ protected function _getPhysicalStructure() @@ -384,7 +381,6 @@ public function getDownloadLocation($id) } /** - * {@inheritDoc} * @see AbstractDocument::getFileInfo() */ public function getFileInfo($id) @@ -401,7 +397,6 @@ public function getFileInfo($id) } /** - * {@inheritDoc} * @see AbstractDocument::getFileLocation() */ public function getFileLocation($id) @@ -426,7 +421,6 @@ public function getFileLocation($id) } /** - * {@inheritDoc} * @see AbstractDocument::getFileMimeType() */ public function getFileMimeType($id) @@ -452,7 +446,6 @@ public function getFileMimeType($id) } /** - * {@inheritDoc} * @see AbstractDocument::getLogicalStructure() */ public function getLogicalStructure($id, $recursive = false) @@ -624,7 +617,6 @@ public function getManifestMetadata($id, $cPid = 0, $withDescription = true, $wi } /** - * {@inheritDoc} * @see AbstractDocument::getMetadata() */ public function getMetadata($id, $cPid = 0) @@ -711,7 +703,6 @@ public function getMetadata($id, $cPid = 0) } /** - * {@inheritDoc} * @see AbstractDocument::_getSmLinks() */ protected function _getSmLinks() @@ -772,7 +763,6 @@ private function smLinkCanvasToResource(CanvasInterface $canvas, IiifResourceInt } /** - * {@inheritDoc} * @see AbstractDocument::getFullText() */ //TODO: rewrite it to get full OCR @@ -840,7 +830,6 @@ public function getIiif() } /** - * {@inheritDoc} * @see AbstractDocument::init() */ protected function init($location) @@ -849,7 +838,6 @@ protected function init($location) } /** - * {@inheritDoc} * @see AbstractDocument::loadLocation() */ protected function loadLocation($location) @@ -873,7 +861,6 @@ protected function loadLocation($location) } /** - * {@inheritDoc} * @see AbstractDocument::prepareMetadataArray() */ protected function prepareMetadataArray($cPid) @@ -883,7 +870,6 @@ protected function prepareMetadataArray($cPid) } /** - * {@inheritDoc} * @see AbstractDocument::setPreloadedDocument() */ protected function setPreloadedDocument($preloadedDocument) @@ -896,7 +882,6 @@ protected function setPreloadedDocument($preloadedDocument) } /** - * {@inheritDoc} * @see AbstractDocument::ensureHasFulltextIsSet() */ protected function ensureHasFulltextIsSet() @@ -943,7 +928,6 @@ protected function ensureHasFulltextIsSet() } /** - * {@inheritDoc} * @see AbstractDocument::_getThumbnail() */ protected function _getThumbnail($forceReload = false) @@ -952,7 +936,6 @@ protected function _getThumbnail($forceReload = false) } /** - * {@inheritDoc} * @see AbstractDocument::_getToplevelId() */ protected function _getToplevelId() diff --git a/Classes/Common/IiifUrlReader.php b/Classes/Common/IiifUrlReader.php index cbdd28ef5..a5f53080f 100644 --- a/Classes/Common/IiifUrlReader.php +++ b/Classes/Common/IiifUrlReader.php @@ -36,8 +36,6 @@ class IiifUrlReader implements UrlReaderInterface protected static $instance; /** - * - * {@inheritDoc} * @see UrlReaderInterface::getContent() */ public function getContent($url) diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index f25f665ba..d8a729304 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -176,8 +176,6 @@ public function addMetadataFromMets(&$metadata, $id) } /** - * - * {@inheritDoc} * @see AbstractDocument::establishRecordId() */ protected function establishRecordId($pid) @@ -197,8 +195,6 @@ protected function establishRecordId($pid) } /** - * - * {@inheritDoc} * @see AbstractDocument::getDownloadLocation() */ public function getDownloadLocation($id) @@ -242,7 +238,6 @@ public function getFileInfo($id) } /** - * {@inheritDoc} * @see AbstractDocument::getFileLocation() */ public function getFileLocation($id) @@ -260,7 +255,6 @@ public function getFileLocation($id) } /** - * {@inheritDoc} * @see AbstractDocument::getFileMimeType() */ public function getFileMimeType($id) @@ -278,7 +272,6 @@ public function getFileMimeType($id) } /** - * {@inheritDoc} * @see AbstractDocument::getLogicalStructure() */ public function getLogicalStructure($id, $recursive = false) @@ -427,7 +420,6 @@ protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recurs } /** - * {@inheritDoc} * @see AbstractDocument::getMetadata() */ public function getMetadata($id, $cPid = 0) @@ -706,7 +698,6 @@ protected function getMetadataIds($id) } /** - * {@inheritDoc} * @see AbstractDocument::getFullText() */ public function getFullText($id) @@ -722,7 +713,6 @@ public function getFullText($id) } /** - * {@inheritDoc} * @see AbstractDocument::getStructureDepth() */ public function getStructureDepth($logId) @@ -736,7 +726,6 @@ public function getStructureDepth($logId) } /** - * {@inheritDoc} * @see AbstractDocument::init() */ protected function init($location) @@ -761,7 +750,6 @@ protected function init($location) } /** - * {@inheritDoc} * @see AbstractDocument::loadLocation() */ protected function loadLocation($location) @@ -780,7 +768,6 @@ protected function loadLocation($location) } /** - * {@inheritDoc} * @see AbstractDocument::ensureHasFulltextIsSet() */ protected function ensureHasFulltextIsSet() @@ -792,7 +779,6 @@ protected function ensureHasFulltextIsSet() } /** - * {@inheritDoc} * @see AbstractDocument::setPreloadedDocument() */ protected function setPreloadedDocument($preloadedDocument) @@ -806,7 +792,6 @@ protected function setPreloadedDocument($preloadedDocument) } /** - * {@inheritDoc} * @see AbstractDocument::getDocument() */ protected function getDocument() @@ -969,7 +954,16 @@ protected function _getFileGrps() } /** - * {@inheritDoc} + * @access protected + * @return array + */ + protected function _getFileInfos() + { + $this->_getFileGrps(); + return $this->fileInfos; + } + + /** * @see AbstractDocument::prepareMetadataArray() */ protected function prepareMetadataArray($cPid) @@ -997,7 +991,6 @@ protected function _getMets() } /** - * {@inheritDoc} * @see AbstractDocument::_getPhysicalStructure() */ protected function _getPhysicalStructure() @@ -1060,7 +1053,6 @@ protected function _getPhysicalStructure() } /** - * {@inheritDoc} * @see AbstractDocument::_getSmLinks() */ protected function _getSmLinks() @@ -1079,7 +1071,6 @@ protected function _getSmLinks() } /** - * {@inheritDoc} * @see AbstractDocument::_getThumbnail() */ protected function _getThumbnail($forceReload = false) @@ -1159,7 +1150,6 @@ protected function _getThumbnail($forceReload = false) } /** - * {@inheritDoc} * @see AbstractDocument::_getToplevelId() */ protected function _getToplevelId() From 59fdeec04b97eab2d735899ce0fe008a69bf2390 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Thu, 28 Sep 2023 21:46:27 +0200 Subject: [PATCH 05/76] Unify and improve PHPDocs for classes (#1012) Co-authored-by: Sebastian Meyer --- Classes/Api/Orcid/Client.php | 4 +- Classes/Api/Orcid/Profile.php | 2 +- Classes/Api/Viaf/Client.php | 6 +- Classes/Api/Viaf/Profile.php | 2 +- Classes/Command/BaseCommand.php | 2 +- Classes/Command/HarvestCommand.php | 2 +- Classes/Command/IndexCommand.php | 2 +- Classes/Command/ReindexCommand.php | 2 +- Classes/Common/AbstractDocument.php | 48 ++++++++----- Classes/Common/FulltextInterface.php | 3 +- Classes/Common/Helper.php | 3 +- Classes/Common/IiifManifest.php | 52 +++++++++----- Classes/Common/IiifUrlReader.php | 2 +- Classes/Common/Indexer.php | 2 +- Classes/Common/KitodoFlashMessageRenderer.php | 5 ++ Classes/Common/MetadataInterface.php | 3 +- Classes/Common/MetsDocument.php | 71 +++++++++---------- .../Common/Solr/SearchResult/Highlight.php | 2 +- Classes/Common/Solr/SearchResult/Page.php | 2 +- Classes/Common/Solr/SearchResult/Region.php | 2 +- .../Solr/SearchResult/ResultDocument.php | 2 +- Classes/Common/Solr/Solr.php | 22 +++--- Classes/Common/Solr/SolrSearch.php | 5 ++ Classes/Common/Solr/SolrSearchQuery.php | 8 +++ Classes/Common/StdOutStream.php | 5 ++ Classes/Controller/AbstractController.php | 4 +- Classes/Controller/AudioPlayerController.php | 2 +- .../Backend/NewTenantController.php | 3 +- Classes/Controller/BasketController.php | 2 +- Classes/Controller/CalendarController.php | 3 +- Classes/Controller/CollectionController.php | 2 +- Classes/Controller/FeedsController.php | 3 +- Classes/Controller/ListViewController.php | 5 +- Classes/Controller/MetadataController.php | 2 +- Classes/Controller/NavigationController.php | 2 +- Classes/Controller/OaiPmhController.php | 3 +- Classes/Controller/PageGridController.php | 3 +- Classes/Controller/PageViewController.php | 2 +- Classes/Controller/SearchController.php | 5 +- Classes/Controller/StatisticsController.php | 2 +- .../Controller/TableOfContentsController.php | 2 +- Classes/Controller/ToolboxController.php | 2 +- Classes/Controller/View3DController.php | 2 +- Classes/Domain/Model/ActionLog.php | 1 + Classes/Domain/Model/Basket.php | 1 + Classes/Domain/Model/Collection.php | 1 + Classes/Domain/Model/Document.php | 1 + Classes/Domain/Model/Format.php | 1 + Classes/Domain/Model/Library.php | 1 + Classes/Domain/Model/Mail.php | 1 + Classes/Domain/Model/Metadata.php | 1 + Classes/Domain/Model/MetadataFormat.php | 1 + Classes/Domain/Model/PageSelectForm.php | 1 + Classes/Domain/Model/Printer.php | 1 + Classes/Domain/Model/SolrCore.php | 1 + Classes/Domain/Model/Structure.php | 1 + Classes/Domain/Model/Token.php | 1 + .../Domain/Repository/ActionLogRepository.php | 8 +++ .../Domain/Repository/BasketRepository.php | 8 +++ .../Repository/CollectionRepository.php | 8 +++ .../Domain/Repository/DocumentRepository.php | 8 +++ .../Domain/Repository/FormatRepository.php | 8 +++ .../Domain/Repository/LibraryRepository.php | 8 +++ Classes/Domain/Repository/MailRepository.php | 8 +++ .../Repository/MetadataFormatRepository.php | 8 +++ .../Domain/Repository/MetadataRepository.php | 8 +++ .../Domain/Repository/PrinterRepository.php | 8 +++ .../Domain/Repository/SolrCoreRepository.php | 8 +++ .../Domain/Repository/StructureRepository.php | 8 +++ Classes/Domain/Repository/TokenRepository.php | 9 ++- Classes/Eid/PageViewProxy.php | 2 +- .../DocumentTypeFunctionProvider.php | 2 +- .../DocumentTypeProvider.php | 2 +- Classes/Format/Alto.php | 2 +- Classes/Format/AudioVideoMD.php | 2 +- Classes/Format/Mods.php | 2 +- Classes/Format/TeiHeader.php | 2 +- Classes/Hooks/ConfigurationForm.php | 2 +- Classes/Hooks/DataHandler.php | 2 +- .../EditInProductionWarning.php | 2 +- .../Form/FieldInformation/SolrCoreStatus.php | 2 +- Classes/Hooks/ItemsProcFunc.php | 2 +- Classes/Hooks/KitodoProductionHacks.php | 2 +- Classes/Hooks/ThumbnailCustomElement.php | 8 +++ Classes/Middleware/SearchInDocument.php | 3 +- Classes/Middleware/SearchSuggest.php | 4 +- Classes/Updates/FileLocationUpdater.php | 5 ++ Classes/Updates/MigrateSettings.php | 4 ++ Classes/ViewHelpers/JsFooterViewHelper.php | 7 +- .../MetadataWrapVariableViewHelper.php | 6 +- Classes/ViewHelpers/StdWrapViewHelper.php | 8 +++ 91 files changed, 348 insertions(+), 150 deletions(-) diff --git a/Classes/Api/Orcid/Client.php b/Classes/Api/Orcid/Client.php index 37f3d9a93..9b4f8c496 100644 --- a/Classes/Api/Orcid/Client.php +++ b/Classes/Api/Orcid/Client.php @@ -21,9 +21,9 @@ /** * ORCID API Client class * - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public **/ class Client @@ -73,7 +73,7 @@ class Client /** * Constructs a new instance * - * @param string $orcid: the ORCID to search for + * @param string $orcid the ORCID to search for * @param RequestFactory $requestFactory a request object to inject * @return void **/ diff --git a/Classes/Api/Orcid/Profile.php b/Classes/Api/Orcid/Profile.php index f35a509f4..827d16a26 100644 --- a/Classes/Api/Orcid/Profile.php +++ b/Classes/Api/Orcid/Profile.php @@ -21,9 +21,9 @@ /** * ORCID API Profile class * - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public **/ class Profile diff --git a/Classes/Api/Viaf/Client.php b/Classes/Api/Viaf/Client.php index 5a3d5797f..6dc5fba33 100644 --- a/Classes/Api/Viaf/Client.php +++ b/Classes/Api/Viaf/Client.php @@ -21,9 +21,9 @@ /** * VIAF API Client class * - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public **/ class Client @@ -37,7 +37,7 @@ class Client protected $logger; /** - * The ORCID API endpoint + * The VIAF API endpoint * * @var string **/ @@ -60,7 +60,7 @@ class Client /** * Constructs a new instance * - * @param string $viaf: the VIAF identifier of the profile + * @param string $viaf the VIAF identifier of the profile * @param RequestFactory $requestFactory a request object to inject * @return void **/ diff --git a/Classes/Api/Viaf/Profile.php b/Classes/Api/Viaf/Profile.php index 362ce4a98..7c9d4ce5b 100644 --- a/Classes/Api/Viaf/Profile.php +++ b/Classes/Api/Viaf/Profile.php @@ -21,9 +21,9 @@ /** * VIAF API Profile class * - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public **/ class Profile diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index 02f5cd3d2..b34b5b0c9 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -35,9 +35,9 @@ /** * Base class for CLI Command classes. * - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public */ class BaseCommand extends Command diff --git a/Classes/Command/HarvestCommand.php b/Classes/Command/HarvestCommand.php index 7de2580b3..2cf58a738 100644 --- a/Classes/Command/HarvestCommand.php +++ b/Classes/Command/HarvestCommand.php @@ -28,9 +28,9 @@ /** * CLI Command for harvesting OAI-PMH interfaces into database and Solr. * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class HarvestCommand extends BaseCommand diff --git a/Classes/Command/IndexCommand.php b/Classes/Command/IndexCommand.php index 6e356cc94..01ee83855 100644 --- a/Classes/Command/IndexCommand.php +++ b/Classes/Command/IndexCommand.php @@ -26,9 +26,9 @@ /** * CLI Command for indexing single documents into database and Solr. * - * @author Alexander Bigga * @package TYPO3 * @subpackage dlf + * * @access public */ class IndexCommand extends BaseCommand diff --git a/Classes/Command/ReindexCommand.php b/Classes/Command/ReindexCommand.php index 6d2d35f74..ff5c172dd 100644 --- a/Classes/Command/ReindexCommand.php +++ b/Classes/Command/ReindexCommand.php @@ -25,9 +25,9 @@ /** * CLI Command for re-indexing collections into database and Solr. * - * @author Alexander Bigga * @package TYPO3 * @subpackage dlf + * * @access public */ class ReindexCommand extends BaseCommand diff --git a/Classes/Common/AbstractDocument.php b/Classes/Common/AbstractDocument.php index 9d18becdb..8ebe0688f 100644 --- a/Classes/Common/AbstractDocument.php +++ b/Classes/Common/AbstractDocument.php @@ -23,28 +23,40 @@ /** * Document class for the 'dlf' extension * - * @author Sebastian Meyer - * @author Henrik Lochmann * @package TYPO3 * @subpackage dlf + * * @access public - * @property int $cPid This holds the PID for the configuration - * @property-read array $fileInfos Additional information about files (e.g., ADMID), indexed by ID. - * @property-read bool $hasFulltext Are there any fulltext files available? - * @property-read array $metadataArray This holds the documents' parsed metadata array - * @property-read int $numPages The holds the total number of pages - * @property-read int $parentId This holds the UID of the parent document or zero if not multi-volumed - * @property-read array $physicalStructure This holds the physical structure - * @property-read array $physicalStructureInfo This holds the physical structure metadata - * @property-read int $pid This holds the PID of the document or zero if not in database - * @property-read bool $ready Is the document instantiated successfully? - * @property-read string $recordId The METS file's / IIIF manifest's record identifier - * @property-read int $rootId This holds the UID of the root document or zero if not multi-volumed - * @property-read array $smLinks This holds the smLinks between logical and physical structMap - * @property-read array $tableOfContents This holds the logical structure - * @property-read string $thumbnail This holds the document's thumbnail location - * @property-read string $toplevelId This holds the toplevel structure's "@ID" (METS) or the manifest's "@id" (IIIF) + * * @abstract + * + * @property int $cPid this holds the PID for the configuration + * @property-read array $formats this holds the configuration for all supported metadata encodings + * @property bool $formatsLoaded flag with information if the available metadata formats are loaded + * @property-read bool $hasFulltext flag with information if there are any fulltext files available + * @property array $lastSearchedPhysicalPage the last searched logical and physical page + * @property array $logicalUnits this holds the logical units + * @property-read array $metadataArray this holds the documents' parsed metadata array + * @property bool $metadataArrayLoaded flag with information if the metadata array is loaded + * @property-read int $numPages the holds the total number of pages + * @property-read int $parentId this holds the UID of the parent document or zero if not multi-volumed + * @property-read array $physicalStructure this holds the physical structure + * @property-read array $physicalStructureInfo this holds the physical structure metadata + * @property bool $physicalStructureLoaded flag with information if the physical structure is loaded + * @property-read int $pid this holds the PID of the document or zero if not in database + * @property array $rawTextArray this holds the documents' raw text pages with their corresponding structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key + * @property-read bool $ready Is the document instantiated successfully? + * @property-read string $recordId the METS file's / IIIF manifest's record identifier + * @property array $registry this holds the singleton object of the document + * @property-read int $rootId this holds the UID of the root document or zero if not multi-volumed + * @property-read array $smLinks this holds the smLinks between logical and physical structMap + * @property bool $smLinksLoaded flag with information if the smLinks are loaded + * @property-read array $tableOfContents this holds the logical structure + * @property bool $tableOfContentsLoaded flag with information if the table of contents is loaded + * @property-read string $thumbnail this holds the document's thumbnail location + * @property bool $thumbnailLoaded flag with information if the thumbnail is loaded + * @property-read string $toplevelId this holds the toplevel structure's "@ID" (METS) or the manifest's "@id" (IIIF) + * @property \SimpleXMLElement $xml this holds the whole XML file as \SimpleXMLElement object */ abstract class AbstractDocument { diff --git a/Classes/Common/FulltextInterface.php b/Classes/Common/FulltextInterface.php index b6ac05484..27b6623fa 100644 --- a/Classes/Common/FulltextInterface.php +++ b/Classes/Common/FulltextInterface.php @@ -15,10 +15,11 @@ /** * Fulltext interface for the 'dlf' extension * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public + * * @abstract */ interface FulltextInterface diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index 7c3659be2..dbcf992bc 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -33,10 +33,9 @@ /** * Helper class for the 'dlf' extension * - * @author Sebastian Meyer - * @author Henrik Lochmann * @package TYPO3 * @subpackage dlf + * * @access public */ class Helper diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index 13621dec9..0822431dd 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -36,25 +36,45 @@ /** * IiifManifest class for the 'dlf' extension. * - * @author Lutz Helm * @package TYPO3 * @subpackage dlf + * * @access public - * @property int $cPid This holds the PID for the configuration - * @property-read bool $hasFulltext Are there any fulltext files available? - * @property-read array $metadataArray This holds the documents' parsed metadata array - * @property-read int $numPages The holds the total number of pages - * @property-read int $parentId This holds the UID of the parent document or zero if not multi-volumed - * @property-read array $physicalStructure This holds the physical structure - * @property-read array $physicalStructureInfo This holds the physical structure metadata - * @property-read int $pid This holds the PID of the document or zero if not in database + * + * @property int $cPid this holds the PID for the configuration + * @property-read array $formats this holds the configuration for all supported metadata encodings + * @property bool $formatsLoaded flag with information if the available metadata formats are loaded + * @property-read bool $hasFulltext flag with information if there are any fulltext files available + * @property array $lastSearchedPhysicalPage the last searched logical and physical page + * @property array $logicalUnits this holds the logical units + * @property-read array $metadataArray this holds the documents' parsed metadata array + * @property bool $metadataArrayLoaded flag with information if the metadata array is loaded + * @property-read int $numPages the holds the total number of pages + * @property-read int $parentId this holds the UID of the parent document or zero if not multi-volumed + * @property-read array $physicalStructure this holds the physical structure + * @property-read array $physicalStructureInfo this holds the physical structure metadata + * @property bool $physicalStructureLoaded flag with information if the physical structure is loaded + * @property-read int $pid this holds the PID of the document or zero if not in database + * @property array $rawTextArray this holds the documents' raw text pages with their corresponding structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key * @property-read bool $ready Is the document instantiated successfully? - * @property-read string $recordId The IIIF manifest's record identifier - * @property-read int $rootId This holds the UID of the root document or zero if not multi-volumed - * @property-read array $smLinks This holds the connections between resources and canvases - * @property-read array $tableOfContents This holds the logical structure - * @property-read string $thumbnail This holds the document's thumbnail location - * @property-read string $toplevelId This holds the toplevel manifest's @id + * @property-read string $recordId the METS file's / IIIF manifest's record identifier + * @property array $registry this holds the singleton object of the document + * @property-read int $rootId this holds the UID of the root document or zero if not multi-volumed + * @property-read array $smLinks this holds the smLinks between logical and physical structMap + * @property bool $smLinksLoaded flag with information if the smLinks are loaded + * @property-read array $tableOfContents this holds the logical structure + * @property bool $tableOfContentsLoaded flag with information if the table of contents is loaded + * @property-read string $thumbnail this holds the document's thumbnail location + * @property bool $thumbnailLoaded flag with information if the thumbnail is loaded + * @property-read string $toplevelId this holds the toplevel structure's "@ID" (METS) or the manifest's "@id" (IIIF) + * @property \SimpleXMLElement $xml this holds the whole XML file as \SimpleXMLElement object + * @property string $asJson this holds the manifest file as string for serialization purposes + * @property ManifestInterface $iiif a PHP object representation of a IIIF manifest + * @property string $iiifVersion 'IIIF1', 'IIIF2' or 'IIIF3', depending on the API $this->iiif conforms to + * @property bool $hasFulltextSet flag if document has already been analyzed for presence of the fulltext for the Solr index + * @property array $originalMetadataArray this holds the original manifest's parsed metadata array with their corresponding resource (Manifest / Sequence / Range) ID as array key + * @property array $mimeTypes this holds the mime types of linked resources in the manifest (extracted during parsing) for later us + * */ final class IiifManifest extends AbstractDocument { @@ -75,7 +95,7 @@ final class IiifManifest extends AbstractDocument protected $iiif; /** - * 'IIIF1', 'IIIF2' or 'IIIF3', depending on the API $this->iiif confrms to: + * 'IIIF1', 'IIIF2' or 'IIIF3', depending on the API $this->iiif conforms to: * IIIF Metadata API 1, IIIF Presentation API 2 or 3 * @var string * @access protected diff --git a/Classes/Common/IiifUrlReader.php b/Classes/Common/IiifUrlReader.php index a5f53080f..9b51c7568 100644 --- a/Classes/Common/IiifUrlReader.php +++ b/Classes/Common/IiifUrlReader.php @@ -20,9 +20,9 @@ * Allows the use of TYPO3 framework functions for loading remote documents in the * IIIF library. * - * @author Lutz Helm * @package TYPO3 * @subpackage dlf + * * @access public */ class IiifUrlReader implements UrlReaderInterface diff --git a/Classes/Common/Indexer.php b/Classes/Common/Indexer.php index fd2ae7a38..bffcd62fb 100644 --- a/Classes/Common/Indexer.php +++ b/Classes/Common/Indexer.php @@ -27,9 +27,9 @@ /** * Indexer class for the 'dlf' extension * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class Indexer diff --git a/Classes/Common/KitodoFlashMessageRenderer.php b/Classes/Common/KitodoFlashMessageRenderer.php index ea4d69ce3..171c2d615 100644 --- a/Classes/Common/KitodoFlashMessageRenderer.php +++ b/Classes/Common/KitodoFlashMessageRenderer.php @@ -21,6 +21,11 @@ * bootstrap HTML/CSS framework. It is used in backend context. * The created output contains all classes which are required for * the TYPO3 backend. Any kind of message contains also a nice icon. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public */ class KitodoFlashMessageRenderer implements FlashMessageRendererInterface { diff --git a/Classes/Common/MetadataInterface.php b/Classes/Common/MetadataInterface.php index 42dd1ccdd..6b7e7c27c 100644 --- a/Classes/Common/MetadataInterface.php +++ b/Classes/Common/MetadataInterface.php @@ -15,10 +15,11 @@ /** * Metadata interface for the 'dlf' extension * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public + * * @abstract */ interface MetadataInterface diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index d8a729304..29c668a57 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -23,30 +23,45 @@ /** * MetsDocument class for the 'dlf' extension. * - * @author Sebastian Meyer - * @author Henrik Lochmann * @package TYPO3 * @subpackage dlf + * * @access public - * @property int $cPid This holds the PID for the configuration - * @property-read array $mdSec Associative array of METS metadata sections indexed by their IDs. - * @property-read array $dmdSec Subset of `$mdSec` storing only the dmdSec entries; kept for compatibility. - * @property-read array $fileGrps This holds the file ID -> USE concordance - * @property-read bool $hasFulltext Are there any fulltext files available? - * @property-read array $metadataArray This holds the documents' parsed metadata array - * @property-read \SimpleXMLElement $mets This holds the XML file's METS part as \SimpleXMLElement object - * @property-read int $numPages The holds the total number of pages - * @property-read int $parentId This holds the UID of the parent document or zero if not multi-volumed - * @property-read array $physicalStructure This holds the physical structure - * @property-read array $physicalStructureInfo This holds the physical structure metadata - * @property-read int $pid This holds the PID of the document or zero if not in database + * + * @property int $cPid this holds the PID for the configuration + * @property-read array $formats this holds the configuration for all supported metadata encodings + * @property bool $formatsLoaded flag with information if the available metadata formats are loaded + * @property-read bool $hasFulltext flag with information if there are any fulltext files available + * @property array $lastSearchedPhysicalPage the last searched logical and physical page + * @property array $logicalUnits this holds the logical units + * @property-read array $metadataArray this holds the documents' parsed metadata array + * @property bool $metadataArrayLoaded flag with information if the metadata array is loaded + * @property-read int $numPages the holds the total number of pages + * @property-read int $parentId this holds the UID of the parent document or zero if not multi-volumed + * @property-read array $physicalStructure this holds the physical structure + * @property-read array $physicalStructureInfo this holds the physical structure metadata + * @property bool $physicalStructureLoaded flag with information if the physical structure is loaded + * @property-read int $pid this holds the PID of the document or zero if not in database + * @property array $rawTextArray this holds the documents' raw text pages with their corresponding structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key * @property-read bool $ready Is the document instantiated successfully? - * @property-read string $recordId The METS file's / IIIF manifest's record identifier - * @property-read int $rootId This holds the UID of the root document or zero if not multi-volumed - * @property-read array $smLinks This holds the smLinks between logical and physical structMap - * @property-read array $tableOfContents This holds the logical structure - * @property-read string $thumbnail This holds the document's thumbnail location - * @property-read string $toplevelId This holds the toplevel structure's @ID (METS) or the manifest's @id (IIIF) + * @property-read string $recordId the METS file's / IIIF manifest's record identifier + * @property array $registry this holds the singleton object of the document + * @property-read int $rootId this holds the UID of the root document or zero if not multi-volumed + * @property-read array $smLinks this holds the smLinks between logical and physical structMap + * @property bool $smLinksLoaded flag with information if the smLinks are loaded + * @property-read array $tableOfContents this holds the logical structure + * @property bool $tableOfContentsLoaded flag with information if the table of contents is loaded + * @property-read string $thumbnail this holds the document's thumbnail location + * @property bool $thumbnailLoaded flag with information if the thumbnail is loaded + * @property-read string $toplevelId this holds the toplevel structure's "@ID" (METS) or the manifest's "@id" (IIIF) + * @property \SimpleXMLElement $xml this holds the whole XML file as \SimpleXMLElement object + * @property-read array $mdSec associative array of METS metadata sections indexed by their IDs. + * @property bool $mdSecLoaded flag with information if the array of METS metadata sections is loaded + * @property-read array $dmdSec subset of `$mdSec` storing only the dmdSec entries; kept for compatibility. + * @property-read array $fileGrps this holds the file ID -> USE concordance + * @property bool $fileGrpsLoaded flag with information if file groups array is loaded + * @property-read array $fileInfos additional information about files (e.g., ADMID), indexed by ID. + * @property-read \SimpleXMLElement $mets this holds the XML file's METS part as \SimpleXMLElement object * @property-read string $parentHref URL of the parent document (determined via mptr element), or empty string if none is available */ final class MetsDocument extends AbstractDocument @@ -104,14 +119,6 @@ final class MetsDocument extends AbstractDocument */ protected $dmdSec = []; - /** - * The extension key - * - * @var string - * @access public - */ - public static $extKey = 'dlf'; - /** * This holds the file ID -> USE concordance * @see _getFileGrps() @@ -138,14 +145,6 @@ final class MetsDocument extends AbstractDocument */ protected $mets; - /** - * This holds the whole XML file as \SimpleXMLElement object - * - * @var \SimpleXMLElement - * @access protected - */ - protected $xml; - /** * URL of the parent document (determined via mptr element), * or empty string if none is available diff --git a/Classes/Common/Solr/SearchResult/Highlight.php b/Classes/Common/Solr/SearchResult/Highlight.php index 66bf89429..dc7afb62b 100644 --- a/Classes/Common/Solr/SearchResult/Highlight.php +++ b/Classes/Common/Solr/SearchResult/Highlight.php @@ -15,9 +15,9 @@ /** * Highlight class for the 'dlf' extension. It keeps highlight for found search phrase. * - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public */ class Highlight diff --git a/Classes/Common/Solr/SearchResult/Page.php b/Classes/Common/Solr/SearchResult/Page.php index d35122d4c..b5b226c3d 100644 --- a/Classes/Common/Solr/SearchResult/Page.php +++ b/Classes/Common/Solr/SearchResult/Page.php @@ -15,9 +15,9 @@ /** * Page class for the 'dlf' extension. It keeps page in which search phrase was found. * - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public */ class Page diff --git a/Classes/Common/Solr/SearchResult/Region.php b/Classes/Common/Solr/SearchResult/Region.php index a0b1536ac..6333c9564 100644 --- a/Classes/Common/Solr/SearchResult/Region.php +++ b/Classes/Common/Solr/SearchResult/Region.php @@ -15,9 +15,9 @@ /** * Region class for the 'dlf' extension. It keeps region in which search phrase was found. * - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public */ class Region diff --git a/Classes/Common/Solr/SearchResult/ResultDocument.php b/Classes/Common/Solr/SearchResult/ResultDocument.php index 65fc2c188..bf3c7e422 100644 --- a/Classes/Common/Solr/SearchResult/ResultDocument.php +++ b/Classes/Common/Solr/SearchResult/ResultDocument.php @@ -15,9 +15,9 @@ /** * ResultDocument class for the 'dlf' extension. It keeps the result of the search in the SOLR index. * - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public */ class ResultDocument diff --git a/Classes/Common/Solr/Solr.php b/Classes/Common/Solr/Solr.php index 99a6924e7..298cb9a56 100644 --- a/Classes/Common/Solr/Solr.php +++ b/Classes/Common/Solr/Solr.php @@ -27,18 +27,22 @@ /** * Solr class for the 'dlf' extension * - * @author Sebastian Meyer - * @author Henrik Lochmann * @package TYPO3 * @subpackage dlf + * * @access public - * @property-read string|null $core This holds the core name for the current instance - * @property-write int $cPid This holds the PID for the configuration - * @property int $limit This holds the max results - * @property-read int $numberOfHits This holds the number of hits for last search - * @property-write array $params This holds the additional query parameters - * @property-read bool $ready Is the Solr service instantiated successfully? - * @property-read \Solarium\Client $service This holds the Solr service object + * + * @property array $config this holds the Solr configuration + * @property-read string|null $core this holds the core name for the current instance + * @property-write int $cPid this holds the PID for the configuration + * @property-read string $extKey the extension key + * @property array $fields the fields for SOLR index + * @property int $limit this holds the max results + * @property-read int $numberOfHits this holds the number of hits for last search + * @property-write array $params this holds the additional query parameters + * @property-read bool $ready flag if the Solr service is instantiated successfully + * @property array $registry this holds the singleton search objects with their core as array key + * @property-read \Solarium\Client $service this holds the Solr service object */ class Solr implements LoggerAwareInterface { diff --git a/Classes/Common/Solr/SolrSearch.php b/Classes/Common/Solr/SolrSearch.php index bf7f0debb..803a69857 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -21,6 +21,11 @@ * - `Countable`: `count()` returns the number of toplevel documents. * - `getNumLoadedDocuments()`: Number of toplevel documents that have been fetched from Solr. * - `ArrayAccess`/`Iterator`: Access *fetched* toplevel documents indexed in order of their ranking. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public */ class SolrSearch implements \Countable, \Iterator, \ArrayAccess, QueryResultInterface { diff --git a/Classes/Common/Solr/SolrSearchQuery.php b/Classes/Common/Solr/SolrSearchQuery.php index c170ef4be..650338642 100644 --- a/Classes/Common/Solr/SolrSearchQuery.php +++ b/Classes/Common/Solr/SolrSearchQuery.php @@ -9,6 +9,14 @@ /** * Targeted towards being used in ``PaginateController`` (````). + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + * + * @property int $limit + * @property int $offset */ class SolrSearchQuery implements QueryInterface { diff --git a/Classes/Common/StdOutStream.php b/Classes/Common/StdOutStream.php index da4c53a05..fcbaf24a7 100644 --- a/Classes/Common/StdOutStream.php +++ b/Classes/Common/StdOutStream.php @@ -18,6 +18,11 @@ /** * Stream decorator to allow printing a stream to standard output in chunks. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public */ class StdOutStream implements StreamInterface, SelfEmittableStreamInterface { diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 2a69ed7e8..036bd94c3 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -28,10 +28,12 @@ /** * Abstract controller class for most of the plugin controller. * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public + * + * @abstract */ abstract class AbstractController extends ActionController implements LoggerAwareInterface { diff --git a/Classes/Controller/AudioPlayerController.php b/Classes/Controller/AudioPlayerController.php index ae11d2b16..cef02f803 100644 --- a/Classes/Controller/AudioPlayerController.php +++ b/Classes/Controller/AudioPlayerController.php @@ -19,9 +19,9 @@ /** * Controller class for the plugin 'AudioPlayer'. * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class AudioplayerController extends AbstractController diff --git a/Classes/Controller/Backend/NewTenantController.php b/Classes/Controller/Backend/NewTenantController.php index 1db29a792..9e55acac6 100644 --- a/Classes/Controller/Backend/NewTenantController.php +++ b/Classes/Controller/Backend/NewTenantController.php @@ -35,10 +35,9 @@ /** * Controller class for the backend module 'New Tenant'. * - * @author Christopher Timm - * @author Alexander Bigga * @package TYPO3 * @subpackage dlf + * * @access public */ class NewTenantController extends AbstractController diff --git a/Classes/Controller/BasketController.php b/Classes/Controller/BasketController.php index b009df004..45418714b 100644 --- a/Classes/Controller/BasketController.php +++ b/Classes/Controller/BasketController.php @@ -28,9 +28,9 @@ /** * Controller class for the plugin 'Basket'. * - * @author Christopher Timm * @package TYPO3 * @subpackage dlf + * * @access public */ class BasketController extends AbstractController diff --git a/Classes/Controller/CalendarController.php b/Classes/Controller/CalendarController.php index 7a4639a47..f4deff303 100644 --- a/Classes/Controller/CalendarController.php +++ b/Classes/Controller/CalendarController.php @@ -18,10 +18,9 @@ /** * Controller class for the plugin 'Calendar'. * - * @author Alexander Bigga - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class CalendarController extends AbstractController diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index d4e103fa7..5e7057bba 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -21,9 +21,9 @@ /** * Controller class for the plugin 'Collection'. * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class CollectionController extends AbstractController diff --git a/Classes/Controller/FeedsController.php b/Classes/Controller/FeedsController.php index fae8ab06c..e02ecc30a 100644 --- a/Classes/Controller/FeedsController.php +++ b/Classes/Controller/FeedsController.php @@ -20,10 +20,9 @@ /** * Controller class for the plugin 'Feeds'. * - * @author Sebastian Meyer - * @author Alexander Bigga * @package TYPO3 * @subpackage dlf + * * @access public */ class FeedsController extends AbstractController diff --git a/Classes/Controller/ListViewController.php b/Classes/Controller/ListViewController.php index 2f31436bd..2b0dd0a3f 100644 --- a/Classes/Controller/ListViewController.php +++ b/Classes/Controller/ListViewController.php @@ -19,12 +19,9 @@ /** * Controller class for the plugin 'ListView'. * - * @author Sebastian Meyer - * @author Henrik Lochmann - * @author Frank Ulrich Weber - * @author Alexander Bigga * @package TYPO3 * @subpackage dlf + * * @access public */ class ListViewController extends AbstractController diff --git a/Classes/Controller/MetadataController.php b/Classes/Controller/MetadataController.php index 7cb6c27ab..12412064b 100644 --- a/Classes/Controller/MetadataController.php +++ b/Classes/Controller/MetadataController.php @@ -22,9 +22,9 @@ /** * Controller class for the plugin 'Metadata'. * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class MetadataController extends AbstractController diff --git a/Classes/Controller/NavigationController.php b/Classes/Controller/NavigationController.php index 3b1a15a79..21b03a913 100644 --- a/Classes/Controller/NavigationController.php +++ b/Classes/Controller/NavigationController.php @@ -17,9 +17,9 @@ /** * Controller class for the plugin 'Navigation'. * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class NavigationController extends AbstractController diff --git a/Classes/Controller/OaiPmhController.php b/Classes/Controller/OaiPmhController.php index 0164684ae..35dad07b5 100644 --- a/Classes/Controller/OaiPmhController.php +++ b/Classes/Controller/OaiPmhController.php @@ -21,10 +21,9 @@ /** * Controller class for the plugin 'OAI-PMH Interface'. * - * @author Sebastian Meyer - * @author Alexander Bigga * @package TYPO3 * @subpackage dlf + * * @access public */ class OaiPmhController extends AbstractController diff --git a/Classes/Controller/PageGridController.php b/Classes/Controller/PageGridController.php index 3253c97c7..dd3877350 100644 --- a/Classes/Controller/PageGridController.php +++ b/Classes/Controller/PageGridController.php @@ -20,10 +20,9 @@ /** * Controller class for the plugin 'Page Grid'. * - * @author Henrik Lochmann - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class PageGridController extends AbstractController diff --git a/Classes/Controller/PageViewController.php b/Classes/Controller/PageViewController.php index ededffc3c..37e196e9a 100644 --- a/Classes/Controller/PageViewController.php +++ b/Classes/Controller/PageViewController.php @@ -20,9 +20,9 @@ /** * Controller class for the plugin 'Page View'. * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class PageViewController extends AbstractController diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index f94ba0a3f..757f3a2bb 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -24,12 +24,9 @@ /** * Controller class for the plugin 'Search'. * - * @author Sebastian Meyer - * @author Henrik Lochmann - * @author Frank Ulrich Weber - * @author Alexander Bigga * @package TYPO3 * @subpackage dlf + * * @access public */ class SearchController extends AbstractController diff --git a/Classes/Controller/StatisticsController.php b/Classes/Controller/StatisticsController.php index 0a48f802e..e8cded48d 100644 --- a/Classes/Controller/StatisticsController.php +++ b/Classes/Controller/StatisticsController.php @@ -16,9 +16,9 @@ /** * Controller class for the plugin 'Statistics'. * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class StatisticsController extends AbstractController diff --git a/Classes/Controller/TableOfContentsController.php b/Classes/Controller/TableOfContentsController.php index 957ee6225..58bb68dde 100644 --- a/Classes/Controller/TableOfContentsController.php +++ b/Classes/Controller/TableOfContentsController.php @@ -18,9 +18,9 @@ /** * Controller class for plugin 'Table Of Contents'. * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class TableOfContentsController extends AbstractController diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index 239014ebc..d81faf18b 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -19,9 +19,9 @@ /** * Controller class for plugin 'Toolbox'. * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class ToolboxController extends AbstractController diff --git a/Classes/Controller/View3DController.php b/Classes/Controller/View3DController.php index ed99b4d60..4d213c0b7 100644 --- a/Classes/Controller/View3DController.php +++ b/Classes/Controller/View3DController.php @@ -14,9 +14,9 @@ /** * Plugin 'View3D' for the 'dlf' extension * - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public */ class View3DController extends AbstractController diff --git a/Classes/Domain/Model/ActionLog.php b/Classes/Domain/Model/ActionLog.php index 325874c12..fb14f3fbc 100644 --- a/Classes/Domain/Model/ActionLog.php +++ b/Classes/Domain/Model/ActionLog.php @@ -19,6 +19,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class ActionLog extends AbstractEntity diff --git a/Classes/Domain/Model/Basket.php b/Classes/Domain/Model/Basket.php index 1f79073ff..f96653bc6 100644 --- a/Classes/Domain/Model/Basket.php +++ b/Classes/Domain/Model/Basket.php @@ -19,6 +19,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class Basket extends AbstractEntity diff --git a/Classes/Domain/Model/Collection.php b/Classes/Domain/Model/Collection.php index 0b3c5b0ce..9e597942e 100644 --- a/Classes/Domain/Model/Collection.php +++ b/Classes/Domain/Model/Collection.php @@ -19,6 +19,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class Collection extends AbstractEntity diff --git a/Classes/Domain/Model/Document.php b/Classes/Domain/Model/Document.php index 19f941b26..2c225a225 100644 --- a/Classes/Domain/Model/Document.php +++ b/Classes/Domain/Model/Document.php @@ -23,6 +23,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class Document extends AbstractEntity diff --git a/Classes/Domain/Model/Format.php b/Classes/Domain/Model/Format.php index 3b8884a97..e652310d2 100644 --- a/Classes/Domain/Model/Format.php +++ b/Classes/Domain/Model/Format.php @@ -25,6 +25,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class Format extends AbstractEntity diff --git a/Classes/Domain/Model/Library.php b/Classes/Domain/Model/Library.php index 6ee1bee4d..94fd153f5 100644 --- a/Classes/Domain/Model/Library.php +++ b/Classes/Domain/Model/Library.php @@ -26,6 +26,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class Library extends AbstractEntity diff --git a/Classes/Domain/Model/Mail.php b/Classes/Domain/Model/Mail.php index 685389803..3b86dd823 100644 --- a/Classes/Domain/Model/Mail.php +++ b/Classes/Domain/Model/Mail.php @@ -19,6 +19,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class Mail extends AbstractEntity diff --git a/Classes/Domain/Model/Metadata.php b/Classes/Domain/Model/Metadata.php index 4dd8322e3..f96549a21 100644 --- a/Classes/Domain/Model/Metadata.php +++ b/Classes/Domain/Model/Metadata.php @@ -21,6 +21,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class Metadata extends AbstractEntity diff --git a/Classes/Domain/Model/MetadataFormat.php b/Classes/Domain/Model/MetadataFormat.php index c3c678ef6..0e683f699 100644 --- a/Classes/Domain/Model/MetadataFormat.php +++ b/Classes/Domain/Model/MetadataFormat.php @@ -25,6 +25,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class MetadataFormat extends AbstractEntity diff --git a/Classes/Domain/Model/PageSelectForm.php b/Classes/Domain/Model/PageSelectForm.php index ba29b917a..8ca16def3 100644 --- a/Classes/Domain/Model/PageSelectForm.php +++ b/Classes/Domain/Model/PageSelectForm.php @@ -19,6 +19,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class PageSelectForm extends AbstractEntity diff --git a/Classes/Domain/Model/Printer.php b/Classes/Domain/Model/Printer.php index c0b2e855f..dad67d8da 100644 --- a/Classes/Domain/Model/Printer.php +++ b/Classes/Domain/Model/Printer.php @@ -19,6 +19,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class Printer extends AbstractEntity diff --git a/Classes/Domain/Model/SolrCore.php b/Classes/Domain/Model/SolrCore.php index 84f94cf27..b70718c67 100644 --- a/Classes/Domain/Model/SolrCore.php +++ b/Classes/Domain/Model/SolrCore.php @@ -21,6 +21,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class SolrCore extends AbstractEntity diff --git a/Classes/Domain/Model/Structure.php b/Classes/Domain/Model/Structure.php index 46d241078..4793f3ef2 100644 --- a/Classes/Domain/Model/Structure.php +++ b/Classes/Domain/Model/Structure.php @@ -19,6 +19,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class Structure extends AbstractEntity diff --git a/Classes/Domain/Model/Token.php b/Classes/Domain/Model/Token.php index 95d8ed4e9..3add8b008 100644 --- a/Classes/Domain/Model/Token.php +++ b/Classes/Domain/Model/Token.php @@ -19,6 +19,7 @@ * * @package TYPO3 * @subpackage dlf + * * @access public */ class Token extends AbstractEntity diff --git a/Classes/Domain/Repository/ActionLogRepository.php b/Classes/Domain/Repository/ActionLogRepository.php index e83557a01..9164804ad 100644 --- a/Classes/Domain/Repository/ActionLogRepository.php +++ b/Classes/Domain/Repository/ActionLogRepository.php @@ -14,6 +14,14 @@ use TYPO3\CMS\Extbase\Persistence\Repository; +/** + * (Basket Plugin) Action log repository for mails and printouts. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class ActionLogRepository extends Repository { diff --git a/Classes/Domain/Repository/BasketRepository.php b/Classes/Domain/Repository/BasketRepository.php index da28f4737..2212675d6 100644 --- a/Classes/Domain/Repository/BasketRepository.php +++ b/Classes/Domain/Repository/BasketRepository.php @@ -14,6 +14,14 @@ use TYPO3\CMS\Extbase\Persistence\Repository; +/** + * (Basket Plugin) Basket repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class BasketRepository extends Repository { diff --git a/Classes/Domain/Repository/CollectionRepository.php b/Classes/Domain/Repository/CollectionRepository.php index 16cbedec9..078db5641 100644 --- a/Classes/Domain/Repository/CollectionRepository.php +++ b/Classes/Domain/Repository/CollectionRepository.php @@ -19,6 +19,14 @@ use TYPO3\CMS\Extbase\Persistence\QueryInterface; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; +/** + * Collection repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class CollectionRepository extends Repository { /** diff --git a/Classes/Domain/Repository/DocumentRepository.php b/Classes/Domain/Repository/DocumentRepository.php index e47f53072..f59bcfa81 100644 --- a/Classes/Domain/Repository/DocumentRepository.php +++ b/Classes/Domain/Repository/DocumentRepository.php @@ -27,6 +27,14 @@ use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\QueryInterface; +/** + * Document repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class DocumentRepository extends Repository { /** diff --git a/Classes/Domain/Repository/FormatRepository.php b/Classes/Domain/Repository/FormatRepository.php index 4ec3948dc..e4db44365 100644 --- a/Classes/Domain/Repository/FormatRepository.php +++ b/Classes/Domain/Repository/FormatRepository.php @@ -14,6 +14,14 @@ use TYPO3\CMS\Extbase\Persistence\Repository; +/** + * Format repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class FormatRepository extends Repository { diff --git a/Classes/Domain/Repository/LibraryRepository.php b/Classes/Domain/Repository/LibraryRepository.php index dba73b830..d951b85c0 100644 --- a/Classes/Domain/Repository/LibraryRepository.php +++ b/Classes/Domain/Repository/LibraryRepository.php @@ -14,6 +14,14 @@ use TYPO3\CMS\Extbase\Persistence\Repository; +/** + * Library repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class LibraryRepository extends Repository { diff --git a/Classes/Domain/Repository/MailRepository.php b/Classes/Domain/Repository/MailRepository.php index 412ab06e7..c06d7cebd 100644 --- a/Classes/Domain/Repository/MailRepository.php +++ b/Classes/Domain/Repository/MailRepository.php @@ -16,6 +16,14 @@ use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; use TYPO3\CMS\Extbase\Persistence\Repository; +/** + * Mail repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class MailRepository extends Repository { diff --git a/Classes/Domain/Repository/MetadataFormatRepository.php b/Classes/Domain/Repository/MetadataFormatRepository.php index c7b724f0a..3b32b5431 100644 --- a/Classes/Domain/Repository/MetadataFormatRepository.php +++ b/Classes/Domain/Repository/MetadataFormatRepository.php @@ -14,6 +14,14 @@ use TYPO3\CMS\Extbase\Persistence\Repository; +/** + * Metadata format repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class MetadataFormatRepository extends Repository { diff --git a/Classes/Domain/Repository/MetadataRepository.php b/Classes/Domain/Repository/MetadataRepository.php index d8c4b79f4..b13979dd7 100644 --- a/Classes/Domain/Repository/MetadataRepository.php +++ b/Classes/Domain/Repository/MetadataRepository.php @@ -16,6 +16,14 @@ use TYPO3\CMS\Extbase\Persistence\QueryInterface; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; +/** + * Metadata repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class MetadataRepository extends Repository { /** diff --git a/Classes/Domain/Repository/PrinterRepository.php b/Classes/Domain/Repository/PrinterRepository.php index 5433b390a..6d039ea7a 100644 --- a/Classes/Domain/Repository/PrinterRepository.php +++ b/Classes/Domain/Repository/PrinterRepository.php @@ -14,6 +14,14 @@ use TYPO3\CMS\Extbase\Persistence\Repository; +/** + * Printer repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class PrinterRepository extends Repository { diff --git a/Classes/Domain/Repository/SolrCoreRepository.php b/Classes/Domain/Repository/SolrCoreRepository.php index 9cb250ea5..1b6992368 100644 --- a/Classes/Domain/Repository/SolrCoreRepository.php +++ b/Classes/Domain/Repository/SolrCoreRepository.php @@ -14,6 +14,14 @@ use TYPO3\CMS\Extbase\Persistence\Repository; +/** + * SOLR core repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class SolrCoreRepository extends Repository { diff --git a/Classes/Domain/Repository/StructureRepository.php b/Classes/Domain/Repository/StructureRepository.php index 906076b2d..6c9b0d8ef 100644 --- a/Classes/Domain/Repository/StructureRepository.php +++ b/Classes/Domain/Repository/StructureRepository.php @@ -14,6 +14,14 @@ use TYPO3\CMS\Extbase\Persistence\Repository; +/** + * Structure repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class StructureRepository extends Repository { diff --git a/Classes/Domain/Repository/TokenRepository.php b/Classes/Domain/Repository/TokenRepository.php index 25b83f3fc..4f14dc371 100644 --- a/Classes/Domain/Repository/TokenRepository.php +++ b/Classes/Domain/Repository/TokenRepository.php @@ -14,7 +14,14 @@ use TYPO3\CMS\Extbase\Persistence\Repository; - +/** + * Token repository. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class TokenRepository extends Repository { /** diff --git a/Classes/Eid/PageViewProxy.php b/Classes/Eid/PageViewProxy.php index 511774d67..c6a19d819 100644 --- a/Classes/Eid/PageViewProxy.php +++ b/Classes/Eid/PageViewProxy.php @@ -29,9 +29,9 @@ * - `url` (mandatory): The URL to be proxied * - `uHash` (mandatory): HMAC of the URL * - * @author Alexander Bigga * @package TYPO3 * @subpackage dlf + * * @access public */ class PageViewProxy diff --git a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php index a2fbd3b71..c852fa2ef 100644 --- a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php +++ b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php @@ -28,9 +28,9 @@ /** * Provider class for additional "getDocumentType" function to the ExpressionLanguage. * - * @author Alexander Bigga * @package TYPO3 * @subpackage dlf + * * @access public */ class DocumentTypeFunctionProvider implements ExpressionFunctionProviderInterface, LoggerAwareInterface diff --git a/Classes/ExpressionLanguage/DocumentTypeProvider.php b/Classes/ExpressionLanguage/DocumentTypeProvider.php index 44b35aa72..c841fcd13 100644 --- a/Classes/ExpressionLanguage/DocumentTypeProvider.php +++ b/Classes/ExpressionLanguage/DocumentTypeProvider.php @@ -17,9 +17,9 @@ /** * Wrapper class to provide variables and functions for the ExpressionLanguage. * - * @author Alexander Bigga * @package TYPO3 * @subpackage dlf + * * @access public */ class DocumentTypeProvider extends AbstractProvider diff --git a/Classes/Format/Alto.php b/Classes/Format/Alto.php index 7297b51b2..410d0a2f8 100644 --- a/Classes/Format/Alto.php +++ b/Classes/Format/Alto.php @@ -17,9 +17,9 @@ * * ** This currently supports only ALTO 2.x ** * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class Alto implements \Kitodo\Dlf\Common\FulltextInterface diff --git a/Classes/Format/AudioVideoMD.php b/Classes/Format/AudioVideoMD.php index ede534833..391192eb8 100644 --- a/Classes/Format/AudioVideoMD.php +++ b/Classes/Format/AudioVideoMD.php @@ -20,9 +20,9 @@ * The technical reason for handling both formats here is that this makes it slightly more * straightforward to extract `duration` as either video duration or audio duration. * - * @author Kajetan Dvoracek * @package TYPO3 * @subpackage dlf + * * @access public */ class AudioVideoMD implements MetadataInterface diff --git a/Classes/Format/Mods.php b/Classes/Format/Mods.php index a8c038789..8ac47e54d 100644 --- a/Classes/Format/Mods.php +++ b/Classes/Format/Mods.php @@ -19,9 +19,9 @@ /** * Metadata MODS format class for the 'dlf' extension * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class Mods implements MetadataInterface diff --git a/Classes/Format/TeiHeader.php b/Classes/Format/TeiHeader.php index bab6aacd7..1a77de662 100644 --- a/Classes/Format/TeiHeader.php +++ b/Classes/Format/TeiHeader.php @@ -17,9 +17,9 @@ /** * Metadata TEI-Header format class for the 'dlf' extension * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class TeiHeader implements MetadataInterface diff --git a/Classes/Hooks/ConfigurationForm.php b/Classes/Hooks/ConfigurationForm.php index 9861335db..daa254715 100644 --- a/Classes/Hooks/ConfigurationForm.php +++ b/Classes/Hooks/ConfigurationForm.php @@ -19,9 +19,9 @@ /** * Hooks and helper for \TYPO3\CMS\Core\TypoScript\ConfigurationForm * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class ConfigurationForm diff --git a/Classes/Hooks/DataHandler.php b/Classes/Hooks/DataHandler.php index 404a89cc0..97fec474d 100644 --- a/Classes/Hooks/DataHandler.php +++ b/Classes/Hooks/DataHandler.php @@ -28,9 +28,9 @@ /** * Hooks and helper for \TYPO3\CMS\Core\DataHandling\DataHandler * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class DataHandler implements LoggerAwareInterface diff --git a/Classes/Hooks/Form/FieldInformation/EditInProductionWarning.php b/Classes/Hooks/Form/FieldInformation/EditInProductionWarning.php index 26ae12bd0..386cf2de2 100644 --- a/Classes/Hooks/Form/FieldInformation/EditInProductionWarning.php +++ b/Classes/Hooks/Form/FieldInformation/EditInProductionWarning.php @@ -19,9 +19,9 @@ /** * FieldInformation renderType for TYPO3 FormEngine * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class EditInProductionWarning extends AbstractNode diff --git a/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php b/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php index 66f497412..6ac113452 100644 --- a/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php +++ b/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php @@ -20,9 +20,9 @@ /** * FieldInformation renderType for TYPO3 FormEngine * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class SolrCoreStatus extends AbstractNode diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php index aa58e62b7..01893849f 100644 --- a/Classes/Hooks/ItemsProcFunc.php +++ b/Classes/Hooks/ItemsProcFunc.php @@ -24,9 +24,9 @@ /** * Helper for FlexForm's custom "itemsProcFunc" * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class ItemsProcFunc implements LoggerAwareInterface diff --git a/Classes/Hooks/KitodoProductionHacks.php b/Classes/Hooks/KitodoProductionHacks.php index 022b76733..081ea86cc 100644 --- a/Classes/Hooks/KitodoProductionHacks.php +++ b/Classes/Hooks/KitodoProductionHacks.php @@ -15,9 +15,9 @@ /** * Hooks and hacks for Kitodo.Production * - * @author Sebastian Meyer * @package TYPO3 * @subpackage dlf + * * @access public */ class KitodoProductionHacks diff --git a/Classes/Hooks/ThumbnailCustomElement.php b/Classes/Hooks/ThumbnailCustomElement.php index b1b828456..a357c18fc 100644 --- a/Classes/Hooks/ThumbnailCustomElement.php +++ b/Classes/Hooks/ThumbnailCustomElement.php @@ -14,6 +14,14 @@ use TYPO3\CMS\Backend\Form\Element\AbstractFormElement; +/** + * Custom Thumbnail element for Form + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class ThumbnailCustomElement extends AbstractFormElement { public function render() diff --git a/Classes/Middleware/SearchInDocument.php b/Classes/Middleware/SearchInDocument.php index 44894cf6d..7cf6475bb 100644 --- a/Classes/Middleware/SearchInDocument.php +++ b/Classes/Middleware/SearchInDocument.php @@ -26,10 +26,9 @@ /** * Search in document Middleware for plugin 'Search' of the 'dlf' extension * - * @author Alexander Bigga - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public */ class SearchInDocument implements MiddlewareInterface diff --git a/Classes/Middleware/SearchSuggest.php b/Classes/Middleware/SearchSuggest.php index 4dde41c07..81c9ce88a 100644 --- a/Classes/Middleware/SearchSuggest.php +++ b/Classes/Middleware/SearchSuggest.php @@ -25,11 +25,9 @@ /** * Search suggestions Middleware for plugin 'Search' of the 'dlf' extension * - * @author Henrik Lochmann - * @author Sebastian Meyer - * @author Beatrycze Volk * @package TYPO3 * @subpackage dlf + * * @access public */ class SearchSuggest implements MiddlewareInterface diff --git a/Classes/Updates/FileLocationUpdater.php b/Classes/Updates/FileLocationUpdater.php index 162ff9c4e..6bf2e7450 100644 --- a/Classes/Updates/FileLocationUpdater.php +++ b/Classes/Updates/FileLocationUpdater.php @@ -28,6 +28,11 @@ /** * Migrate reference of thumbnail image in collections record. + * + * @package TYPO3 + * @subpackage dlf + * + * @access public */ class FileLocationUpdater implements UpgradeWizardInterface, ChattyInterface, LoggerAwareInterface { diff --git a/Classes/Updates/MigrateSettings.php b/Classes/Updates/MigrateSettings.php index a2bd0d027..13700e081 100644 --- a/Classes/Updates/MigrateSettings.php +++ b/Classes/Updates/MigrateSettings.php @@ -20,6 +20,10 @@ /** * Class MigrateSettings + * + * @package TYPO3 + * @subpackage dlf + * * @internal */ class MigrateSettings implements UpgradeWizardInterface diff --git a/Classes/ViewHelpers/JsFooterViewHelper.php b/Classes/ViewHelpers/JsFooterViewHelper.php index 38790efc4..be7a5feac 100755 --- a/Classes/ViewHelpers/JsFooterViewHelper.php +++ b/Classes/ViewHelpers/JsFooterViewHelper.php @@ -17,7 +17,12 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; /** - * Add inline JavaScript code to footer * + * Add inline JavaScript code to footer + * + * @package TYPO3 + * @subpackage dlf + * + * @access public */ class JsFooterViewHelper extends AbstractViewHelper { diff --git a/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php b/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php index 8183c0e74..f9f325329 100644 --- a/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php +++ b/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php @@ -17,7 +17,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; /** - * Viewhelper to parse TypoScript that is used to declare wrapping of metadata + * View helper to parse TypoScript that is used to declare wrapping of metadata * fields and stores the result into a Fluid variable. * * The TypoScript should be passed as child and may contain stdWrap information @@ -34,6 +34,10 @@ * * {typoscript -> kitodo:metadataWrapVariable(name: 'wrapInfo')} * + * @package TYPO3 + * @subpackage dlf + * + * @access public */ class MetadataWrapVariableViewHelper extends AbstractViewHelper { diff --git a/Classes/ViewHelpers/StdWrapViewHelper.php b/Classes/ViewHelpers/StdWrapViewHelper.php index 534e416a5..502b1be76 100644 --- a/Classes/ViewHelpers/StdWrapViewHelper.php +++ b/Classes/ViewHelpers/StdWrapViewHelper.php @@ -15,6 +15,14 @@ use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; +/** + * Standard wrapper view helper + * + * @package TYPO3 + * @subpackage dlf + * + * @access public + */ class StdWrapViewHelper extends AbstractViewHelper { protected $escapeOutput = false; From 157f997e4565b677ac622f7c630523d42676852e Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 29 Sep 2023 12:23:32 +0200 Subject: [PATCH 06/76] [MAINTENANCE] Unify and improve PHPDocs for class properties (#1013) Co-authored-by: Sebastian Meyer --- Classes/Api/Orcid/Client.php | 30 ++-- Classes/Api/Orcid/Profile.php | 17 +-- Classes/Api/Viaf/Client.php | 17 +-- Classes/Api/Viaf/Profile.php | 19 +-- Classes/Command/BaseCommand.php | 10 +- Classes/Common/AbstractDocument.php | 143 ++++++------------ Classes/Common/Helper.php | 26 ++-- Classes/Common/IiifManifest.php | 34 +---- Classes/Common/IiifUrlReader.php | 4 +- Classes/Common/Indexer.php | 31 ++-- Classes/Common/MetsDocument.php | 55 +++---- .../Common/Solr/SearchResult/Highlight.php | 24 +-- Classes/Common/Solr/SearchResult/Page.php | 16 +- Classes/Common/Solr/SearchResult/Region.php | 36 ++--- .../Solr/SearchResult/ResultDocument.php | 48 ++---- Classes/Common/Solr/Solr.php | 45 ++---- Classes/Common/Solr/SolrSearch.php | 11 ++ Classes/Common/Solr/SolrSearchQuery.php | 6 +- Classes/Controller/AbstractController.php | 15 +- Classes/Controller/AudioPlayerController.php | 2 +- .../Backend/NewTenantController.php | 24 +-- Classes/Controller/BasketController.php | 4 + Classes/Controller/CalendarController.php | 5 +- Classes/Controller/CollectionController.php | 2 + Classes/Controller/FeedsController.php | 4 +- Classes/Controller/ListViewController.php | 4 +- Classes/Controller/MetadataController.php | 4 + Classes/Controller/OaiPmhController.php | 12 +- Classes/Controller/PageViewController.php | 14 +- Classes/Controller/SearchController.php | 4 +- .../Controller/TableOfContentsController.php | 2 +- Classes/Controller/ToolboxController.php | 5 +- Classes/Domain/Model/ActionLog.php | 5 + Classes/Domain/Model/Basket.php | 4 + Classes/Domain/Model/Collection.php | 23 ++- Classes/Domain/Model/Document.php | 68 ++++++--- Classes/Domain/Model/Format.php | 20 +-- Classes/Domain/Model/Library.php | 38 ++--- Classes/Domain/Model/Mail.php | 3 + Classes/Domain/Model/Metadata.php | 37 +++-- Classes/Domain/Model/MetadataFormat.php | 25 ++- Classes/Domain/Model/PageSelectForm.php | 4 + Classes/Domain/Model/Printer.php | 4 + Classes/Domain/Model/SolrCore.php | 11 +- Classes/Domain/Model/Structure.php | 7 + Classes/Domain/Model/Token.php | 15 +- .../Repository/CollectionRepository.php | 5 +- .../Domain/Repository/DocumentRepository.php | 4 +- Classes/Eid/PageViewProxy.php | 2 + Classes/Format/Mods.php | 10 +- Classes/Hooks/DataHandler.php | 1 + Classes/Hooks/ItemsProcFunc.php | 1 + Classes/Updates/FileLocationUpdater.php | 8 +- Classes/ViewHelpers/StdWrapViewHelper.php | 4 + 54 files changed, 441 insertions(+), 531 deletions(-) diff --git a/Classes/Api/Orcid/Client.php b/Classes/Api/Orcid/Client.php index 9b4f8c496..f85a24adc 100644 --- a/Classes/Api/Orcid/Client.php +++ b/Classes/Api/Orcid/Client.php @@ -29,44 +29,42 @@ class Client { /** - * constants for API endpoint + * @var string constant for API hostname **/ const HOSTNAME = 'orcid.org'; + + /** + * @var string constant for API version + **/ const VERSION = '3.0'; /** - * This holds the logger - * - * @var Logger * @access protected + * @var Logger This holds the logger */ protected $logger; /** - * The ORCID API endpoint - * - * @var string + * @access private + * @var string The ORCID API endpoint **/ private $endpoint = 'record'; /** - * The ORCID API access level - * - * @var string + * @access private + * @var string The ORCID API access level **/ private $level = 'pub'; /** - * The ORCID ID to search for - * - * @var string + * @access private + * @var string The ORCID ID to search for **/ private $orcid = null; /** - * The request object - * - * @var RequestFactoryInterface + * @access private + * @var RequestFactoryInterface The request object **/ private $requestFactory = null; diff --git a/Classes/Api/Orcid/Profile.php b/Classes/Api/Orcid/Profile.php index 827d16a26..aa1e7225d 100644 --- a/Classes/Api/Orcid/Profile.php +++ b/Classes/Api/Orcid/Profile.php @@ -29,25 +29,20 @@ class Profile { /** - * This holds the logger - * - * @var Logger * @access protected + * @var Logger This holds the logger */ protected $logger; /** - * This holds the client - * - * @var Client - * @access protected + * @access private + * @var Client This holds the client */ - protected $client; + private $client; /** - * The raw ORCID profile - * - * @var \SimpleXmlElement|false + * @access private + * @var \SimpleXmlElement|false The raw ORCID profile **/ private $raw = null; diff --git a/Classes/Api/Viaf/Client.php b/Classes/Api/Viaf/Client.php index 6dc5fba33..b171c8103 100644 --- a/Classes/Api/Viaf/Client.php +++ b/Classes/Api/Viaf/Client.php @@ -29,31 +29,28 @@ class Client { /** - * This holds the logger - * - * @var Logger * @access protected + * @var Logger This holds the logger */ protected $logger; /** * The VIAF API endpoint * - * @var string + * @access private + * @var string The VIAF API endpoint **/ private $endpoint = 'viaf.xml'; /** - * The VIAF URL for the profile - * - * @var string + * @access private + * @var string The VIAF URL for the profile **/ private $viafUrl = null; /** - * The request object - * - * @var RequestFactoryInterface + * @access private + * @var RequestFactoryInterface The request object **/ private $requestFactory = null; diff --git a/Classes/Api/Viaf/Profile.php b/Classes/Api/Viaf/Profile.php index 7c9d4ce5b..05b23179a 100644 --- a/Classes/Api/Viaf/Profile.php +++ b/Classes/Api/Viaf/Profile.php @@ -29,25 +29,20 @@ class Profile { /** - * This holds the logger - * - * @var Logger - * @access protected + * @access private + * @var Logger This holds the logger */ protected $logger; /** - * This holds the client - * - * @var Client - * @access protected + * @access private + * @var Client This holds the client */ - protected $client; + private $client; /** - * The raw VIAF profile - * - * @var \SimpleXmlElement|false + * @access private + * @var \SimpleXmlElement|false The raw VIAF profile or false if not found **/ private $raw = null; diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index b34b5b0c9..028db96ab 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -43,38 +43,44 @@ class BaseCommand extends Command { /** + * @access protected * @var CollectionRepository */ protected $collectionRepository; /** + * @access protected * @var DocumentRepository */ protected $documentRepository; /** + * @access protected * @var LibraryRepository */ protected $libraryRepository; /** + * @access protected * @var StructureRepository */ protected $structureRepository; /** + * @access protected * @var int */ protected $storagePid; /** + * @access protected * @var Library */ protected $owner; /** - * @var array * @access protected + * @var array */ protected $extConf; @@ -101,7 +107,7 @@ public function __construct(CollectionRepository $collectionRepository, /** * Initialize the extbase repository based on the given storagePid. * - * TYPO3 10+: Find a better solution e.g. based on Symfonie Dependency Injection. + * TYPO3 10+: Find a better solution e.g. based on Symfony Dependency Injection. * * @param int $storagePid The storage pid * diff --git a/Classes/Common/AbstractDocument.php b/Classes/Common/AbstractDocument.php index 8ebe0688f..5527cf2da 100644 --- a/Classes/Common/AbstractDocument.php +++ b/Classes/Common/AbstractDocument.php @@ -61,43 +61,35 @@ abstract class AbstractDocument { /** - * This holds the logger - * - * @var Logger * @access protected + * @var Logger This holds the logger */ protected $logger; /** - * This holds the PID for the configuration - * - * @var int * @access protected + * @var int This holds the PID for the configuration */ protected $cPid = 0; /** - * The extension key - * - * @var string * @access public + * @static + * @var string The extension key */ public static $extKey = 'dlf'; /** - * Additional information about files (e.g., ADMID), indexed by ID. - * - * @var array * @access protected + * @var array Additional information about files (e.g., ADMID), indexed by ID. */ protected $fileInfos = []; /** - * This holds the configuration for all supported metadata encodings - * @see loadFormats() - * - * @var array * @access protected + * @var array This holds the configuration for all supported metadata encodings + * + * @see loadFormats() */ protected $formats = [ 'OAI' => [ @@ -115,11 +107,10 @@ abstract class AbstractDocument ]; /** - * Are the available metadata formats loaded? - * @see $formats - * - * @var bool * @access protected + * @var bool Are the available metadata formats loaded? + * + * @see $formats */ protected $formatsLoaded = false; @@ -128,24 +119,20 @@ abstract class AbstractDocument * with motivation 'painting' if Kitodo.Presentation is configured to store text * annotations as fulltext. * - * @var bool * @access protected + * @var bool */ protected $hasFulltext = false; /** - * Last searched logical and physical page - * - * @var array * @access protected + * @var array Last searched logical and physical page */ protected $lastSearchedPhysicalPage = ['logicalPage' => null, 'physicalPage' => null]; /** - * This holds the logical units - * - * @var array * @access protected + * @var array This holds the logical units */ protected $logicalUnits = []; @@ -153,66 +140,54 @@ abstract class AbstractDocument * This holds the documents' parsed metadata array with their corresponding * structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key * - * @var array * @access protected + * @var array */ protected $metadataArray = []; /** - * Is the metadata array loaded? - * @see $metadataArray - * - * @var bool * @access protected + * @var bool Is the metadata array loaded? + * + * @see $metadataArray */ protected $metadataArrayLoaded = false; /** - * The holds the total number of pages - * - * @var int * @access protected + * @var int The holds the total number of pages */ protected $numPages = 0; /** - * This holds the UID of the parent document or zero if not multi-volumed - * - * @var int * @access protected + * @var int This holds the UID of the parent document or zero if not multi-volumed */ protected $parentId = 0; /** - * This holds the physical structure - * - * @var array * @access protected + * @var array This holds the physical structure */ protected $physicalStructure = []; /** - * This holds the physical structure metadata - * - * @var array * @access protected + * @var array This holds the physical structure metadata */ protected $physicalStructureInfo = []; /** - * Is the physical structure loaded? - * @see $physicalStructure - * - * @var bool * @access protected + * @var bool Is the physical structure loaded? + * + * @see $physicalStructure */ protected $physicalStructureLoaded = false; /** - * This holds the PID of the document or zero if not in database - * - * @var int * @access protected + * @var int This holds the PID of the document or zero if not in database */ protected $pid = 0; @@ -220,117 +195,97 @@ abstract class AbstractDocument * This holds the documents' raw text pages with their corresponding * structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key * - * @var array * @access protected + * @var array */ protected $rawTextArray = []; /** - * Is the document instantiated successfully? - * - * @var bool * @access protected + * @var bool Is the document instantiated successfully? */ protected $ready = false; /** - * The METS file's / IIIF manifest's record identifier - * - * @var string * @access protected + * @var string The METS file's / IIIF manifest's record identifier */ protected $recordId; /** - * This holds the singleton object of the document - * - * @var array (AbstractDocument) - * @static * @access protected + * @static + * @var array (AbstractDocument) This holds the singleton object of the document */ protected static $registry = []; /** - * This holds the UID of the root document or zero if not multi-volumed - * - * @var int * @access protected + * @var int This holds the UID of the root document or zero if not multi-volumed */ protected $rootId = 0; /** - * Is the root id loaded? - * @see $rootId - * - * @var bool * @access protected + * @var bool Is the root id loaded? + * + * @see $rootId */ protected $rootIdLoaded = false; /** - * This holds the smLinks between logical and physical structMap - * - * @var array * @access protected + * @var array This holds the smLinks between logical and physical structMap */ protected $smLinks = ['l2p' => [], 'p2l' => []]; /** - * Are the smLinks loaded? - * @see $smLinks - * - * @var bool * @access protected + * @var bool Are the smLinks loaded? + * + * @see $smLinks */ protected $smLinksLoaded = false; /** * This holds the logical structure * - * @var array * @access protected + * @var array */ protected $tableOfContents = []; /** - * Is the table of contents loaded? - * @see $tableOfContents - * - * @var bool * @access protected + * @var bool Is the table of contents loaded? + * + * @see $tableOfContents */ protected $tableOfContentsLoaded = false; /** - * This holds the document's thumbnail location - * - * @var string * @access protected + * @var string This holds the document's thumbnail location */ protected $thumbnail = ''; /** - * Is the document's thumbnail location loaded? - * @see $thumbnail - * - * @var bool * @access protected + * @var bool Is the document's thumbnail location loaded? + * + * @see $thumbnail */ protected $thumbnailLoaded = false; /** - * This holds the toplevel structure's "@ID" (METS) or the manifest's "@id" (IIIF) - * - * @var string * @access protected + * @var string This holds the toplevel structure's "@ID" (METS) or the manifest's "@id" (IIIF) */ protected $toplevelId = ''; /** - * This holds the whole XML file as \SimpleXMLElement object - * - * @var \SimpleXMLElement * @access protected + * @var \SimpleXMLElement This holds the whole XML file as \SimpleXMLElement object */ protected $xml; diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index dbcf992bc..3fb068a4a 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -41,36 +41,34 @@ class Helper { /** - * The extension key - * - * @var string * @access public + * @static + * @var string The extension key */ public static $extKey = 'dlf'; /** - * This holds the cipher algorithm - * @see openssl_get_cipher_methods() for options - * - * @var string * @access protected + * @static + * @var string This holds the cipher algorithm + * + * @see openssl_get_cipher_methods() for options */ protected static $cipherAlgorithm = 'aes-256-ctr'; /** - * This holds the hash algorithm - * @see openssl_get_md_methods() for options - * - * @var string * @access protected + * @static + * @var string This holds the hash algorithm + * + * @see openssl_get_md_methods() for options */ protected static $hashAlgorithm = 'sha256'; /** - * The locallang array for flash messages - * - * @var array * @access protected + * @static + * @var array The locallang array for flash messages */ protected static $messages = []; diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index 0822431dd..f5e40435c 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -79,61 +79,43 @@ final class IiifManifest extends AbstractDocument { /** - * This holds the manifest file as string for serialization purposes - * @see __sleep() / __wakeup() - * - * @var string * @access protected + * @var string This holds the manifest file as string for serialization purposes + * + * @see __sleep() / __wakeup() */ protected $asJson = ''; /** - * A PHP object representation of a IIIF manifest. - * @var ManifestInterface * @access protected + * @var ManifestInterface A PHP object representation of a IIIF manifest */ protected $iiif; /** - * 'IIIF1', 'IIIF2' or 'IIIF3', depending on the API $this->iiif conforms to: - * IIIF Metadata API 1, IIIF Presentation API 2 or 3 - * @var string * @access protected + * @var string 'IIIF1', 'IIIF2' or 'IIIF3', depending on the API $this->iiif confrms to: IIIF Metadata API 1, IIIF Presentation API 2 or 3 */ protected $iiifVersion; /** - * Document has already been analyzed if it contains fulltext for the Solr index - * @var bool * @access protected + * @var bool Document has already been analyzed if it contains fulltext for the Solr index */ protected $hasFulltextSet = false; /** - * This holds the original manifest's parsed metadata array with their corresponding - * resource (Manifest / Sequence / Range) ID as array key - * - * @var array * @access protected + * @var array This holds the original manifest's parsed metadata array with their corresponding resource (Manifest / Sequence / Range) ID as array key */ protected $originalMetadataArray = []; /** - * Holds the mime types of linked resources in the manifest (extracted during parsing) for later use. - * @var array * @access protected + * @var array Holds the mime types of linked resources in the manifest (extracted during parsing) for later use */ protected $mimeTypes = []; - /** - * The extension key - * - * @var string - * @static - * @access public - */ - public static $extKey = 'dlf'; - /** * @see AbstractDocument::establishRecordId() */ diff --git a/Classes/Common/IiifUrlReader.php b/Classes/Common/IiifUrlReader.php index 9b51c7568..ba6012b4b 100644 --- a/Classes/Common/IiifUrlReader.php +++ b/Classes/Common/IiifUrlReader.php @@ -28,10 +28,8 @@ class IiifUrlReader implements UrlReaderInterface { /** - * Singleton instance of the class - * * @access protected - * @var IiifUrlReader + * @var IiifUrlReader Singleton instance of the class */ protected static $instance; diff --git a/Classes/Common/Indexer.php b/Classes/Common/Indexer.php index bffcd62fb..e220cc4a4 100644 --- a/Classes/Common/Indexer.php +++ b/Classes/Common/Indexer.php @@ -35,19 +35,18 @@ class Indexer { /** - * The extension key - * - * @var string * @access public + * @static + * @var string The extension key */ public static $extKey = 'dlf'; /** - * Array of metadata fields' configuration - * @see loadIndexConf() - * - * @var array * @access protected + * @static + * @var array Array of metadata fields' configuration + * + * @see loadIndexConf() */ protected static $fields = [ 'autocomplete' => [], @@ -60,27 +59,25 @@ class Indexer ]; /** - * Is the index configuration loaded? - * @see $fields - * - * @var bool * @access protected + * @static + * @var bool Is the index configuration loaded? + * + * @see $fields */ protected static $fieldsLoaded = false; /** - * List of already processed documents - * - * @var array * @access protected + * @static + * @var array List of already processed documents */ protected static $processedDocs = []; /** - * Instance of \Kitodo\Dlf\Common\Solr\Solr class - * - * @var Solr * @access protected + * @static + * @var Solr Instance of Solr class */ protected static $solr; diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index 29c668a57..3f2ab7858 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -67,90 +67,73 @@ final class MetsDocument extends AbstractDocument { /** - * Subsections / tags that may occur within ``. + * @access protected + * @var string[] Subsections / tags that may occur within `` * * @link https://www.loc.gov/standards/mets/docs/mets.v1-9.html#amdSec * @link https://www.loc.gov/standards/mets/docs/mets.v1-9.html#mdSecType - * - * @var string[] */ protected const ALLOWED_AMD_SEC = ['techMD', 'rightsMD', 'sourceMD', 'digiprovMD']; /** - * This holds the whole XML file as string for serialization purposes - * @see __sleep() / __wakeup() - * - * @var string * @access protected + * @var string This holds the whole XML file as string for serialization purposes + * + * @see __sleep() / __wakeup() */ protected $asXML = ''; /** - * This maps the ID of each amdSec to the IDs of its children (techMD etc.). - * When an ADMID references an amdSec instead of techMD etc., this is used to iterate the child elements. - * - * @var array * @access protected + * @var array This maps the ID of each amdSec to the IDs of its children (techMD etc.). When an ADMID references an amdSec instead of techMD etc., this is used to iterate the child elements. */ protected $amdSecChildIds = []; /** - * Associative array of METS metadata sections indexed by their IDs. - * - * @var array * @access protected + * @var array Associative array of METS metadata sections indexed by their IDs. */ protected $mdSec = []; /** - * Are the METS file's metadata sections loaded? - * @see MetsDocument::$mdSec - * - * @var bool * @access protected + * @var bool Are the METS file's metadata sections loaded? + * + * @see MetsDocument::$mdSec */ protected $mdSecLoaded = false; /** - * Subset of $mdSec storing only the dmdSec entries; kept for compatibility. - * - * @var array * @access protected + * @var array Subset of $mdSec storing only the dmdSec entries; kept for compatibility. */ protected $dmdSec = []; /** - * This holds the file ID -> USE concordance - * @see _getFileGrps() - * - * @var array * @access protected + * @var array This holds the file ID -> USE concordance + * + * @see _getFileGrps() */ protected $fileGrps = []; /** - * Are the image file groups loaded? - * @see $fileGrps - * - * @var bool * @access protected + * @var bool Are the image file groups loaded? + * + * @see $fileGrps */ protected $fileGrpsLoaded = false; /** - * This holds the XML file's METS part as \SimpleXMLElement object - * - * @var \SimpleXMLElement * @access protected + * @var \SimpleXMLElement This holds the XML file's METS part as \SimpleXMLElement object */ protected $mets; /** - * URL of the parent document (determined via mptr element), - * or empty string if none is available - * - * @var string|null * @access protected + * @var string|null URL of the parent document (determined via mptr element), or empty string if none is available */ protected $parentHref; diff --git a/Classes/Common/Solr/SearchResult/Highlight.php b/Classes/Common/Solr/SearchResult/Highlight.php index dc7afb62b..38625ee7b 100644 --- a/Classes/Common/Solr/SearchResult/Highlight.php +++ b/Classes/Common/Solr/SearchResult/Highlight.php @@ -24,50 +24,38 @@ class Highlight { /** - * The identifier in form 'w_h_x_y' - * - * @var string * @access private + * @var string The identifier in form 'w_h_x_y' */ private $id; /** - * The parent region's identifier - * - * @var int * @access private + * @var int The parent region's identifier */ private $parentRegionId; /** - * The horizontal beginning position of found highlight - * - * @var int * @access private + * @var int The horizontal beginning position of found highlight */ private $xBeginPosition; /** - * The horizontal ending position of found highlight - * - * @var int * @access private + * @var int The horizontal ending position of found highlight */ private $xEndPosition; /** - * The vertical beginning position of found highlight - * - * @var int * @access private + * @var int The vertical beginning position of found highlight */ private $yBeginPosition; /** - * The vertical ending position of found highlight - * - * @var int * @access private + * @var int The vertical ending position of found highlight */ private $yEndPosition; diff --git a/Classes/Common/Solr/SearchResult/Page.php b/Classes/Common/Solr/SearchResult/Page.php index b5b226c3d..6b7427735 100644 --- a/Classes/Common/Solr/SearchResult/Page.php +++ b/Classes/Common/Solr/SearchResult/Page.php @@ -24,34 +24,26 @@ class Page { /** - * The identifier of the page - * - * @var int * @access private + * @var int The identifier of the page */ private $id; /** - * The name of the page - * - * @var string * @access private + * @var string The name of the page */ private $name; /** - * The width of found page - * - * @var int * @access private + * @var int The width of found page */ private $width; /** - * The height of found page - * - * @var int * @access private + * @var int The height of found page */ private $height; diff --git a/Classes/Common/Solr/SearchResult/Region.php b/Classes/Common/Solr/SearchResult/Region.php index 6333c9564..741af675b 100644 --- a/Classes/Common/Solr/SearchResult/Region.php +++ b/Classes/Common/Solr/SearchResult/Region.php @@ -24,74 +24,56 @@ class Region { /** - * The identifier of the region - * - * @var int * @access private + * @var int The identifier of the region */ private $id; /** - * The identifier of the page in which text was found - * - * @var int * @access private + * @var int The identifier of the page in which text was found */ private $pageId; /** - * The horizontal beginning position of found region - * - * @var int * @access private + * @var int The horizontal beginning position of found region */ private $xBeginPosition; /** - * The horizontal ending position of found region - * - * @var int * @access private + * @var int The horizontal ending position of found region */ private $xEndPosition; /** - * The vertical beginning position of found region - * - * @var int * @access private + * @var int The vertical beginning position of found region */ private $yBeginPosition; /** - * The vertical ending position of found region - * - * @var int * @access private + * @var int The vertical ending position of found region */ private $yEndPosition; /** - * The width of found region - * - * @var int * @access private + * @var int The width of found region */ private $width; /** - * The height of found region - * - * @var int * @access private + * @var int The height of found region */ private $height; /** - * The text of found region - * - * @var string * @access private + * @var string The text of found region */ private $text; diff --git a/Classes/Common/Solr/SearchResult/ResultDocument.php b/Classes/Common/Solr/SearchResult/ResultDocument.php index bf3c7e422..730b10a9c 100644 --- a/Classes/Common/Solr/SearchResult/ResultDocument.php +++ b/Classes/Common/Solr/SearchResult/ResultDocument.php @@ -24,98 +24,74 @@ class ResultDocument { /** - * The identifier - * - * @var string * @access private + * @var string The identifier */ private $id; /** - * The unified identifier - * - * @var string|null * @access private + * @var string|null The unified identifier */ private $uid; /** - * The page on which result was found - * - * @var int * @access private + * @var int The page on which result was found */ private $page; /** - * All snippets imploded to one string - * - * @var string * @access private + * @var string All snippets imploded to one string */ private $snippets; /** - * The thumbnail URL - * - * @var string * @access private + * @var string The thumbnail URL */ private $thumbnail; /** - * The title of the document / structure element (e.g. chapter) - * - * @var string * @access private + * @var string The title of the document / structure element (e.g. chapter) */ private $title; /** - * It's a toplevel element? - * - * @var boolean * @access private + * @var boolean It's a toplevel element? */ private $toplevel = false; /** - * The structure type - * - * @var string * @access private + * @var string The structure type */ private $type; /** - * All pages in which search phrase was found - * - * @var array(Page) * @access private + * @var Page[] All pages in which search phrase was found */ private $pages = []; /** - * All regions in which search phrase was found - * - * @var array(Region) * @access private + * @var Region[] All regions in which search phrase was found */ private $regions = []; /** - * All highlights of search phrase - * - * @var array(Highlight) * @access private + * @var Highlight[] All highlights of search phrase */ private $highlights = []; /** - * The snippets for given record - * - * @var array * @access private + * @var array The snippets for given record */ private $snippetsForRecord = []; diff --git a/Classes/Common/Solr/Solr.php b/Classes/Common/Solr/Solr.php index 298cb9a56..2bbc12ff8 100644 --- a/Classes/Common/Solr/Solr.php +++ b/Classes/Common/Solr/Solr.php @@ -49,90 +49,69 @@ class Solr implements LoggerAwareInterface use LoggerAwareTrait; /** - * This holds the Solr configuration - * - * @var array * @access protected + * @var array This holds the Solr configuration */ protected $config = []; /** - * This holds the core name - * - * @var string|null * @access protected + * @var string|null This holds the core name */ protected $core = null; /** - * This holds the PID for the configuration - * - * @var int * @access protected + * @var int This holds the PID for the configuration */ protected $cPid = 0; /** - * The extension key - * - * @var string * @access public + * @static + * @var string The extension key */ public static $extKey = 'dlf'; /** - * The fields for SOLR index - * - * @var array * @access public + * @var array The fields for SOLR index */ public static $fields = []; /** - * This holds the max results - * - * @var int * @access protected + * @var int This holds the max results */ protected $limit = 50000; /** - * This holds the number of hits for last search - * - * @var int * @access protected + * @var int This holds the number of hits for last search */ protected $numberOfHits = 0; /** - * This holds the additional query parameters - * - * @var array * @access protected + * @var array This holds the additional query parameters */ protected $params = []; /** - * Is the search instantiated successfully? - * - * @var bool * @access protected + * @var bool Is the search instantiated successfully? */ protected $ready = false; /** - * This holds the singleton search objects with their core as array key - * - * @var array (\Kitodo\Dlf\Common\Solr\Solr) * @access protected + * @var array(Solr) This holds the singleton search objects with their core as array key */ protected static $registry = []; /** - * This holds the Solr service object - * - * @var \Solarium\Client * @access protected + * @var Client This holds the Solr service object */ protected $service; diff --git a/Classes/Common/Solr/SolrSearch.php b/Classes/Common/Solr/SolrSearch.php index 803a69857..5bc6bc765 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -30,38 +30,49 @@ class SolrSearch implements \Countable, \Iterator, \ArrayAccess, QueryResultInterface { /** + * @access private * @var DocumentRepository */ private $documentRepository; /** + * @access private * @var QueryResult|Collection */ private $collection; /** + * @access private * @var array */ private $settings; /** + * @access private * @var array */ private $searchParams; /** + * @access private * @var QueryResult */ private $listedMetadata; /** + * @access private * @var array */ private $params; + /** + * @access private + * @var array + */ private $result; /** + * @access private * @var int */ protected $position = 0; diff --git a/Classes/Common/Solr/SolrSearchQuery.php b/Classes/Common/Solr/SolrSearchQuery.php index 650338642..da0cbc773 100644 --- a/Classes/Common/Solr/SolrSearchQuery.php +++ b/Classes/Common/Solr/SolrSearchQuery.php @@ -21,20 +21,20 @@ class SolrSearchQuery implements QueryInterface { /** - * @var SolrSearch * @access private + * @var SolrSearch */ private $solrSearch; /** - * @var int * @access private + * @var int */ private $limit; /** - * @var int * @access private + * @var int */ private $offset; diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 036bd94c3..8d806f115 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -40,6 +40,7 @@ abstract class AbstractController extends ActionController implements LoggerAwar use LoggerAwareTrait; /** + * @access protected * @var DocumentRepository */ protected $documentRepository; @@ -53,32 +54,26 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) } /** - * This holds the current document - * - * @var Document * @access protected + * @var Document This holds the current document */ protected $document; /** - * @var array * @access protected + * @var array */ protected $extConf; /** - * This holds the request parameter - * - * @var array * @access protected + * @var array This holds the request parameter */ protected $requestData; /** - * This holds some common data for the fluid view - * - * @var array * @access protected + * @var array This holds some common data for the fluid view */ protected $viewData; diff --git a/Classes/Controller/AudioPlayerController.php b/Classes/Controller/AudioPlayerController.php index cef02f803..23c368085 100644 --- a/Classes/Controller/AudioPlayerController.php +++ b/Classes/Controller/AudioPlayerController.php @@ -29,8 +29,8 @@ class AudioplayerController extends AbstractController /** * Holds the current audio file's URL, MIME type and optional label * - * @var array * @access protected + * @var array Holds the current audio file's URL, MIME type and optional label */ protected $audio = []; diff --git a/Classes/Controller/Backend/NewTenantController.php b/Classes/Controller/Backend/NewTenantController.php index 9e55acac6..2f1973b8c 100644 --- a/Classes/Controller/Backend/NewTenantController.php +++ b/Classes/Controller/Backend/NewTenantController.php @@ -23,6 +23,7 @@ use Kitodo\Dlf\Domain\Repository\StructureRepository; use Kitodo\Dlf\Domain\Repository\SolrCoreRepository; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Backend\View\BackendTemplateView; use TYPO3\CMS\Core\Localization\LocalizationFactory; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -43,37 +44,37 @@ class NewTenantController extends AbstractController { /** + * @access protected * @var int */ protected $pid; /** + * @access protected * @var array */ protected $pageInfo; /** - * All configured site languages - * - * @var array + * @access protected + * @var array All configured site languages */ protected $siteLanguages; /** - * LanguageFactory to get language key/values by our own. - * - * @var \TYPO3\CMS\Core\Localization\LocalizationFactory + * @access protected + * @var LocalizationFactory Language factory to get language key/values by our own. */ protected $languageFactory; /** - * Backend Template Container - * - * @var string + * @access protected + * @var string Backend Template Container */ - protected $defaultViewObjectName = \TYPO3\CMS\Backend\View\BackendTemplateView::class; + protected $defaultViewObjectName = BackendTemplateView::class; /** + * @access protected * @var FormatRepository */ protected $formatRepository; @@ -87,6 +88,7 @@ public function injectFormatRepository(FormatRepository $formatRepository) } /** + * @access protected * @var MetadataRepository */ protected $metadataRepository; @@ -100,6 +102,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) } /** + * @access protected * @var StructureRepository */ protected $structureRepository; @@ -113,6 +116,7 @@ public function injectStructureRepository(StructureRepository $structureReposito } /** + * @access protected * @var SolrCoreRepository */ protected $solrCoreRepository; diff --git a/Classes/Controller/BasketController.php b/Classes/Controller/BasketController.php index 45418714b..7731d3157 100644 --- a/Classes/Controller/BasketController.php +++ b/Classes/Controller/BasketController.php @@ -36,6 +36,7 @@ class BasketController extends AbstractController { /** + * @access protected * @var BasketRepository */ protected $basketRepository; @@ -49,6 +50,7 @@ public function injectBasketRepository(BasketRepository $basketRepository) } /** + * @access protected * @var MailRepository */ protected $mailRepository; @@ -62,6 +64,7 @@ public function injectMailRepository(MailRepository $mailRepository) } /** + * @access protected * @var PrinterRepository */ protected $printerRepository; @@ -75,6 +78,7 @@ public function injectPrinterRepository(PrinterRepository $printerRepository) } /** + * @access protected * @var ActionLogRepository */ protected $actionLogRepository; diff --git a/Classes/Controller/CalendarController.php b/Classes/Controller/CalendarController.php index f4deff303..0fa51b3a6 100644 --- a/Classes/Controller/CalendarController.php +++ b/Classes/Controller/CalendarController.php @@ -26,6 +26,7 @@ class CalendarController extends AbstractController { /** + * @access protected * @var StructureRepository */ protected $structureRepository; @@ -39,10 +40,8 @@ public function injectStructureRepository(StructureRepository $structureReposito } /** - * This holds all issues for the list view. - * - * @var array * @access protected + * @var array This holds all issues for the list view. */ protected $allIssues = []; diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index 5e7057bba..ab723f0bd 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -29,6 +29,7 @@ class CollectionController extends AbstractController { /** + * @access protected * @var CollectionRepository */ protected $collectionRepository; @@ -42,6 +43,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos } /** + * @access protected * @var MetadataRepository */ protected $metadataRepository; diff --git a/Classes/Controller/FeedsController.php b/Classes/Controller/FeedsController.php index e02ecc30a..2f0862d6a 100644 --- a/Classes/Controller/FeedsController.php +++ b/Classes/Controller/FeedsController.php @@ -12,7 +12,6 @@ namespace Kitodo\Dlf\Controller; use Kitodo\Dlf\Common\AbstractDocument; -use Kitodo\Dlf\Domain\Model\Library; use Kitodo\Dlf\Domain\Repository\LibraryRepository; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -29,6 +28,7 @@ class FeedsController extends AbstractController { /** + * @access protected * @var LibraryRepository */ protected $libraryRepository; @@ -62,7 +62,7 @@ public function mainAction() $requestData = $this->request->getArguments(); // get library information - /** @var Library|null $library */ + /** @var \Kitodo\Dlf\Domain\Model\Library|null $library */ $library = $this->libraryRepository->findByUid($this->settings['library']); $feedMeta = []; diff --git a/Classes/Controller/ListViewController.php b/Classes/Controller/ListViewController.php index 2b0dd0a3f..690ab052f 100644 --- a/Classes/Controller/ListViewController.php +++ b/Classes/Controller/ListViewController.php @@ -27,6 +27,7 @@ class ListViewController extends AbstractController { /** + * @access protected * @var CollectionRepository */ protected $collectionRepository; @@ -40,6 +41,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos } /** + * @access protected * @var MetadataRepository */ protected $metadataRepository; @@ -53,8 +55,8 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) } /** - * @var array $this->searchParams: The current search parameter * @access protected + * @var array The current search parameter */ protected $searchParams; diff --git a/Classes/Controller/MetadataController.php b/Classes/Controller/MetadataController.php index 12412064b..056f75077 100644 --- a/Classes/Controller/MetadataController.php +++ b/Classes/Controller/MetadataController.php @@ -30,11 +30,13 @@ class MetadataController extends AbstractController { /** + * @access private * @var Doc */ private $doc; /** + * @access protected * @var CollectionRepository */ protected $collectionRepository; @@ -48,6 +50,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos } /** + * @access protected * @var MetadataRepository */ protected $metadataRepository; @@ -61,6 +64,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) } /** + * @access protected * @var StructureRepository */ protected $structureRepository; diff --git a/Classes/Controller/OaiPmhController.php b/Classes/Controller/OaiPmhController.php index 35dad07b5..572af11fa 100644 --- a/Classes/Controller/OaiPmhController.php +++ b/Classes/Controller/OaiPmhController.php @@ -29,6 +29,7 @@ class OaiPmhController extends AbstractController { /** + * @access protected * @var TokenRepository */ protected $tokenRepository; @@ -42,6 +43,7 @@ public function injectTokenRepository(TokenRepository $tokenRepository) } /** + * @access protected * @var CollectionRepository */ protected $collectionRepository; @@ -55,6 +57,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos } /** + * @access protected * @var LibraryRepository */ protected $libraryRepository; @@ -78,18 +81,14 @@ public function initializeAction() } /** - * Did an error occur? - * - * @var string * @access protected + * @var string Did an error occur? */ protected $error; /** - * This holds the configuration for all supported metadata prefixes - * - * @var array * @access protected + * @var array This holds the configuration for all supported metadata prefixes */ protected $formats = [ 'oai_dc' => [ @@ -110,6 +109,7 @@ public function initializeAction() ]; /** + * @access protected * @var array */ protected $parameters = []; diff --git a/Classes/Controller/PageViewController.php b/Classes/Controller/PageViewController.php index 37e196e9a..fb74989c5 100644 --- a/Classes/Controller/PageViewController.php +++ b/Classes/Controller/PageViewController.php @@ -28,34 +28,28 @@ class PageViewController extends AbstractController { /** - * Holds the controls to add to the map - * - * @var array * @access protected + * @var array Holds the controls to add to the map */ protected $controls = []; /** - * Holds the current images' URLs and MIME types - * - * @var array * @access protected + * @var array Holds the current images' URLs and MIME types */ protected $images = []; /** - * Holds the current fulltexts' URLs - * - * @var array * @access protected + * @var array Holds the current full texts' URLs */ protected $fulltexts = []; /** * Holds the current AnnotationLists / AnnotationPages * - * @var array * @access protected + * @var array Holds the current AnnotationLists / AnnotationPages */ protected $annotationContainers = []; diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index 757f3a2bb..e13910d05 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -32,6 +32,7 @@ class SearchController extends AbstractController { /** + * @access protected * @var CollectionRepository */ protected $collectionRepository; @@ -45,6 +46,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos } /** + * @access protected * @var MetadataRepository */ protected $metadataRepository; @@ -58,8 +60,8 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) } /** - * @var array $this->searchParams: The current search parameter * @access protected + * @var array The current search parameter */ protected $searchParams; diff --git a/Classes/Controller/TableOfContentsController.php b/Classes/Controller/TableOfContentsController.php index 58bb68dde..7b2f7cd5f 100644 --- a/Classes/Controller/TableOfContentsController.php +++ b/Classes/Controller/TableOfContentsController.php @@ -28,8 +28,8 @@ class TableOfContentsController extends AbstractController /** * This holds the active entries according to the currently selected page * - * @var array * @access protected + * @var array This holds the active entries according to the currently selected page */ protected $activeEntries = []; diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index d81faf18b..afad6a47e 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -11,7 +11,6 @@ namespace Kitodo\Dlf\Controller; -use Kitodo\Dlf\Common\AbstractDocument; use Kitodo\Dlf\Common\Helper; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -28,10 +27,8 @@ class ToolboxController extends AbstractController { /** - * This holds the current document - * - * @var AbstractDocument * @access private + * @var \Kitodo\Dlf\Common\AbstractDocument This holds the current document */ private $doc; diff --git a/Classes/Domain/Model/ActionLog.php b/Classes/Domain/Model/ActionLog.php index fb14f3fbc..cfaa9569e 100644 --- a/Classes/Domain/Model/ActionLog.php +++ b/Classes/Domain/Model/ActionLog.php @@ -25,26 +25,31 @@ class ActionLog extends AbstractEntity { /** + * @access protected * @var int */ protected $userId; /** + * @access protected * @var string */ protected $fileName; /** + * @access protected * @var int */ protected $countPages; /** + * @access protected * @var string */ protected $name; /** + * @access protected * @var string */ protected $label; diff --git a/Classes/Domain/Model/Basket.php b/Classes/Domain/Model/Basket.php index f96653bc6..3029b1f3d 100644 --- a/Classes/Domain/Model/Basket.php +++ b/Classes/Domain/Model/Basket.php @@ -25,21 +25,25 @@ class Basket extends AbstractEntity { /** + * @access protected * @var string|null */ protected $docIds; /** + * @access protected * @var int */ protected $feUserId; /** + * @access protected * @var string */ protected $label; /** + * @access protected * @var string */ protected $sessionId; diff --git a/Classes/Domain/Model/Collection.php b/Classes/Domain/Model/Collection.php index 9e597942e..e93c5cf36 100644 --- a/Classes/Domain/Model/Collection.php +++ b/Classes/Domain/Model/Collection.php @@ -12,6 +12,7 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; /** @@ -25,63 +26,73 @@ class Collection extends AbstractEntity { /** + * @access protected * @var int */ protected $feCruserId; /** + * @access protected * @var string */ protected $feGroup; /** + * @access protected * @var string */ protected $label; /** + * @access protected * @var string */ protected $indexName; /** + * @access protected * @var string */ protected $indexSearch; /** + * @access protected * @var string */ protected $oaiName; /** + * @access protected * @var string */ protected $description; /** - * thumbnail - * - * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference + * @access protected + * @var FileReference thumbnail */ protected $thumbnail = null; /** + * @access protected * @var int */ protected $priority; /** + * @access protected * @var int */ protected $documents; /** + * @access protected * @var int */ protected $owner; /** + * @access protected * @var int */ protected $status; @@ -201,15 +212,15 @@ public function setDescription(string $description): void /** * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference */ - public function getThumbnail(): ?\TYPO3\CMS\Extbase\Domain\Model\FileReference + public function getThumbnail(): ?FileReference { return $this->thumbnail; } /** - * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $thumbnail + * @param FileReference $thumbnail */ - public function setThumbnail(?\TYPO3\CMS\Extbase\Domain\Model\FileReference $thumbnail): void + public function setThumbnail(?FileReference $thumbnail): void { $this->thumbnail = $thumbnail; } diff --git a/Classes/Domain/Model/Document.php b/Classes/Domain/Model/Document.php index 2c225a225..1737c393d 100644 --- a/Classes/Domain/Model/Document.php +++ b/Classes/Domain/Model/Document.php @@ -29,165 +29,195 @@ class Document extends AbstractEntity { /** + * @access protected * @var \DateTime */ protected $crdate; /** + * @access protected * @var \DateTime */ protected $tstamp; /** - * This contains the representative of the raw XML / IIIF data of the document. - * - * @var AbstractDocument|null + * @access protected + * @var AbstractDocument|null This contains the representative of the raw XML / IIIF data of the document. */ protected $currentDocument = null; /** + * @access protected * @var string */ protected $title; /** + * @access protected * @var string */ protected $prodId; /** + * @access protected * @var string */ protected $location; /** + * @access protected * @var string */ protected $recordId; /** + * @access protected * @var string */ protected $opacId; /** + * @access protected * @var string */ protected $unionId; /** + * @access protected * @var string */ protected $urn; /** + * @access protected * @var string */ protected $purl; /** + * @access protected * @var string */ protected $titleSorting; /** + * @access protected * @var string */ protected $author; /** + * @access protected * @var string */ protected $year; /** + * @access protected * @var string */ protected $place; /** + * @access protected * @var string */ protected $thumbnail; /** - * @var \Kitodo\Dlf\Domain\Model\Structure + * @access protected + * @var Structure */ protected $structure; /** + * @access protected * @var int */ protected $partof = 0; /** + * @access protected * @var string */ protected $volume; /** + * @access protected * @var string */ protected $volumeSorting; /** + * @access protected * @var string */ protected $license; /** + * @access protected * @var string */ protected $terms; /** + * @access protected * @var string */ protected $restrictions; /** + * @access protected * @var string */ protected $outOfPrint; /** + * @access protected * @var string */ protected $rightsInfo; /** - * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Kitodo\Dlf\Domain\Model\Collection> + * @access protected + * @var ObjectStorage * @Extbase\ORM\Lazy */ protected $collections = null; /** + * @access protected * @var string */ protected $metsLabel; /** + * @access protected * @var string */ protected $metsOrderlabel; /** - * @var \Kitodo\Dlf\Domain\Model\Library + * @access protected + * @var Library * @Extbase\ORM\Lazy */ protected $owner; /** + * @access protected * @var int */ protected $solrcore; /** + * @access protected * @var int */ protected $status; /** + * @access protected * @var string */ protected $documentFormat; @@ -431,17 +461,17 @@ public function setThumbnail(string $thumbnail): void } /** - * @return \Kitodo\Dlf\Domain\Model\Structure + * @return Structure */ - public function getStructure(): \Kitodo\Dlf\Domain\Model\Structure + public function getStructure(): Structure { return $this->structure; } /** - * @param \Kitodo\Dlf\Domain\Model\Structure $structure + * @param Structure $structure */ - public function setStructure(\Kitodo\Dlf\Domain\Model\Structure $structure): void + public function setStructure(Structure $structure): void { $this->structure = $structure; } @@ -578,7 +608,7 @@ public function setRightsInfo(string $rightsInfo): void /** * Returns the collections * - * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Kitodo\Dlf\Domain\Model\Collection> $collections + * @return ObjectStorage $collections */ public function getCollections() { @@ -586,7 +616,7 @@ public function getCollections() } /** - * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Kitodo\Dlf\Domain\Model\Collection> $collections + * @param ObjectStorage $collections */ public function setCollections(?ObjectStorage $collections): void { @@ -596,9 +626,9 @@ public function setCollections(?ObjectStorage $collections): void /** * Adds a collection * - * @param \Kitodo\Dlf\Domain\Model\Collection $collection + * @param Collection $collection */ - public function addCollection(\Kitodo\Dlf\Domain\Model\Collection $collection): void + public function addCollection(Collection $collection): void { $this->collections->attach($collection); } @@ -606,9 +636,9 @@ public function addCollection(\Kitodo\Dlf\Domain\Model\Collection $collection): /** * Removes a collection * - * @param \Kitodo\Dlf\Domain\Model\Collection $collection + * @param Collection $collection * - * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Kitodo\Dlf\Domain\Model\Collection> collections + * @return ObjectStorage collections */ public function removeCollection(Collection $collection) { @@ -648,7 +678,7 @@ public function setMetsOrderlabel(string $metsOrderlabel): void } /** - * @return \Kitodo\Dlf\Domain\Model\Library|null + * @return Library|null */ public function getOwner(): ?Library { @@ -658,9 +688,9 @@ public function getOwner(): ?Library } /** - * @param \Kitodo\Dlf\Domain\Model\Library $owner + * @param Library $owner */ - public function setOwner(\Kitodo\Dlf\Domain\Model\Library $owner): void + public function setOwner(Library $owner): void { $this->owner = $owner; } diff --git a/Classes/Domain/Model/Format.php b/Classes/Domain/Model/Format.php index e652310d2..3c236af45 100644 --- a/Classes/Domain/Model/Format.php +++ b/Classes/Domain/Model/Format.php @@ -31,30 +31,26 @@ class Format extends AbstractEntity { /** - * Name of the type that is used to reference it. - * - * @var string + * @access protected + * @var string Name of the type that is used to reference it. */ protected $type; /** - * The XML root element used by this format. - * - * @var string + * @access protected + * @var string The XML root element used by this format. */ protected $root; /** - * The XML namespace URI used by this format. - * - * @var string + * @access protected + * @var string The XML namespace URI used by this format. */ protected $namespace; /** - * Fully qualified name of the PHP class that handles the format, or the empty string if no such class is configured. - * - * @var string + * @access protected + * @var string Fully qualified name of the PHP class that handles the format, or the empty string if no such class is configured. */ protected $class; diff --git a/Classes/Domain/Model/Library.php b/Classes/Domain/Model/Library.php index 94fd153f5..d5f75e988 100644 --- a/Classes/Domain/Model/Library.php +++ b/Classes/Domain/Model/Library.php @@ -12,6 +12,7 @@ namespace Kitodo\Dlf\Domain\Model; +use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; /** @@ -32,66 +33,67 @@ class Library extends AbstractEntity { /** + * @access protected * @var string */ protected $label; /** + * @access protected * @var string */ protected $indexName; /** + * @access protected * @var string */ protected $website; /** - * Contact email address of the library (used as ``adminEmail`` in responses - * to OAI ``Identify`` requests). - * - * @var string + * @access protected + * @var string Contact email address of the library (used as ``adminEmail`` in responses to OAI ``Identify`` requests). */ protected $contact; /** - * image - * - * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference + * @access protected + * @var FileReference image */ protected $image; /** - * The label that is used as ``repositoryName`` in responses to OAI - * ``Identify`` requests. - * - * @var string + * @access protected + * @var string The label that is used as ``repositoryName`` in responses to OAI ``Identify`` requests */ protected $oaiLabel; /** - * OAI base URL used when harvesting the library via ``kitodo:harvest``. - * - * @var string + * @access protected + * @var string OAI base URL used when harvesting the library via ``kitodo:harvest``. */ protected $oaiBase; /** + * @access protected * @var string */ protected $opacLabel; /** + * @access protected * @var string */ protected $opacBase; /** + * @access protected * @var string */ protected $unionLabel; /** + * @access protected * @var string */ protected $unionBase; @@ -161,17 +163,17 @@ public function setContact(string $contact): void } /** - * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference + * @return FileReference */ - public function getImage(): \TYPO3\CMS\Extbase\Domain\Model\FileReference + public function getImage(): FileReference { return $this->image; } /** - * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $image + * @param FileReference $image */ - public function setImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $image): void + public function setImage(FileReference $image): void { $this->image = $image; } diff --git a/Classes/Domain/Model/Mail.php b/Classes/Domain/Model/Mail.php index 3b86dd823..11063315d 100644 --- a/Classes/Domain/Model/Mail.php +++ b/Classes/Domain/Model/Mail.php @@ -25,16 +25,19 @@ class Mail extends AbstractEntity { /** + * @access protected * @var string */ protected $mail; /** + * @access protected * @var string */ protected $name; /** + * @access protected * @var string */ protected $label; diff --git a/Classes/Domain/Model/Metadata.php b/Classes/Domain/Model/Metadata.php index f96549a21..1e2eeb4e3 100644 --- a/Classes/Domain/Model/Metadata.php +++ b/Classes/Domain/Model/Metadata.php @@ -27,87 +27,100 @@ class Metadata extends AbstractEntity { /** - * @var \Kitodo\Dlf\Domain\Model\Metadata + * @access protected + * @var Metadata */ protected $l18nParent; /** - * Order (relative position) of this entry in metadata plugin and backend list. - * - * @var int + * @access protected + * @var int Order (relative position) of this entry in metadata plugin and backend list. */ protected $sorting; /** + * @access protected * @var string */ protected $label; /** + * @access protected * @var string */ protected $indexName; /** - * The formats that encode this metadata (local IRRE field to ``tx_dlf_metadataformat``). + * @access protected + * @var ObjectStorage The formats that encode this metadatum (local IRRE field to ``tx_dlf_metadataformat``). * - * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Kitodo\Dlf\Domain\Model\MetadataFormat> * @Extbase\ORM\Lazy * @Extbase\ORM\Cascade("remove") */ protected $format; /** + * @access protected * @var string */ protected $defaultValue; /** + * @access protected * @var string */ protected $wrap; /** + * @access protected * @var int */ protected $indexTokenized; /** + * @access protected * @var int */ protected $indexStored; /** + * @access protected * @var int */ protected $indexIndexed; /** + * @access protected * @var float */ protected $indexBoost; /** + * @access protected * @var int */ protected $isSortable; /** + * @access protected * @var int */ protected $isFacet; /** + * @access protected * @var int */ protected $isListed; /** + * @access protected * @var int */ protected $indexAutocomplete; /** + * @access protected * @var int */ protected $status; @@ -191,7 +204,7 @@ public function setIndexName(string $indexName): void } /** - * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Kitodo\Dlf\Domain\Model\MetadataFormat> $format + * @return ObjectStorage $format */ public function getFormat() { @@ -199,7 +212,7 @@ public function getFormat() } /** - * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Kitodo\Dlf\Domain\Model\MetadataFormat> $format + * @param ObjectStorage $format */ public function setFormat(ObjectStorage $format): void { @@ -209,11 +222,11 @@ public function setFormat(ObjectStorage $format): void /** * Adds a Format * - * @param \Kitodo\Dlf\Domain\Model\MetadataFormat $format + * @param MetadataFormat $format * * @return void */ - public function addFormat(\Kitodo\Dlf\Domain\Model\MetadataFormat $format) + public function addFormat(MetadataFormat $format) { $this->format->attach($format); } @@ -221,11 +234,11 @@ public function addFormat(\Kitodo\Dlf\Domain\Model\MetadataFormat $format) /** * Removes a Format * - * @param \Kitodo\Dlf\Domain\Model\MetadataFormat $formatToRemove + * @param MetadataFormat $formatToRemove * * @return void */ - public function removeFormat(\Kitodo\Dlf\Domain\Model\MetadataFormat $formatToRemove) + public function removeFormat(MetadataFormat $formatToRemove) { $this->format->detach($formatToRemove); } diff --git a/Classes/Domain/Model/MetadataFormat.php b/Classes/Domain/Model/MetadataFormat.php index 0e683f699..30157c429 100644 --- a/Classes/Domain/Model/MetadataFormat.php +++ b/Classes/Domain/Model/MetadataFormat.php @@ -31,37 +31,32 @@ class MetadataFormat extends AbstractEntity { /** - * UID of the ``tx_dlf_metadata`` that is encoded by this metadata entry. - * - * @var int + * @access protected + * @var int UID of the ``tx_dlf_metadata`` that is encoded by this metadata entry. */ protected $parentId; /** - * UID of the ``tx_dlf_format`` in which this metadata entry is encoded. - * - * @var int + * @access protected + * @var int UID of the ``tx_dlf_format`` in which this metadata entry is encoded. */ protected $encoded; /** - * XPath/JSONPath expression to extract the metadata (relative to the data format root). - * - * @var string + * @access protected + * @var string XPath/JSONPath expression to extract the metadata (relative to the data format root). */ protected $xpath; /** - * XPath/JSONPath expression to extract sorting variant (suffixed ``_sorting``) of the metadata. - * - * @var string + * @access protected + * @var string XPath/JSONPath expression to extract sorting variant (suffixed ``_sorting``) of the metadata. */ protected $xpathSorting; /** - * Whether or not the field is mandatory. Not used at the moment (originally planned to be used in METS validator). - * - * @var int + * @access protected + * @var int Whether or not the field is mandatory. Not used at the moment (originally planned to be used in METS validator). */ protected $mandatory; diff --git a/Classes/Domain/Model/PageSelectForm.php b/Classes/Domain/Model/PageSelectForm.php index 8ca16def3..9d883b570 100644 --- a/Classes/Domain/Model/PageSelectForm.php +++ b/Classes/Domain/Model/PageSelectForm.php @@ -25,21 +25,25 @@ class PageSelectForm extends AbstractEntity { /** + * @access protected * @var integer */ protected $id; /** + * @access protected * @var string */ protected $recordId; /** + * @access protected * @var string */ protected $double; /** + * @access protected * @var integer */ protected $page; diff --git a/Classes/Domain/Model/Printer.php b/Classes/Domain/Model/Printer.php index dad67d8da..8dfe3f864 100644 --- a/Classes/Domain/Model/Printer.php +++ b/Classes/Domain/Model/Printer.php @@ -25,21 +25,25 @@ class Printer extends AbstractEntity { /** + * @access protected * @var string */ protected $mail; /** + * @access protected * @var string */ protected $name; /** + * @access protected * @var string */ protected $label; /** + * @access protected * @var string */ protected $print; diff --git a/Classes/Domain/Model/SolrCore.php b/Classes/Domain/Model/SolrCore.php index b70718c67..ced90803f 100644 --- a/Classes/Domain/Model/SolrCore.php +++ b/Classes/Domain/Model/SolrCore.php @@ -27,21 +27,20 @@ class SolrCore extends AbstractEntity { /** + * @access protected * @var int */ protected $pid; /** - * Label of the core that is displayed in the backend. - * - * @var string + * @access protected + * @var string Label of the core that is displayed in the backend. */ protected $label; /** - * The actual name of the Solr core. - * - * @var string + * @access protected + * @var string The actual name of the Solr core. */ protected $indexName; diff --git a/Classes/Domain/Model/Structure.php b/Classes/Domain/Model/Structure.php index 4793f3ef2..3bea2568c 100644 --- a/Classes/Domain/Model/Structure.php +++ b/Classes/Domain/Model/Structure.php @@ -25,36 +25,43 @@ class Structure extends AbstractEntity { /** + * @access protected * @var Structure */ protected $l18nParent; /** + * @access protected * @var int */ protected $toplevel; /** + * @access protected * @var string */ protected $label; /** + * @access protected * @var string */ protected $indexName; /** + * @access protected * @var string */ protected $oaiName; /** + * @access protected * @var int */ protected $thumbnail; /** + * @access protected * @var int */ protected $status; diff --git a/Classes/Domain/Model/Token.php b/Classes/Domain/Model/Token.php index 3add8b008..cc112c7f6 100644 --- a/Classes/Domain/Model/Token.php +++ b/Classes/Domain/Model/Token.php @@ -25,23 +25,20 @@ class Token extends AbstractEntity { /** - * The resumption token string. - * - * @var string + * @access protected + * @var string The resumption token string. */ protected $token; /** - * Data that is used to resume the previous request. - * - * @var string + * @access protected + * @var string Data that is used to resume the previous request. */ protected $options; /** - * Originally an identifier for the kind of token ('oai'). Not used at the moment. - * - * @var string + * @access protected + * @var string Originally an identifier for the kind of token ('oai'). Not used at the moment. */ protected $ident; diff --git a/Classes/Domain/Repository/CollectionRepository.php b/Classes/Domain/Repository/CollectionRepository.php index 078db5641..4288f3bd2 100644 --- a/Classes/Domain/Repository/CollectionRepository.php +++ b/Classes/Domain/Repository/CollectionRepository.php @@ -30,9 +30,8 @@ class CollectionRepository extends Repository { /** - * Set the default ordering. This is applied to findAll(), too. - * - * @var array + * @access protected + * @var array Set the default ordering. This is applied to findAll(), too. */ protected $defaultOrderings = [ 'label' => QueryInterface::ORDER_ASCENDING, diff --git a/Classes/Domain/Repository/DocumentRepository.php b/Classes/Domain/Repository/DocumentRepository.php index f59bcfa81..026bd1662 100644 --- a/Classes/Domain/Repository/DocumentRepository.php +++ b/Classes/Domain/Repository/DocumentRepository.php @@ -38,10 +38,8 @@ class DocumentRepository extends Repository { /** - * The controller settings passed to the repository for some special actions. - * - * @var array * @access protected + * @var array The controller settings passed to the repository for some special actions. */ protected $settings; diff --git a/Classes/Eid/PageViewProxy.php b/Classes/Eid/PageViewProxy.php index c6a19d819..e31d49a60 100644 --- a/Classes/Eid/PageViewProxy.php +++ b/Classes/Eid/PageViewProxy.php @@ -37,11 +37,13 @@ class PageViewProxy { /** + * @access protected * @var RequestFactory */ protected $requestFactory; /** + * @access protected * @var mixed */ protected $extConf; diff --git a/Classes/Format/Mods.php b/Classes/Format/Mods.php index 8ac47e54d..9ec023452 100644 --- a/Classes/Format/Mods.php +++ b/Classes/Format/Mods.php @@ -27,16 +27,14 @@ class Mods implements MetadataInterface { /** - * The metadata XML - * - * @var \SimpleXMLElement + * @access private + * @var \SimpleXMLElement The metadata XML **/ private $xml; /** - * The metadata array - * - * @var array + * @access private + * @var array The metadata array **/ private $metadata; diff --git a/Classes/Hooks/DataHandler.php b/Classes/Hooks/DataHandler.php index 97fec474d..74b53248d 100644 --- a/Classes/Hooks/DataHandler.php +++ b/Classes/Hooks/DataHandler.php @@ -38,6 +38,7 @@ class DataHandler implements LoggerAwareInterface use LoggerAwareTrait; /** + * @access protected * @var DocumentRepository */ protected $documentRepository; diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php index 01893849f..f670307e8 100644 --- a/Classes/Hooks/ItemsProcFunc.php +++ b/Classes/Hooks/ItemsProcFunc.php @@ -34,6 +34,7 @@ class ItemsProcFunc implements LoggerAwareInterface use LoggerAwareTrait; /** + * @access protected * @var int */ protected $storagePid; diff --git a/Classes/Updates/FileLocationUpdater.php b/Classes/Updates/FileLocationUpdater.php index 6bf2e7450..536f35512 100644 --- a/Classes/Updates/FileLocationUpdater.php +++ b/Classes/Updates/FileLocationUpdater.php @@ -39,24 +39,26 @@ class FileLocationUpdater implements UpgradeWizardInterface, ChattyInterface, Lo use LoggerAwareTrait; /** + * @access protected * @var OutputInterface */ protected $output; /** + * @access protected * @var ResourceStorage */ protected $storage; /** + * @access protected * @var Logger */ protected $logger; /** - * Array with table and fields to migrate - * - * @var array + * @access protected + * @var array Array with table and fields to migrate */ protected $fieldsToMigrate = [ 'tx_dlf_collections' => 'thumbnail' diff --git a/Classes/ViewHelpers/StdWrapViewHelper.php b/Classes/ViewHelpers/StdWrapViewHelper.php index 502b1be76..524feaed7 100644 --- a/Classes/ViewHelpers/StdWrapViewHelper.php +++ b/Classes/ViewHelpers/StdWrapViewHelper.php @@ -25,6 +25,10 @@ */ class StdWrapViewHelper extends AbstractViewHelper { + /** + * @access protected + * @var bool + */ protected $escapeOutput = false; public function initializeArguments() From 133837a96c674cdbb868b3d6b7b74626a8851e14 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 29 Sep 2023 14:13:38 +0200 Subject: [PATCH 07/76] [MAINTENANCE] Unify and improve PHPDocs for functions (#1014) Co-authored-by: Sebastian Meyer --- Classes/Api/Orcid/Client.php | 11 +- Classes/Api/Orcid/Profile.php | 16 +- Classes/Api/Viaf/Client.php | 13 +- Classes/Api/Viaf/Profile.php | 14 +- Classes/Command/BaseCommand.php | 12 +- Classes/Command/HarvestCommand.php | 8 +- Classes/Command/IndexCommand.php | 6 +- Classes/Command/ReindexCommand.php | 6 +- Classes/Common/AbstractDocument.php | 93 ++++++---- Classes/Common/FulltextInterface.php | 4 +- Classes/Common/Helper.php | 132 +++++++++---- Classes/Common/IiifManifest.php | 24 ++- Classes/Common/IiifUrlReader.php | 2 + Classes/Common/Indexer.php | 48 +++-- Classes/Common/KitodoFlashMessageRenderer.php | 10 + Classes/Common/MetadataInterface.php | 4 +- Classes/Common/MetsDocument.php | 23 ++- Classes/Common/Solr/Solr.php | 30 +-- Classes/Common/Solr/SolrSearch.php | 175 +++++++++++++++++- Classes/Common/Solr/SolrSearchQuery.php | 50 +++++ Classes/Common/StdOutStream.php | 5 + Classes/Controller/AbstractController.php | 18 +- Classes/Controller/AudioPlayerController.php | 2 + .../Backend/NewTenantController.php | 44 ++++- Classes/Controller/BasketController.php | 43 ++++- Classes/Controller/CalendarController.php | 10 +- Classes/Controller/CollectionController.php | 16 +- Classes/Controller/FeedsController.php | 4 + Classes/Controller/ListViewController.php | 10 + Classes/Controller/MetadataController.php | 24 ++- Classes/Controller/NavigationController.php | 8 +- Classes/Controller/OaiPmhController.php | 27 ++- Classes/Controller/PageGridController.php | 6 +- Classes/Controller/PageViewController.php | 11 +- Classes/Controller/SearchController.php | 31 +++- Classes/Controller/StatisticsController.php | 2 + .../Controller/TableOfContentsController.php | 5 +- Classes/Controller/ToolboxController.php | 6 +- Classes/Controller/View3DController.php | 2 + .../Repository/CollectionRepository.php | 23 +++ .../Domain/Repository/DocumentRepository.php | 34 +++- Classes/Domain/Repository/MailRepository.php | 9 + .../Domain/Repository/MetadataRepository.php | 2 + Classes/Domain/Repository/TokenRepository.php | 2 + Classes/Eid/PageViewProxy.php | 27 ++- .../DocumentTypeFunctionProvider.php | 10 +- .../DocumentTypeProvider.php | 7 + Classes/Format/Alto.php | 8 +- Classes/Format/AudioVideoMD.php | 4 +- Classes/Format/Mods.php | 66 ++++++- Classes/Format/TeiHeader.php | 4 +- Classes/Hooks/DataHandler.php | 29 +-- .../Form/FieldInformation/SolrCoreStatus.php | 3 +- Classes/Hooks/ItemsProcFunc.php | 42 ++--- Classes/Hooks/KitodoProductionHacks.php | 4 +- Classes/Hooks/ThumbnailCustomElement.php | 7 + Classes/Updates/FileLocationUpdater.php | 24 +++ Classes/Updates/MigrateSettings.php | 18 ++ Classes/ViewHelpers/JsFooterViewHelper.php | 5 + .../MetadataWrapVariableViewHelper.php | 9 +- Classes/ViewHelpers/StdWrapViewHelper.php | 9 + 61 files changed, 1055 insertions(+), 246 deletions(-) diff --git a/Classes/Api/Orcid/Client.php b/Classes/Api/Orcid/Client.php index f85a24adc..ef7d60faf 100644 --- a/Classes/Api/Orcid/Client.php +++ b/Classes/Api/Orcid/Client.php @@ -71,8 +71,11 @@ class Client /** * Constructs a new instance * + * @access public + * * @param string $orcid the ORCID to search for * @param RequestFactory $requestFactory a request object to inject + * * @return void **/ public function __construct($orcid, RequestFactory $requestFactory) @@ -85,7 +88,9 @@ public function __construct($orcid, RequestFactory $requestFactory) /** * Sets API endpoint * - * @param string $endpoint the shortname of the endpoint + * @access public + * + * @param string $endpoint the shortname of the endpoint * * @return void */ @@ -96,6 +101,8 @@ public function setEndpoint($endpoint) { /** * Get the profile data * + * @access public + * * @return object|bool **/ public function getData() @@ -113,6 +120,8 @@ public function getData() /** * Creates the qualified API endpoint for retrieving the desired data * + * @access private + * * @return string **/ private function getApiEndpoint() diff --git a/Classes/Api/Orcid/Profile.php b/Classes/Api/Orcid/Profile.php index aa1e7225d..174006d74 100644 --- a/Classes/Api/Orcid/Profile.php +++ b/Classes/Api/Orcid/Profile.php @@ -49,6 +49,8 @@ class Profile /** * Constructs client instance * + * @access public + * * @param string $orcid: the ORCID to search for * * @return void @@ -62,6 +64,8 @@ public function __construct($orcid) /** * Get the ORCID profile data * + * @access public + * * @return array|false **/ public function getData() @@ -82,6 +86,8 @@ public function getData() /** * Get the address * + * @access public + * * @return string|false **/ public function getAddress() @@ -99,6 +105,8 @@ public function getAddress() /** * Get the email * + * @access public + * * @return string|false **/ public function getEmail() @@ -116,6 +124,8 @@ public function getEmail() /** * Get the full name * + * @access public + * * @return string|false **/ public function getFullName() @@ -135,11 +145,13 @@ public function getFullName() /** * Get the ORCID part of profile data for given endpoint * - * @param string $endpoint the shortname of the endpoint + * @access private + * + * @param string $endpoint the shortname of the endpoint * * @return void **/ - protected function getRaw($endpoint) + private function getRaw($endpoint) { $this->client->setEndpoint($endpoint); $data = $this->client->getData(); diff --git a/Classes/Api/Viaf/Client.php b/Classes/Api/Viaf/Client.php index b171c8103..8e58d9f33 100644 --- a/Classes/Api/Viaf/Client.php +++ b/Classes/Api/Viaf/Client.php @@ -57,8 +57,11 @@ class Client /** * Constructs a new instance * + * @access public + * * @param string $viaf the VIAF identifier of the profile * @param RequestFactory $requestFactory a request object to inject + * * @return void **/ public function __construct($viaf, RequestFactory $requestFactory) @@ -71,7 +74,9 @@ public function __construct($viaf, RequestFactory $requestFactory) /** * Sets API endpoint * - * @param string $endpoint the shortname of the endpoint + * @access public + * + * @param string $endpoint the shortname of the endpoint * * @return void */ @@ -82,6 +87,8 @@ public function setEndpoint($endpoint) { /** * Get the profile data * + * @access public + * * @return object|bool **/ public function getData() @@ -98,10 +105,12 @@ public function getData() /** * Creates the qualified API endpoint for retrieving the desired data + * + * @access private * * @return string **/ - protected function getApiEndpoint() + private function getApiEndpoint() { return $this->viafUrl . '/' . $this->endpoint; } diff --git a/Classes/Api/Viaf/Profile.php b/Classes/Api/Viaf/Profile.php index 05b23179a..6fd1befcc 100644 --- a/Classes/Api/Viaf/Profile.php +++ b/Classes/Api/Viaf/Profile.php @@ -49,7 +49,9 @@ class Profile /** * Constructs client instance * - * @param string $viaf: the VIAF identifier of the profile + * @access public + * + * @param string $viaf the VIAF identifier of the profile * * @return void **/ @@ -62,6 +64,8 @@ public function __construct($viaf) /** * Get the VIAF profile data * + * @access public + * * @return array|false **/ public function getData() @@ -81,6 +85,8 @@ public function getData() /** * Get the address * + * @access public + * * @return string|false **/ public function getAddress() @@ -97,6 +103,8 @@ public function getAddress() /** * Get the full name * + * @access public + * * @return string|false **/ public function getFullName() @@ -116,9 +124,11 @@ public function getFullName() /** * Get the VIAF raw profile data * + * @access private + * * @return void **/ - protected function getRaw() + private function getRaw() { $data = $this->client->getData(); if (!isset($this->raw) && $data != false) { diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index 028db96ab..be29ef428 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -109,6 +109,8 @@ public function __construct(CollectionRepository $collectionRepository, * * TYPO3 10+: Find a better solution e.g. based on Symfony Dependency Injection. * + * @access protected + * * @param int $storagePid The storage pid * * @return bool @@ -134,6 +136,8 @@ protected function initializeRepositories($storagePid) /** * Return matching uid of Solr core depending on the input value. * + * @access protected + * * @param array $solrCores array of the valid Solr cores * @param string|bool|null $inputSolrId possible uid or name of Solr core * @@ -152,6 +156,8 @@ protected function getSolrCoreUid(array $solrCores, $inputSolrId): int /** * Fetches all Solr cores on given page. * + * @access protected + * * @param int $pageId The UID of the Solr core or 0 to disable indexing * * @return array Array of valid Solr cores @@ -183,7 +189,9 @@ protected function getSolrCores(int $pageId): array /** * Update or insert document to database * - * @param int|string $doc The document uid from DB OR the location of a mets document. + * @access protected + * + * @param int|string $doc The document uid from DB OR the location of a METS document. * * @return bool true on success */ @@ -303,6 +311,8 @@ protected function saveToDatabase(Document $document) * Currently only applies to METS documents. * * @access protected + * + * @param Document $document for which parent UID should be taken * * @return int The parent document's id. */ diff --git a/Classes/Command/HarvestCommand.php b/Classes/Command/HarvestCommand.php index 2cf58a738..831935b80 100644 --- a/Classes/Command/HarvestCommand.php +++ b/Classes/Command/HarvestCommand.php @@ -38,6 +38,8 @@ class HarvestCommand extends BaseCommand /** * Configure the command by defining the name, options and arguments * + * @access public + * * @return void */ public function configure() @@ -90,7 +92,9 @@ public function configure() } /** - * Executes the command to index the given document to db and solr. + * Executes the command to index the given document to DB and SOLR. + * + * @access protected * * @param InputInterface $input The input parameters * @param OutputInterface $output The Symfony interface for outputs on console @@ -257,6 +261,8 @@ protected function execute(InputInterface $input, OutputInterface $output) /** * Handles OAI errors * + * @access protected + * * @param BaseoaipmhException $exception Instance of exception thrown * @param SymfonyStyle $io * diff --git a/Classes/Command/IndexCommand.php b/Classes/Command/IndexCommand.php index 01ee83855..4352330ed 100644 --- a/Classes/Command/IndexCommand.php +++ b/Classes/Command/IndexCommand.php @@ -37,6 +37,8 @@ class IndexCommand extends BaseCommand /** * Configure the command by defining the name, options and arguments * + * @access public + * * @return void */ public function configure() @@ -77,7 +79,9 @@ public function configure() } /** - * Executes the command to index the given document to db and solr. + * Executes the command to index the given document to DB and SOLR. + * + * @access protected * * @param InputInterface $input The input parameters * @param OutputInterface $output The Symfony interface for outputs on console diff --git a/Classes/Command/ReindexCommand.php b/Classes/Command/ReindexCommand.php index ff5c172dd..e6fc74de0 100644 --- a/Classes/Command/ReindexCommand.php +++ b/Classes/Command/ReindexCommand.php @@ -35,6 +35,8 @@ class ReindexCommand extends BaseCommand /** * Configure the command by defining the name, options and arguments * + * @access public + * * @return void */ public function configure() @@ -81,7 +83,9 @@ public function configure() } /** - * Executes the command to index the given document to db and solr. + * Executes the command to index the given document to DB and SOLR. + * + * @access protected * * @param InputInterface $input The input parameters * @param OutputInterface $output The Symfony interface for outputs on console diff --git a/Classes/Common/AbstractDocument.php b/Classes/Common/AbstractDocument.php index 5527cf2da..7a7614bd5 100644 --- a/Classes/Common/AbstractDocument.php +++ b/Classes/Common/AbstractDocument.php @@ -313,6 +313,7 @@ public static function clearRegistry() * * @param int $pid: ID of the configuration page with the recordId config * + * @return void */ protected abstract function establishRecordId($pid); @@ -335,9 +336,9 @@ protected abstract function getDocument(); * * @abstract * - * @param string $id: The "@ID" attribute of the file node (METS) or the "@id" property of the IIIF resource + * @param string $id The "@ID" attribute of the file node (METS) or the "@id" property of the IIIF resource * - * @return string The file's location as URL + * @return string The file's location as URL */ public abstract function getDownloadLocation($id); @@ -361,7 +362,7 @@ public abstract function getFileInfo($id); * * @abstract * - * @param string $id: The "@ID" attribute of the file node (METS) or the "@id" property of the IIIF resource + * @param string $id The "@ID" attribute of the file node (METS) or the "@id" property of the IIIF resource * * @return string The file's location as URL */ @@ -374,7 +375,7 @@ public abstract function getFileLocation($id); * * @abstract * - * @param string $id: The "@ID" attribute of the file node + * @param string $id The "@ID" attribute of the file node * * @return string The file's MIME type */ @@ -387,9 +388,9 @@ public abstract function getFileMimeType($id); * * @static * - * @param string $location: The URL of XML file or the IRI of the IIIF resource + * @param string $location The URL of XML file or the IRI of the IIIF resource * @param array $settings - * @param bool $forceReload: Force reloading the document instead of returning the cached instance + * @param bool $forceReload Force reloading the document instead of returning the cached instance * * @return AbstractDocument|null Instance of this class, either MetsDocument or IiifManifest */ @@ -457,9 +458,9 @@ public static function &getInstance($location, $settings = [], $forceReload = fa * * @abstract * - * @param string $id: The "@ID" attribute of the logical structure node (METS) or + * @param string $id The "@ID" attribute of the logical structure node (METS) or * the "@id" property of the Manifest / Range (IIIF) - * @param bool $recursive: Whether to include the child elements / resources + * @param bool $recursive Whether to include the child elements / resources * * @return array Array of the element's id, label, type and physical page indexes/mptr link */ @@ -472,10 +473,9 @@ public abstract function getLogicalStructure($id, $recursive = false); * * @abstract * - * @param string $id: The "@ID" attribute of the logical structure node (METS) or the "@id" property + * @param string $id The "@ID" attribute of the logical structure node (METS) or the "@id" property * of the Manifest / Range (IIIF) - * @param int $cPid: The PID for the metadata definitions - * (defaults to $this->cPid or $this->pid) + * @param int $cPid The PID for the metadata definitions (defaults to $this->cPid or $this->pid) * * @return array The logical structure node's / the IIIF resource's parsed metadata array */ @@ -486,7 +486,7 @@ public abstract function getMetadata($id, $cPid = 0); * * @access public * - * @param string $logicalPage: The label (or a part of the label) of the logical page + * @param string $logicalPage The label (or a part of the label) of the logical page * * @return int The physical page number */ @@ -519,7 +519,7 @@ public function getPhysicalPage($logicalPage) * * @abstract * - * @param string $id: The "@ID" attribute of the physical structure node (METS) or the "@id" property + * @param string $id The "@ID" attribute of the physical structure node (METS) or the "@id" property * of the Manifest / Range (IIIF) * * @return string The OCR full text @@ -531,7 +531,7 @@ public abstract function getFullText($id); * XML full text representation (currently only ALTO). For IIIF manifests, ALTO documents have * to be given in the Canvas' / Manifest's "seeAlso" property. * - * @param string $id: The "@ID" attribute of the physical structure node (METS) or the "@id" property + * @param string $id The "@ID" attribute of the physical structure node (METS) or the "@id" property * of the Manifest / Range (IIIF) * * @return string The OCR full text @@ -596,7 +596,7 @@ class_exists($class) * * @access private * - * @param string $fileContent: content of the XML file + * @param string $fileContent content of the XML file * * @return string The format of the OCR full text */ @@ -619,8 +619,8 @@ private function getTextFormat($fileContent) * * @static * - * @param int $uid: The UID of the document - * @param bool $recursive: Search superior documents for a title, too? + * @param int $uid The UID of the document + * @param bool $recursive Search superior documents for a title, too? * * @return string The title of the document itself or a parent document */ @@ -673,7 +673,7 @@ public static function getTitle($uid, $recursive = false) * * @access public * - * @param int $cPid: The PID for the metadata definitions + * @param int $cPid The PID for the metadata definitions * * @return array The logical structure node's / resource's parsed metadata array */ @@ -704,11 +704,11 @@ public function getTitledata($cPid = 0) * * @access protected * - * @param array $structure: logical structure array - * @param int $depth: current tree depth - * @param string $logId: ID of the logical structure whose depth is requested + * @param array $structure logical structure array + * @param int $depth current tree depth + * @param string $logId ID of the logical structure whose depth is requested * - * @return int|bool: false if structure with $logId is not a child of this substructure, + * @return int|bool false if structure with $logId is not a child of this substructure, * or the actual depth. */ protected function getTreeDepth($structure, $depth, $logId) @@ -731,7 +731,8 @@ protected function getTreeDepth($structure, $depth, $logId) * * @access public * - * @param string $logId: The id of the logical structure element whose depth is requested + * @param string $logId The id of the logical structure element whose depth is requested + * * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC. */ public function getStructureDepth($logId) @@ -746,7 +747,7 @@ public function getStructureDepth($logId) * * @abstract * - * @param string $location:The location URL of the XML file to parse + * @param string $location The location URL of the XML file to parse * * @return void */ @@ -759,7 +760,7 @@ protected abstract function init($location); * * @abstract * - * @param \SimpleXMLElement|IiifResourceInterface $preloadedDocument: any instance that has already been loaded + * @param \SimpleXMLElement|IiifResourceInterface $preloadedDocument any instance that has already been loaded * * @return bool true if $preloadedDocument can actually be reused, false if it has to be loaded again */ @@ -772,7 +773,7 @@ protected abstract function setPreloadedDocument($preloadedDocument); * * @abstract * - * @param string $location: The URL of the file to load + * @param string $location The URL of the file to load * * @return bool true on success or false on failure */ @@ -783,7 +784,7 @@ protected abstract function loadLocation($location); * * @access protected * - * @param string $location: The URL of the file to load + * @param string $location The URL of the file to load * * @return bool true on success or false on failure */ @@ -805,6 +806,8 @@ protected function load($location) * @access protected * * @abstract + * + * @return void */ protected abstract function ensureHasFulltextIsSet(); @@ -852,7 +855,7 @@ protected function loadFormats() * * @access public * - * @param \SimpleXMLElement|\DOMXPath &$obj: \SimpleXMLElement or \DOMXPath object + * @param \SimpleXMLElement|\DOMXPath &$obj \SimpleXMLElement or \DOMXPath object * * @return void */ @@ -949,6 +952,8 @@ protected function _getHasFulltext() * @abstract * * @param int $cPid + * + * @return void */ protected abstract function prepareMetadataArray($cPid); @@ -1124,7 +1129,7 @@ protected function _getTableOfContents() * * @abstract * - * @param bool $forceReload: Force reloading the thumbnail instead of returning the cached value + * @param bool $forceReload Force reloading the thumbnail instead of returning the cached value * * @return string The document's thumbnail location */ @@ -1146,7 +1151,7 @@ protected abstract function _getToplevelId(); * * @access protected * - * @param int $value: The new PID for the metadata definitions + * @param int $value The new PID for the metadata definitions * * @return void */ @@ -1161,9 +1166,9 @@ protected function _setCPid($value) * * @access protected * - * @param string $location: The location URL of the XML file to parse - * @param int $pid: If > 0, then only document with this PID gets loaded - * @param \SimpleXMLElement|IiifResourceInterface $preloadedDocument: Either null or the \SimpleXMLElement + * @param string $location The location URL of the XML file to parse + * @param int $pid If > 0, then only document with this PID gets loaded + * @param \SimpleXMLElement|IiifResourceInterface $preloadedDocument Either null or the \SimpleXMLElement * or IiifResourceInterface that has been loaded to determine the basic document format. * * @return void @@ -1182,7 +1187,7 @@ protected function __construct($location, $pid, $preloadedDocument) * * @access public * - * @param string $var: Name of variable to get + * @param string $var Name of variable to get * * @return mixed Value of $this->$var */ @@ -1205,7 +1210,7 @@ public function __get($var) * * @access public * - * @param string $var: Name of variable to check + * @param string $var Name of variable to check * * @return bool true if variable is set and not empty, false otherwise */ @@ -1219,8 +1224,8 @@ public function __isset($var) * * @access public * - * @param string $var: Name of variable to set - * @param mixed $value: New value of variable + * @param string $var Name of variable to set + * @param mixed $value New value of variable * * @return void */ @@ -1238,9 +1243,14 @@ public function __set($var, $value) } /** - * get Cache Hit for $doc + * Gets Cache Hit for $doc + * + * @access private + * + * @static * * @param string $location + * * @return Doc|false */ private static function getDocCache(string $location) @@ -1253,10 +1263,15 @@ private static function getDocCache(string $location) } /** - * set Cache for $doc + * Sets Cache for $doc + * + * @access private + * + * @static * * @param string $location * @param AbstractDocument $currentDocument + * * @return void */ private static function setDocCache(string $location, AbstractDocument $currentDocument) diff --git a/Classes/Common/FulltextInterface.php b/Classes/Common/FulltextInterface.php index 27b6623fa..cb20f80cd 100644 --- a/Classes/Common/FulltextInterface.php +++ b/Classes/Common/FulltextInterface.php @@ -29,7 +29,7 @@ interface FulltextInterface * * @access public * - * @param \SimpleXMLElement $xml: The XML to extract the metadata from + * @param \SimpleXMLElement $xml The XML to extract the metadata from * * @return string The raw unformatted fulltext */ @@ -40,7 +40,7 @@ public function getRawText(\SimpleXMLElement $xml); * * @access public * - * @param \SimpleXMLElement $xml: The XML to extract the raw text from + * @param \SimpleXMLElement $xml The XML to extract the raw text from * * @return string The unformatted fulltext in MiniOCR format */ diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index 3fb068a4a..6088753cc 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -77,11 +77,13 @@ class Helper * * @access public * - * @param string $message: The body of the message - * @param string $title: The title of the message - * @param int $severity: The message's severity - * @param bool $session: Should the message be saved in the user's session? - * @param string $queue: The queue's unique identifier + * @static + * + * @param string $message The body of the message + * @param string $title The title of the message + * @param int $severity The message's severity + * @param bool $session Should the message be saved in the user's session? + * @param string $queue The queue's unique identifier * * @return FlashMessageQueue The queue the message was added to */ @@ -104,9 +106,10 @@ public static function addMessage($message, $title, $severity, $session = false, * * @access public * - * @param string $id: The identifier to check - * @param string $type: What type is the identifier supposed to be? - * Possible values: PPN, IDN, PND, ZDB, SWD, GKD + * @static + * + * @param string $id The identifier to check + * @param string $type What type is the identifier supposed to be? Possible values: PPN, IDN, PND, ZDB, SWD, GKD * * @return bool Is $id a valid GNL identifier of the given $type? */ @@ -171,7 +174,9 @@ public static function checkIdentifier($id, $type) * * @access public * - * @param string $encrypted: The encrypted value to decrypt + * @static + * + * @param string $encrypted The encrypted value to decrypt * * @return mixed The decrypted value or false on error */ @@ -211,6 +216,8 @@ public static function decrypt($encrypted) * * @access public * + * @static + * * @param string $content: content of file to read * * @return \SimpleXMLElement|false @@ -241,9 +248,10 @@ public static function getXmlFileAsString($content) * * @access public * - * @param string $message: The message to log - * @param int $severity: The severity of the message - * 0 is info, 1 is notice, 2 is warning, 3 is fatal error, -1 is "OK" message + * @static + * + * @param string $message The message to log + * @param int $severity The severity of the message 0 is info, 1 is notice, 2 is warning, 3 is fatal error, -1 is "OK" message * * @return void */ @@ -274,7 +282,9 @@ public static function log($message, $severity = 0) * * @access public * - * @param string $string: The string to encrypt + * @static + * + * @param string $string The string to encrypt * * @return mixed Hashed string or false on error */ @@ -294,7 +304,9 @@ public static function digest($string) * * @access public * - * @param string $string: The string to encrypt + * @static + * + * @param string $string The string to encrypt * * @return mixed Encrypted string or false on error */ @@ -328,13 +340,15 @@ public static function encrypt($string) * * @access public * - * @param string $qualifiedClassname: The qualified class name from get_class() + * @static + * + * @param string $qualifiedClassName The qualified class name from get_class() * * @return string The unqualified class name */ - public static function getUnqualifiedClassName($qualifiedClassname) + public static function getUnqualifiedClassName($qualifiedClassName) { - $nameParts = explode('\\', $qualifiedClassname); + $nameParts = explode('\\', $qualifiedClassName); return end($nameParts); } @@ -343,7 +357,9 @@ public static function getUnqualifiedClassName($qualifiedClassname) * * @access public * - * @param string $string: The string to clean up + * @static + * + * @param string $string The string to clean up * * @return string The cleaned up string */ @@ -365,7 +381,9 @@ public static function getCleanString($string) * * @access public * - * @param string $scriptRelPath: The path to the class file + * @static + * + * @param string $scriptRelPath The path to the class file * * @return array Array of hook objects for the class */ @@ -385,9 +403,11 @@ public static function getHookObjects($scriptRelPath) * * @access public * - * @param int $uid: The UID of the record - * @param string $table: Get the "index_name" from this table - * @param int $pid: Get the "index_name" from this page + * @static + * + * @param int $uid The UID of the record + * @param string $table Get the "index_name" from this table + * @param int $pid Get the "index_name" from this page * * @return string "index_name" for the given UID */ @@ -446,7 +466,9 @@ public static function getIndexNameFromUid($uid, $table, $pid = -1) * * @access public * - * @param string $code: ISO 639-1 or ISO 639-2/B language code + * @static + * + * @param string $code ISO 639-1 or ISO 639-2/B language code * * @return string Localized full name of language or unchanged input */ @@ -474,7 +496,11 @@ public static function getLanguageName($code) /** * Get all document structures as array * - * @param int $pid: Get the "index_name" from this page only + * @access public + * + * @static + * + * @param int $pid Get the "index_name" from this page only * * @return array */ @@ -516,8 +542,10 @@ public static function getDocumentStructures($pid = -1) * * @access public * - * @param string $base: The namespace and base URN - * @param string $id: The object's identifier + * @static + * + * @param string $base The namespace and base URN + * @param string $id The object's identifier * * @return string Uniform Resource Name as string */ @@ -585,7 +613,9 @@ public static function getURN($base, $id) * * @access public * - * @param string $id: The identifier to check + * @static + * + * @param string $id The identifier to check * * @return bool Is $id a valid PPN? */ @@ -597,6 +627,10 @@ public static function isPPN($id) /** * Determine whether or not $url is a valid URL using HTTP or HTTPS scheme. * + * @access public + * + * @static + * * @param string $url * * @return bool @@ -620,11 +654,13 @@ public static function isValidHttpUrl($url) * * @access public * - * @param array $original: Original array - * @param array $overrule: Overrule array, overruling the original array - * @param bool $addKeys: If set to false, keys that are not found in $original will not be set - * @param bool $includeEmptyValues: If set, values from $overrule will overrule if they are empty - * @param bool $enableUnsetFeature: If set, special value "__UNSET" can be used in the overrule array to unset keys in the original array + * @static + * + * @param array $original Original array + * @param array $overrule Overrule array, overruling the original array + * @param bool $addKeys If set to false, keys that are not found in $original will not be set + * @param bool $includeEmptyValues If set, values from $overrule will overrule if they are empty + * @param bool $enableUnsetFeature If set, special value "__UNSET" can be used in the overrule array to unset keys in the original array * * @return array Merged array */ @@ -638,8 +674,10 @@ public static function mergeRecursiveWithOverrule(array $original, array $overru * Fetches and renders all available flash messages from the queue. * * @access public + * + * @static * - * @param string $queue: The queue's unique identifier + * @param string $queue The queue's unique identifier * * @return string All flash messages in the queue rendered as HTML. */ @@ -658,9 +696,11 @@ public static function renderFlashMessages($queue = 'kitodo.default.flashMessage * * @access public * - * @param string $index_name: The internal "index_name" to translate - * @param string $table: Get the translation from this table - * @param string $pid: Get the translation from this page + * @static + * + * @param string $index_name The internal "index_name" to translate + * @param string $table Get the translation from this table + * @param string $pid Get the translation from this page * * @return string Localized label for $index_name */ @@ -787,8 +827,10 @@ public static function translate($index_name, $table, $pid) * * @access public * - * @param string $table: Table name as defined in TCA - * @param bool $showHidden: Ignore the hidden flag? + * @static + * + * @param string $table Table name as defined in TCA + * @param bool $showHidden Ignore the hidden flag? * * @return string Additional WHERE expression */ @@ -826,6 +868,8 @@ public static function whereExpression($table, $showHidden = false) * Prevent instantiation by hiding the constructor * * @access private + * + * @return void */ private function __construct() { @@ -835,6 +879,10 @@ private function __construct() /** * Returns the LanguageService * + * @access public + * + * @static + * * @return LanguageService */ public static function getLanguageService(): LanguageService @@ -849,6 +897,8 @@ public static function getLanguageService(): LanguageService * * @access public * + * @static + * * @param string $url * * @return string|bool @@ -887,9 +937,11 @@ public static function getUrl(string $url) * * @access public * - * @param mixed $id: The ID value to check + * @static + * + * @param mixed $id The ID value to check * - * @return bool: TRUE if $id is valid XML ID, FALSE otherwise + * @return bool TRUE if $id is valid XML ID, FALSE otherwise */ public static function isValidXmlId($id): bool { diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index f5e40435c..8d5f3fd67 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -481,9 +481,10 @@ public function getLogicalStructure($id, $recursive = false) * * @access protected * - * @param IiifResourceInterface $resource: IIIF resource, either a manifest or range. - * @param bool $recursive: Whether to include the child elements - * @param array $processedStructures: IIIF resources that already have been processed + * @param IiifResourceInterface $resource IIIF resource, either a manifest or range. + * @param bool $recursive Whether to include the child elements + * @param array $processedStructures IIIF resources that already have been processed + * * @return array Logical structure array */ protected function getLogicalStructureInfo(IiifResourceInterface $resource, $recursive = false, &$processedStructures = []) @@ -569,11 +570,11 @@ protected function getLogicalStructureInfo(IiifResourceInterface $resource, $rec * * @access public * - * @param string $id: the ID of the IIIF resource - * @param int $cPid: the configuration folder's id - * @param bool $withDescription: add description / summary to the return value - * @param bool $withRights: add attribution and license / rights and requiredStatement to the return value - * @param bool $withRelated: add related links / homepage to the return value + * @param string $id the ID of the IIIF resource + * @param int $cPid the configuration folder's id + * @param bool $withDescription add description / summary to the return value + * @param bool $withRights add attribution and license / rights and requiredStatement to the return value + * @param bool $withRelated add related links / homepage to the return value * * @return array * @@ -730,7 +731,9 @@ protected function _getSmLinks() * * @access private * - * @param RangeInterface $range: Current range whose canvases shall be linked + * @param RangeInterface $range Current range whose canvases shall be linked + * + * @return void */ private function smLinkRangeCanvasesRecursively(RangeInterface $range) { @@ -755,6 +758,8 @@ private function smLinkRangeCanvasesRecursively(RangeInterface $range) * * @param CanvasInterface $canvas * @param IiifResourceInterface $resource + * + * @return void */ private function smLinkCanvasToResource(CanvasInterface $canvas, IiifResourceInterface $resource) { @@ -976,6 +981,7 @@ public function __wakeup() } /** + * @access public * * @return string[] */ diff --git a/Classes/Common/IiifUrlReader.php b/Classes/Common/IiifUrlReader.php index ba6012b4b..46e1be777 100644 --- a/Classes/Common/IiifUrlReader.php +++ b/Classes/Common/IiifUrlReader.php @@ -49,6 +49,8 @@ public function getContent($url) /** * Return a singleton instance. * + * @access public + * * @static * * @return IiifUrlReader diff --git a/Classes/Common/Indexer.php b/Classes/Common/Indexer.php index e220cc4a4..17c1cae7d 100644 --- a/Classes/Common/Indexer.php +++ b/Classes/Common/Indexer.php @@ -86,7 +86,9 @@ class Indexer * * @access public * - * @param Document $document: The document to add + * @static + * + * @param Document $document The document to add * * @return bool true on success or false on failure */ @@ -197,8 +199,10 @@ public static function add(Document $document, DocumentRepository $documentRepos * * @access public * - * @param string $index_name: The metadata field's name in database - * @param int $pid: UID of the configuration page + * @static + * + * @param string $index_name The metadata field's name in database + * @param int $pid UID of the configuration page * * @return string The field's dynamic index name */ @@ -225,7 +229,9 @@ public static function getIndexFieldName($index_name, $pid = 0) * * @access protected * - * @param int $pid: The configuration page's UID + * @static + * + * @param int $pid The configuration page's UID * * @return void */ @@ -295,8 +301,10 @@ protected static function loadIndexConf($pid) * * @access protected * - * @param Document $document: The METS document - * @param array $logicalUnit: Array of the logical unit to process + * @static + * + * @param Document $document The METS document + * @param array $logicalUnit Array of the logical unit to process * * @return bool true on success or false on failure */ @@ -424,9 +432,11 @@ protected static function processLogical(Document $document, array $logicalUnit) * * @access protected * - * @param Document $document: The METS document - * @param int $page: The page number - * @param array $physicalUnit: Array of the physical unit to process + * @static + * + * @param Document $document The METS document + * @param int $page The page number + * @param array $physicalUnit Array of the physical unit to process * * @return bool true on success or false on failure */ @@ -511,8 +521,10 @@ protected static function processPhysical(Document $document, $page, array $phys * * @access protected * - * @param int $core: UID of the Solr core - * @param int $pid: UID of the configuration page + * @static + * + * @param int $core UID of the Solr core + * @param int $pid UID of the configuration page * * @return bool true on success or false on failure */ @@ -540,10 +552,12 @@ protected static function solrConnect($core, $pid = 0) * * @access private * + * @static + * * @param Query $updateQuery solarium query - * @param Document $document: The METS document - * @param array $unit: Array of the logical or physical unit to process - * @param string $fullText: Text containing full text for indexing + * @param Document $document The METS document + * @param array $unit Array of the logical or physical unit to process + * @param string $fullText Text containing full text for indexing * * @return DocumentInterface */ @@ -567,7 +581,9 @@ private static function getSolrDocument($updateQuery, $document, $unit, $fullTex * * @access private * - * @param array|string $authors: Array or string containing author/authors + * @static + * + * @param array|string $authors Array or string containing author/authors * * @return array|string */ @@ -585,6 +601,8 @@ private static function removeAppendsFromAuthor($authors) { * Prevent instantiation by hiding the constructor * * @access private + * + * @return void */ private function __construct(DocumentRepository $documentRepository) { diff --git a/Classes/Common/KitodoFlashMessageRenderer.php b/Classes/Common/KitodoFlashMessageRenderer.php index 171c2d615..21f9f6091 100644 --- a/Classes/Common/KitodoFlashMessageRenderer.php +++ b/Classes/Common/KitodoFlashMessageRenderer.php @@ -53,8 +53,11 @@ class KitodoFlashMessageRenderer implements FlashMessageRendererInterface /** * Render method + * + * @access public * * @param FlashMessage[] $flashMessages + * * @return string Representation of the flash message */ public function render(array $flashMessages): string @@ -65,6 +68,8 @@ public function render(array $flashMessages): string /** * Gets the message severity class name * + * @access public + * * @param FlashMessage $flashMessage * * @return string The message severity class name @@ -77,6 +82,8 @@ protected function getClass(FlashMessage $flashMessage): string /** * Gets the message severity icon name * + * @access public + * * @param FlashMessage $flashMessage * * @return string The message severity icon name @@ -89,7 +96,10 @@ protected function getIconName(FlashMessage $flashMessage): string /** * Gets the message rendered as clean and secure markup * + * @access public + * * @param FlashMessage[] $flashMessages + * * @return string */ protected function getMessageAsMarkup(array $flashMessages): string diff --git a/Classes/Common/MetadataInterface.php b/Classes/Common/MetadataInterface.php index 6b7e7c27c..b79cd7e9a 100644 --- a/Classes/Common/MetadataInterface.php +++ b/Classes/Common/MetadataInterface.php @@ -29,8 +29,8 @@ interface MetadataInterface * * @access public * - * @param \SimpleXMLElement $xml: The XML to extract the metadata from - * @param array &$metadata: The metadata array to fill + * @param \SimpleXMLElement $xml The XML to extract the metadata from + * @param array &$metadata The metadata array to fill * * @return void */ diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index 3f2ab7858..400884bcb 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -140,12 +140,12 @@ final class MetsDocument extends AbstractDocument /** * This adds metadata from METS structural map to metadata array. * - * @access public + * @access public * - * @param array &$metadata: The metadata array to extend - * @param string $id: The "@ID" attribute of the logical structure node + * @param array &$metadata The metadata array to extend + * @param string $id The "@ID" attribute of the logical structure node * - * @return void + * @return void */ public function addMetadataFromMets(&$metadata, $id) { @@ -292,8 +292,8 @@ public function getLogicalStructure($id, $recursive = false) * * @access protected * - * @param \SimpleXMLElement $structure: The logical structure node - * @param bool $recursive: Whether to include the child elements + * @param \SimpleXMLElement $structure The logical structure node + * @param bool $recursive Whether to include the child elements * * @return array Array of the element's id, label, type and physical page indexes/mptr link */ @@ -631,7 +631,7 @@ class_exists($class) * * @access protected * - * @param string $id: The "@ID" attribute of the file node + * @param string $id The "@ID" attribute of the file node * * @return array */ @@ -831,6 +831,13 @@ protected function _getMdSec() return $this->mdSec; } + /** + * Gets the document's metadata sections + * + * @access protected + * + * @return array Array of metadata sections with their IDs as array key + */ protected function _getDmdSec() { $this->_getMdSec(); @@ -1162,6 +1169,8 @@ protected function _getToplevelId() /** * Try to determine URL of parent document. * + * @access public + * * @return string */ public function _getParentHref() diff --git a/Classes/Common/Solr/Solr.php b/Classes/Common/Solr/Solr.php index 2bbc12ff8..fe2ef26c2 100644 --- a/Classes/Common/Solr/Solr.php +++ b/Classes/Common/Solr/Solr.php @@ -120,7 +120,7 @@ class Solr implements LoggerAwareInterface * * @access public * - * @param string $core: The name of the new core. If empty, the next available core name is used. + * @param string $core The name of the new core. If empty, the next available core name is used. * * @return string The name of the new core */ @@ -168,7 +168,7 @@ public static function createCore($core = '') * * @access public * - * @param string $query: The query string + * @param string $query The query string * * @return string The escaped query string */ @@ -185,8 +185,8 @@ public static function escapeQuery($query) * * @access public * - * @param string $query: The query string - * @param int $pid: The PID for the field configuration + * @param string $query The query string + * @param int $pid The PID for the field configuration * * @return string The escaped query string */ @@ -282,7 +282,7 @@ public static function getFields() * * @access public * - * @param mixed $core: Name or UID of the core to load or null to get core admin endpoint + * @param mixed $core Name or UID of the core to load or null to get core admin endpoint * * @return Solr Instance of this class */ @@ -323,7 +323,7 @@ public static function getInstance($core = null) * * @access public * - * @param int $number: Number to start with + * @param int $number Number to start with * * @return int First unused core number found */ @@ -383,7 +383,7 @@ protected function loadSolrConnectionInfo() * * @access public * - * @param array $parameters: Additional search parameters + * @param array $parameters Additional search parameters * * @return array The Apache Solr Documents that were fetched */ @@ -476,7 +476,7 @@ protected function _getService() * * @access protected * - * @param int $value: The new PID for the metadata definitions + * @param int $value The new PID for the metadata definitions * * @return void */ @@ -490,7 +490,7 @@ protected function _setCPid($value) * * @access protected * - * @param int $value: The max number of results + * @param int $value The max number of results * * @return void */ @@ -504,7 +504,7 @@ protected function _setLimit($value) * * @access protected * - * @param array $value: The query parameters + * @param array $value The query parameters * * @return void */ @@ -518,7 +518,7 @@ protected function _setParams(array $value) * * @access public * - * @param string $var: Name of variable to get + * @param string $var Name of variable to get * * @return mixed Value of $this->$var */ @@ -541,7 +541,7 @@ public function __get($var) * * @access public * - * @param string $var: Name of variable to check + * @param string $var Name of variable to check * * @return bool true if variable is set and not empty, false otherwise */ @@ -555,8 +555,8 @@ public function __isset($var) * * @access public * - * @param string $var: Name of variable to set - * @param mixed $value: New value of variable + * @param string $var Name of variable to set + * @param mixed $value New value of variable * * @return void */ @@ -578,7 +578,7 @@ public function __set($var, $value) * * @access protected * - * @param string|null $core: The name of the core to use or null for core admin endpoint + * @param string|null $core The name of the core to use or null for core admin endpoint * * @return void */ diff --git a/Classes/Common/Solr/SolrSearch.php b/Classes/Common/Solr/SolrSearch.php index 5bc6bc765..c7a7c7e1a 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -78,12 +78,17 @@ class SolrSearch implements \Countable, \Iterator, \ArrayAccess, QueryResultInte protected $position = 0; /** + * Constructs SolrSearch instance. + * + * @access public * * @param DocumentRepository $documentRepository * @param QueryResult|Collection $collection * @param array $settings * @param array $searchParams * @param QueryResult $listedMetadata + * + * @return void */ public function __construct($documentRepository, $collection, $settings, $searchParams, $listedMetadata = null) { @@ -94,11 +99,25 @@ public function __construct($documentRepository, $collection, $settings, $search $this->listedMetadata = $listedMetadata; } + /** + * Gets amount of loaded documents. + * + * @access public + * + * @return int + */ public function getNumLoadedDocuments() { return count($this->result['documents']); } + /** + * Count results. + * + * @access public + * + * @return int + */ public function count(): int { if ($this->result === null) { @@ -108,37 +127,88 @@ public function count(): int return $this->result['numberOfToplevels']; } + /** + * Current result. + * + * @access public + * + * @return SolrSearch + */ public function current() { return $this[$this->position]; } + /** + * Current key. + * + * @access public + * + * @return int + */ public function key() { return $this->position; } + /** + * Next key. + * + * @access public + * + * @return int + */ public function next(): void { $this->position++; } + /** + * First key. + * + * @access public + * + * @return int + */ public function rewind(): void { $this->position = 0; } + /** + * @access public + * + * @return bool + */ public function valid(): bool { return isset($this[$this->position]); } + /** + * Checks if the document with given offset exists. + * + * @access public + * + * @param int $offset + * + * @return bool + */ public function offsetExists($offset): bool { $idx = $this->result['document_keys'][$offset]; return isset($this->result['documents'][$idx]); } + /** + * Gets the document with given offset. + * + * @access public + * + * @param int $offset + * + * @return mixed + */ public function offsetGet($offset) { $idx = $this->result['document_keys'][$offset]; @@ -168,36 +238,96 @@ public function offsetGet($offset) return $document; } + /** + * Not supported. + * + * @access public + * + * @param int $offset + * @param int $value + * + * @return void + * + * @throws \Exception + */ public function offsetSet($offset, $value): void { throw new \Exception("SolrSearch: Modifying result list is not supported"); } + /** + * Not supported. + * + * @access public + * + * @param int $offset + * + * @return void + * + * @throws \Exception + */ public function offsetUnset($offset): void { throw new \Exception("SolrSearch: Modifying result list is not supported"); } + /** + * Gets SOLR results. + * + * @access public + * + * @return mixed + */ public function getSolrResults() { return $this->result['solrResults']; } + /** + * Gets by UID. + * + * @access public + * + * @param int $uid + * + * @return mixed + */ public function getByUid($uid) { return $this->result['documents'][$uid]; } + /** + * Gets query. + * + * @access public + * + * @return SolrSearchQuery + */ public function getQuery() { return new SolrSearchQuery($this); } + /** + * Gets first. + * + * @access public + * + * @return SolrSearch + */ public function getFirst() { return $this[0]; } + /** + * Parses results to array. + * + * @access public + * + * @return array + */ public function toArray() { return array_values($this->result['documents']); @@ -207,12 +337,23 @@ public function toArray() * Get total number of hits. * * This can be accessed in Fluid template using `.numFound`. + * + * @access public + * + * @return int */ public function getNumFound() { return $this->result['numFound']; } + /** + * Prepares SOLR search. + * + * @access public + * + * @return void + */ public function prepare() { // Prepare query parameters. @@ -358,6 +499,17 @@ public function prepare() $this->submit(0, 1, false); } + /** + * Submits SOLR search. + * + * @access public + * + * @param int $start + * @param int $rows + * @param bool $processResults default value is true + * + * @return void + */ public function submit($start, $rows, $processResults = true) { $params = $this->params; @@ -462,7 +614,10 @@ public function submit($start, $rows, $processResults = true) /** * Find all listed metadata using specified query params. * - * @param int $queryParams + * @access protected + * + * @param array $queryParams + * * @return array */ protected function fetchToplevelMetadataFromSolr($queryParams) @@ -508,10 +663,10 @@ protected function fetchToplevelMetadataFromSolr($queryParams) /** * Processes a search request * - * @access public + * @access protected * - * @param array $parameters: Additional search parameters - * @param boolean $enableCache: Enable caching of Solr requests + * @param array $parameters Additional search parameters + * @param boolean $enableCache Enable caching of Solr requests * * @return array The Apache Solr Documents that were fetched */ @@ -608,6 +763,18 @@ protected function searchSolr($parameters = [], $enableCache = true) return $resultSet; } + /** + * Gets a document + * + * @access private + * + * @param array $record + * @param array $highlighting + * @param array $fields + * @param array $parameters + * + * @return array The Apache Solr Documents that were fetched + */ private function getDocument($record, $highlighting, $fields, $parameters) { $resultDocument = new ResultDocument($record, $highlighting, $fields); diff --git a/Classes/Common/Solr/SolrSearchQuery.php b/Classes/Common/Solr/SolrSearchQuery.php index da0cbc773..98fd5ad45 100644 --- a/Classes/Common/Solr/SolrSearchQuery.php +++ b/Classes/Common/Solr/SolrSearchQuery.php @@ -38,6 +38,15 @@ class SolrSearchQuery implements QueryInterface */ private $offset; + /** + * Constructs SolrSearchQuery instance. + * + * @access public + * + * @param SolrSearch $solrSearch + * + * @return void + */ public function __construct($solrSearch) { $this->solrSearch = $solrSearch; @@ -48,6 +57,15 @@ public function __construct($solrSearch) public function getSource() {} + /** + * Executes SOLR search query. + * + * @access public + * + * @param bool $returnRawQueryResult + * + * @return array + */ public function execute($returnRawQueryResult = false) { $this->solrSearch->submit($this->offset, $this->limit); @@ -63,12 +81,30 @@ public function execute($returnRawQueryResult = false) public function setOrderings(array $orderings) {} + /** + * Sets limit for SOLR search query. + * + * @access public + * + * @param int $limit + * + * @return SolrSearchQuery + */ public function setLimit($limit) { $this->limit = $limit; return $this; } + /** + * Sets offset for SOLR search query. + * + * @access public + * + * @param int $offset + * + * @return SolrSearchQuery + */ public function setOffset($offset) { $this->offset = $offset; @@ -98,11 +134,25 @@ public function count() public function getOrderings() {} + /** + * Gets limit for SOLR search query. + * + * @access public + * + * @return int + */ public function getLimit() { return $this->limit; } + /** + * Gets offset for SOLR search query. + * + * @access public + * + * @return int + */ public function getOffset() { return $this->offset; diff --git a/Classes/Common/StdOutStream.php b/Classes/Common/StdOutStream.php index fcbaf24a7..2a12b674f 100644 --- a/Classes/Common/StdOutStream.php +++ b/Classes/Common/StdOutStream.php @@ -28,6 +28,11 @@ class StdOutStream implements StreamInterface, SelfEmittableStreamInterface { use StreamDecoratorTrait; + /** + * @access public + * + * @return void + */ public function emit() { // Disable output buffering diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 8d806f115..5ff09d569 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -46,7 +46,11 @@ abstract class AbstractController extends ActionController implements LoggerAwar protected $documentRepository; /** + * @access public + * * @param DocumentRepository $documentRepository + * + * @return void */ public function injectDocumentRepository(DocumentRepository $documentRepository) { @@ -81,6 +85,7 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) * Initialize the plugin controller * * @access protected + * * @return void */ protected function initialize() @@ -105,7 +110,7 @@ protected function initialize() * * @access protected * - * @param int $documentId: The document's UID (fallback: $this->requestData[id]) + * @param int $documentId The document's UID (fallback: $this->requestData[id]) * * @return void */ @@ -199,6 +204,8 @@ protected function configureProxyUrl(&$url) { /** * Checks if doc is missing or is empty (no pages) * + * @access protected + * * @return boolean */ protected function isDocMissingOrEmpty() @@ -209,6 +216,8 @@ protected function isDocMissingOrEmpty() /** * Checks if doc is missing * + * @access protected + * * @return boolean */ protected function isDocMissing() @@ -219,6 +228,8 @@ protected function isDocMissing() /** * Returns the LanguageService * + * @access protected + * * @return LanguageService */ protected function getLanguageService(): LanguageService @@ -227,8 +238,9 @@ protected function getLanguageService(): LanguageService } /** - * Safely gets Parameters from request - * if they exist + * Safely gets Parameters from request if they exist + * + * @access protected * * @param string $parameterName * diff --git a/Classes/Controller/AudioPlayerController.php b/Classes/Controller/AudioPlayerController.php index 23c368085..49c4023e1 100644 --- a/Classes/Controller/AudioPlayerController.php +++ b/Classes/Controller/AudioPlayerController.php @@ -69,6 +69,8 @@ protected function addPlayerJS() /** * The main method of the plugin * + * @access public + * * @return void */ public function mainAction() diff --git a/Classes/Controller/Backend/NewTenantController.php b/Classes/Controller/Backend/NewTenantController.php index 2f1973b8c..b6b13989e 100644 --- a/Classes/Controller/Backend/NewTenantController.php +++ b/Classes/Controller/Backend/NewTenantController.php @@ -80,7 +80,11 @@ class NewTenantController extends AbstractController protected $formatRepository; /** + * @access public + * * @param FormatRepository $formatRepository + * + * @return void */ public function injectFormatRepository(FormatRepository $formatRepository) { @@ -94,7 +98,11 @@ public function injectFormatRepository(FormatRepository $formatRepository) protected $metadataRepository; /** + * @access public + * * @param MetadataRepository $metadataRepository + * + * @return void */ public function injectMetadataRepository(MetadataRepository $metadataRepository) { @@ -108,7 +116,11 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) protected $structureRepository; /** + * @access public + * * @param StructureRepository $structureRepository + * + * @return void */ public function injectStructureRepository(StructureRepository $structureRepository) { @@ -122,7 +134,11 @@ public function injectStructureRepository(StructureRepository $structureReposito protected $solrCoreRepository; /** + * @access public + * * @param SolrCoreRepository $solrCoreRepository + * + * @return void */ public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository) { @@ -132,6 +148,9 @@ public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository) /** * Initialization for all actions * + * @access protected + * + * @return void */ protected function initializeAction() { @@ -154,6 +173,10 @@ protected function initializeAction() /** * Action adding formats records + * + * @access public + * + * @return void */ public function addFormatAction() { @@ -192,6 +215,10 @@ public function addFormatAction() /** * Action adding metadata records + * + * @access public + * + * @return void */ public function addMetadataAction() { @@ -267,6 +294,10 @@ public function addMetadataAction() /** * Action adding Solr core records + * + * @access public + * + * @return void */ public function addSolrCoreAction() { @@ -299,6 +330,10 @@ public function addSolrCoreAction() /** * Action adding structure records + * + * @access public + * + * @return void */ public function addStructureAction() { @@ -349,8 +384,11 @@ public function addStructureAction() /** * Set up the doc header properly here + * + * @access protected * * @param ViewInterface $view + * * @return void */ protected function initializeView(ViewInterface $view) @@ -371,6 +409,7 @@ protected function initializeView(ViewInterface $view) * * @access public * + * @return void */ public function indexAction() { @@ -402,6 +441,7 @@ public function indexAction() * * @access public * + * @return void */ public function errorAction() { @@ -409,12 +449,14 @@ public function errorAction() /** * Get language label for given key and language. + * + * @access protected * * @param string $index * @param string $lang * @param array $langArray * - * @access public + * @return string */ protected function getLLL($index, $lang, $langArray) { diff --git a/Classes/Controller/BasketController.php b/Classes/Controller/BasketController.php index 7731d3157..36cabf723 100644 --- a/Classes/Controller/BasketController.php +++ b/Classes/Controller/BasketController.php @@ -42,7 +42,11 @@ class BasketController extends AbstractController protected $basketRepository; /** + * @access public + * * @param BasketRepository $basketRepository + * + * @return void */ public function injectBasketRepository(BasketRepository $basketRepository) { @@ -56,7 +60,11 @@ public function injectBasketRepository(BasketRepository $basketRepository) protected $mailRepository; /** + * @access public + * * @param MailRepository $mailRepository + * + * @return void */ public function injectMailRepository(MailRepository $mailRepository) { @@ -70,7 +78,11 @@ public function injectMailRepository(MailRepository $mailRepository) protected $printerRepository; /** + * @access public + * * @param PrinterRepository $printerRepository + * + * @return void */ public function injectPrinterRepository(PrinterRepository $printerRepository) { @@ -84,7 +96,11 @@ public function injectPrinterRepository(PrinterRepository $printerRepository) protected $actionLogRepository; /** + * @access public + * * @param ActionLogRepository $actionLogRepository + * + * @return void */ public function injectActionLogRepository(ActionLogRepository $actionLogRepository) { @@ -93,6 +109,8 @@ public function injectActionLogRepository(ActionLogRepository $actionLogReposito /** * Different actions which depends on the chosen action (form) + * + * @access public * * @return void */ @@ -141,6 +159,8 @@ public function basketAction() /** * Add documents to the basket * + * @access public + * * @return void */ public function addAction() @@ -160,6 +180,8 @@ public function addAction() /** * The main method of the plugin * + * @access public + * * @return void */ public function mainAction() @@ -206,6 +228,8 @@ public function mainAction() /** * The basket data from user session. + * + * @access protected * * @return Basket The found data from user session. */ @@ -244,8 +268,7 @@ protected function getBasketData() * * @access protected * - * @param array $data: DocumentData - * @param array $template: Template information + * @param array $data DocumentData * * @return string One basket entry */ @@ -294,13 +317,14 @@ protected function getEntry($data) } /** - * Returns the downloadurl configured in the basket + * Returns the download url configured in the basket * * @access protected * - * @param int $id: Document id + * @param int $id Document id + * @param array $data DocumentData * - * @return mixed download url or false + * @return string|false download url or false */ protected function getDocumentData($id, $data) { @@ -366,8 +390,8 @@ protected function getDocumentData($id, $data) * * @access protected * - * @param array $_piVars: piVars - * @param Basket $basket: basket object + * @param array $_piVars piVars + * @param Basket $basket basket object * * @return array Basket data and JavaScript output */ @@ -471,8 +495,8 @@ protected function addToBasket($_piVars, $basket) * * @access protected * - * @param array $_piVars: plugin variables - * @param Basket $basket: basket object + * @param array $_piVars plugin variables + * @param Basket $basket basket object * * @return Basket basket */ @@ -589,6 +613,7 @@ protected function sendMail() * Sends document information to an external printer (url) * * @access protected + * * @param Basket basket object * * @return void diff --git a/Classes/Controller/CalendarController.php b/Classes/Controller/CalendarController.php index 0fa51b3a6..97900de8f 100644 --- a/Classes/Controller/CalendarController.php +++ b/Classes/Controller/CalendarController.php @@ -32,7 +32,11 @@ class CalendarController extends AbstractController protected $structureRepository; /** + * @access public + * * @param StructureRepository $structureRepository + * + * @return void */ public function injectStructureRepository(StructureRepository $structureRepository) { @@ -48,6 +52,8 @@ public function injectStructureRepository(StructureRepository $structureReposito /** * The main method of the plugin * + * @access public + * * @return void */ public function mainAction() @@ -91,8 +97,8 @@ public function mainAction() * * @access public * - * @param string $content: The PlugIn content - * @param array $conf: The PlugIn configuration + * @param string $content The PlugIn content + * @param array $conf The PlugIn configuration * * @return void */ diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index ab723f0bd..83153bca2 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -35,7 +35,11 @@ class CollectionController extends AbstractController protected $collectionRepository; /** + * @access public + * * @param CollectionRepository $collectionRepository + * + * @return void */ public function injectCollectionRepository(CollectionRepository $collectionRepository) { @@ -49,7 +53,11 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos protected $metadataRepository; /** + * @access public + * * @param MetadataRepository $metadataRepository + * + * @return void */ public function injectMetadataRepository(MetadataRepository $metadataRepository) { @@ -59,6 +67,8 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) /** * Show a list of collections * + * @access public + * * @return void */ public function listAction() @@ -147,7 +157,7 @@ public function listAction() * * @access protected * - * @param Collection $collection: The collection object + * @param Collection $collection The collection object * * @return void */ @@ -155,7 +165,7 @@ public function showAction(Collection $collection) { $searchParams = $this->getParametersSafely('searchParameter'); - // Instaniate the Solr. Without Solr present, we can't do anything. + // Instantiate the Solr. Without Solr present, we can't do anything. $solr = Solr::getInstance($this->settings['solrcore']); if (!$solr->ready) { $this->logger->error('Apache Solr not available'); @@ -200,7 +210,7 @@ public function showAction(Collection $collection) /** * This is an uncached helper action to make sorting possible on collection single views. * - * @access protected + * @access public * * @return void */ diff --git a/Classes/Controller/FeedsController.php b/Classes/Controller/FeedsController.php index 2f0862d6a..363cc123e 100644 --- a/Classes/Controller/FeedsController.php +++ b/Classes/Controller/FeedsController.php @@ -44,6 +44,8 @@ public function injectLibraryRepository(LibraryRepository $libraryRepository) /** * Initializes the current action * + * @access public + * * @return void */ public function initializeAction() @@ -54,6 +56,8 @@ public function initializeAction() /** * The main method of the plugin * + * @access public + * * @return void */ public function mainAction() diff --git a/Classes/Controller/ListViewController.php b/Classes/Controller/ListViewController.php index 690ab052f..75d24d1af 100644 --- a/Classes/Controller/ListViewController.php +++ b/Classes/Controller/ListViewController.php @@ -33,7 +33,11 @@ class ListViewController extends AbstractController protected $collectionRepository; /** + * @access public + * * @param CollectionRepository $collectionRepository + * + * @return void */ public function injectCollectionRepository(CollectionRepository $collectionRepository) { @@ -47,7 +51,11 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos protected $metadataRepository; /** + * @access public + * * @param MetadataRepository $metadataRepository + * + * @return void */ public function injectMetadataRepository(MetadataRepository $metadataRepository) { @@ -63,6 +71,8 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) /** * The main method of the plugin * + * @access public + * * @return void */ public function mainAction() diff --git a/Classes/Controller/MetadataController.php b/Classes/Controller/MetadataController.php index 056f75077..7b68ffbc9 100644 --- a/Classes/Controller/MetadataController.php +++ b/Classes/Controller/MetadataController.php @@ -31,7 +31,7 @@ class MetadataController extends AbstractController { /** * @access private - * @var Doc + * @var AbstractDocument */ private $doc; @@ -42,7 +42,11 @@ class MetadataController extends AbstractController protected $collectionRepository; /** + * @access public + * * @param CollectionRepository $collectionRepository + * + * @return void */ public function injectCollectionRepository(CollectionRepository $collectionRepository) { @@ -56,7 +60,11 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos protected $metadataRepository; /** + * @access public + * * @param MetadataRepository $metadataRepository + * + * @return void */ public function injectMetadataRepository(MetadataRepository $metadataRepository) { @@ -70,7 +78,11 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) protected $structureRepository; /** + * @access public + * * @param StructureRepository $structureRepository + * + * @return void */ public function injectStructureRepository(StructureRepository $structureRepository) { @@ -78,6 +90,8 @@ public function injectStructureRepository(StructureRepository $structureReposito } /** + * @access public + * * @return void */ public function mainAction() @@ -120,8 +134,8 @@ public function mainAction() * * @access protected * - * @param array $metadata: The metadata array - * @param bool $useOriginalIiifManifestMetadata: Output IIIF metadata as simple key/value pairs? + * @param array $metadata The metadata array + * @param bool $useOriginalIiifManifestMetadata Output IIIF metadata as simple key/value pairs? * * @return string The metadata array ready for output */ @@ -404,8 +418,8 @@ private function getMetadata() * * @access private * - * @param array $id: An array with ids - * @param array $metadata: An array with metadata + * @param array $id An array with ids + * @param array $metadata An array with metadata * * @return array metadata */ diff --git a/Classes/Controller/NavigationController.php b/Classes/Controller/NavigationController.php index 21b03a913..2f95d7576 100644 --- a/Classes/Controller/NavigationController.php +++ b/Classes/Controller/NavigationController.php @@ -25,8 +25,12 @@ class NavigationController extends AbstractController { /** - * Method to get the page select values and use them with chash + * Method to get the page select values and use them with cHash + * + * @access public + * * @param PageSelectForm|NULL $pageSelectForm + * * @return void */ public function pageSelectAction(PageSelectForm $pageSelectForm = NULL) { @@ -49,6 +53,8 @@ public function pageSelectAction(PageSelectForm $pageSelectForm = NULL) { /** * The main method of the plugin * + * @access public + * * @return void */ public function mainAction() diff --git a/Classes/Controller/OaiPmhController.php b/Classes/Controller/OaiPmhController.php index 572af11fa..edb567ff5 100644 --- a/Classes/Controller/OaiPmhController.php +++ b/Classes/Controller/OaiPmhController.php @@ -35,7 +35,11 @@ class OaiPmhController extends AbstractController protected $tokenRepository; /** + * @access public + * * @param TokenRepository $tokenRepository + * + * @return void */ public function injectTokenRepository(TokenRepository $tokenRepository) { @@ -49,7 +53,11 @@ public function injectTokenRepository(TokenRepository $tokenRepository) protected $collectionRepository; /** + * @access public + * * @param CollectionRepository $collectionRepository + * + * @return void */ public function injectCollectionRepository(CollectionRepository $collectionRepository) { @@ -63,7 +71,11 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos protected $libraryRepository; /** + * @access public + * * @param LibraryRepository $libraryRepository + * + * @return void */ public function injectLibraryRepository(LibraryRepository $libraryRepository) { @@ -73,6 +85,8 @@ public function injectLibraryRepository(LibraryRepository $libraryRepository) /** * Initializes the current action * + * @access public + * * @return void */ public function initializeAction() @@ -161,9 +175,9 @@ protected function getUrlParams() * * @access protected * - * @param array $record : The full record array + * @param array $record The full record array * - * @return array $metadata: The mapped metadata array + * @return array The mapped metadata array */ protected function getDcData(array $record) { @@ -198,6 +212,8 @@ protected function getDcData(array $record) } /** + * @access private + * * @param array $metadata The mapped metadata array * @param string $key The key to which record value should be assigned * @param string $value The key from record array @@ -216,9 +232,9 @@ private function addDcData(&$metadata, $key, $value) { * * @access protected * - * @param array $record : The full record array + * @param array $record The full record array * - * @return string: The fetched METS XML + * @return string The fetched METS XML */ protected function getMetsData(array $record) { @@ -242,6 +258,8 @@ protected function getMetsData(array $record) /** * The main method of the plugin * + * @access public + * * @return void */ public function mainAction() @@ -680,6 +698,7 @@ protected function fetchDocumentUIDs() /** * Fetch more information for document list + * * @access protected * * @param array $documentListSet diff --git a/Classes/Controller/PageGridController.php b/Classes/Controller/PageGridController.php index dd3877350..63265cf16 100644 --- a/Classes/Controller/PageGridController.php +++ b/Classes/Controller/PageGridController.php @@ -30,6 +30,8 @@ class PageGridController extends AbstractController /** * The main method of the plugin * + * @access public + * * @return void */ public function mainAction() @@ -78,8 +80,8 @@ public function mainAction() * * @access protected * - * @param int $number: The page to render - * @param string $fileGrpThumbs: the file group(s) of thumbs + * @param int $number The page to render + * @param string $fileGrpThumbs the file group(s) of thumbs * * @return array The rendered entry ready for fluid */ diff --git a/Classes/Controller/PageViewController.php b/Classes/Controller/PageViewController.php index fb74989c5..10ac217d9 100644 --- a/Classes/Controller/PageViewController.php +++ b/Classes/Controller/PageViewController.php @@ -56,6 +56,8 @@ class PageViewController extends AbstractController /** * The main method of the plugin * + * @access public + * * @return void */ public function mainAction() @@ -96,7 +98,7 @@ public function mainAction() * * @access protected * - * @param int $page: Page number + * @param int $page Page number * * @return array URL and MIME type of fulltext file */ @@ -157,9 +159,8 @@ protected function addViewerJS() * * @access protected * - * @param int $page: Page number - * @return array An array containing the IRIs of the AnnotationLists / AnnotationPages as well as - * some information about the canvas. + * @param int $page Page number + * @return array An array containing the IRIs of the AnnotationLists / AnnotationPages as well as some information about the canvas. */ protected function getAnnotationContainers($page) { @@ -214,7 +215,7 @@ protected function getAnnotationContainers($page) * * @access protected * - * @param int $page: Page number + * @param int $page Page number * * @return array URL and MIME type of image file */ diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index e13910d05..7006f13dd 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -38,7 +38,11 @@ class SearchController extends AbstractController protected $collectionRepository; /** + * @access public + * * @param CollectionRepository $collectionRepository + * + * @return void */ public function injectCollectionRepository(CollectionRepository $collectionRepository) { @@ -52,7 +56,11 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos protected $metadataRepository; /** + * @access public + * * @param MetadataRepository $metadataRepository + * + * @return void */ public function injectMetadataRepository(MetadataRepository $metadataRepository) { @@ -68,6 +76,8 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) /** * Search Action * + * @access public + * * @return void */ public function searchAction() @@ -84,6 +94,8 @@ public function searchAction() * * This shows the search form and optional the facets and extended search form. * + * @access public + * * @return void */ public function mainAction() @@ -210,8 +222,7 @@ protected function addFacetsMenu() * * @access public * - * @param string $content: The PlugIn content - * @param array $conf: The PlugIn configuration + * @param array $facets * * @return array HMENU array */ @@ -402,11 +413,11 @@ private function addCollectionsQuery($query) { * * @access private * - * @param string $field: The facet's index_name - * @param string $value: The facet's value - * @param int $count: Number of hits for this facet - * @param array $search: The parameters of the current search query - * @param string &$state: The state of the parent item + * @param string $field The facet's index_name + * @param string $value The facet's value + * @param int $count Number of hits for this facet + * @param array $search The parameters of the current search query + * @param string &$state The state of the parent item * * @return array The array for the facet's menu entry */ @@ -492,8 +503,10 @@ private function processResults($facet, $facetCollectionArray, $search) { /** * Translates value depending on the index name. * - * @param string $field: The facet's index_name - * @param string $value: The facet's value + * @access private + * + * @param string $field The facet's index_name + * @param string $value The facet's value * * @return string */ diff --git a/Classes/Controller/StatisticsController.php b/Classes/Controller/StatisticsController.php index e8cded48d..336caeab3 100644 --- a/Classes/Controller/StatisticsController.php +++ b/Classes/Controller/StatisticsController.php @@ -26,6 +26,8 @@ class StatisticsController extends AbstractController /** * The main method of the plugin * + * @access public + * * @return void */ public function mainAction() diff --git a/Classes/Controller/TableOfContentsController.php b/Classes/Controller/TableOfContentsController.php index 7b2f7cd5f..209c4b7da 100644 --- a/Classes/Controller/TableOfContentsController.php +++ b/Classes/Controller/TableOfContentsController.php @@ -110,8 +110,8 @@ private function makeMenuArray() * * @access private * - * @param array $entry : The entry's array from AbstractDocument->getLogicalStructure - * @param bool $recursive : Whether to include the child entries + * @param array $entry The entry's array from AbstractDocument->getLogicalStructure + * @param bool $recursive Whether to include the child entries * * @return array HMENU array for menu entry */ @@ -212,6 +212,7 @@ private function getMenuEntry(array $entry, $recursive = false) * @access private * * @param array $entry + * * @return array */ private function resolveMenuEntry($entry) diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index afad6a47e..8b090c820 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -35,6 +35,8 @@ class ToolboxController extends AbstractController /** * The main method of the plugin * + * @access public + * * @return void */ public function mainAction() @@ -101,6 +103,8 @@ private function renderTool() { * * @access private * + * @param string $tool name + * * @return void */ private function renderToolByName(string $tool) { @@ -218,7 +222,7 @@ private function renderImageDownloadTool() * * @access private * - * @param int $page: Page number + * @param int $page Page number * * @return array Array of image links and image format information */ diff --git a/Classes/Controller/View3DController.php b/Classes/Controller/View3DController.php index 4d213c0b7..3c8fae78f 100644 --- a/Classes/Controller/View3DController.php +++ b/Classes/Controller/View3DController.php @@ -22,6 +22,8 @@ class View3DController extends AbstractController { /** + * @access public + * * @return void */ public function mainAction() diff --git a/Classes/Domain/Repository/CollectionRepository.php b/Classes/Domain/Repository/CollectionRepository.php index 4288f3bd2..b6c373788 100644 --- a/Classes/Domain/Repository/CollectionRepository.php +++ b/Classes/Domain/Repository/CollectionRepository.php @@ -40,6 +40,8 @@ class CollectionRepository extends Repository /** * Finds all collections * + * @access public + * * @param string $uids separated by comma * * @return QueryResultInterface @@ -58,6 +60,15 @@ public function findAllByUids($uids) return $query->execute(); } + /** + * Finds all collections + * + * @access public + * + * @param string $pages + * + * @return QueryResultInterface + */ public function getCollectionForMetadata($pages) { // Get list of collections to show. @@ -71,6 +82,8 @@ public function getCollectionForMetadata($pages) /** * Finds all collection for the given settings * + * @access public + * * @param array $settings * * @return array|QueryResultInterface @@ -113,6 +126,16 @@ public function findCollectionsBySettings($settings = []) return $query->execute(); } + /** + * Gets index name for SOLR + * + * @access public + * + * @param array $settings + * @param mixed $set + * + * @return array|QueryResultInterface + */ public function getIndexNameForSolr($settings, $set) { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) diff --git a/Classes/Domain/Repository/DocumentRepository.php b/Classes/Domain/Repository/DocumentRepository.php index 026bd1662..5afd9de8f 100644 --- a/Classes/Domain/Repository/DocumentRepository.php +++ b/Classes/Domain/Repository/DocumentRepository.php @@ -54,6 +54,8 @@ class DocumentRepository extends Repository * * Currently used by EXT:slub_digitalcollections * + * @access public + * * @param array $parameters * * @return Document|null @@ -101,6 +103,8 @@ public function findOneByParameters($parameters) /** * Find the oldest document * + * @access public + * * @return Document|null */ public function findOldestDocument() @@ -114,9 +118,12 @@ public function findOldestDocument() } /** + * @access public + * * @param int $partOf * @param Structure $structure - * @return array|QueryResultInterface + * + * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface */ public function getChildrenOfYearAnchor($partOf, $structure) { @@ -135,6 +142,8 @@ public function getChildrenOfYearAnchor($partOf, $structure) /** * Finds all documents for the given settings * + * @access public + * * @param int $uid * @param array $settings * @@ -150,9 +159,11 @@ public function findOneByIdAndSettings($uid, $settings = []) /** * Finds all documents for the given settings * + * @access public + * * @param array $settings * - * @return array|QueryResultInterface + * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface */ public function findDocumentsBySettings($settings = []) { @@ -180,10 +191,12 @@ public function findDocumentsBySettings($settings = []) /** * Finds all documents for the given collections * + * @access public + * * @param array $collections * @param int $limit * - * @return array|QueryResultInterface + * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface */ public function findAllByCollectionsLimited($collections, $limit = 50) { @@ -219,6 +232,8 @@ public function findAllByCollectionsLimited($collections, $limit = 50) * a) "leaf" elements i.e. partof != 0 * b) "root" elements that are not referenced by other documents ("root" elements that have no descendants) * + * @access public + * * @param array $settings * * @return array @@ -352,6 +367,8 @@ public function getStatisticsForSelectedCollection($settings) /** * Build table of contents * + * @access public + * * @param int $uid * @param int $pid * @param array $settings @@ -402,6 +419,8 @@ public function getTableOfContentsFromDb($uid, $pid, $settings) /** * Find one document by given settings and identifier * + * @access public + * * @param array $settings * @param array $parameters * @@ -443,6 +462,8 @@ public function getOaiRecord($settings, $parameters) /** * Finds all documents for the given settings * + * @access public + * * @param array $settings * @param array $documentsToProcess * @@ -479,6 +500,8 @@ public function getOaiDocumentList($settings, $documentsToProcess) /** * Finds all documents with given uids * + * @access public + * * @param array $uids * @param array $checkPartof Whether or not to also match $uids against partof. * @@ -528,7 +551,7 @@ public function findAllByUids($uids, $checkPartof = false) } /** - * + * @access public * * @param array $uids * @@ -550,10 +573,13 @@ public function findChildrenOfEach(array $uids) /** * Find all documents with given collection from Solr * + * @access public + * * @param QueryResult|Collection $collection * @param array $settings * @param array $searchParams * @param QueryResult $listedMetadata + * * @return SolrSearch */ public function findSolrByCollection($collection, $settings, $searchParams, $listedMetadata = null) diff --git a/Classes/Domain/Repository/MailRepository.php b/Classes/Domain/Repository/MailRepository.php index c06d7cebd..31c666549 100644 --- a/Classes/Domain/Repository/MailRepository.php +++ b/Classes/Domain/Repository/MailRepository.php @@ -27,6 +27,15 @@ class MailRepository extends Repository { + /** + * Find all mails by pid. + * + * @access public + * + * @param int @pid + * + * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface + */ public function findAllWithPid($pid) { /** @var Typo3QuerySettings $querySettings */ diff --git a/Classes/Domain/Repository/MetadataRepository.php b/Classes/Domain/Repository/MetadataRepository.php index b13979dd7..e5beecc9b 100644 --- a/Classes/Domain/Repository/MetadataRepository.php +++ b/Classes/Domain/Repository/MetadataRepository.php @@ -29,6 +29,8 @@ class MetadataRepository extends Repository /** * Finds all collection for the given settings * + * @access public + * * @param array $settings * * @return array|QueryResultInterface diff --git a/Classes/Domain/Repository/TokenRepository.php b/Classes/Domain/Repository/TokenRepository.php index 4f14dc371..b8799baa5 100644 --- a/Classes/Domain/Repository/TokenRepository.php +++ b/Classes/Domain/Repository/TokenRepository.php @@ -27,6 +27,8 @@ class TokenRepository extends Repository /** * Delete all expired token * + * @access public + * * @param int $expireTime * * @return void diff --git a/Classes/Eid/PageViewProxy.php b/Classes/Eid/PageViewProxy.php index e31d49a60..096c01f62 100644 --- a/Classes/Eid/PageViewProxy.php +++ b/Classes/Eid/PageViewProxy.php @@ -48,6 +48,13 @@ class PageViewProxy */ protected $extConf; + /** + * Constructs the instance + * + * @access public + * + * @return void + */ public function __construct() { $this->requestFactory = GeneralUtility::makeInstance(RequestFactory::class); @@ -57,9 +64,12 @@ public function __construct() /** * Return a response that is derived from $response and contains CORS * headers to be sent to the client. + * + * @access protected * - * @return ResponseInterface $response - * @return ServerRequestInterface $request The incoming request. + * @param ResponseInterface $response + * @param ServerRequestInterface $request The incoming request. + * * @return ResponseInterface */ protected function withCorsResponseHeaders( @@ -78,9 +88,12 @@ protected function withCorsResponseHeaders( * Takes headers listed in $headerNames from $fromResponse, adds them to * $toResponse and returns the result. * + * @access protected + * * @param ResponseInterface $fromResponse * @param ResponseInterface $toResponse * @param array $headerNames + * * @return ResponseInterface */ protected function copyHeaders( @@ -104,7 +117,10 @@ protected function copyHeaders( /** * Handle an OPTIONS request. * + * @access protected + * * @param ServerRequestInterface $request + * * @return ResponseInterface */ protected function handleOptions(ServerRequestInterface $request): ResponseInterface @@ -118,7 +134,10 @@ protected function handleOptions(ServerRequestInterface $request): ResponseInter /** * Handle an HEAD request. * + * @access protected + * * @param ServerRequestInterface $request + * * @return ResponseInterface */ protected function handleHead(ServerRequestInterface $request): ResponseInterface @@ -151,7 +170,10 @@ protected function handleHead(ServerRequestInterface $request): ResponseInterfac /** * Handle a GET request. * + * @access protected + * * @param ServerRequestInterface $request + * * @return ResponseInterface */ protected function handleGet(ServerRequestInterface $request): ResponseInterface @@ -208,6 +230,7 @@ protected function handleGet(ServerRequestInterface $request): ResponseInterface * @access public * * @param ServerRequestInterface $request + * * @return ResponseInterface */ public function main(ServerRequestInterface $request) diff --git a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php index c852fa2ef..cc7935b34 100644 --- a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php +++ b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php @@ -38,6 +38,8 @@ class DocumentTypeFunctionProvider implements ExpressionFunctionProviderInterfac use LoggerAwareTrait; /** + * @access public + * * @return ExpressionFunction[] An array of Function instances */ public function getFunctions() @@ -80,6 +82,8 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) /** * Initialize the extbase repositories * + * @access protected + * * @param int $storagePid The storage pid * * @return void @@ -97,6 +101,8 @@ protected function initializeRepositories($storagePid) /** * Shortcut function to access field values * + * @access protected + * * @return ExpressionFunction */ protected function getDocumentTypeFunction(): ExpressionFunction @@ -149,8 +155,8 @@ function($arguments, $cPid) * * @access protected * - * @param array $requestData: The request data - * @param int $pid: Storage Pid + * @param array $requestData The request data + * @param int $pid Storage Pid * * @return void */ diff --git a/Classes/ExpressionLanguage/DocumentTypeProvider.php b/Classes/ExpressionLanguage/DocumentTypeProvider.php index c841fcd13..fd10ead97 100644 --- a/Classes/ExpressionLanguage/DocumentTypeProvider.php +++ b/Classes/ExpressionLanguage/DocumentTypeProvider.php @@ -24,6 +24,13 @@ */ class DocumentTypeProvider extends AbstractProvider { + /** + * Construct the instance + * + * @access public + * + * @return void + */ public function __construct() { $this->expressionLanguageProviders = [ diff --git a/Classes/Format/Alto.php b/Classes/Format/Alto.php index 410d0a2f8..01ea86d25 100644 --- a/Classes/Format/Alto.php +++ b/Classes/Format/Alto.php @@ -29,7 +29,7 @@ class Alto implements \Kitodo\Dlf\Common\FulltextInterface * * @access public * - * @param \SimpleXMLElement $xml: The XML to extract the raw text from + * @param \SimpleXMLElement $xml The XML to extract the raw text from * * @return string The raw unformatted fulltext */ @@ -62,7 +62,7 @@ public function getRawText(\SimpleXMLElement $xml) * * @access public * - * @param \SimpleXMLElement $xml: The XML to extract the raw text from + * @param \SimpleXMLElement $xml The XML to extract the raw text from * * @return string The unformatted fulltext in MiniOCR format */ @@ -107,7 +107,7 @@ public function getTextAsMiniOcr(\SimpleXMLElement $xml) * * @access private * - * @param \SimpleXMLElement $attributes: The XML to extract the word + * @param \SimpleXMLElement $attributes The XML to extract the word * * @return string The parsed word extracted from attribute */ @@ -127,7 +127,7 @@ private function getWord($attributes) * * @access private * - * @param \SimpleXMLElement $attributes: The XML to extract the word coordinates + * @param \SimpleXMLElement $attributes The XML to extract the word coordinates * * @return string The parsed word coordinates extracted from attribute */ diff --git a/Classes/Format/AudioVideoMD.php b/Classes/Format/AudioVideoMD.php index 391192eb8..52a6f0b30 100644 --- a/Classes/Format/AudioVideoMD.php +++ b/Classes/Format/AudioVideoMD.php @@ -32,8 +32,8 @@ class AudioVideoMD implements MetadataInterface * * @access public * - * @param \SimpleXMLElement $xml: The XML to extract the metadata from - * @param array &$metadata: The metadata array to fill + * @param \SimpleXMLElement $xml The XML to extract the metadata from + * @param array &$metadata The metadata array to fill * * @return void */ diff --git a/Classes/Format/Mods.php b/Classes/Format/Mods.php index 9ec023452..295a01183 100644 --- a/Classes/Format/Mods.php +++ b/Classes/Format/Mods.php @@ -43,8 +43,8 @@ class Mods implements MetadataInterface * * @access public * - * @param \SimpleXMLElement $xml: The XML to extract the metadata from - * @param array &$metadata: The metadata array to fill + * @param \SimpleXMLElement $xml The XML to extract the metadata from + * @param array &$metadata The metadata array to fill * * @return void */ @@ -92,6 +92,17 @@ private function getAuthors() { } } + /** + * Get author from ORCID API. + * + * @access private + * + * @param string $orcidId + * @param array $authors + * @param int $i + * + * @return void + */ private function getAuthorFromOrcidApi($orcidId, $authors, $i) { $profile = new OrcidProfile($orcidId); $name = $profile->getFullName(); @@ -106,6 +117,16 @@ private function getAuthorFromOrcidApi($orcidId, $authors, $i) { } } + /** + * Get author from XML. + * + * @access private + * + * @param array $authors + * @param int $i + * + * @return void + */ private function getAuthorFromXml($authors, $i) { $this->getAuthorFromXmlDisplayForm($authors, $i); @@ -149,6 +170,16 @@ private function getAuthorFromXml($authors, $i) { } } + /** + * Get author from XML display form. + * + * @access private + * + * @param array $authors + * @param int $i + * + * @return void + */ private function getAuthorFromXmlDisplayForm($authors, $i) { $displayForm = $authors[$i]->xpath('./mods:displayForm'); if ($displayForm) { @@ -180,6 +211,17 @@ private function getHolders() { } } + /** + * Get holder from VIAF API. + * + * @access private + * + * @param string $viafId + * @param array $holders + * @param int $i + * + * @return void + */ private function getHolderFromViafApi($viafId, $holders, $i) { $profile = new ViafProfile($viafId); $name = $profile->getFullName(); @@ -194,6 +236,16 @@ private function getHolderFromViafApi($viafId, $holders, $i) { } } + /** + * Get holder from XML. + * + * @access private + * + * @param array $holders + * @param int $i + * + * @return void + */ private function getHolderFromXml($holders, $i) { $this->getHolderFromXmlDisplayForm($holders, $i); // Append "valueURI" to name using Unicode unit separator. @@ -202,6 +254,16 @@ private function getHolderFromXml($holders, $i) { } } + /** + * Get holder from XML display form. + * + * @access private + * + * @param array $holders + * @param int $i + * + * @return void + */ private function getHolderFromXmlDisplayForm($holders, $i) { // Check if there is a display form. $displayForm = $holders[$i]->xpath('./mods:displayForm'); diff --git a/Classes/Format/TeiHeader.php b/Classes/Format/TeiHeader.php index 1a77de662..ef5cab94f 100644 --- a/Classes/Format/TeiHeader.php +++ b/Classes/Format/TeiHeader.php @@ -29,8 +29,8 @@ class TeiHeader implements MetadataInterface * * @access public * - * @param \SimpleXMLElement $xml: The XML to extract the metadata from - * @param array &$metadata: The metadata array to fill + * @param \SimpleXMLElement $xml The XML to extract the metadata from + * @param array &$metadata The metadata array to fill * * @return void */ diff --git a/Classes/Hooks/DataHandler.php b/Classes/Hooks/DataHandler.php index 74b53248d..97e140b9a 100644 --- a/Classes/Hooks/DataHandler.php +++ b/Classes/Hooks/DataHandler.php @@ -43,6 +43,13 @@ class DataHandler implements LoggerAwareInterface */ protected $documentRepository; + /** + * Gets document repository + * + * @access protected + * + * @return DocumentRepository + */ protected function getDocumentRepository() { if ($this->documentRepository === null) { @@ -58,10 +65,10 @@ protected function getDocumentRepository() * * @access public * - * @param string $status: 'new' or 'update' - * @param string $table: The destination table - * @param int $id: The uid of the record - * @param array &$fieldArray: Array of field values + * @param string $status 'new' or 'update' + * @param string $table The destination table + * @param int $id The uid of the record + * @param array &$fieldArray Array of field values * * @return void */ @@ -190,10 +197,10 @@ public function processDatamap_postProcessFieldArray($status, $table, $id, &$fie * * @access public * - * @param string $status: 'new' or 'update' - * @param string $table: The destination table - * @param int $id: The uid of the record - * @param array &$fieldArray: Array of field values + * @param string $status 'new' or 'update' + * @param string $table The destination table + * @param int $id The uid of the record + * @param array &$fieldArray Array of field values * * @return void */ @@ -271,9 +278,9 @@ public function processDatamap_afterDatabaseOperations($status, $table, $id, &$f * * @access public * - * @param string $command: 'move', 'copy', 'localize', 'inlineLocalizeSynchronize', 'delete' or 'undelete' - * @param string $table: The destination table - * @param int $id: The uid of the record + * @param string $command 'move', 'copy', 'localize', 'inlineLocalizeSynchronize', 'delete' or 'undelete' + * @param string $table The destination table + * @param int $id The uid of the record * * @return void */ diff --git a/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php b/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php index 6ac113452..ddb911beb 100644 --- a/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php +++ b/Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php @@ -32,8 +32,7 @@ class SolrCoreStatus extends AbstractNode * * @access public * - * @return array As defined in initializeResultArray() of AbstractNode - * Allowed tags are: "

" + * @return array As defined in initializeResultArray() of AbstractNode. Allowed tags are: "

" */ public function render(): array { diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php index f670307e8..e25f40347 100644 --- a/Classes/Hooks/ItemsProcFunc.php +++ b/Classes/Hooks/ItemsProcFunc.php @@ -44,7 +44,7 @@ class ItemsProcFunc implements LoggerAwareInterface * * @access public * - * @param array &$params: An array with parameters + * @param array &$params An array with parameters * * @return void */ @@ -56,46 +56,46 @@ public function toolList(&$params) } /** - * Extract typoscript configuration from site root of the plugin + * Extract typoScript configuration from site root of the plugin * * @access public * - * @param $params + * @param array $params * * @return void */ public function getTyposcriptConfigFromPluginSiteRoot($params) { $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $pid = $params['flexParentDatabaseRow']['pid']; - $rootline = BackendUtility::BEgetRootLine($pid); - $siterootRow = []; - foreach ($rootline as $_row) { + $rootLine = BackendUtility::BEgetRootLine($pid); + $siteRootRow = []; + foreach ($rootLine as $_row) { if ($_row['is_siteroot'] == '1') { - $siterootRow = $_row; + $siteRootRow = $_row; break; } } try { - $ts = $objectManager->get(TemplateService::class, [$siterootRow['uid']]); - $ts->rootLine = $rootline; - $ts->runThroughTemplates($rootline, 0); + $ts = $objectManager->get(TemplateService::class, [$siteRootRow['uid']]); + $ts->rootLine = $rootLine; + $ts->runThroughTemplates($rootLine, 0); $ts->generateConfig(); } catch (\Exception $e) { $this->logger->error($e->getMessage()); } - $typoscriptConfig = $ts->setup; - $this->storagePid = $typoscriptConfig['plugin.']['tx_dlf.']['persistence.']['storagePid']; + $typoScriptConfig = $ts->setup; + $this->storagePid = $typoScriptConfig['plugin.']['tx_dlf.']['persistence.']['storagePid']; } /** - * Helper to get flexform's items array for plugin "Search" + * Helper to get flexForm's items array for plugin "Search" * * @access public * - * @param array &$params: An array with parameters + * @param array &$params An array with parameters * * @return void */ @@ -111,11 +111,11 @@ public function extendedSearchList(&$params) } /** - * Helper to get flexform's items array for plugin "Search" + * Helper to get flexForm's items array for plugin "Search" * * @access public * - * @param array &$params: An array with parameters + * @param array &$params An array with parameters */ public function getFacetsList(array &$params): void { @@ -133,11 +133,11 @@ public function getFacetsList(array &$params): void * * @access protected * - * @param array &$params: An array with parameters - * @param string $fields: Comma-separated list of fields to fetch - * @param string $table: Table name to fetch the items from - * @param string $sorting: Field to sort items by (optionally appended by 'ASC' or 'DESC') - * @param string $andWhere: Additional AND WHERE clause + * @param array &$params An array with parameters + * @param string $fields Comma-separated list of fields to fetch + * @param string $table Table name to fetch the items from + * @param string $sorting Field to sort items by (optionally appended by 'ASC' or 'DESC') + * @param string $andWhere Additional AND WHERE clause * * @return void */ diff --git a/Classes/Hooks/KitodoProductionHacks.php b/Classes/Hooks/KitodoProductionHacks.php index 081ea86cc..49a3f37b5 100644 --- a/Classes/Hooks/KitodoProductionHacks.php +++ b/Classes/Hooks/KitodoProductionHacks.php @@ -29,8 +29,8 @@ class KitodoProductionHacks * * @access public * - * @param \SimpleXMLElement &$xml: The XML object - * @param mixed $record_id: The record identifier + * @param \SimpleXMLElement &$xml The XML object + * @param mixed $record_id The record identifier * * @return void */ diff --git a/Classes/Hooks/ThumbnailCustomElement.php b/Classes/Hooks/ThumbnailCustomElement.php index a357c18fc..10ae1e95a 100644 --- a/Classes/Hooks/ThumbnailCustomElement.php +++ b/Classes/Hooks/ThumbnailCustomElement.php @@ -24,6 +24,13 @@ */ class ThumbnailCustomElement extends AbstractFormElement { + /** + * Renders thumbnail custom element. + * + * @access public + * + * @return array + */ public function render() { // Custom TCA properties and other data can be found in $this->data, for example the above diff --git a/Classes/Updates/FileLocationUpdater.php b/Classes/Updates/FileLocationUpdater.php index 536f35512..51c977ea8 100644 --- a/Classes/Updates/FileLocationUpdater.php +++ b/Classes/Updates/FileLocationUpdater.php @@ -65,6 +65,8 @@ class FileLocationUpdater implements UpgradeWizardInterface, ChattyInterface, Lo ]; /** + * @access public + * * @return string Unique identifier of this updater */ public function getIdentifier(): string @@ -75,6 +77,8 @@ public function getIdentifier(): string /** * Return the speaking name of this wizard * + * @access public + * * @return string */ public function getTitle(): string @@ -85,6 +89,8 @@ public function getTitle(): string /** * Get description * + * @access public + * * @return string Longer description of this updater */ public function getDescription(): string @@ -98,6 +104,8 @@ public function getDescription(): string * Is used to determine whether a wizard needs to be run. * Check if data for migration exists. * + * @access public + * * @return bool */ public function updateNecessary(): bool @@ -110,6 +118,8 @@ public function updateNecessary(): bool } /** + * @access public + * * @return string[] All new fields and tables must exist */ public function getPrerequisites(): array @@ -120,6 +130,8 @@ public function getPrerequisites(): array } /** + * @access public + * * @param OutputInterface $output */ public function setOutput(OutputInterface $output): void @@ -132,6 +144,8 @@ public function setOutput(OutputInterface $output): void * * Called when a wizard reports that an update is necessary * + * @access public + * * @return bool */ public function executeUpdate(): bool @@ -155,7 +169,10 @@ public function executeUpdate(): bool * * Work based on BackendLayoutIconUpdateWizard::class * + * @access public + * * @return array|int + * * @throws \RuntimeException */ protected function getRecordsFromTable($countOnly = false) @@ -209,6 +226,8 @@ protected function getRecordsFromTable($countOnly = false) /** * Performs the database update. * + * @access public + * * @return bool TRUE on success, FALSE on error */ protected function performUpdate(): bool @@ -235,8 +254,13 @@ protected function performUpdate(): bool /** * Migrates a single field. * + * @access public + * * @param string $table * @param array $row + * + * @return void + * * @throws \Exception */ protected function migrateField($table, $row) diff --git a/Classes/Updates/MigrateSettings.php b/Classes/Updates/MigrateSettings.php index 13700e081..e9b591b9e 100644 --- a/Classes/Updates/MigrateSettings.php +++ b/Classes/Updates/MigrateSettings.php @@ -33,6 +33,8 @@ class MigrateSettings implements UpgradeWizardInterface * Return the identifier for this wizard * This should be the same string as used in the ext_localconf class registration * + * @access public + * * @return string */ public function getIdentifier(): string @@ -43,6 +45,8 @@ public function getIdentifier(): string /** * Return the speaking name of this wizard * + * @access public + * * @return string */ public function getTitle(): string @@ -53,6 +57,8 @@ public function getTitle(): string /** * Return the description for this wizard * + * @access public + * * @return string */ public function getDescription(): string @@ -67,6 +73,8 @@ public function getDescription(): string * * Called when a wizard reports that an update is necessary * + * @access public + * * @return bool */ public function executeUpdate(): bool @@ -112,6 +120,8 @@ public function executeUpdate(): bool * * Looks for fe plugins in tt_content table to be migrated * + * @access public + * * @return bool */ public function updateNecessary(): bool @@ -149,6 +159,8 @@ public function updateNecessary(): bool * This way a wizard can define dependencies like "database up-to-date" or * "reference index updated" * + * @access public + * * @return string[] */ public function getPrerequisites(): array @@ -160,7 +172,10 @@ public function getPrerequisites(): array /** + * @access protected + * * @param string $oldValue + * * @return string */ protected function migrateFlexFormSettings(string $oldValue): string @@ -182,7 +197,10 @@ protected function migrateFlexFormSettings(string $oldValue): string } /** + * @access protected + * * @param string $flexFormXml + * * @return bool */ protected function checkForOldSettings(string $flexFormXml): bool diff --git a/Classes/ViewHelpers/JsFooterViewHelper.php b/Classes/ViewHelpers/JsFooterViewHelper.php index be7a5feac..de4b6d8ec 100755 --- a/Classes/ViewHelpers/JsFooterViewHelper.php +++ b/Classes/ViewHelpers/JsFooterViewHelper.php @@ -28,6 +28,8 @@ class JsFooterViewHelper extends AbstractViewHelper { /** * Initialize arguments. + * + * @access public */ public function initializeArguments() { @@ -36,6 +38,9 @@ public function initializeArguments() } /** + * @access public + * + * @static * * @param array $arguments * @param \Closure $renderChildrenClosure diff --git a/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php b/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php index f9f325329..10231bd49 100644 --- a/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php +++ b/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php @@ -42,6 +42,8 @@ class MetadataWrapVariableViewHelper extends AbstractViewHelper { /** + * @access public + * * @return void */ public function initializeArguments() @@ -50,10 +52,15 @@ public function initializeArguments() } /** + * @access public + * + * @static + * * @param array $arguments * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext - * @return null + * + * @return void */ public static function renderStatic( array $arguments, diff --git a/Classes/ViewHelpers/StdWrapViewHelper.php b/Classes/ViewHelpers/StdWrapViewHelper.php index 524feaed7..32b55a8b3 100644 --- a/Classes/ViewHelpers/StdWrapViewHelper.php +++ b/Classes/ViewHelpers/StdWrapViewHelper.php @@ -31,6 +31,13 @@ class StdWrapViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; + /** + * Initializes arguments. + * + * @access public + * + * @return void + */ public function initializeArguments() { parent::initializeArguments(); @@ -41,6 +48,8 @@ public function initializeArguments() /** * Wraps the given value * + * @access public + * * @return string */ public function render() From aa77dc72480873fe60eb847a9f5aa55fd4f08a0a Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 29 Sep 2023 22:19:17 +0200 Subject: [PATCH 08/76] [MAINTENANCE] Consistently use type declaration for parameters and return values - part 1 (#1018) Co-authored-by: Sebastian Meyer --- Classes/Api/Orcid/Client.php | 16 +- Classes/Api/Orcid/Profile.php | 10 +- Classes/Api/Viaf/Client.php | 14 +- Classes/Api/Viaf/Profile.php | 6 +- Classes/Command/BaseCommand.php | 28 ++-- Classes/Command/HarvestCommand.php | 6 +- Classes/Command/IndexCommand.php | 4 +- Classes/Command/ReindexCommand.php | 4 +- Classes/Common/AbstractDocument.php | 150 +++++++++--------- Classes/Common/FulltextInterface.php | 4 +- Classes/Common/Helper.php | 47 +++--- Classes/Common/IiifManifest.php | 69 ++++---- Classes/Common/IiifUrlReader.php | 4 +- Classes/Common/Indexer.php | 49 +++--- Classes/Common/KitodoFlashMessageRenderer.php | 8 +- Classes/Common/MetadataInterface.php | 2 +- Classes/Common/MetsDocument.php | 84 +++++----- .../Common/Solr/SearchResult/Highlight.php | 24 +-- Classes/Common/Solr/SearchResult/Page.php | 18 +-- Classes/Common/Solr/SearchResult/Region.php | 42 ++--- .../Solr/SearchResult/ResultDocument.php | 88 +++++----- Classes/Common/Solr/Solr.php | 62 ++++---- Classes/Common/Solr/SolrSearch.php | 35 ++-- Classes/Common/Solr/SolrSearchQuery.php | 14 +- Classes/Common/SolrPaginator.php | 5 +- Classes/Eid/PageViewProxy.php | 10 +- .../DocumentTypeFunctionProvider.php | 10 +- Classes/Format/Alto.php | 8 +- Classes/Format/AudioVideoMD.php | 2 +- Classes/Format/Mods.php | 32 ++-- Classes/Format/TeiHeader.php | 2 +- Classes/Hooks/ConfigurationForm.php | 2 +- Classes/Hooks/DataHandler.php | 14 +- Classes/Hooks/ItemsProcFunc.php | 9 +- Classes/Hooks/KitodoProductionHacks.php | 2 +- Classes/Hooks/ThumbnailCustomElement.php | 3 +- Classes/Middleware/SearchInDocument.php | 6 +- Classes/Pagination/PageGridPaginator.php | 6 +- Classes/Updates/FileLocationUpdater.php | 16 +- Classes/ViewHelpers/JsFooterViewHelper.php | 6 +- .../MetadataWrapVariableViewHelper.php | 5 +- Classes/ViewHelpers/StdWrapViewHelper.php | 4 +- Tests/Functional/Common/SolrIndexingTest.php | 2 +- 43 files changed, 471 insertions(+), 461 deletions(-) diff --git a/Classes/Api/Orcid/Client.php b/Classes/Api/Orcid/Client.php index ef7d60faf..b2cb38c10 100644 --- a/Classes/Api/Orcid/Client.php +++ b/Classes/Api/Orcid/Client.php @@ -42,31 +42,31 @@ class Client * @access protected * @var Logger This holds the logger */ - protected $logger; + protected Logger $logger; /** * @access private * @var string The ORCID API endpoint **/ - private $endpoint = 'record'; + private string $endpoint = 'record'; /** * @access private * @var string The ORCID API access level **/ - private $level = 'pub'; + private string $level = 'pub'; /** * @access private * @var string The ORCID ID to search for **/ - private $orcid = null; + private string $orcid; /** * @access private * @var RequestFactoryInterface The request object **/ - private $requestFactory = null; + private RequestFactoryInterface $requestFactory; /** * Constructs a new instance @@ -78,7 +78,7 @@ class Client * * @return void **/ - public function __construct($orcid, RequestFactory $requestFactory) + public function __construct(string $orcid, RequestFactory $requestFactory) { $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class); $this->orcid = $orcid; @@ -94,7 +94,7 @@ public function __construct($orcid, RequestFactory $requestFactory) * * @return void */ - public function setEndpoint($endpoint) { + public function setEndpoint(string $endpoint): void { $this->endpoint = $endpoint; } @@ -124,7 +124,7 @@ public function getData() * * @return string **/ - private function getApiEndpoint() + private function getApiEndpoint(): string { $url = 'https://' . $this->level . '.' . self::HOSTNAME; $url .= '/v' . self::VERSION . '/'; diff --git a/Classes/Api/Orcid/Profile.php b/Classes/Api/Orcid/Profile.php index 174006d74..3d77bd3dd 100644 --- a/Classes/Api/Orcid/Profile.php +++ b/Classes/Api/Orcid/Profile.php @@ -32,19 +32,19 @@ class Profile * @access protected * @var Logger This holds the logger */ - protected $logger; + protected Logger $logger; /** * @access private * @var Client This holds the client */ - private $client; + private Client $client; /** * @access private * @var \SimpleXmlElement|false The raw ORCID profile **/ - private $raw = null; + private $raw; /** * Constructs client instance @@ -55,7 +55,7 @@ class Profile * * @return void **/ - public function __construct($orcid) + public function __construct(string $orcid) { $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class); $this->client = new Client($orcid, GeneralUtility::makeInstance(RequestFactory::class)); @@ -151,7 +151,7 @@ public function getFullName() * * @return void **/ - private function getRaw($endpoint) + private function getRaw(string $endpoint): void { $this->client->setEndpoint($endpoint); $data = $this->client->getData(); diff --git a/Classes/Api/Viaf/Client.php b/Classes/Api/Viaf/Client.php index 8e58d9f33..b4f82e01f 100644 --- a/Classes/Api/Viaf/Client.php +++ b/Classes/Api/Viaf/Client.php @@ -32,7 +32,7 @@ class Client * @access protected * @var Logger This holds the logger */ - protected $logger; + protected Logger $logger; /** * The VIAF API endpoint @@ -40,19 +40,19 @@ class Client * @access private * @var string The VIAF API endpoint **/ - private $endpoint = 'viaf.xml'; + private string $endpoint = 'viaf.xml'; /** * @access private * @var string The VIAF URL for the profile **/ - private $viafUrl = null; + private string $viafUrl; /** * @access private * @var RequestFactoryInterface The request object **/ - private $requestFactory = null; + private RequestFactoryInterface $requestFactory; /** * Constructs a new instance @@ -64,7 +64,7 @@ class Client * * @return void **/ - public function __construct($viaf, RequestFactory $requestFactory) + public function __construct(string $viaf, RequestFactory $requestFactory) { $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class); $this->viafUrl = 'http://viaf.org/viaf/' . $viaf; @@ -80,7 +80,7 @@ public function __construct($viaf, RequestFactory $requestFactory) * * @return void */ - public function setEndpoint($endpoint) { + public function setEndpoint(string $endpoint): void { $this->endpoint = $endpoint; } @@ -110,7 +110,7 @@ public function getData() * * @return string **/ - private function getApiEndpoint() + private function getApiEndpoint(): string { return $this->viafUrl . '/' . $this->endpoint; } diff --git a/Classes/Api/Viaf/Profile.php b/Classes/Api/Viaf/Profile.php index 6fd1befcc..0f2ad0568 100644 --- a/Classes/Api/Viaf/Profile.php +++ b/Classes/Api/Viaf/Profile.php @@ -44,7 +44,7 @@ class Profile * @access private * @var \SimpleXmlElement|false The raw VIAF profile or false if not found **/ - private $raw = null; + private $raw; /** * Constructs client instance @@ -55,7 +55,7 @@ class Profile * * @return void **/ - public function __construct($viaf) + public function __construct(string $viaf) { $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class); $this->client = new Client($viaf, GeneralUtility::makeInstance(RequestFactory::class)); @@ -128,7 +128,7 @@ public function getFullName() * * @return void **/ - private function getRaw() + private function getRaw(): void { $data = $this->client->getData(); if (!isset($this->raw) && $data != false) { diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index be29ef428..e35630cbc 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -46,48 +46,48 @@ class BaseCommand extends Command * @access protected * @var CollectionRepository */ - protected $collectionRepository; + protected CollectionRepository $collectionRepository; /** * @access protected * @var DocumentRepository */ - protected $documentRepository; + protected DocumentRepository $documentRepository; /** * @access protected * @var LibraryRepository */ - protected $libraryRepository; + protected LibraryRepository $libraryRepository; /** * @access protected * @var StructureRepository */ - protected $structureRepository; + protected StructureRepository $structureRepository; /** * @access protected * @var int */ - protected $storagePid; + protected int $storagePid; /** * @access protected - * @var Library + * @var Library|null */ - protected $owner; + protected ?Library $owner; /** * @access protected * @var array */ - protected $extConf; + protected array $extConf; /** * @var ConfigurationManager */ - protected $configurationManager; + protected ConfigurationManager $configurationManager; public function __construct(CollectionRepository $collectionRepository, DocumentRepository $documentRepository, @@ -115,7 +115,7 @@ public function __construct(CollectionRepository $collectionRepository, * * @return bool */ - protected function initializeRepositories($storagePid) + protected function initializeRepositories(int $storagePid): bool { if (MathUtility::canBeInterpretedAsInteger($storagePid)) { $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); @@ -191,11 +191,11 @@ protected function getSolrCores(int $pageId): array * * @access protected * - * @param int|string $doc The document uid from DB OR the location of a METS document. + * @param Document $doc The document instance * - * @return bool true on success + * @return bool true on success, false otherwise */ - protected function saveToDatabase(Document $document) + protected function saveToDatabase(Document $document): bool { $doc = $document->getCurrentDocument(); if ($doc === null) { @@ -316,7 +316,7 @@ protected function saveToDatabase(Document $document) * * @return int The parent document's id. */ - protected function getParentDocumentUidForSaving(Document $document) + protected function getParentDocumentUidForSaving(Document $document): int { $doc = $document->getCurrentDocument(); diff --git a/Classes/Command/HarvestCommand.php b/Classes/Command/HarvestCommand.php index 831935b80..c9293e62f 100644 --- a/Classes/Command/HarvestCommand.php +++ b/Classes/Command/HarvestCommand.php @@ -42,7 +42,7 @@ class HarvestCommand extends BaseCommand * * @return void */ - public function configure() + public function configure(): void { $this ->setDescription('Harvest OAI-PMH contents into database and Solr.') @@ -101,7 +101,7 @@ public function configure() * * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $dryRun = $input->getOption('dry-run') != false ? true : false; @@ -268,7 +268,7 @@ protected function execute(InputInterface $input, OutputInterface $output) * * @return void */ - protected function handleOaiError(BaseoaipmhException $exception, SymfonyStyle $io) + protected function handleOaiError(BaseoaipmhException $exception, SymfonyStyle $io): void { $io->error('ERROR: Trying to retrieve data from OAI interface resulted in error:' . "\n " . $exception->getMessage()); } diff --git a/Classes/Command/IndexCommand.php b/Classes/Command/IndexCommand.php index 4352330ed..f719f92ad 100644 --- a/Classes/Command/IndexCommand.php +++ b/Classes/Command/IndexCommand.php @@ -41,7 +41,7 @@ class IndexCommand extends BaseCommand * * @return void */ - public function configure() + public function configure(): void { $this ->setDescription('Index single document into database and Solr.') @@ -88,7 +88,7 @@ public function configure() * * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $dryRun = $input->getOption('dry-run') != false ? true : false; diff --git a/Classes/Command/ReindexCommand.php b/Classes/Command/ReindexCommand.php index e6fc74de0..19df87ff1 100644 --- a/Classes/Command/ReindexCommand.php +++ b/Classes/Command/ReindexCommand.php @@ -39,7 +39,7 @@ class ReindexCommand extends BaseCommand * * @return void */ - public function configure() + public function configure(): void { $this ->setDescription('Reindex a collection into database and Solr.') @@ -92,7 +92,7 @@ public function configure() * * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $dryRun = $input->getOption('dry-run') != false ? true : false; diff --git a/Classes/Common/AbstractDocument.php b/Classes/Common/AbstractDocument.php index 7a7614bd5..ac14b7e84 100644 --- a/Classes/Common/AbstractDocument.php +++ b/Classes/Common/AbstractDocument.php @@ -64,20 +64,20 @@ abstract class AbstractDocument * @access protected * @var Logger This holds the logger */ - protected $logger; + protected Logger $logger; /** * @access protected * @var int This holds the PID for the configuration */ - protected $cPid = 0; + protected int $cPid = 0; /** * @access public * @static * @var string The extension key */ - public static $extKey = 'dlf'; + public static string $extKey = 'dlf'; /** * @access protected @@ -91,7 +91,7 @@ abstract class AbstractDocument * * @see loadFormats() */ - protected $formats = [ + protected array $formats = [ 'OAI' => [ 'rootElement' => 'OAI-PMH', 'namespaceURI' => 'http://www.openarchives.org/OAI/2.0/', @@ -112,7 +112,7 @@ abstract class AbstractDocument * * @see $formats */ - protected $formatsLoaded = false; + protected bool $formatsLoaded = false; /** * Are there any fulltext files available? This also includes IIIF text annotations @@ -122,19 +122,19 @@ abstract class AbstractDocument * @access protected * @var bool */ - protected $hasFulltext = false; + protected bool $hasFulltext = false; /** * @access protected * @var array Last searched logical and physical page */ - protected $lastSearchedPhysicalPage = ['logicalPage' => null, 'physicalPage' => null]; + protected array $lastSearchedPhysicalPage = ['logicalPage' => null, 'physicalPage' => null]; /** * @access protected * @var array This holds the logical units */ - protected $logicalUnits = []; + protected array $logicalUnits = []; /** * This holds the documents' parsed metadata array with their corresponding @@ -143,7 +143,7 @@ abstract class AbstractDocument * @access protected * @var array */ - protected $metadataArray = []; + protected array $metadataArray = []; /** * @access protected @@ -151,31 +151,31 @@ abstract class AbstractDocument * * @see $metadataArray */ - protected $metadataArrayLoaded = false; + protected bool $metadataArrayLoaded = false; /** * @access protected * @var int The holds the total number of pages */ - protected $numPages = 0; + protected int $numPages = 0; /** * @access protected * @var int This holds the UID of the parent document or zero if not multi-volumed */ - protected $parentId = 0; + protected int $parentId = 0; /** * @access protected * @var array This holds the physical structure */ - protected $physicalStructure = []; + protected array $physicalStructure = []; /** * @access protected * @var array This holds the physical structure metadata */ - protected $physicalStructureInfo = []; + protected array $physicalStructureInfo = []; /** * @access protected @@ -183,13 +183,13 @@ abstract class AbstractDocument * * @see $physicalStructure */ - protected $physicalStructureLoaded = false; + protected bool $physicalStructureLoaded = false; /** * @access protected * @var int This holds the PID of the document or zero if not in database */ - protected $pid = 0; + protected int $pid = 0; /** * This holds the documents' raw text pages with their corresponding @@ -198,32 +198,32 @@ abstract class AbstractDocument * @access protected * @var array */ - protected $rawTextArray = []; + protected array $rawTextArray = []; /** * @access protected * @var bool Is the document instantiated successfully? */ - protected $ready = false; + protected bool $ready = false; /** * @access protected * @var string The METS file's / IIIF manifest's record identifier */ - protected $recordId; + protected ?string $recordId; /** * @access protected * @static * @var array (AbstractDocument) This holds the singleton object of the document */ - protected static $registry = []; + protected static array $registry = []; /** * @access protected * @var int This holds the UID of the root document or zero if not multi-volumed */ - protected $rootId = 0; + protected int $rootId = 0; /** * @access protected @@ -231,13 +231,13 @@ abstract class AbstractDocument * * @see $rootId */ - protected $rootIdLoaded = false; + protected bool $rootIdLoaded = false; /** * @access protected * @var array This holds the smLinks between logical and physical structMap */ - protected $smLinks = ['l2p' => [], 'p2l' => []]; + protected array $smLinks = ['l2p' => [], 'p2l' => []]; /** * @access protected @@ -245,7 +245,7 @@ abstract class AbstractDocument * * @see $smLinks */ - protected $smLinksLoaded = false; + protected bool $smLinksLoaded = false; /** * This holds the logical structure @@ -253,7 +253,7 @@ abstract class AbstractDocument * @access protected * @var array */ - protected $tableOfContents = []; + protected array $tableOfContents = []; /** * @access protected @@ -261,13 +261,13 @@ abstract class AbstractDocument * * @see $tableOfContents */ - protected $tableOfContentsLoaded = false; + protected bool $tableOfContentsLoaded = false; /** * @access protected * @var string This holds the document's thumbnail location */ - protected $thumbnail = ''; + protected string $thumbnail = ''; /** * @access protected @@ -275,19 +275,19 @@ abstract class AbstractDocument * * @see $thumbnail */ - protected $thumbnailLoaded = false; + protected bool $thumbnailLoaded = false; /** * @access protected * @var string This holds the toplevel structure's "@ID" (METS) or the manifest's "@id" (IIIF) */ - protected $toplevelId = ''; + protected string $toplevelId = ''; /** * @access protected * @var \SimpleXMLElement This holds the whole XML file as \SimpleXMLElement object */ - protected $xml; + protected \SimpleXMLElement $xml; /** * This clears the static registry to prevent memory exhaustion @@ -298,7 +298,7 @@ abstract class AbstractDocument * * @return void */ - public static function clearRegistry() + public static function clearRegistry(): void { // Reset registry array. self::$registry = []; @@ -315,7 +315,7 @@ public static function clearRegistry() * * @return void */ - protected abstract function establishRecordId($pid); + protected abstract function establishRecordId(int $pid); /** * Source document PHP object which is represented by a Document instance @@ -340,7 +340,7 @@ protected abstract function getDocument(); * * @return string The file's location as URL */ - public abstract function getDownloadLocation($id); + public abstract function getDownloadLocation(string $id): string; /** * This gets all file information stored in single array. @@ -366,7 +366,7 @@ public abstract function getFileInfo($id); * * @return string The file's location as URL */ - public abstract function getFileLocation($id); + public abstract function getFileLocation(string $id): string; /** * This gets the MIME type of a file representing a physical page or track @@ -379,7 +379,7 @@ public abstract function getFileLocation($id); * * @return string The file's MIME type */ - public abstract function getFileMimeType($id); + public abstract function getFileMimeType(string $id): string; /** * This is a singleton class, thus an instance must be created by this method @@ -394,7 +394,7 @@ public abstract function getFileMimeType($id); * * @return AbstractDocument|null Instance of this class, either MetsDocument or IiifManifest */ - public static function &getInstance($location, $settings = [], $forceReload = false) + public static function &getInstance(string $location, array $settings = [], bool $forceReload = false): ?AbstractDocument { // Create new instance depending on format (METS or IIIF) ... $documentFormat = null; @@ -464,7 +464,7 @@ public static function &getInstance($location, $settings = [], $forceReload = fa * * @return array Array of the element's id, label, type and physical page indexes/mptr link */ - public abstract function getLogicalStructure($id, $recursive = false); + public abstract function getLogicalStructure(string $id, bool $recursive = false): array; /** * This extracts all the metadata for a logical structure node @@ -479,7 +479,7 @@ public abstract function getLogicalStructure($id, $recursive = false); * * @return array The logical structure node's / the IIIF resource's parsed metadata array */ - public abstract function getMetadata($id, $cPid = 0); + public abstract function getMetadata(string $id, int $cPid = 0): array; /** * This returns the first corresponding physical page number of a given logical page label @@ -490,7 +490,7 @@ public abstract function getMetadata($id, $cPid = 0); * * @return int The physical page number */ - public function getPhysicalPage($logicalPage) + public function getPhysicalPage(string $logicalPage): int { if ( !empty($this->lastSearchedPhysicalPage['logicalPage']) @@ -524,7 +524,7 @@ public function getPhysicalPage($logicalPage) * * @return string The OCR full text */ - public abstract function getFullText($id); + public abstract function getFullText(string $id): string; /** * This extracts the OCR full text for a physical structure node / IIIF Manifest / Canvas from an @@ -536,7 +536,7 @@ public abstract function getFullText($id); * * @return string The OCR full text */ - protected function getFullTextFromXml($id) + protected function getFullTextFromXml(string $id): string { $fullText = ''; // Load available text formats, ... @@ -600,7 +600,7 @@ class_exists($class) * * @return string The format of the OCR full text */ - private function getTextFormat($fileContent) + private function getTextFormat(string $fileContent): string { $xml = Helper::getXmlFileAsString($fileContent); @@ -624,7 +624,7 @@ private function getTextFormat($fileContent) * * @return string The title of the document itself or a parent document */ - public static function getTitle($uid, $recursive = false) + public static function getTitle(int $uid, bool $recursive = false): string { $title = ''; // Sanitize input. @@ -677,7 +677,7 @@ public static function getTitle($uid, $recursive = false) * * @return array The logical structure node's / resource's parsed metadata array */ - public function getTitledata($cPid = 0) + public function getTitledata(int $cPid = 0): array { $titledata = $this->getMetadata($this->_getToplevelId(), $cPid); // Add information from METS structural map to titledata array. @@ -711,7 +711,7 @@ public function getTitledata($cPid = 0) * @return int|bool false if structure with $logId is not a child of this substructure, * or the actual depth. */ - protected function getTreeDepth($structure, $depth, $logId) + protected function getTreeDepth(array $structure, int $depth, string $logId) { foreach ($structure as $element) { if ($element['id'] == $logId) { @@ -735,7 +735,7 @@ protected function getTreeDepth($structure, $depth, $logId) * * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC. */ - public function getStructureDepth($logId) + public function getStructureDepth(string $logId) { return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId); } @@ -751,7 +751,7 @@ public function getStructureDepth($logId) * * @return void */ - protected abstract function init($location); + protected abstract function init(string $location): void; /** * Reuse any document object that might have been already loaded to determine whether document is METS or IIIF @@ -764,7 +764,7 @@ protected abstract function init($location); * * @return bool true if $preloadedDocument can actually be reused, false if it has to be loaded again */ - protected abstract function setPreloadedDocument($preloadedDocument); + protected abstract function setPreloadedDocument($preloadedDocument): bool; /** * METS/IIIF specific part of loading a location @@ -777,7 +777,7 @@ protected abstract function setPreloadedDocument($preloadedDocument); * * @return bool true on success or false on failure */ - protected abstract function loadLocation($location); + protected abstract function loadLocation(string $location): bool; /** * Load XML file / IIIF resource from URL @@ -788,7 +788,7 @@ protected abstract function loadLocation($location); * * @return bool true on success or false on failure */ - protected function load($location) + protected function load(string $location): bool { // Load XML / JSON-LD file. if (GeneralUtility::isValidUrl($location)) { @@ -818,7 +818,7 @@ protected abstract function ensureHasFulltextIsSet(); * * @return void */ - protected function loadFormats() + protected function loadFormats(): void { if (!$this->formatsLoaded) { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) @@ -859,7 +859,7 @@ protected function loadFormats() * * @return void */ - public function registerNamespaces(&$obj) + public function registerNamespaces(&$obj): void { // TODO Check usage. XML specific method does not seem to be used anywhere outside this class within the project, but it is public and may be used by extensions. $this->loadFormats(); @@ -887,7 +887,7 @@ public function registerNamespaces(&$obj) * * @return array */ - protected function initializeMetadata($format) { + protected function initializeMetadata(string $format): array { return [ 'title' => [], 'title_sorting' => [], @@ -926,7 +926,7 @@ protected function initializeMetadata($format) { * * @return int The PID of the metadata definitions */ - protected function _getCPid() + protected function _getCPid(): int { return $this->cPid; } @@ -938,7 +938,7 @@ protected function _getCPid() * * @return bool Are there any fulltext files available? */ - protected function _getHasFulltext() + protected function _getHasFulltext(): bool { $this->ensureHasFulltextIsSet(); return $this->hasFulltext; @@ -955,7 +955,7 @@ protected function _getHasFulltext() * * @return void */ - protected abstract function prepareMetadataArray($cPid); + protected abstract function prepareMetadataArray(int $cPid): void; /** * This builds an array of the document's metadata @@ -964,7 +964,7 @@ protected abstract function prepareMetadataArray($cPid); * * @return array Array of metadata with their corresponding logical structure node ID as key */ - protected function _getMetadataArray() + protected function _getMetadataArray(): array { // Set metadata definitions' PID. $cPid = ($this->cPid ? $this->cPid : $this->pid); @@ -990,7 +990,7 @@ protected function _getMetadataArray() * * @return int The total number of pages and/or tracks */ - protected function _getNumPages() + protected function _getNumPages(): int { $this->_getPhysicalStructure(); return $this->numPages; @@ -1003,7 +1003,7 @@ protected function _getNumPages() * * @return int The UID of the parent document or zero if not applicable */ - protected function _getParentId() + protected function _getParentId(): int { return $this->parentId; } @@ -1018,7 +1018,7 @@ protected function _getParentId() * @return array Array of physical elements' id, type, label and file representations ordered * by "@ORDER" attribute / IIIF Sequence's Canvases */ - protected abstract function _getPhysicalStructure(); + protected abstract function _getPhysicalStructure(): array; /** * This gives an array of the document's physical structure metadata @@ -1027,7 +1027,7 @@ protected abstract function _getPhysicalStructure(); * * @return array Array of elements' type, label and file representations ordered by "@ID" attribute / Canvas order */ - protected function _getPhysicalStructureInfo() + protected function _getPhysicalStructureInfo(): array { // Is there no physical structure array yet? if (!$this->physicalStructureLoaded) { @@ -1044,7 +1044,7 @@ protected function _getPhysicalStructureInfo() * * @return int The PID of the document or zero if not in database */ - protected function _getPid() + protected function _getPid(): int { return $this->pid; } @@ -1056,7 +1056,7 @@ protected function _getPid() * * @return bool Is the document instantiated successfully? */ - protected function _getReady() + protected function _getReady(): bool { return $this->ready; } @@ -1080,7 +1080,7 @@ protected function _getRecordId() * * @return int The UID of the root document or zero if not applicable */ - protected function _getRootId() + protected function _getRootId(): int { if (!$this->rootIdLoaded) { if ($this->parentId) { @@ -1102,7 +1102,7 @@ protected function _getRootId() * * @return array The links between logical and physical nodes / Range, Manifest and Canvas */ - protected abstract function _getSmLinks(); + protected abstract function _getSmLinks(): array; /** * This builds an array of the document's logical structure @@ -1111,7 +1111,7 @@ protected abstract function _getSmLinks(); * * @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved */ - protected function _getTableOfContents() + protected function _getTableOfContents(): array { // Is there no logical structure array yet? if (!$this->tableOfContentsLoaded) { @@ -1133,7 +1133,7 @@ protected function _getTableOfContents() * * @return string The document's thumbnail location */ - protected abstract function _getThumbnail($forceReload = false); + protected abstract function _getThumbnail(bool $forceReload = false): string; /** * This returns the ID of the toplevel logical structure node @@ -1144,7 +1144,7 @@ protected abstract function _getThumbnail($forceReload = false); * * @return string The logical structure node's ID */ - protected abstract function _getToplevelId(); + protected abstract function _getToplevelId(): string; /** * This sets $this->cPid via __set() @@ -1155,7 +1155,7 @@ protected abstract function _getToplevelId(); * * @return void */ - protected function _setCPid($value) + protected function _setCPid(int $value): void { $this->cPid = max(intval($value), 0); } @@ -1173,7 +1173,7 @@ protected function _setCPid($value) * * @return void */ - protected function __construct($location, $pid, $preloadedDocument) + protected function __construct(string $location, int $pid, $preloadedDocument) { $this->pid = $pid; $this->setPreloadedDocument($preloadedDocument); @@ -1191,7 +1191,7 @@ protected function __construct($location, $pid, $preloadedDocument) * * @return mixed Value of $this->$var */ - public function __get($var) + public function __get(string $var) { $method = '_get' . ucfirst($var); if ( @@ -1199,7 +1199,7 @@ public function __get($var) || !method_exists($this, $method) ) { $this->logger->warning('There is no getter function for property "' . $var . '"'); - return; + return null; } else { return $this->$method(); } @@ -1214,7 +1214,7 @@ public function __get($var) * * @return bool true if variable is set and not empty, false otherwise */ - public function __isset($var) + public function __isset(string $var): bool { return !empty($this->__get($var)); } @@ -1229,7 +1229,7 @@ public function __isset($var) * * @return void */ - public function __set($var, $value) + public function __set(string $var, $value): void { $method = '_set' . ucfirst($var); if ( @@ -1274,7 +1274,7 @@ private static function getDocCache(string $location) * * @return void */ - private static function setDocCache(string $location, AbstractDocument $currentDocument) + private static function setDocCache(string $location, AbstractDocument $currentDocument): void { $cacheIdentifier = md5($location); $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_doc'); diff --git a/Classes/Common/FulltextInterface.php b/Classes/Common/FulltextInterface.php index cb20f80cd..2b0c3098d 100644 --- a/Classes/Common/FulltextInterface.php +++ b/Classes/Common/FulltextInterface.php @@ -33,7 +33,7 @@ interface FulltextInterface * * @return string The raw unformatted fulltext */ - public function getRawText(\SimpleXMLElement $xml); + public function getRawText(\SimpleXMLElement $xml): string; /** * This extracts the fulltext data from ALTO XML and returns it in MiniOCR format @@ -44,5 +44,5 @@ public function getRawText(\SimpleXMLElement $xml); * * @return string The unformatted fulltext in MiniOCR format */ - public function getTextAsMiniOcr(\SimpleXMLElement $xml); + public function getTextAsMiniOcr(\SimpleXMLElement $xml): string; } diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index 6088753cc..60a0ce1ca 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -45,7 +45,7 @@ class Helper * @static * @var string The extension key */ - public static $extKey = 'dlf'; + public static string $extKey = 'dlf'; /** * @access protected @@ -54,7 +54,7 @@ class Helper * * @see openssl_get_cipher_methods() for options */ - protected static $cipherAlgorithm = 'aes-256-ctr'; + protected static string $cipherAlgorithm = 'aes-256-ctr'; /** * @access protected @@ -63,14 +63,14 @@ class Helper * * @see openssl_get_md_methods() for options */ - protected static $hashAlgorithm = 'sha256'; + protected static string $hashAlgorithm = 'sha256'; /** * @access protected * @static * @var array The locallang array for flash messages */ - protected static $messages = []; + protected static array $messages = []; /** * Generates a flash message and adds it to a message queue. @@ -87,7 +87,7 @@ class Helper * * @return FlashMessageQueue The queue the message was added to */ - public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages') + public static function addMessage(string $message, string $title, int $severity, bool $session = false, string $queue = 'kitodo.default.flashMessages'): FlashMessageQueue { $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); @@ -113,7 +113,7 @@ public static function addMessage($message, $title, $severity, $session = false, * * @return bool Is $id a valid GNL identifier of the given $type? */ - public static function checkIdentifier($id, $type) + public static function checkIdentifier(string $id, string $type): bool { $digits = substr($id, 0, 8); $checksum = 0; @@ -180,7 +180,7 @@ public static function checkIdentifier($id, $type) * * @return mixed The decrypted value or false on error */ - public static function decrypt($encrypted) + public static function decrypt(string $encrypted) { if ( !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) @@ -222,6 +222,7 @@ public static function decrypt($encrypted) * * @return \SimpleXMLElement|false */ + //TODO: make sure that this is called only with string then update public static function getXmlFileAsString($content) { // Don't make simplexml_load_string throw (when $content is an array @@ -255,7 +256,7 @@ public static function getXmlFileAsString($content) * * @return void */ - public static function log($message, $severity = 0) + public static function log(string $message, int $severity = 0): void { $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(get_called_class()); @@ -288,7 +289,7 @@ public static function log($message, $severity = 0) * * @return mixed Hashed string or false on error */ - public static function digest($string) + public static function digest(string $string) { if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(true))) { self::log('OpenSSL library doesn\'t support hash algorithm', LOG_SEVERITY_ERROR); @@ -310,7 +311,7 @@ public static function digest($string) * * @return mixed Encrypted string or false on error */ - public static function encrypt($string) + public static function encrypt(string $string) { if ( !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) @@ -346,7 +347,7 @@ public static function encrypt($string) * * @return string The unqualified class name */ - public static function getUnqualifiedClassName($qualifiedClassName) + public static function getUnqualifiedClassName(string $qualifiedClassName): string { $nameParts = explode('\\', $qualifiedClassName); return end($nameParts); @@ -363,7 +364,7 @@ public static function getUnqualifiedClassName($qualifiedClassName) * * @return string The cleaned up string */ - public static function getCleanString($string) + public static function getCleanString(string $string): string { // Convert to lowercase. $string = strtolower($string); @@ -387,7 +388,7 @@ public static function getCleanString($string) * * @return array Array of hook objects for the class */ - public static function getHookObjects($scriptRelPath) + public static function getHookObjects(string $scriptRelPath): array { $hookObjects = []; if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'])) { @@ -411,7 +412,7 @@ public static function getHookObjects($scriptRelPath) * * @return string "index_name" for the given UID */ - public static function getIndexNameFromUid($uid, $table, $pid = -1) + public static function getIndexNameFromUid(int $uid, string $table, int $pid = -1): string { // Sanitize input. $uid = max(intval($uid), 0); @@ -472,7 +473,7 @@ public static function getIndexNameFromUid($uid, $table, $pid = -1) * * @return string Localized full name of language or unchanged input */ - public static function getLanguageName($code) + public static function getLanguageName(string $code): string { // Analyze code and set appropriate ISO table. $isoCode = strtolower(trim($code)); @@ -504,7 +505,7 @@ public static function getLanguageName($code) * * @return array */ - public static function getDocumentStructures($pid = -1) + public static function getDocumentStructures(int $pid = -1): array { // TODO: Against redundancy with getIndexNameFromUid @@ -549,7 +550,7 @@ public static function getDocumentStructures($pid = -1) * * @return string Uniform Resource Name as string */ - public static function getURN($base, $id) + public static function getURN(string $base, string $id): string { $concordance = [ '0' => 1, @@ -619,7 +620,7 @@ public static function getURN($base, $id) * * @return bool Is $id a valid PPN? */ - public static function isPPN($id) + public static function isPPN(string $id): bool { return self::checkIdentifier($id, 'PPN'); } @@ -635,7 +636,7 @@ public static function isPPN($id) * * @return bool */ - public static function isValidHttpUrl($url) + public static function isValidHttpUrl(string $url): bool { if (!GeneralUtility::isValidUrl($url)) { return false; @@ -664,7 +665,7 @@ public static function isValidHttpUrl($url) * * @return array Merged array */ - public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) + public static function mergeRecursiveWithOverrule(array $original, array $overrule, bool $addKeys = true, bool $includeEmptyValues = true, bool $enableUnsetFeature = true): array { ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature); return $original; @@ -681,7 +682,7 @@ public static function mergeRecursiveWithOverrule(array $original, array $overru * * @return string All flash messages in the queue rendered as HTML. */ - public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') + public static function renderFlashMessages(string $queue = 'kitodo.default.flashMessages'): string { $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); @@ -704,7 +705,7 @@ public static function renderFlashMessages($queue = 'kitodo.default.flashMessage * * @return string Localized label for $index_name */ - public static function translate($index_name, $table, $pid) + public static function translate(string $index_name, string $table, string $pid): string { // Load labels into static variable for future use. static $labels = []; @@ -834,7 +835,7 @@ public static function translate($index_name, $table, $pid) * * @return string Additional WHERE expression */ - public static function whereExpression($table, $showHidden = false) + public static function whereExpression(string $table, bool $showHidden = false): string { // TODO: Check with applicationType; TYPO3_MODE is removed in v12 if (\TYPO3_MODE === 'FE') { diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index 8d5f3fd67..639d3c121 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -84,42 +84,42 @@ final class IiifManifest extends AbstractDocument * * @see __sleep() / __wakeup() */ - protected $asJson = ''; + protected string $asJson = ''; /** * @access protected * @var ManifestInterface A PHP object representation of a IIIF manifest */ - protected $iiif; + protected ManifestInterface $iiif; /** * @access protected * @var string 'IIIF1', 'IIIF2' or 'IIIF3', depending on the API $this->iiif confrms to: IIIF Metadata API 1, IIIF Presentation API 2 or 3 */ - protected $iiifVersion; + protected string $iiifVersion; /** * @access protected * @var bool Document has already been analyzed if it contains fulltext for the Solr index */ - protected $hasFulltextSet = false; + protected bool $hasFulltextSet = false; /** * @access protected * @var array This holds the original manifest's parsed metadata array with their corresponding resource (Manifest / Sequence / Range) ID as array key */ - protected $originalMetadataArray = []; + protected array $originalMetadataArray = []; /** * @access protected * @var array Holds the mime types of linked resources in the manifest (extracted during parsing) for later use */ - protected $mimeTypes = []; + protected array $mimeTypes = []; /** * @see AbstractDocument::establishRecordId() */ - protected function establishRecordId($pid) + protected function establishRecordId(int $pid): void { if ($this->iiif !== null) { /* @@ -174,7 +174,7 @@ protected function establishRecordId($pid) /** * @see AbstractDocument::getDocument() */ - protected function getDocument() + protected function getDocument(): IiifResourceInterface { return $this->iiif; } @@ -188,7 +188,7 @@ protected function getDocument() * @return string 'IIIF1' if the resource is a Metadata API 1 resource, 'IIIF2' / 'IIIF3' if * the resource is a Presentation API 2 / 3 resource */ - public function getIiifVersion() + public function getIiifVersion(): string { if (!isset($this->iiifVersion)) { if ($this->iiif instanceof AbstractIiifResource1) { @@ -208,7 +208,7 @@ public function getIiifVersion() * @var bool * @access protected */ - protected $useGrpsLoaded = false; + protected bool $useGrpsLoaded = false; /** * Holds the configured useGrps as array. @@ -216,7 +216,7 @@ public function getIiifVersion() * @var array * @access protected */ - protected $useGrps = []; + protected array $useGrps = []; /** * IiifManifest also populates the physical structure array entries for matching @@ -230,7 +230,7 @@ public function getIiifVersion() * * @return array|string */ - protected function getUseGroups($use) + protected function getUseGroups(string $use) { if (!$this->useGrpsLoaded) { // Get configured USE attributes. @@ -258,7 +258,7 @@ protected function getUseGroups($use) /** * @see AbstractDocument::_getPhysicalStructure() */ - protected function _getPhysicalStructure() + protected function _getPhysicalStructure(): array { // Is there no physical structure array yet? if (!$this->physicalStructureLoaded) { @@ -372,7 +372,7 @@ protected function _getPhysicalStructure() * {@inheritDoc} * @see AbstractDocument::getDownloadLocation() */ - public function getDownloadLocation($id) + public function getDownloadLocation(string $id): string { $fileLocation = $this->getFileLocation($id); $resource = $this->iiif->getContainedResourceById($fileLocation); @@ -401,7 +401,7 @@ public function getFileInfo($id) /** * @see AbstractDocument::getFileLocation() */ - public function getFileLocation($id) + public function getFileLocation(string $id): string { if ($id == null) { return null; @@ -425,7 +425,7 @@ public function getFileLocation($id) /** * @see AbstractDocument::getFileMimeType() */ - public function getFileMimeType($id) + public function getFileMimeType(string $id): string { $fileResource = $this->iiif->getContainedResourceById($id); if ($fileResource instanceof CanvasInterface) { @@ -450,7 +450,7 @@ public function getFileMimeType($id) /** * @see AbstractDocument::getLogicalStructure() */ - public function getLogicalStructure($id, $recursive = false) + public function getLogicalStructure(string $id, bool $recursive = false): array { $details = []; if (!$recursive && !empty($this->logicalUnits[$id])) { @@ -487,7 +487,7 @@ public function getLogicalStructure($id, $recursive = false) * * @return array Logical structure array */ - protected function getLogicalStructureInfo(IiifResourceInterface $resource, $recursive = false, &$processedStructures = []) + protected function getLogicalStructureInfo(IiifResourceInterface $resource, bool $recursive = false, array &$processedStructures = []): array { $details = []; $details['id'] = $resource->getId(); @@ -571,7 +571,6 @@ protected function getLogicalStructureInfo(IiifResourceInterface $resource, $rec * @access public * * @param string $id the ID of the IIIF resource - * @param int $cPid the configuration folder's id * @param bool $withDescription add description / summary to the return value * @param bool $withRights add attribution and license / rights and requiredStatement to the return value * @param bool $withRelated add related links / homepage to the return value @@ -580,7 +579,7 @@ protected function getLogicalStructureInfo(IiifResourceInterface $resource, $rec * * @todo This method is still in experimental; the method signature may change. */ - public function getManifestMetadata($id, $cPid = 0, $withDescription = true, $withRights = true, $withRelated = true) + public function getManifestMetadata(string $id, bool $withDescription = true, bool $withRights = true, bool $withRelated = true): array { if (!empty($this->originalMetadataArray[$id])) { return $this->originalMetadataArray[$id]; @@ -622,7 +621,7 @@ public function getManifestMetadata($id, $cPid = 0, $withDescription = true, $wi /** * @see AbstractDocument::getMetadata() */ - public function getMetadata($id, $cPid = 0) + public function getMetadata(string $id, int $cPid = 0): array { if (!empty($this->metadataArray[$id]) && $this->metadataArray[0] == $cPid) { return $this->metadataArray[$id]; @@ -708,7 +707,7 @@ public function getMetadata($id, $cPid = 0) /** * @see AbstractDocument::_getSmLinks() */ - protected function _getSmLinks() + protected function _getSmLinks(): array { if (!$this->smLinksLoaded && isset($this->iiif) && $this->iiif instanceof ManifestInterface) { if (!empty($this->iiif->getDefaultCanvases())) { @@ -735,7 +734,7 @@ protected function _getSmLinks() * * @return void */ - private function smLinkRangeCanvasesRecursively(RangeInterface $range) + private function smLinkRangeCanvasesRecursively(RangeInterface $range): void { // map range's canvases including all child ranges' canvases if (!$range->isTopRange()) { @@ -761,7 +760,7 @@ private function smLinkRangeCanvasesRecursively(RangeInterface $range) * * @return void */ - private function smLinkCanvasToResource(CanvasInterface $canvas, IiifResourceInterface $resource) + private function smLinkCanvasToResource(CanvasInterface $canvas, IiifResourceInterface $resource): void { $this->smLinks['l2p'][$resource->getId()][] = $canvas->getId(); if (!is_array($this->smLinks['p2l'][$canvas->getId()]) || !in_array($resource->getId(), $this->smLinks['p2l'][$canvas->getId()])) { @@ -773,7 +772,7 @@ private function smLinkCanvasToResource(CanvasInterface $canvas, IiifResourceInt * @see AbstractDocument::getFullText() */ //TODO: rewrite it to get full OCR - public function getFullText($id) + public function getFullText(string $id): string { $rawText = ''; // Get text from raw text array if available. @@ -831,7 +830,7 @@ public function getFullText($id) * * @return IiifResourceInterface */ - public function getIiif() + public function getIiif(): IiifResourceInterface { return $this->iiif; } @@ -839,7 +838,7 @@ public function getIiif() /** * @see AbstractDocument::init() */ - protected function init($location) + protected function init(string $location): void { $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class); } @@ -847,7 +846,7 @@ protected function init($location) /** * @see AbstractDocument::loadLocation() */ - protected function loadLocation($location) + protected function loadLocation(string $location): bool { $fileResource = GeneralUtility::getUrl($location); if ($fileResource !== false) { @@ -870,7 +869,7 @@ protected function loadLocation($location) /** * @see AbstractDocument::prepareMetadataArray() */ - protected function prepareMetadataArray($cPid) + protected function prepareMetadataArray(int $cPid): void { $id = $this->iiif->getId(); $this->metadataArray[(string) $id] = $this->getMetadata((string) $id, $cPid); @@ -879,7 +878,7 @@ protected function prepareMetadataArray($cPid) /** * @see AbstractDocument::setPreloadedDocument() */ - protected function setPreloadedDocument($preloadedDocument) + protected function setPreloadedDocument($preloadedDocument): bool { if ($preloadedDocument instanceof ManifestInterface) { $this->iiif = $preloadedDocument; @@ -891,7 +890,7 @@ protected function setPreloadedDocument($preloadedDocument) /** * @see AbstractDocument::ensureHasFulltextIsSet() */ - protected function ensureHasFulltextIsSet() + protected function ensureHasFulltextIsSet(): void { /* * TODO Check annotations and annotation lists of canvas for ALTO documents. @@ -937,7 +936,7 @@ protected function ensureHasFulltextIsSet() /** * @see AbstractDocument::_getThumbnail() */ - protected function _getThumbnail($forceReload = false) + protected function _getThumbnail(bool $forceReload = false): string { return $this->iiif->getThumbnailUrl(); } @@ -945,7 +944,7 @@ protected function _getThumbnail($forceReload = false) /** * @see AbstractDocument::_getToplevelId() */ - protected function _getToplevelId() + protected function _getToplevelId(): string { if (empty($this->toplevelId)) { if (isset($this->iiif)) { @@ -963,7 +962,7 @@ protected function _getToplevelId() * * @return void */ - public function __wakeup() + public function __wakeup(): void { $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); IiifHelper::setUrlReader(IiifUrlReader::getInstance()); @@ -985,7 +984,7 @@ public function __wakeup() * * @return string[] */ - public function __sleep() + public function __sleep(): array { // TODO implement serializiation in IIIF library $jsonArray = $this->iiif->getOriginalJsonArray(); diff --git a/Classes/Common/IiifUrlReader.php b/Classes/Common/IiifUrlReader.php index 46e1be777..f56e63d24 100644 --- a/Classes/Common/IiifUrlReader.php +++ b/Classes/Common/IiifUrlReader.php @@ -31,7 +31,7 @@ class IiifUrlReader implements UrlReaderInterface * @access protected * @var IiifUrlReader Singleton instance of the class */ - protected static $instance; + protected static IiifUrlReader $instance; /** * @see UrlReaderInterface::getContent() @@ -55,7 +55,7 @@ public function getContent($url) * * @return IiifUrlReader */ - public static function getInstance() + public static function getInstance(): IiifUrlReader { if (!isset(self::$instance)) { self::$instance = new IiifUrlReader(); diff --git a/Classes/Common/Indexer.php b/Classes/Common/Indexer.php index 17c1cae7d..0462251d9 100644 --- a/Classes/Common/Indexer.php +++ b/Classes/Common/Indexer.php @@ -39,7 +39,7 @@ class Indexer * @static * @var string The extension key */ - public static $extKey = 'dlf'; + public static string $extKey = 'dlf'; /** * @access protected @@ -48,7 +48,7 @@ class Indexer * * @see loadIndexConf() */ - protected static $fields = [ + protected static array $fields = [ 'autocomplete' => [], 'facets' => [], 'sortables' => [], @@ -65,21 +65,21 @@ class Indexer * * @see $fields */ - protected static $fieldsLoaded = false; + protected static bool $fieldsLoaded = false; /** * @access protected * @static * @var array List of already processed documents */ - protected static $processedDocs = []; + protected static array $processedDocs = []; /** * @access protected * @static * @var Solr Instance of Solr class */ - protected static $solr; + protected static Solr $solr; /** * Insert given document into Solr index @@ -92,7 +92,7 @@ class Indexer * * @return bool true on success or false on failure */ - public static function add(Document $document, DocumentRepository $documentRepository) + public static function add(Document $document, DocumentRepository $documentRepository): bool { if (in_array($document->getUid(), self::$processedDocs)) { return true; @@ -206,7 +206,7 @@ public static function add(Document $document, DocumentRepository $documentRepos * * @return string The field's dynamic index name */ - public static function getIndexFieldName($index_name, $pid = 0) + public static function getIndexFieldName(string $index_name, int $pid = 0): string { // Sanitize input. $pid = max(intval($pid), 0); @@ -235,7 +235,7 @@ public static function getIndexFieldName($index_name, $pid = 0) * * @return void */ - protected static function loadIndexConf($pid) + protected static function loadIndexConf(int $pid): void { if (!self::$fieldsLoaded) { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) @@ -308,7 +308,7 @@ protected static function loadIndexConf($pid) * * @return bool true on success or false on failure */ - protected static function processLogical(Document $document, array $logicalUnit) + protected static function processLogical(Document $document, array $logicalUnit): bool { $success = true; $doc = $document->getCurrentDocument(); @@ -440,7 +440,7 @@ protected static function processLogical(Document $document, array $logicalUnit) * * @return bool true on success or false on failure */ - protected static function processPhysical(Document $document, $page, array $physicalUnit) + protected static function processPhysical(Document $document, int $page, array $physicalUnit): bool { $doc = $document->getCurrentDocument(); $doc->cPid = $document->getPid(); @@ -528,23 +528,20 @@ protected static function processPhysical(Document $document, $page, array $phys * * @return bool true on success or false on failure */ - protected static function solrConnect($core, $pid = 0) + protected static function solrConnect(int $core, int $pid = 0): bool { // Get Solr instance. - if (!self::$solr) { - // Connect to Solr server. - $solr = Solr::getInstance($core); - if ($solr->ready) { - self::$solr = $solr; - // Load indexing configuration if needed. - if ($pid) { - self::loadIndexConf($pid); - } - } else { - return false; + // Connect to Solr server. + $solr = Solr::getInstance($core); + if ($solr->ready) { + self::$solr = $solr; + // Load indexing configuration if needed. + if ($pid) { + self::loadIndexConf($pid); } + return true; } - return true; + return false; } /** @@ -561,7 +558,8 @@ protected static function solrConnect($core, $pid = 0) * * @return DocumentInterface */ - private static function getSolrDocument($updateQuery, $document, $unit, $fullText = '') { + private static function getSolrDocument(Query $updateQuery, Document $document, array $unit, string $fullText = ''): DocumentInterface + { $solrDoc = $updateQuery->createDocument(); // Create unique identifier from document's UID and unit's XML ID. $solrDoc->setField('id', $document->getUid() . $unit['id']); @@ -587,7 +585,8 @@ private static function getSolrDocument($updateQuery, $document, $unit, $fullTex * * @return array|string */ - private static function removeAppendsFromAuthor($authors) { + private static function removeAppendsFromAuthor($authors) + { if (is_array($authors)) { foreach ($authors as $i => $author) { $splitName = explode(chr(31), $author); diff --git a/Classes/Common/KitodoFlashMessageRenderer.php b/Classes/Common/KitodoFlashMessageRenderer.php index 21f9f6091..d47e91574 100644 --- a/Classes/Common/KitodoFlashMessageRenderer.php +++ b/Classes/Common/KitodoFlashMessageRenderer.php @@ -30,9 +30,9 @@ class KitodoFlashMessageRenderer implements FlashMessageRendererInterface { /** - * @var string The message severity class names + * @var array The message severity class names */ - protected static $classes = [ + protected static array $classes = [ FlashMessage::NOTICE => 'notice', FlashMessage::INFO => 'info', FlashMessage::OK => 'success', @@ -41,9 +41,9 @@ class KitodoFlashMessageRenderer implements FlashMessageRendererInterface ]; /** - * @var string The message severity icon names + * @var array The message severity icon names */ - protected static $icons = [ + protected static array $icons = [ FlashMessage::NOTICE => 'lightbulb-o', FlashMessage::INFO => 'info', FlashMessage::OK => 'check', diff --git a/Classes/Common/MetadataInterface.php b/Classes/Common/MetadataInterface.php index b79cd7e9a..5ff6f624e 100644 --- a/Classes/Common/MetadataInterface.php +++ b/Classes/Common/MetadataInterface.php @@ -34,5 +34,5 @@ interface MetadataInterface * * @return void */ - public function extractMetadata(\SimpleXMLElement $xml, array &$metadata); + public function extractMetadata(\SimpleXMLElement $xml, array &$metadata): void; } diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index 400884bcb..851fe11b0 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -81,19 +81,19 @@ final class MetsDocument extends AbstractDocument * * @see __sleep() / __wakeup() */ - protected $asXML = ''; + protected string $asXML = ''; /** * @access protected * @var array This maps the ID of each amdSec to the IDs of its children (techMD etc.). When an ADMID references an amdSec instead of techMD etc., this is used to iterate the child elements. */ - protected $amdSecChildIds = []; + protected array $amdSecChildIds = []; /** * @access protected * @var array Associative array of METS metadata sections indexed by their IDs. */ - protected $mdSec = []; + protected array $mdSec = []; /** * @access protected @@ -101,13 +101,13 @@ final class MetsDocument extends AbstractDocument * * @see MetsDocument::$mdSec */ - protected $mdSecLoaded = false; + protected bool $mdSecLoaded = false; /** * @access protected * @var array Subset of $mdSec storing only the dmdSec entries; kept for compatibility. */ - protected $dmdSec = []; + protected array $dmdSec = []; /** * @access protected @@ -115,7 +115,7 @@ final class MetsDocument extends AbstractDocument * * @see _getFileGrps() */ - protected $fileGrps = []; + protected array $fileGrps = []; /** * @access protected @@ -123,19 +123,19 @@ final class MetsDocument extends AbstractDocument * * @see $fileGrps */ - protected $fileGrpsLoaded = false; + protected bool $fileGrpsLoaded = false; /** * @access protected * @var \SimpleXMLElement This holds the XML file's METS part as \SimpleXMLElement object */ - protected $mets; + protected \SimpleXMLElement $mets; /** * @access protected - * @var string|null URL of the parent document (determined via mptr element), or empty string if none is available + * @var string URL of the parent document (determined via mptr element), or empty string if none is available */ - protected $parentHref; + protected string $parentHref = ''; /** * This adds metadata from METS structural map to metadata array. @@ -147,7 +147,7 @@ final class MetsDocument extends AbstractDocument * * @return void */ - public function addMetadataFromMets(&$metadata, $id) + public function addMetadataFromMets(array &$metadata, string $id): void { $details = $this->getLogicalStructure($id); if (!empty($details)) { @@ -160,7 +160,7 @@ public function addMetadataFromMets(&$metadata, $id) /** * @see AbstractDocument::establishRecordId() */ - protected function establishRecordId($pid) + protected function establishRecordId(int $pid): void { // Check for METS object @ID. if (!empty($this->mets['OBJID'])) { @@ -179,7 +179,7 @@ protected function establishRecordId($pid) /** * @see AbstractDocument::getDownloadLocation() */ - public function getDownloadLocation($id) + public function getDownloadLocation(string $id): string { $file = $this->getFileInfo($id); if ($file['mimeType'] === 'application/vnd.kitodo.iiif') { @@ -222,7 +222,7 @@ public function getFileInfo($id) /** * @see AbstractDocument::getFileLocation() */ - public function getFileLocation($id) + public function getFileLocation(string $id): string { $location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/mets:FLocat[@LOCTYPE="URL"]'); if ( @@ -239,7 +239,7 @@ public function getFileLocation($id) /** * @see AbstractDocument::getFileMimeType() */ - public function getFileMimeType($id) + public function getFileMimeType(string $id): string { $mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/@MIMETYPE'); if ( @@ -256,7 +256,7 @@ public function getFileMimeType($id) /** * @see AbstractDocument::getLogicalStructure() */ - public function getLogicalStructure($id, $recursive = false) + public function getLogicalStructure(string $id, bool $recursive = false): array { $details = []; // Is the requested logical unit already loaded? @@ -297,7 +297,7 @@ public function getLogicalStructure($id, $recursive = false) * * @return array Array of the element's id, label, type and physical page indexes/mptr link */ - protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false) + protected function getLogicalStructureInfo(\SimpleXMLElement $structure, bool $recursive = false): array { // Get attributes. foreach ($structure->attributes() as $attribute => $value) { @@ -404,7 +404,7 @@ protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recurs /** * @see AbstractDocument::getMetadata() */ - public function getMetadata($id, $cPid = 0) + public function getMetadata(string $id, int $cPid = 0): array { // Make sure $cPid is a non-negative integer. $cPid = max(intval($cPid), 0); @@ -635,7 +635,7 @@ class_exists($class) * * @return array */ - protected function getMetadataIds($id) + protected function getMetadataIds(string $id): array { // Load amdSecChildIds concordance $this->_getMdSec(); @@ -682,7 +682,7 @@ protected function getMetadataIds($id) /** * @see AbstractDocument::getFullText() */ - public function getFullText($id) + public function getFullText(string $id): string { $fullText = ''; @@ -697,7 +697,7 @@ public function getFullText($id) /** * @see AbstractDocument::getStructureDepth() */ - public function getStructureDepth($logId) + public function getStructureDepth(string $logId) { $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $logId . '"]/ancestor::*'); if (!empty($ancestors)) { @@ -710,7 +710,7 @@ public function getStructureDepth($logId) /** * @see AbstractDocument::init() */ - protected function init($location) + protected function init(string $location): void { $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(get_class($this)); // Get METS node from XML file. @@ -734,7 +734,7 @@ protected function init($location) /** * @see AbstractDocument::loadLocation() */ - protected function loadLocation($location) + protected function loadLocation(string $location): bool { $fileResource = Helper::getUrl($location); if ($fileResource !== false) { @@ -752,7 +752,7 @@ protected function loadLocation($location) /** * @see AbstractDocument::ensureHasFulltextIsSet() */ - protected function ensureHasFulltextIsSet() + protected function ensureHasFulltextIsSet(): void { // Are the fileGrps already loaded? if (!$this->fileGrpsLoaded) { @@ -763,7 +763,7 @@ protected function ensureHasFulltextIsSet() /** * @see AbstractDocument::setPreloadedDocument() */ - protected function setPreloadedDocument($preloadedDocument) + protected function setPreloadedDocument($preloadedDocument): bool { if ($preloadedDocument instanceof \SimpleXMLElement) { @@ -776,7 +776,7 @@ protected function setPreloadedDocument($preloadedDocument) /** * @see AbstractDocument::getDocument() */ - protected function getDocument() + protected function getDocument(): \SimpleXMLElement { return $this->mets; } @@ -788,7 +788,7 @@ protected function getDocument() * * @return array Array of metadata sections with their IDs as array key */ - protected function _getMdSec() + protected function _getMdSec(): array { if (!$this->mdSecLoaded) { $this->loadFormats(); @@ -838,7 +838,7 @@ protected function _getMdSec() * * @return array Array of metadata sections with their IDs as array key */ - protected function _getDmdSec() + protected function _getDmdSec(): array { $this->_getMdSec(); return $this->dmdSec; @@ -853,7 +853,7 @@ protected function _getDmdSec() * * @return array|null The processed metadata section */ - protected function processMdSec($element) + protected function processMdSec(\SimpleXMLElement $element): ?array { $mdId = (string) $element->attributes()->ID; if (empty($mdId)) { @@ -894,7 +894,7 @@ protected function processMdSec($element) * * @return array Array of file use groups with file IDs */ - protected function _getFileGrps() + protected function _getFileGrps(): array { if (!$this->fileGrpsLoaded) { // Get configured USE attributes. @@ -955,7 +955,7 @@ protected function _getFileInfos() /** * @see AbstractDocument::prepareMetadataArray() */ - protected function prepareMetadataArray($cPid) + protected function prepareMetadataArray(int $cPid): void { $ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID'); // Get all logical structure nodes with metadata. @@ -974,7 +974,7 @@ protected function prepareMetadataArray($cPid) * * @return \SimpleXMLElement The XML's METS part as \SimpleXMLElement object */ - protected function _getMets() + protected function _getMets(): \SimpleXMLElement { return $this->mets; } @@ -982,7 +982,7 @@ protected function _getMets() /** * @see AbstractDocument::_getPhysicalStructure() */ - protected function _getPhysicalStructure() + protected function _getPhysicalStructure(): array { // Is there no physical structure array yet? if (!$this->physicalStructureLoaded) { @@ -1044,7 +1044,7 @@ protected function _getPhysicalStructure() /** * @see AbstractDocument::_getSmLinks() */ - protected function _getSmLinks() + protected function _getSmLinks(): array { if (!$this->smLinksLoaded) { $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink'); @@ -1062,7 +1062,7 @@ protected function _getSmLinks() /** * @see AbstractDocument::_getThumbnail() */ - protected function _getThumbnail($forceReload = false) + protected function _getThumbnail(bool $forceReload = false): string { if ( !$this->thumbnailLoaded @@ -1141,7 +1141,7 @@ protected function _getThumbnail($forceReload = false) /** * @see AbstractDocument::_getToplevelId() */ - protected function _getToplevelId() + protected function _getToplevelId(): string { if (empty($this->toplevelId)) { // Get all logical structure nodes with metadata, but without associated METS-Pointers. @@ -1173,11 +1173,9 @@ protected function _getToplevelId() * * @return string */ - public function _getParentHref() + public function _getParentHref(): string { - if ($this->parentHref === null) { - $this->parentHref = ''; - + if (empty($this->parentHref)) { // Get the closest ancestor of the current document which has a MPTR child. $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $this->toplevelId . '"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr'); if (!empty($parentMptr)) { @@ -1196,7 +1194,7 @@ public function _getParentHref() * * @return array Properties to be serialized */ - public function __sleep() + public function __sleep(): array { // \SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization $this->asXML = $this->xml->asXML(); @@ -1210,7 +1208,7 @@ public function __sleep() * * @return string String representing the METS object */ - public function __toString() + public function __toString(): string { $xml = new \DOMDocument('1.0', 'utf-8'); $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true)); @@ -1226,7 +1224,7 @@ public function __toString() * * @return void */ - public function __wakeup() + public function __wakeup(): void { $xml = Helper::getXmlFileAsString($this->asXML); if ($xml !== false) { diff --git a/Classes/Common/Solr/SearchResult/Highlight.php b/Classes/Common/Solr/SearchResult/Highlight.php index 38625ee7b..a484c5ac4 100644 --- a/Classes/Common/Solr/SearchResult/Highlight.php +++ b/Classes/Common/Solr/SearchResult/Highlight.php @@ -27,37 +27,37 @@ class Highlight * @access private * @var string The identifier in form 'w_h_x_y' */ - private $id; + private string $id; /** * @access private * @var int The parent region's identifier */ - private $parentRegionId; + private int $parentRegionId; /** * @access private * @var int The horizontal beginning position of found highlight */ - private $xBeginPosition; + private int $xBeginPosition; /** * @access private * @var int The horizontal ending position of found highlight */ - private $xEndPosition; + private int $xEndPosition; /** * @access private * @var int The vertical beginning position of found highlight */ - private $yBeginPosition; + private int $yBeginPosition; /** * @access private * @var int The vertical ending position of found highlight */ - private $yEndPosition; + private int $yEndPosition; /** * The constructor for highlight. @@ -68,7 +68,7 @@ class Highlight * * @return void */ - public function __construct($highlight) + public function __construct(array $highlight) { $this->parentRegionId = $highlight['parentRegionIdx']; $this->xBeginPosition = $highlight['ulx']; @@ -85,7 +85,7 @@ public function __construct($highlight) * * @return string The highlight's identifier */ - public function getId() + public function getId(): string { return $this->id; } @@ -97,7 +97,7 @@ public function getId() * * @return int The highlight's horizontal beginning position */ - public function getXBeginPosition() + public function getXBeginPosition(): int { return $this->xBeginPosition; } @@ -109,7 +109,7 @@ public function getXBeginPosition() * * @return int The highlight's horizontal ending position */ - public function getXEndPosition() + public function getXEndPosition(): int { return $this->xEndPosition; } @@ -121,7 +121,7 @@ public function getXEndPosition() * * @return int The highlight's vertical beginning position */ - public function getYBeginPosition() + public function getYBeginPosition(): int { return $this->yBeginPosition; } @@ -133,7 +133,7 @@ public function getYBeginPosition() * * @return int The highlight's vertical ending position */ - public function getYEndPosition() + public function getYEndPosition(): int { return $this->yEndPosition; } diff --git a/Classes/Common/Solr/SearchResult/Page.php b/Classes/Common/Solr/SearchResult/Page.php index 6b7427735..b58630f47 100644 --- a/Classes/Common/Solr/SearchResult/Page.php +++ b/Classes/Common/Solr/SearchResult/Page.php @@ -27,25 +27,25 @@ class Page * @access private * @var int The identifier of the page */ - private $id; + private int $id; /** * @access private * @var string The name of the page */ - private $name; + private string $name; /** * @access private * @var int The width of found page */ - private $width; + private int $width; /** * @access private * @var int The height of found page */ - private $height; + private int $height; /** * The constructor for region. @@ -57,7 +57,7 @@ class Page * * @return void */ - public function __construct($id, $page) + public function __construct(int $id, array $page) { $this->id = $id; $this->name = $page['id']; @@ -72,7 +72,7 @@ public function __construct($id, $page) * * @return int The page's identifier */ - public function getId() + public function getId(): int { return $this->id; } @@ -84,7 +84,7 @@ public function getId() * * @return string The page's name */ - public function getName() + public function getName(): string { return $this->name; } @@ -96,7 +96,7 @@ public function getName() * * @return int The page's width */ - public function getWidth() + public function getWidth(): int { return $this->width; } @@ -108,7 +108,7 @@ public function getWidth() * * @return int The page's height */ - public function getHeight() + public function getHeight(): int { return $this->height; } diff --git a/Classes/Common/Solr/SearchResult/Region.php b/Classes/Common/Solr/SearchResult/Region.php index 741af675b..86b21c506 100644 --- a/Classes/Common/Solr/SearchResult/Region.php +++ b/Classes/Common/Solr/SearchResult/Region.php @@ -27,55 +27,55 @@ class Region * @access private * @var int The identifier of the region */ - private $id; + private int $id; /** * @access private - * @var int The identifier of the page in which text was found + * @var int|null The identifier of the page in which text was found */ - private $pageId; + private ?int $pageId; /** * @access private * @var int The horizontal beginning position of found region */ - private $xBeginPosition; + private int $xBeginPosition; /** * @access private * @var int The horizontal ending position of found region */ - private $xEndPosition; + private int $xEndPosition; /** * @access private * @var int The vertical beginning position of found region */ - private $yBeginPosition; + private int $yBeginPosition; /** * @access private * @var int The vertical ending position of found region */ - private $yEndPosition; + private int $yEndPosition; /** * @access private * @var int The width of found region */ - private $width; + private int $width; /** * @access private * @var int The height of found region */ - private $height; + private int $height; /** * @access private * @var string The text of found region */ - private $text; + private string $text; /** * The constructor for region. @@ -87,7 +87,7 @@ class Region * * @return void */ - public function __construct($id, $region) + public function __construct(int $id, array $region) { $this->id = $id; $this->pageId = $region['pageIdx']; @@ -107,7 +107,7 @@ public function __construct($id, $region) * * @return int The region's identifier */ - public function getId() + public function getId(): int { return $this->id; } @@ -117,9 +117,9 @@ public function getId() * * @access public * - * @return int The region's page identifier + * @return int|null The region's page identifier */ - public function getPageId() + public function getPageId(): ?int { return $this->pageId; } @@ -131,7 +131,7 @@ public function getPageId() * * @return int The region's horizontal beginning position */ - public function getXBeginPosition() + public function getXBeginPosition(): int { return $this->xBeginPosition; } @@ -143,7 +143,7 @@ public function getXBeginPosition() * * @return int The region's horizontal ending position */ - public function getXEndPosition() + public function getXEndPosition(): int { return $this->xEndPosition; } @@ -155,7 +155,7 @@ public function getXEndPosition() * * @return int The region's vertical beginning position */ - public function getYBeginPosition() + public function getYBeginPosition(): int { return $this->yBeginPosition; } @@ -167,7 +167,7 @@ public function getYBeginPosition() * * @return int The region's vertical ending position */ - public function getYEndPosition() + public function getYEndPosition(): int { return $this->yEndPosition; } @@ -179,7 +179,7 @@ public function getYEndPosition() * * @return int The region's width */ - public function getWidth() + public function getWidth(): int { return $this->width; } @@ -191,7 +191,7 @@ public function getWidth() * * @return int The region's height */ - public function getHeight() + public function getHeight(): int { return $this->height; } @@ -203,7 +203,7 @@ public function getHeight() * * @return string The region's text */ - public function getText() + public function getText(): string { return $this->text; } diff --git a/Classes/Common/Solr/SearchResult/ResultDocument.php b/Classes/Common/Solr/SearchResult/ResultDocument.php index 730b10a9c..2105c73df 100644 --- a/Classes/Common/Solr/SearchResult/ResultDocument.php +++ b/Classes/Common/Solr/SearchResult/ResultDocument.php @@ -12,6 +12,8 @@ namespace Kitodo\Dlf\Common\Solr\SearchResult; +use Solarium\QueryType\Select\Result\Document; + /** * ResultDocument class for the 'dlf' extension. It keeps the result of the search in the SOLR index. * @@ -27,86 +29,86 @@ class ResultDocument * @access private * @var string The identifier */ - private $id; + private ?string $id; /** * @access private * @var string|null The unified identifier */ - private $uid; + private ?string $uid; /** * @access private - * @var int The page on which result was found + * @var int|null The page on which result was found */ - private $page; + private ?int $page; /** * @access private - * @var string All snippets imploded to one string + * @var string|null All snippets imploded to one string */ - private $snippets; + private ?string $snippets; /** * @access private - * @var string The thumbnail URL + * @var string|null The thumbnail URL */ - private $thumbnail; + private ?string $thumbnail; /** * @access private - * @var string The title of the document / structure element (e.g. chapter) + * @var string|null The title of the document / structure element (e.g. chapter) */ - private $title; + private ?string $title; /** * @access private - * @var boolean It's a toplevel element? + * @var bool It's a toplevel element? */ - private $toplevel = false; + private bool $toplevel = false; /** * @access private - * @var string The structure type + * @var string|null The structure type */ - private $type; + private ?string $type; /** * @access private * @var Page[] All pages in which search phrase was found */ - private $pages = []; + private array $pages = []; /** * @access private * @var Region[] All regions in which search phrase was found */ - private $regions = []; + private array $regions = []; /** * @access private * @var Highlight[] All highlights of search phrase */ - private $highlights = []; + private array $highlights = []; /** * @access private * @var array The snippets for given record */ - private $snippetsForRecord = []; + private array $snippetsForRecord = []; /** * The constructor for result. * * @access public * - * @param array $record: Array of found document record + * @param Document $record: found document record * @param array $highlighting: Array of found highlight elements * @param array $fields: Array of fields used for search * * @return void */ - public function __construct($record, $highlighting, $fields) + public function __construct(Document $record, array $highlighting, array $fields) { $this->id = $record[$fields['id']]; $this->uid = $record[$fields['uid']]; @@ -132,7 +134,7 @@ public function __construct($record, $highlighting, $fields) * * @return string The result's record identifier */ - public function getId() + public function getId(): ?string { return $this->id; } @@ -144,7 +146,7 @@ public function getId() * * @return string|null The result's record unified identifier */ - public function getUid() + public function getUid(): ?string { return $this->uid; } @@ -154,9 +156,9 @@ public function getUid() * * @access public * - * @return int The result's record page + * @return int|null The result's record page */ - public function getPage() + public function getPage(): ?int { return $this->page; } @@ -166,9 +168,9 @@ public function getPage() * * @access public * - * @return string All result's record snippets imploded to one string + * @return string|null All result's record snippets imploded to one string */ - public function getSnippets() + public function getSnippets(): ?string { return $this->snippets; } @@ -178,9 +180,9 @@ public function getSnippets() * * @access public * - * @return string + * @return string|null */ - public function getThumbnail() + public function getThumbnail(): ?string { return $this->thumbnail; } @@ -190,9 +192,9 @@ public function getThumbnail() * * @access public * - * @return string + * @return string|null */ - public function getTitle() + public function getTitle(): ?string { return $this->title; } @@ -202,9 +204,9 @@ public function getTitle() * * @access public * - * @return boolean + * @return bool */ - public function getToplevel() + public function getToplevel(): bool { return $this->toplevel; } @@ -214,9 +216,9 @@ public function getToplevel() * * @access public * - * @return string + * @return string|null */ - public function getType() + public function getType(): ?string { return $this->type; } @@ -228,7 +230,7 @@ public function getType() * * @return array(Page) All result's pages which contain search phrase */ - public function getPages() + public function getPages(): array { return $this->pages; } @@ -240,7 +242,7 @@ public function getPages() * * @return array(Region) All result's regions which contain search phrase */ - public function getRegions() + public function getRegions(): array { return $this->regions; } @@ -252,7 +254,7 @@ public function getRegions() * * @return array(Highlight) All result's highlights of search phrase */ - public function getHighlights() + public function getHighlights(): array { return $this->highlights; } @@ -264,7 +266,7 @@ public function getHighlights() * * @return array(string) All result's highlights of search phrase */ - public function getHighlightsIds() + public function getHighlightsIds(): array { $highlightsIds = []; foreach ($this->highlights as $highlight) { @@ -281,7 +283,7 @@ public function getHighlightsIds() * * @return void */ - private function parseSnippets() + private function parseSnippets(): void { $snippetArray = $this->getArrayByIndex('text'); @@ -296,7 +298,7 @@ private function parseSnippets() * * @return void */ - private function parsePages() + private function parsePages(): void { $pageArray = $this->getArrayByIndex('pages'); @@ -317,7 +319,7 @@ private function parsePages() * * @return void */ - private function parseRegions() + private function parseRegions(): void { $regionArray = $this->getArrayByIndex('regions'); @@ -338,7 +340,7 @@ private function parseRegions() * * @return void */ - private function parseHighlights() + private function parseHighlights(): void { $highlightArray = $this->getArrayByIndex('highlights'); @@ -360,7 +362,7 @@ private function parseHighlights() * * @return array */ - private function getArrayByIndex($index) + private function getArrayByIndex(string $index): array { $objectArray = []; foreach ($this->snippetsForRecord as $snippet) { diff --git a/Classes/Common/Solr/Solr.php b/Classes/Common/Solr/Solr.php index fe2ef26c2..496837bce 100644 --- a/Classes/Common/Solr/Solr.php +++ b/Classes/Common/Solr/Solr.php @@ -52,68 +52,68 @@ class Solr implements LoggerAwareInterface * @access protected * @var array This holds the Solr configuration */ - protected $config = []; + protected array $config = []; /** * @access protected * @var string|null This holds the core name */ - protected $core = null; + protected ?string $core = null; /** * @access protected * @var int This holds the PID for the configuration */ - protected $cPid = 0; + protected int $cPid = 0; /** * @access public * @static * @var string The extension key */ - public static $extKey = 'dlf'; + public static string $extKey = 'dlf'; /** * @access public * @var array The fields for SOLR index */ - public static $fields = []; + public static array $fields = []; /** * @access protected * @var int This holds the max results */ - protected $limit = 50000; + protected int $limit = 50000; /** * @access protected * @var int This holds the number of hits for last search */ - protected $numberOfHits = 0; + protected int $numberOfHits = 0; /** * @access protected * @var array This holds the additional query parameters */ - protected $params = []; + protected array $params = []; /** * @access protected * @var bool Is the search instantiated successfully? */ - protected $ready = false; + protected bool $ready = false; /** * @access protected * @var array(Solr) This holds the singleton search objects with their core as array key */ - protected static $registry = []; + protected static array $registry = []; /** * @access protected * @var Client This holds the Solr service object */ - protected $service; + protected Client $service; /** * Add a new core to Apache Solr @@ -124,7 +124,7 @@ class Solr implements LoggerAwareInterface * * @return string The name of the new core */ - public static function createCore($core = '') + public static function createCore($core = ''): string { // Get next available core name if none given. if (empty($core)) { @@ -172,7 +172,7 @@ public static function createCore($core = '') * * @return string The escaped query string */ - public static function escapeQuery($query) + public static function escapeQuery(string $query): string { // Escape query by disallowing range and field operators // Permit operators: wildcard, boolean, fuzzy, proximity, boost, grouping @@ -190,7 +190,7 @@ public static function escapeQuery($query) * * @return string The escaped query string */ - public static function escapeQueryKeepField($query, $pid) + public static function escapeQueryKeepField(string $query, int $pid): string { // Is there a field query? if (preg_match('/^[[:alnum:]]+_[tu][su]i:\(?.*\)?$/', $query)) { @@ -241,7 +241,7 @@ public static function escapeQueryKeepField($query, $pid) * * @return array fields */ - public static function getFields() + public static function getFields(): array { if (empty(self::$fields)) { $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); @@ -327,7 +327,7 @@ public static function getInstance($core = null) * * @return int First unused core number found */ - public static function getNextCoreNumber($number = 0) + public static function getNextCoreNumber(int $number = 0): int { $number = max(intval($number), 0); // Check if core already exists. @@ -346,7 +346,7 @@ public static function getNextCoreNumber($number = 0) * * @return void */ - protected function loadSolrConnectionInfo() + protected function loadSolrConnectionInfo(): void { if (empty($this->config)) { $config = []; @@ -387,7 +387,7 @@ protected function loadSolrConnectionInfo() * * @return array The Apache Solr Documents that were fetched */ - public function search_raw($parameters = []) + public function search_raw(array $parameters = []): array { // Set additional query parameters. $parameters['start'] = 0; @@ -418,7 +418,7 @@ public function search_raw($parameters = []) * * @return string|null The core name of the current query endpoint or null if core admin endpoint */ - protected function _getCore() + protected function _getCore(): ?string { return $this->core; } @@ -430,7 +430,7 @@ protected function _getCore() * * @return int The max number of results */ - protected function _getLimit() + protected function _getLimit(): int { return $this->limit; } @@ -442,7 +442,7 @@ protected function _getLimit() * * @return int Total number of hits for last search */ - protected function _getNumberOfHits() + protected function _getNumberOfHits(): int { return $this->numberOfHits; } @@ -454,7 +454,7 @@ protected function _getNumberOfHits() * * @return bool Is the search instantiated successfully? */ - protected function _getReady() + protected function _getReady(): bool { return $this->ready; } @@ -464,9 +464,9 @@ protected function _getReady() * * @access protected * - * @return \Solarium\Client Apache Solr service object + * @return Client Apache Solr service object */ - protected function _getService() + protected function _getService(): Client { return $this->service; } @@ -480,7 +480,7 @@ protected function _getService() * * @return void */ - protected function _setCPid($value) + protected function _setCPid(int $value): void { $this->cPid = max(intval($value), 0); } @@ -494,7 +494,7 @@ protected function _setCPid($value) * * @return void */ - protected function _setLimit($value) + protected function _setLimit(int $value): void { $this->limit = max(intval($value), 0); } @@ -508,7 +508,7 @@ protected function _setLimit($value) * * @return void */ - protected function _setParams(array $value) + protected function _setParams(array $value): void { $this->params = $value; } @@ -522,7 +522,7 @@ protected function _setParams(array $value) * * @return mixed Value of $this->$var */ - public function __get($var) + public function __get(string $var) { $method = '_get' . ucfirst($var); if ( @@ -545,7 +545,7 @@ public function __get($var) * * @return bool true if variable is set and not empty, false otherwise */ - public function __isset($var) + public function __isset(string $var): bool { return !empty($this->__get($var)); } @@ -560,7 +560,7 @@ public function __isset($var) * * @return void */ - public function __set($var, $value) + public function __set(string $var, $value): void { $method = '_set' . ucfirst($var); if ( @@ -582,7 +582,7 @@ public function __set($var, $value) * * @return void */ - protected function __construct($core) + protected function __construct(?string $core) { // Get Solr connection parameters from configuration. $this->loadSolrConnectionInfo(); diff --git a/Classes/Common/Solr/SolrSearch.php b/Classes/Common/Solr/SolrSearch.php index c7a7c7e1a..77ac18ace 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -5,9 +5,10 @@ use Kitodo\Dlf\Common\AbstractDocument; use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\Indexer; +use Kitodo\Dlf\Common\Solr\SearchResult\ResultDocument; use Kitodo\Dlf\Domain\Model\Collection; use Kitodo\Dlf\Domain\Repository\DocumentRepository; -use Kitodo\Dlf\Common\Solr\SearchResult\ResultDocument; +use Solarium\QueryType\Select\Result\Document; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -33,11 +34,11 @@ class SolrSearch implements \Countable, \Iterator, \ArrayAccess, QueryResultInte * @access private * @var DocumentRepository */ - private $documentRepository; + private DocumentRepository $documentRepository; /** * @access private - * @var QueryResult|Collection + * @var QueryResult|Collection|null */ private $collection; @@ -45,25 +46,25 @@ class SolrSearch implements \Countable, \Iterator, \ArrayAccess, QueryResultInte * @access private * @var array */ - private $settings; + private array $settings; /** * @access private * @var array */ - private $searchParams; + private array $searchParams; /** * @access private * @var QueryResult */ - private $listedMetadata; + private ?QueryResult $listedMetadata; /** * @access private * @var array */ - private $params; + private array $params; /** * @access private @@ -75,7 +76,7 @@ class SolrSearch implements \Countable, \Iterator, \ArrayAccess, QueryResultInte * @access private * @var int */ - protected $position = 0; + protected int $position = 0; /** * Constructs SolrSearch instance. @@ -83,14 +84,14 @@ class SolrSearch implements \Countable, \Iterator, \ArrayAccess, QueryResultInte * @access public * * @param DocumentRepository $documentRepository - * @param QueryResult|Collection $collection + * @param QueryResult|Collection|null $collection * @param array $settings * @param array $searchParams * @param QueryResult $listedMetadata * * @return void */ - public function __construct($documentRepository, $collection, $settings, $searchParams, $listedMetadata = null) + public function __construct(DocumentRepository $documentRepository, $collection, array $settings, array $searchParams, QueryResult $listedMetadata = null) { $this->documentRepository = $documentRepository; $this->collection = $collection; @@ -106,7 +107,7 @@ public function __construct($documentRepository, $collection, $settings, $search * * @return int */ - public function getNumLoadedDocuments() + public function getNumLoadedDocuments(): int { return count($this->result['documents']); } @@ -132,9 +133,9 @@ public function count(): int * * @access public * - * @return SolrSearch + * @return array */ - public function current() + public function current(): array { return $this[$this->position]; } @@ -146,7 +147,7 @@ public function current() * * @return int */ - public function key() + public function key(): int { return $this->position; } @@ -620,7 +621,7 @@ public function submit($start, $rows, $processResults = true) * * @return array */ - protected function fetchToplevelMetadataFromSolr($queryParams) + protected function fetchToplevelMetadataFromSolr(array $queryParams): array { // Prepare query parameters. $params = $queryParams; @@ -768,14 +769,14 @@ protected function searchSolr($parameters = [], $enableCache = true) * * @access private * - * @param array $record + * @param Document $record * @param array $highlighting * @param array $fields * @param array $parameters * * @return array The Apache Solr Documents that were fetched */ - private function getDocument($record, $highlighting, $fields, $parameters) { + private function getDocument(Document $record, array $highlighting, array $fields, $parameters) { $resultDocument = new ResultDocument($record, $highlighting, $fields); $document = [ diff --git a/Classes/Common/Solr/SolrSearchQuery.php b/Classes/Common/Solr/SolrSearchQuery.php index 98fd5ad45..1ab24a327 100644 --- a/Classes/Common/Solr/SolrSearchQuery.php +++ b/Classes/Common/Solr/SolrSearchQuery.php @@ -24,19 +24,19 @@ class SolrSearchQuery implements QueryInterface * @access private * @var SolrSearch */ - private $solrSearch; + private SolrSearch $solrSearch; /** * @access private * @var int */ - private $limit; + private int $limit; /** * @access private * @var int */ - private $offset; + private int $offset; /** * Constructs SolrSearchQuery instance. @@ -90,7 +90,7 @@ public function setOrderings(array $orderings) {} * * @return SolrSearchQuery */ - public function setLimit($limit) + public function setLimit($limit): SolrSearchQuery { $this->limit = $limit; return $this; @@ -105,7 +105,7 @@ public function setLimit($limit) * * @return SolrSearchQuery */ - public function setOffset($offset) + public function setOffset($offset): SolrSearchQuery { $this->offset = $offset; return $this; @@ -141,7 +141,7 @@ public function getOrderings() {} * * @return int */ - public function getLimit() + public function getLimit(): int { return $this->limit; } @@ -153,7 +153,7 @@ public function getLimit() * * @return int */ - public function getOffset() + public function getOffset(): int { return $this->offset; } diff --git a/Classes/Common/SolrPaginator.php b/Classes/Common/SolrPaginator.php index 7ce877b0f..48a945bbe 100644 --- a/Classes/Common/SolrPaginator.php +++ b/Classes/Common/SolrPaginator.php @@ -12,6 +12,7 @@ namespace Kitodo\Dlf\Common; +use Kitodo\Dlf\Common\Solr\SolrSearch; use TYPO3\CMS\Core\Pagination\AbstractPaginator; class SolrPaginator extends AbstractPaginator @@ -19,12 +20,12 @@ class SolrPaginator extends AbstractPaginator /** * @var SolrSearch */ - private $solrSearch; + private SolrSearch $solrSearch; /** * @var array */ - private $paginatedItems = []; + private array $paginatedItems = []; public function __construct( SolrSearch $solrSearch, diff --git a/Classes/Eid/PageViewProxy.php b/Classes/Eid/PageViewProxy.php index 096c01f62..d745b5064 100644 --- a/Classes/Eid/PageViewProxy.php +++ b/Classes/Eid/PageViewProxy.php @@ -40,13 +40,13 @@ class PageViewProxy * @access protected * @var RequestFactory */ - protected $requestFactory; + protected RequestFactory $requestFactory; /** * @access protected - * @var mixed + * @var array */ - protected $extConf; + protected array $extConf; /** * Constructs the instance @@ -100,7 +100,7 @@ protected function copyHeaders( ResponseInterface $fromResponse, ResponseInterface $toResponse, array $headerNames - ) { + ): ResponseInterface { $result = $toResponse; foreach ($headerNames as $headerName) { @@ -233,7 +233,7 @@ protected function handleGet(ServerRequestInterface $request): ResponseInterface * * @return ResponseInterface */ - public function main(ServerRequestInterface $request) + public function main(ServerRequestInterface $request): ResponseInterface { switch ($request->getMethod()) { case 'OPTIONS': diff --git a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php index cc7935b34..424e8c7f6 100644 --- a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php +++ b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php @@ -55,14 +55,14 @@ public function getFunctions() * @var Document * @access protected */ - protected $document; + protected Document $document; /** * @var ConfigurationManager */ protected $configurationManager; - public function injectConfigurationManager(ConfigurationManager $configurationManager) + public function injectConfigurationManager(ConfigurationManager $configurationManager): void { $this->configurationManager = $configurationManager; } @@ -75,7 +75,7 @@ public function injectConfigurationManager(ConfigurationManager $configurationMa /** * @param DocumentRepository $documentRepository */ - public function injectDocumentRepository(DocumentRepository $documentRepository) + public function injectDocumentRepository(DocumentRepository $documentRepository): void { $this->documentRepository = $documentRepository; } @@ -88,7 +88,7 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) * * @return void */ - protected function initializeRepositories($storagePid) + protected function initializeRepositories(int $storagePid): void { $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); @@ -160,7 +160,7 @@ function($arguments, $cPid) * * @return void */ - protected function loadDocument($requestData, int $pid) + protected function loadDocument(array $requestData, int $pid): void { // Try to get document format from database if (!empty($requestData['id'])) { diff --git a/Classes/Format/Alto.php b/Classes/Format/Alto.php index 01ea86d25..e07dc8c6b 100644 --- a/Classes/Format/Alto.php +++ b/Classes/Format/Alto.php @@ -33,7 +33,7 @@ class Alto implements \Kitodo\Dlf\Common\FulltextInterface * * @return string The raw unformatted fulltext */ - public function getRawText(\SimpleXMLElement $xml) + public function getRawText(\SimpleXMLElement $xml): string { $rawText = ''; $xml->registerXPathNamespace('alto', 'http://www.loc.gov/standards/alto/ns-v2#'); @@ -66,7 +66,7 @@ public function getRawText(\SimpleXMLElement $xml) * * @return string The unformatted fulltext in MiniOCR format */ - public function getTextAsMiniOcr(\SimpleXMLElement $xml) + public function getTextAsMiniOcr(\SimpleXMLElement $xml): string { $xml->registerXPathNamespace('alto', 'http://www.loc.gov/standards/alto/ns-v2#'); @@ -111,7 +111,7 @@ public function getTextAsMiniOcr(\SimpleXMLElement $xml) * * @return string The parsed word extracted from attribute */ - private function getWord($attributes) + private function getWord(\SimpleXMLElement $attributes): string { if (!empty($attributes['SUBS_CONTENT'])) { if ($attributes['SUBS_TYPE'] == 'HypPart1') { @@ -131,7 +131,7 @@ private function getWord($attributes) * * @return string The parsed word coordinates extracted from attribute */ - private function getCoordinates($attributes) + private function getCoordinates(\SimpleXMLElement $attributes): string { return (string) $attributes['HPOS'] . ' ' . (string) $attributes['VPOS'] . ' ' . (string) $attributes['WIDTH'] . ' ' . (string) $attributes['HEIGHT']; } diff --git a/Classes/Format/AudioVideoMD.php b/Classes/Format/AudioVideoMD.php index 52a6f0b30..3cd4ec93a 100644 --- a/Classes/Format/AudioVideoMD.php +++ b/Classes/Format/AudioVideoMD.php @@ -37,7 +37,7 @@ class AudioVideoMD implements MetadataInterface * * @return void */ - public function extractMetadata(\SimpleXMLElement $xml, array &$metadata) + public function extractMetadata(\SimpleXMLElement $xml, array &$metadata): void { $xml->registerXPathNamespace('audiomd', 'http://www.loc.gov/audioMD/'); $xml->registerXPathNamespace('videomd', 'http://www.loc.gov/videoMD/'); diff --git a/Classes/Format/Mods.php b/Classes/Format/Mods.php index 295a01183..eca0b2764 100644 --- a/Classes/Format/Mods.php +++ b/Classes/Format/Mods.php @@ -48,7 +48,7 @@ class Mods implements MetadataInterface * * @return void */ - public function extractMetadata(\SimpleXMLElement $xml, array &$metadata) + public function extractMetadata(\SimpleXMLElement $xml, array &$metadata): void { $this->xml = $xml; $this->metadata = $metadata; @@ -70,7 +70,8 @@ public function extractMetadata(\SimpleXMLElement $xml, array &$metadata) * * @return void */ - private function getAuthors() { + private function getAuthors(): void + { $authors = $this->xml->xpath('./mods:name[./mods:role/mods:roleTerm[@type="code" and @authority="marcrelator"]="aut"]'); // Get "author" and "author_sorting" again if that was too sophisticated. @@ -103,7 +104,8 @@ private function getAuthors() { * * @return void */ - private function getAuthorFromOrcidApi($orcidId, $authors, $i) { + private function getAuthorFromOrcidApi(string $orcidId, array $authors, int $i): void + { $profile = new OrcidProfile($orcidId); $name = $profile->getFullName(); if (!empty($name)) { @@ -127,7 +129,8 @@ private function getAuthorFromOrcidApi($orcidId, $authors, $i) { * * @return void */ - private function getAuthorFromXml($authors, $i) { + private function getAuthorFromXml(array $authors, int $i): void + { $this->getAuthorFromXmlDisplayForm($authors, $i); $nameParts = $authors[$i]->xpath('./mods:namePart'); @@ -180,7 +183,8 @@ private function getAuthorFromXml($authors, $i) { * * @return void */ - private function getAuthorFromXmlDisplayForm($authors, $i) { + private function getAuthorFromXmlDisplayForm(array $authors, int $i): void + { $displayForm = $authors[$i]->xpath('./mods:displayForm'); if ($displayForm) { $this->metadata['author'][$i] = (string) $displayForm[0]; @@ -194,7 +198,8 @@ private function getAuthorFromXmlDisplayForm($authors, $i) { * * @return void */ - private function getHolders() { + private function getHolders(): void + { $holders = $this->xml->xpath('./mods:name[./mods:role/mods:roleTerm[@type="code" and @authority="marcrelator"]="prv"]'); if (!empty($holders)) { @@ -222,7 +227,8 @@ private function getHolders() { * * @return void */ - private function getHolderFromViafApi($viafId, $holders, $i) { + private function getHolderFromViafApi(string $viafId, array $holders, int $i): void + { $profile = new ViafProfile($viafId); $name = $profile->getFullName(); if (!empty($name)) { @@ -246,7 +252,8 @@ private function getHolderFromViafApi($viafId, $holders, $i) { * * @return void */ - private function getHolderFromXml($holders, $i) { + private function getHolderFromXml(array $holders, int $i): void + { $this->getHolderFromXmlDisplayForm($holders, $i); // Append "valueURI" to name using Unicode unit separator. if (isset($holders[$i]['valueURI'])) { @@ -264,7 +271,8 @@ private function getHolderFromXml($holders, $i) { * * @return void */ - private function getHolderFromXmlDisplayForm($holders, $i) { + private function getHolderFromXmlDisplayForm(array $holders, int $i): void + { // Check if there is a display form. $displayForm = $holders[$i]->xpath('./mods:displayForm'); if ($displayForm) { @@ -279,7 +287,8 @@ private function getHolderFromXmlDisplayForm($holders, $i) { * * @return void */ - private function getPlaces() { + private function getPlaces(): void + { $places = $this->xml->xpath('./mods:originInfo[not(./mods:edition="[Electronic ed.]")]/mods:place/mods:placeTerm'); // Get "place" and "place_sorting" again if that was to sophisticated. if (empty($places)) { @@ -303,7 +312,8 @@ private function getPlaces() { * * @return void */ - private function getYears() { + private function getYears(): void + { // Get "year_sorting". if (($years_sorting = $this->xml->xpath('./mods:originInfo[not(./mods:edition="[Electronic ed.]")]/mods:dateOther[@type="order" and @encoding="w3cdtf"]'))) { foreach ($years_sorting as $year_sorting) { diff --git a/Classes/Format/TeiHeader.php b/Classes/Format/TeiHeader.php index ef5cab94f..0dcb05719 100644 --- a/Classes/Format/TeiHeader.php +++ b/Classes/Format/TeiHeader.php @@ -34,7 +34,7 @@ class TeiHeader implements MetadataInterface * * @return void */ - public function extractMetadata(\SimpleXMLElement $xml, array &$metadata) + public function extractMetadata(\SimpleXMLElement $xml, array &$metadata): void { $xml->registerXPathNamespace('teihdr', 'http://www.tei-c.org/ns/1.0'); } diff --git a/Classes/Hooks/ConfigurationForm.php b/Classes/Hooks/ConfigurationForm.php index daa254715..f79d01fd7 100644 --- a/Classes/Hooks/ConfigurationForm.php +++ b/Classes/Hooks/ConfigurationForm.php @@ -34,7 +34,7 @@ class ConfigurationForm * * @return string Message informing the user of success or failure */ - public function checkSolrConnection() + public function checkSolrConnection(): string { $solr = Solr::getInstance(); if ($solr->ready) { diff --git a/Classes/Hooks/DataHandler.php b/Classes/Hooks/DataHandler.php index 97e140b9a..b61dca4aa 100644 --- a/Classes/Hooks/DataHandler.php +++ b/Classes/Hooks/DataHandler.php @@ -41,7 +41,7 @@ class DataHandler implements LoggerAwareInterface * @access protected * @var DocumentRepository */ - protected $documentRepository; + protected DocumentRepository $documentRepository; /** * Gets document repository @@ -50,7 +50,7 @@ class DataHandler implements LoggerAwareInterface * * @return DocumentRepository */ - protected function getDocumentRepository() + protected function getDocumentRepository(): DocumentRepository { if ($this->documentRepository === null) { $objectManager = GeneralUtility::makeInstance(ObjectManager::class); @@ -72,7 +72,7 @@ protected function getDocumentRepository() * * @return void */ - public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray) + public function processDatamap_postProcessFieldArray(string $status, string $table, int $id, array &$fieldArray): void { if ($status == 'new') { switch ($table) { @@ -204,7 +204,7 @@ public function processDatamap_postProcessFieldArray($status, $table, $id, &$fie * * @return void */ - public function processDatamap_afterDatabaseOperations($status, $table, $id, &$fieldArray) + public function processDatamap_afterDatabaseOperations(string $status, string $table, int $id, array &$fieldArray): void { if ($status == 'update') { switch ($table) { @@ -268,7 +268,7 @@ public function processDatamap_afterDatabaseOperations($status, $table, $id, &$f } } } - break; + break; } } } @@ -284,7 +284,7 @@ public function processDatamap_afterDatabaseOperations($status, $table, $id, &$f * * @return void */ - public function processCmdmap_postProcess($command, $table, $id) + public function processCmdmap_postProcess(string $command, string $table, int $id): void { if ( in_array($command, ['move', 'delete', 'undelete']) @@ -343,7 +343,7 @@ public function processCmdmap_postProcess($command, $table, $id) $doc = AbstractDocument::getInstance($document->getLocation(), ['storagePid' => $document->getPid()], true); if ($document !== null && $doc !== null) { $document->setCurrentDocument($doc); - Indexer::add($document); + Indexer::add($document, $this->getDocumentRepository()); } else { $this->logger->error('Failed to re-index document with UID ' . $id); } diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php index e25f40347..84482667a 100644 --- a/Classes/Hooks/ItemsProcFunc.php +++ b/Classes/Hooks/ItemsProcFunc.php @@ -48,7 +48,7 @@ class ItemsProcFunc implements LoggerAwareInterface * * @return void */ - public function toolList(&$params) + public function toolList(array &$params): void { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'] as $class => $label) { $params['items'][] = [Helper::getLanguageService()->sL($label), $class]; @@ -64,7 +64,8 @@ public function toolList(&$params) * * @return void */ - public function getTyposcriptConfigFromPluginSiteRoot($params) { + public function getTyposcriptConfigFromPluginSiteRoot(array $params): void + { $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $pid = $params['flexParentDatabaseRow']['pid']; $rootLine = BackendUtility::BEgetRootLine($pid); @@ -99,7 +100,7 @@ public function getTyposcriptConfigFromPluginSiteRoot($params) { * * @return void */ - public function extendedSearchList(&$params) + public function extendedSearchList(array &$params): void { $this->generateList( $params, @@ -141,7 +142,7 @@ public function getFacetsList(array &$params): void * * @return void */ - protected function generateList(&$params, $fields, $table, $sorting, $andWhere = '') + protected function generateList(array &$params, string $fields, string $table, string $sorting, string $andWhere = ''): void { $this->getTyposcriptConfigFromPluginSiteRoot($params); diff --git a/Classes/Hooks/KitodoProductionHacks.php b/Classes/Hooks/KitodoProductionHacks.php index 49a3f37b5..3faab53d5 100644 --- a/Classes/Hooks/KitodoProductionHacks.php +++ b/Classes/Hooks/KitodoProductionHacks.php @@ -34,7 +34,7 @@ class KitodoProductionHacks * * @return void */ - public function construct_postProcessRecordId(\SimpleXMLElement &$xml, &$record_id) + public function construct_postProcessRecordId(\SimpleXMLElement &$xml, &$record_id): void { if (!$record_id) { $xml->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); diff --git a/Classes/Hooks/ThumbnailCustomElement.php b/Classes/Hooks/ThumbnailCustomElement.php index 10ae1e95a..f0c77895e 100644 --- a/Classes/Hooks/ThumbnailCustomElement.php +++ b/Classes/Hooks/ThumbnailCustomElement.php @@ -24,6 +24,7 @@ */ class ThumbnailCustomElement extends AbstractFormElement { + /** * Renders thumbnail custom element. * @@ -31,7 +32,7 @@ class ThumbnailCustomElement extends AbstractFormElement * * @return array */ - public function render() + public function render(): array { // Custom TCA properties and other data can be found in $this->data, for example the above // parameters are available in $this->data['parameterArray']['fieldConf']['config']['parameters'] diff --git a/Classes/Middleware/SearchInDocument.php b/Classes/Middleware/SearchInDocument.php index 7cf6475bb..bc0803792 100644 --- a/Classes/Middleware/SearchInDocument.php +++ b/Classes/Middleware/SearchInDocument.php @@ -167,11 +167,11 @@ private function executeSolrQuery($parameters) * * @access private * - * @param array|object $parameters parsed from request body + * @param array $parameters parsed from request body * * @return string SOLR query */ - private function getQuery($parameters) + private function getQuery(array $parameters): string { return $this->fields['fulltext'] . ':(' . Solr::escapeQuery((string) $parameters['q']) . ') AND ' . $this->fields['uid'] . ':' . $this->getUid($parameters['uid']); } @@ -186,7 +186,7 @@ private function getQuery($parameters) * * @return int|string uid of the document */ - private function getUid($uid) + private function getUid(string $uid) { return is_numeric($uid) ? intval($uid) : $uid; } diff --git a/Classes/Pagination/PageGridPaginator.php b/Classes/Pagination/PageGridPaginator.php index e98c25c42..40cf7552d 100644 --- a/Classes/Pagination/PageGridPaginator.php +++ b/Classes/Pagination/PageGridPaginator.php @@ -24,17 +24,17 @@ final class PageGridPaginator extends AbstractPaginator /** * @var array */ - private $items; + private array $items; /** * @var int */ - public $publicItemsPerPage; + public int $publicItemsPerPage; /** * @var array */ - private $paginatedItems = []; + private array $paginatedItems = []; public function __construct( array $items, diff --git a/Classes/Updates/FileLocationUpdater.php b/Classes/Updates/FileLocationUpdater.php index 51c977ea8..086a2e83c 100644 --- a/Classes/Updates/FileLocationUpdater.php +++ b/Classes/Updates/FileLocationUpdater.php @@ -42,25 +42,19 @@ class FileLocationUpdater implements UpgradeWizardInterface, ChattyInterface, Lo * @access protected * @var OutputInterface */ - protected $output; + protected OutputInterface $output; /** * @access protected * @var ResourceStorage */ - protected $storage; - - /** - * @access protected - * @var Logger - */ - protected $logger; + protected ResourceStorage $storage; /** * @access protected * @var array Array with table and fields to migrate */ - protected $fieldsToMigrate = [ + protected array $fieldsToMigrate = [ 'tx_dlf_collections' => 'thumbnail' ]; @@ -175,7 +169,7 @@ public function executeUpdate(): bool * * @throws \RuntimeException */ - protected function getRecordsFromTable($countOnly = false) + protected function getRecordsFromTable(bool $countOnly = false) { $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $allResults = []; @@ -263,7 +257,7 @@ protected function performUpdate(): bool * * @throws \Exception */ - protected function migrateField($table, $row) + protected function migrateField(string $table, array $row): void { $fieldItem = trim($row[$this->fieldsToMigrate[$table]]); diff --git a/Classes/ViewHelpers/JsFooterViewHelper.php b/Classes/ViewHelpers/JsFooterViewHelper.php index de4b6d8ec..a0d303def 100755 --- a/Classes/ViewHelpers/JsFooterViewHelper.php +++ b/Classes/ViewHelpers/JsFooterViewHelper.php @@ -1,4 +1,5 @@ * @@ -31,7 +32,7 @@ class JsFooterViewHelper extends AbstractViewHelper * * @access public */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('inlineCode', 'string', 'Inline JavaScript', true); @@ -50,7 +51,8 @@ public static function renderStatic( array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext - ) { + ): void + { $inlineCode = $arguments['inlineCode']; /** @var $pageRenderer PageRenderer */ diff --git a/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php b/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php index 10231bd49..5f8771e2d 100644 --- a/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php +++ b/Classes/ViewHelpers/MetadataWrapVariableViewHelper.php @@ -46,7 +46,7 @@ class MetadataWrapVariableViewHelper extends AbstractViewHelper * * @return void */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('name', 'string', 'Name of variable to create', true); } @@ -66,7 +66,8 @@ public static function renderStatic( array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext - ) { + ): void + { $parser = GeneralUtility::makeInstance(TypoScriptParser::class); $parser->parse($renderChildrenClosure()); $wrap = [ diff --git a/Classes/ViewHelpers/StdWrapViewHelper.php b/Classes/ViewHelpers/StdWrapViewHelper.php index 32b55a8b3..164b38199 100644 --- a/Classes/ViewHelpers/StdWrapViewHelper.php +++ b/Classes/ViewHelpers/StdWrapViewHelper.php @@ -38,7 +38,7 @@ class StdWrapViewHelper extends AbstractViewHelper * * @return void */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('wrap', 'string', 'The wrap information', true); @@ -52,7 +52,7 @@ public function initializeArguments() * * @return string */ - public function render() + public function render(): string { $wrap = $this->arguments['wrap']; $data = $this->arguments['data'] ?? []; diff --git a/Tests/Functional/Common/SolrIndexingTest.php b/Tests/Functional/Common/SolrIndexingTest.php index 90fda4f8e..559d69df5 100644 --- a/Tests/Functional/Common/SolrIndexingTest.php +++ b/Tests/Functional/Common/SolrIndexingTest.php @@ -92,7 +92,7 @@ public function canIndexAndSearchDocument() // Check that the title stored in Solr matches the title of database entry $docTitleInSolr = false; foreach ($solrSearch->getSolrResults()['documents'] as $solrDoc) { - if ($solrDoc['toplevel'] && $solrDoc['uid'] === $document->getUid()) { + if ($solrDoc['toplevel'] && intval($solrDoc['uid']) === intval($document->getUid())) { $this->assertEquals($document->getTitle(), $solrDoc['title']); $docTitleInSolr = true; break; From 2fa20c80f7c89c1920795331822fbb76f3e63551 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 29 Sep 2023 22:41:06 +0200 Subject: [PATCH 09/76] [BUGFIX] Fix calls for Indexer::add function (#1019) Co-authored-by: Sebastian Meyer --- Classes/Command/BaseCommand.php | 2 +- Classes/Common/Indexer.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index e35630cbc..f5b093f3a 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -341,7 +341,7 @@ protected function getParentDocumentUidForSaving(Document $document): int if ($success === true) { // add to index - Indexer::add($parentDocument); + Indexer::add($parentDocument, $this->documentRepository); return $parentDocument->getUid(); } } diff --git a/Classes/Common/Indexer.php b/Classes/Common/Indexer.php index 0462251d9..c9d0e7878 100644 --- a/Classes/Common/Indexer.php +++ b/Classes/Common/Indexer.php @@ -89,6 +89,7 @@ class Indexer * @static * * @param Document $document The document to add + * @param DocumentRepository $documentRepository The document repository for search of parent * * @return bool true on success or false on failure */ From 4cdd51207c878d8f0683474801e6a703b0dacdd0 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 29 Sep 2023 23:53:02 +0200 Subject: [PATCH 10/76] [BUGFIX] Fix returns in functions of IiifManifest class (#1027) Co-authored-by: Sebastian Meyer --- Classes/Common/IiifManifest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index 639d3c121..f5d2dbe13 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -263,7 +263,7 @@ protected function _getPhysicalStructure(): array // Is there no physical structure array yet? if (!$this->physicalStructureLoaded) { if ($this->iiif == null || !($this->iiif instanceof ManifestInterface)) { - return null; + return []; } $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); $iiifId = $this->iiif->getId(); @@ -404,7 +404,7 @@ public function getFileInfo($id) public function getFileLocation(string $id): string { if ($id == null) { - return null; + return ''; } $resource = $this->iiif->getContainedResourceById($id); if (isset($resource)) { From cb42f3e0b009e7f33fded63e576d1c300e9e80c5 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 4 Oct 2023 21:16:19 +0200 Subject: [PATCH 11/76] [BUGFIX] Fix initialization and checks for rawData in API profiles (#1025) Co-authored-by: Sebastian Meyer --- Classes/Api/Orcid/Profile.php | 12 ++++++------ Classes/Api/Viaf/Profile.php | 14 ++++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Classes/Api/Orcid/Profile.php b/Classes/Api/Orcid/Profile.php index 3d77bd3dd..b3545cecd 100644 --- a/Classes/Api/Orcid/Profile.php +++ b/Classes/Api/Orcid/Profile.php @@ -44,7 +44,7 @@ class Profile * @access private * @var \SimpleXmlElement|false The raw ORCID profile **/ - private $raw; + private $raw = false; /** * Constructs client instance @@ -71,7 +71,7 @@ public function __construct(string $orcid) public function getData() { $this->getRaw('person'); - if (!empty($this->raw)) { + if ($this->raw !== false && !empty($this->raw)) { $data = []; $data['address'] = $this->getAddress(); $data['email'] = $this->getEmail(); @@ -93,7 +93,7 @@ public function getData() public function getAddress() { $this->getRaw('address'); - if (!empty($this->raw)) { + if ($this->raw !== false && !empty($this->raw)) { $this->raw->registerXPathNamespace('address', 'http://www.orcid.org/ns/address'); return (string) $this->raw->xpath('./address:address/address:country')[0]; } else { @@ -112,7 +112,7 @@ public function getAddress() public function getEmail() { $this->getRaw('email'); - if (!empty($this->raw)) { + if ($this->raw !== false && !empty($this->raw)) { $this->raw->registerXPathNamespace('email', 'http://www.orcid.org/ns/email'); return (string) $this->raw->xpath('./email:email/email:email')[0]; } else { @@ -131,7 +131,7 @@ public function getEmail() public function getFullName() { $this->getRaw('personal-details'); - if (!empty($this->raw)) { + if ($this->raw !== false && !empty($this->raw)) { $this->raw->registerXPathNamespace('personal-details', 'http://www.orcid.org/ns/personal-details'); $givenNames = $this->raw->xpath('./personal-details:name/personal-details:given-names'); $familyName = $this->raw->xpath('./personal-details:name/personal-details:family-name'); @@ -155,7 +155,7 @@ private function getRaw(string $endpoint): void { $this->client->setEndpoint($endpoint); $data = $this->client->getData(); - if (!isset($this->raw) && $data != false) { + if ($data != false) { $this->raw = Helper::getXmlFileAsString($data); } } diff --git a/Classes/Api/Viaf/Profile.php b/Classes/Api/Viaf/Profile.php index 0f2ad0568..236cf685f 100644 --- a/Classes/Api/Viaf/Profile.php +++ b/Classes/Api/Viaf/Profile.php @@ -44,7 +44,7 @@ class Profile * @access private * @var \SimpleXmlElement|false The raw VIAF profile or false if not found **/ - private $raw; + private $raw = false; /** * Constructs client instance @@ -71,7 +71,7 @@ public function __construct(string $viaf) public function getData() { $this->getRaw(); - if (!empty($this->raw)) { + if ($this->raw !== false && !empty($this->raw)) { $data = []; $data['address'] = $this->getAddress(); $data['fullName'] = $this->getFullName(); @@ -92,7 +92,7 @@ public function getData() public function getAddress() { $this->getRaw(); - if (!empty($this->raw->asXML())) { + if ($this->raw !== false && !empty($this->raw->asXML())) { return (string) $this->raw->xpath('./ns1:nationalityOfEntity/ns1:data/ns1:text')[0]; } else { $this->logger->warning('No address found for given VIAF URL'); @@ -110,7 +110,7 @@ public function getAddress() public function getFullName() { $this->getRaw(); - if (!empty($this->raw->asXML())) { + if ($this->raw !== false && !empty($this->raw->asXML())) { $rawName = $this->raw->xpath('./ns1:mainHeadings/ns1:data/ns1:text'); $name = (string) $rawName[0]; $name = trim(trim(trim($name), ','), '.'); @@ -131,9 +131,11 @@ public function getFullName() private function getRaw(): void { $data = $this->client->getData(); - if (!isset($this->raw) && $data != false) { + if ($data != false) { $this->raw = Helper::getXmlFileAsString($data); - $this->raw->registerXPathNamespace('ns1', 'http://viaf.org/viaf/terms#'); + if ($this->raw != false && !empty($this->raw->asXML())) { + $this->raw->registerXPathNamespace('ns1', 'http://viaf.org/viaf/terms#'); + } } } } From 1ced4e0bdd04300b46c16d74331e315fe9cf3538 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 4 Oct 2023 21:24:23 +0200 Subject: [PATCH 12/76] [BUGFIX] Fix getting AbstractDocument instance from cache (#1026) Co-authored-by: Sebastian Meyer --- Classes/Common/AbstractDocument.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Classes/Common/AbstractDocument.php b/Classes/Common/AbstractDocument.php index ac14b7e84..6d3bf2465 100644 --- a/Classes/Common/AbstractDocument.php +++ b/Classes/Common/AbstractDocument.php @@ -401,12 +401,15 @@ public static function &getInstance(string $location, array $settings = [], bool $xml = null; $iiif = null; - if ($instance = self::getDocCache($location) && !$forceReload) { - return $instance; - } else { - $instance = null; + if (!$forceReload) { + $instance = self::getDocumentCache($location); + if ($instance !== false) { + return $instance; + } } + $instance = null; + // Try to load a file from the url if (GeneralUtility::isValidUrl($location)) { // Load extension configuration @@ -444,8 +447,8 @@ public static function &getInstance(string $location, array $settings = [], bool $instance = new IiifManifest($location, $pid, $iiif); } - if ($instance) { - self::setDocCache($location, $instance); + if (!is_null($instance)) { + self::setDocumentCache($location, $instance); } return $instance; @@ -1243,7 +1246,7 @@ public function __set(string $var, $value): void } /** - * Gets Cache Hit for $doc + * Get Cache Hit for document instance * * @access private * @@ -1251,9 +1254,9 @@ public function __set(string $var, $value): void * * @param string $location * - * @return Doc|false + * @return AbstractDocument|false */ - private static function getDocCache(string $location) + private static function getDocumentCache(string $location) { $cacheIdentifier = md5($location); $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_doc'); @@ -1263,7 +1266,7 @@ private static function getDocCache(string $location) } /** - * Sets Cache for $doc + * Set Cache for document instance * * @access private * @@ -1274,7 +1277,7 @@ private static function getDocCache(string $location) * * @return void */ - private static function setDocCache(string $location, AbstractDocument $currentDocument): void + private static function setDocumentCache(string $location, AbstractDocument $currentDocument): void { $cacheIdentifier = md5($location); $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_doc'); From fd44f90e185aef93d5bc43c00b03efd435d59b4d Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 4 Oct 2023 21:26:54 +0200 Subject: [PATCH 13/76] [BUGFIX] Remove documentRepository from Indexer constructor (#1028) Co-authored-by: Sebastian Meyer --- Classes/Common/Indexer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Classes/Common/Indexer.php b/Classes/Common/Indexer.php index c9d0e7878..53bda4773 100644 --- a/Classes/Common/Indexer.php +++ b/Classes/Common/Indexer.php @@ -604,9 +604,7 @@ private static function removeAppendsFromAuthor($authors) * * @return void */ - private function __construct(DocumentRepository $documentRepository) + private function __construct() { - // This is a static class, thus no instances should be created. - $this->documentRepository = $documentRepository; } } From fbf1e92e55af486f774fc002802c89bae36994bb Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 4 Oct 2023 21:39:31 +0200 Subject: [PATCH 14/76] [MAINTENANCE] Update MetadataController with AbstractDocument usage (#1030) Co-authored-by: Sebastian Meyer --- Classes/Controller/MetadataController.php | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Classes/Controller/MetadataController.php b/Classes/Controller/MetadataController.php index 7b68ffbc9..cc8a03fc0 100644 --- a/Classes/Controller/MetadataController.php +++ b/Classes/Controller/MetadataController.php @@ -33,7 +33,7 @@ class MetadataController extends AbstractController * @access private * @var AbstractDocument */ - private $doc; + private $currentDocument; /** * @access protected @@ -110,14 +110,15 @@ public function mainAction() $this->setDefault('displayIiifLinks', 1); } - $this->doc = $this->document->getCurrentDocument(); + $this->currentDocument = $this->document->getCurrentDocument(); - $useOriginalIiifManifestMetadata = $this->settings['originalIiifMetadata'] == 1 && $this->doc instanceof IiifManifest; + $useOriginalIiifManifestMetadata = $this->settings['originalIiifMetadata'] == 1 && $this->currentDocument instanceof IiifManifest; $metadata = $this->getMetadata(); + $topLevelId = $this->currentDocument->toplevelId; // Get titledata? - if (empty($metadata) || ($this->settings['rootline'] == 1 && $metadata[0]['_id'] != $this->doc->toplevelId)) { - $data = $useOriginalIiifManifestMetadata ? $this->doc->getManifestMetadata($this->doc->toplevelId, $this->settings['storagePid']) : $this->doc->getTitledata($this->settings['storagePid']); - $data['_id'] = $this->doc->toplevelId; + if (empty($metadata) || ($this->settings['rootline'] == 1 && $metadata[0]['_id'] != $topLevelId)) { + $data = $useOriginalIiifManifestMetadata ? $this->currentDocument->getManifestMetadata($topLevelId, $this->settings['storagePid']) : $this->currentDocument->getTitledata($this->settings['storagePid']); + $data['_id'] = $topLevelId; array_unshift($metadata, $data); } if (empty($metadata)) { @@ -285,7 +286,7 @@ private function buildUrlFromMetadata(array $metadata) foreach ($metadata as $i => $section) { if ($this->settings['linkTitle'] && $section['_id'] && isset($section['title']) && !empty($section['title'])) { - $details = $this->doc->getLogicalStructure($section['_id']); + $details = $this->currentDocument->getLogicalStructure($section['_id']); $buildUrl[$i]['title'] = [ 'id' => $this->document->getUid(), 'page' => (!empty($details['points']) ? intval($details['points']) : 1), @@ -390,9 +391,10 @@ private function getMetadata() if ($this->settings['rootline'] < 2) { // Get current structure's @ID. $ids = []; - if (!empty($this->doc->physicalStructure[$this->requestData['page']]) && !empty($this->doc->smLinks['p2l'][$this->doc->physicalStructure[$this->requestData['page']]])) { - foreach ($this->doc->smLinks['p2l'][$this->doc->physicalStructure[$this->requestData['page']]] as $logId) { - $count = $this->doc->getStructureDepth($logId); + $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; } } @@ -425,12 +427,12 @@ private function getMetadata() */ private function getMetadataForIds($id, $metadata) { - $useOriginalIiifManifestMetadata = $this->settings['originalIiifMetadata'] == 1 && $this->doc instanceof IiifManifest; + $useOriginalIiifManifestMetadata = $this->settings['originalIiifMetadata'] == 1 && $this->currentDocument instanceof IiifManifest; foreach ($id as $sid) { if ($useOriginalIiifManifestMetadata) { - $data = $this->doc->getManifestMetadata($sid, $this->settings['storagePid']); + $data = $this->currentDocument->getManifestMetadata($sid, $this->settings['storagePid']); } else { - $data = $this->doc->getMetadata($sid, $this->settings['storagePid']); + $data = $this->currentDocument->getMetadata($sid, $this->settings['storagePid']); } if (!empty($data)) { $data['_id'] = $sid; From a50ede14d25dd61bb2f755420dd494832ba4723b Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 4 Oct 2023 21:51:13 +0200 Subject: [PATCH 15/76] [BUGFIX] Fix call findOneByIndexName (#1031) Co-authored-by: Sebastian Meyer --- Classes/Command/BaseCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index f5b093f3a..24e1108e6 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -222,7 +222,7 @@ protected function saveToDatabase(Document $document): bool $document->setMetsLabel($metadata['mets_label'][0] ? : ''); $document->setMetsOrderlabel($metadata['mets_orderlabel'][0] ? : ''); - $structure = $this->structureRepository->findOneByIndexName($metadata['type'][0], 'tx_dlf_structures'); + $structure = $this->structureRepository->findOneByIndexName($metadata['type'][0]); $document->setStructure($structure); if (is_array($metadata['collection'])) { From 9d27e14601b1fcbdefb111f92e4895eeaa9bccf6 Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Wed, 4 Oct 2023 22:01:06 +0200 Subject: [PATCH 16/76] [MAINTENANCE] Adds curly braces around blocks in loops and conditionals (#1032) Co-authored-by: Sebastian Meyer --- .../Public/JavaScript/PageView/AltoParser.js | 11 +++-- .../JavaScript/PageView/AnnotationParser.js | 41 +++++++++++-------- .../Public/JavaScript/PageView/Utility.js | 8 +++- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/Resources/Public/JavaScript/PageView/AltoParser.js b/Resources/Public/JavaScript/PageView/AltoParser.js index 2762eb561..e30df4ac3 100644 --- a/Resources/Public/JavaScript/PageView/AltoParser.js +++ b/Resources/Public/JavaScript/PageView/AltoParser.js @@ -163,8 +163,9 @@ dlfAltoParser.prototype.parseFeatures = function(document) { * @return {Array} */ feature.getTextblocks = function() { - if (this.get('printspace') !== undefined && this.get('printspace').get('textblocks')) - return this.get('printspace').get('textblocks') + if (this.get('printspace') !== undefined && this.get('printspace').get('textblocks')) { + return this.get('printspace').get('textblocks'); + } return []; }; @@ -229,8 +230,9 @@ dlfAltoParser.prototype.parseGeometry_ = function(node) { y2 = y1 + height, coordinatesWithoutScale = [[[x1, y1], [x2, y1], [x2, y2], [x1, y2], [x1, y1]]]; - if (isNaN(width) || isNaN(height)) + if (isNaN(width) || isNaN(height)) { return undefined; + } // If page dimensions are given in the ALTO, use them to rescale the coordinates var scale = 1; @@ -260,8 +262,9 @@ dlfAltoParser.prototype.parseGeometry_ = function(node) { dlfAltoParser.prototype.parsePrintSpaceFeature_ = function(node) { var printspace = $(node).find('PrintSpace'); - if (printspace.length === 0) + if (printspace.length === 0) { return; + } return this.parseAltoFeature_(printspace[0]); }; diff --git a/Resources/Public/JavaScript/PageView/AnnotationParser.js b/Resources/Public/JavaScript/PageView/AnnotationParser.js index 9f79fccf1..aa5bc298b 100644 --- a/Resources/Public/JavaScript/PageView/AnnotationParser.js +++ b/Resources/Public/JavaScript/PageView/AnnotationParser.js @@ -145,12 +145,14 @@ DlfIiifAnnotationParser.prototype.parseGeometry = function(annotation) { var xywh = this.getXYWHForAnnotation(annotation), coordinatesWithoutScale = [[[xywh.x1, xywh.y1], [xywh.x2, xywh.y1], [xywh.x2, xywh.y2], [xywh.x1, xywh.y2], [xywh.x1, xywh.y1]]]; - if (isNaN(xywh.width) || isNaN(xywh.height)) + if (isNaN(xywh.width) || isNaN(xywh.height)) { return undefined; + } // return geometry without rescale - if (!dlfUtils.exists(this.image_) || !dlfUtils.exists(this.width_)) + if (!dlfUtils.exists(this.image_) || !dlfUtils.exists(this.width_)) { return new ol.geom.Polygon(coordinatesWithoutScale); + } // rescale coordinates var scale = this.image_.width / this.width_, @@ -174,22 +176,25 @@ DlfIiifAnnotationParser.prototype.parseGeometry = function(annotation) { DlfIiifAnnotationParser.prototype.getXYWHForAnnotation = function (annotation) { var fragmentPos = annotation.on.indexOf("#xywh="), xywh = fragmentPos > -1 ? annotation.on.substr(fragmentPos+6).split(",") : undefined; - if (xywh === undefined) return { - x1: 0, - y1: 0, - width: this.width, - height: this.height, - x2: this.width - 1, - y2: this.height - 1 - }; - return { - x1: parseInt(xywh[0]), - y1: parseInt(xywh[1]), - width: parseInt(xywh[2]), - height: parseInt(xywh[3]), - x2: parseInt(xywh[0]) + parseInt(xywh[2]) - 1, - y2: parseInt(xywh[1]) + parseInt(xywh[3]) - 1 - }; + if (xywh === undefined) { + return { + x1: 0, + y1: 0, + width: this.width, + height: this.height, + x2: this.width - 1, + y2: this.height - 1 + }; + } else { + return { + x1: parseInt(xywh[0]), + y1: parseInt(xywh[1]), + width: parseInt(xywh[2]), + height: parseInt(xywh[3]), + x2: parseInt(xywh[0]) + parseInt(xywh[2]) - 1, + y2: parseInt(xywh[1]) + parseInt(xywh[3]) - 1 + }; + } }; /** diff --git a/Resources/Public/JavaScript/PageView/Utility.js b/Resources/Public/JavaScript/PageView/Utility.js index 9bdb669b8..7354f8279 100644 --- a/Resources/Public/JavaScript/PageView/Utility.js +++ b/Resources/Public/JavaScript/PageView/Utility.js @@ -437,7 +437,9 @@ dlfUtils.fetchIIPData = function (imageSourceObj) { url: dlfViewerSource.IIP.getMetdadataURL(imageSourceObj.url) //'http://localhost:8000/fcgi-bin/iipsrv.fcgi?FIF=F4713/HD7.tif&obj=IIP,1.0&obj=Max-size&obj=Tile-size&obj=Resolution-number', }).done(cb); function cb(response, type) { - if (type !== 'success') throw new Error('Problems while fetching ImageProperties.xml'); + if (type !== 'success') { + throw new Error('Problems while fetching ImageProperties.xml'); + } var imageDataObj = $.extend({ src: imageSourceObj.url, @@ -621,7 +623,9 @@ dlfUtils.scaleToImageSize = function (features, imageObj, width, height, opt_off }; } - if (image === undefined) return []; + if (image === undefined) { + return []; + } var scale = image.scale, offset = opt_offset !== undefined ? opt_offset : 0; From 33abfa0af620b2ef8b28a2b734fc3cdfafded5d6 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 4 Oct 2023 22:04:35 +0200 Subject: [PATCH 17/76] [BUGFIX] Fix property type for feCruserId in Collection model (#1033) Co-authored-by: Sebastian Meyer --- Classes/Domain/Model/Collection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Domain/Model/Collection.php b/Classes/Domain/Model/Collection.php index e93c5cf36..e7f706d39 100644 --- a/Classes/Domain/Model/Collection.php +++ b/Classes/Domain/Model/Collection.php @@ -106,9 +106,9 @@ public function getFeCruserId(): int } /** - * @param string $feCruserId + * @param int $feCruserId */ - public function setFeCruserId(string $feCruserId): void + public function setFeCruserId(int $feCruserId): void { $this->feCruserId = $feCruserId; } From 061c727dc2db7f0e44840753cdf1c4436fc9cd1e Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 4 Oct 2023 22:19:54 +0200 Subject: [PATCH 18/76] [BUGFIX] Fix namespaces in DocumentTypeFunctionProvider class (#1034) Co-authored-by: Sebastian Meyer --- Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php index 424e8c7f6..2c075e13f 100644 --- a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php +++ b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php @@ -20,6 +20,7 @@ use Psr\Log\LoggerAwareTrait; use Symfony\Component\ExpressionLanguage\ExpressionFunction; use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; +use TYPO3\CMS\Core\ExpressionLanguage\RequestWrapper; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; From 2974a8cacbb7963f84efee7c6247634af1ea39d5 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 4 Oct 2023 22:26:09 +0200 Subject: [PATCH 19/76] [BUGFIX] Remove check for $this->document not null (#1035) Co-authored-by: Sebastian Meyer --- Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php index 2c075e13f..ee27d4c59 100644 --- a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php +++ b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php @@ -207,7 +207,7 @@ protected function loadDocument(array $requestData, int $pid): void if ($this->document !== null) { $doc = AbstractDocument::getInstance($this->document->getLocation(), ['storagePid' => $pid], true); - if ($this->document !== null && $doc !== null) { + if ($doc !== null) { $this->document->setCurrentDocument($doc); } else { $this->logger->error('Failed to load document with record ID "' . $requestData['recordId'] . '"'); From 6d555682604838a282b0b90cbeaf899ea0890b10 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 4 Oct 2023 22:31:48 +0200 Subject: [PATCH 20/76] [BUGFIX] Fix var declaration for PageRender (#1036) Co-authored-by: Sebastian Meyer --- Classes/ViewHelpers/JsFooterViewHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/ViewHelpers/JsFooterViewHelper.php b/Classes/ViewHelpers/JsFooterViewHelper.php index a0d303def..32c5a5818 100755 --- a/Classes/ViewHelpers/JsFooterViewHelper.php +++ b/Classes/ViewHelpers/JsFooterViewHelper.php @@ -55,7 +55,7 @@ public static function renderStatic( { $inlineCode = $arguments['inlineCode']; - /** @var $pageRenderer PageRenderer */ + /** @var PageRenderer $pageRenderer */ $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); $pageRenderer->addJsFooterInlineCode('js-dlf-inline-footer', $inlineCode); } From 2978629ca8ce316922953d851670e11d56e7462e Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Wed, 4 Oct 2023 22:45:06 +0200 Subject: [PATCH 21/76] [BUGFIX] Adds missing semicolons (#1037) Co-authored-by: Sebastian Meyer --- Resources/Public/JavaScript/PageView/AnnotationControl.js | 2 +- Resources/Public/JavaScript/PageView/AnnotationParser.js | 2 +- Resources/Public/JavaScript/PageView/FulltextControl.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Resources/Public/JavaScript/PageView/AnnotationControl.js b/Resources/Public/JavaScript/PageView/AnnotationControl.js index bce640d68..bb23445de 100644 --- a/Resources/Public/JavaScript/PageView/AnnotationControl.js +++ b/Resources/Public/JavaScript/PageView/AnnotationControl.js @@ -340,4 +340,4 @@ DlfAnnotationControl.prototype.fetchAnnotationContainersFromServer = function(an annotationListData.push(parser.parseAnnotationList(responseJson, canvas.id)); }); return annotationListData; -} +}; diff --git a/Resources/Public/JavaScript/PageView/AnnotationParser.js b/Resources/Public/JavaScript/PageView/AnnotationParser.js index aa5bc298b..ecf807e3a 100644 --- a/Resources/Public/JavaScript/PageView/AnnotationParser.js +++ b/Resources/Public/JavaScript/PageView/AnnotationParser.js @@ -208,4 +208,4 @@ DlfIiifAnnotationParser.getTargetIdentifierWithoutFragment = function(uri) { return null; } return uri.split("#")[0]; -} +}; diff --git a/Resources/Public/JavaScript/PageView/FulltextControl.js b/Resources/Public/JavaScript/PageView/FulltextControl.js index a78b7d5b7..5d1b13a0e 100644 --- a/Resources/Public/JavaScript/PageView/FulltextControl.js +++ b/Resources/Public/JavaScript/PageView/FulltextControl.js @@ -490,7 +490,7 @@ dlfViewerFullTextControl.prototype.disableFulltextSelect = function() { } var className = 'fulltext-visible'; - $("#tx-dlf-tools-fulltext").removeClass(className) + $("#tx-dlf-tools-fulltext").removeClass(className); if(this.activateFullTextInitially === 0) { $("#tx-dlf-tools-fulltext") From d7898d3a39aa3e0d9c50c8a0ffc8eb55c7e8a330 Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Wed, 4 Oct 2023 22:48:47 +0200 Subject: [PATCH 22/76] [BUGFIX] Removes unnecessary semicolons (#1038) Co-authored-by: Sebastian Meyer --- .../Public/JavaScript/PageView/AltoParser.js | 16 ++++++++-------- .../JavaScript/PageView/AnnotationControl.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Resources/Public/JavaScript/PageView/AltoParser.js b/Resources/Public/JavaScript/PageView/AltoParser.js index e30df4ac3..f25e3b327 100644 --- a/Resources/Public/JavaScript/PageView/AltoParser.js +++ b/Resources/Public/JavaScript/PageView/AltoParser.js @@ -249,7 +249,7 @@ dlfAltoParser.prototype.parseGeometry_ = function(node) { // In ALTO, the y coordinate increases downwards; // in OL, it increases upwards. 0 - (scale * coordinatesWithoutScale[0][i][1])]); - }; + } return new ol.geom.Polygon([coordinatesRescale]); }; @@ -285,11 +285,11 @@ dlfAltoParser.prototype.parseTextBlockFeatures_ = function(node) { // aggregated fulltexts for (var j = 0; j < textlines.length; j++) { fulltext += textlines[j].get('fulltext') + '\n'; - }; + } feature.setProperties({'fulltext':fulltext}); textblockFeatures.push(feature); - }; + } return textblockFeatures; }; @@ -311,11 +311,11 @@ dlfAltoParser.prototype.parseTextLineFeatures_ = function(node) { // parse fulltexts for (var j = 0; j < fulltextElements.length; j++) { fulltext += fulltextElements[j].get('fulltext'); - }; + } feature.setProperties({'fulltext':fulltext}); textlineFeatures.push(feature); - }; + } return textlineFeatures; }; @@ -346,11 +346,11 @@ dlfAltoParser.prototype.parseContentFeatures_ = function(node) { break; default: fulltext = ''; - }; + } feature.setProperties({fulltext}); textLineContentFeatures.push(feature); - }; + } return textLineContentFeatures; }; @@ -381,6 +381,6 @@ dlfAltoParser.prototype.parseString_ = function(textLineContentElement) { dlfAltoParser.prototype.parseXML_ = function(document) { if (typeof document === 'string' || document instanceof String) { return $.parseXML(document); - }; + } return document; }; diff --git a/Resources/Public/JavaScript/PageView/AnnotationControl.js b/Resources/Public/JavaScript/PageView/AnnotationControl.js index bb23445de..2fd6a7bc6 100644 --- a/Resources/Public/JavaScript/PageView/AnnotationControl.js +++ b/Resources/Public/JavaScript/PageView/AnnotationControl.js @@ -290,7 +290,7 @@ DlfAnnotationControl.prototype.disableAnnotationSelect = function() { if (this.layers_.hasOwnProperty(key)) { this.map.removeLayer(this.layers_[String(key)]); } - }; + } var className = 'fulltext-visible'; $("#tx-dlf-tools-annotations").removeClass(className) .text(this.dic['annotations-on']) From c7c1368adcb48b91e681ca89337a693593a9ce4a Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 4 Oct 2023 22:51:17 +0200 Subject: [PATCH 23/76] [BUGFIX] Change check for empty result set (#1039) Co-authored-by: Sebastian Meyer --- Classes/Common/Solr/SolrSearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Common/Solr/SolrSearch.php b/Classes/Common/Solr/SolrSearch.php index 77ac18ace..d4cb96b33 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -754,7 +754,7 @@ protected function searchSolr($parameters = [], $enableCache = true) } // Save value in cache. - if (!empty($resultSet) && $enableCache === true) { + if (!empty($resultSet['documents']) && $enableCache === true) { $cache->set($cacheIdentifier, $resultSet); } } else { From 2dfbef8c44c3ccc1bbe507d2b6eb1a95a0a96cb9 Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Wed, 4 Oct 2023 22:57:40 +0200 Subject: [PATCH 24/76] [SECURITY] Fixes security issues #4526, #4523 und #4522 reported by CodeQL (#1041) Co-authored-by: Sebastian Meyer --- .../PageView/ImageManipulationControl.js | 2 +- .../Public/JavaScript/PageView/PageView.js | 3 +-- .../JavaScript/PageView/SearchInDocument.js | 13 ++++++++----- Resources/Public/JavaScript/PageView/Utility.js | 17 +++++------------ 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Resources/Public/JavaScript/PageView/ImageManipulationControl.js b/Resources/Public/JavaScript/PageView/ImageManipulationControl.js index 3f5fe0f09..d5265cc66 100644 --- a/Resources/Public/JavaScript/PageView/ImageManipulationControl.js +++ b/Resources/Public/JavaScript/PageView/ImageManipulationControl.js @@ -45,7 +45,7 @@ dlfViewerImageManipulationControl = function(options) { * @type {Element} * @private */ - this.toolContainerEl_ = dlfUtils.exists(options.toolContainer) ? options.toolContainer : $(this.dic['parentContainer'])[0]; + this.toolContainerEl_ = dlfUtils.exists(options.toolContainer) ? options.toolContainer : $.find(this.dic['parentContainer'])[0]; // // Append open/close behavior to toolbox diff --git a/Resources/Public/JavaScript/PageView/PageView.js b/Resources/Public/JavaScript/PageView/PageView.js index 40c94cb93..bf5b39186 100644 --- a/Resources/Public/JavaScript/PageView/PageView.js +++ b/Resources/Public/JavaScript/PageView/PageView.js @@ -447,8 +447,7 @@ dlfViewer.prototype.displayHighlightWord = function(highlightWords = null) { // exctract highlighWords from URL if (this.highlightWords === null) { - var urlParams = dlfUtils.getUrlParams(); - this.highlightWords = urlParams['tx_dlf[highlight_word]']; + this.highlightWords = dlfUtils.getUrlParam('tx_dlf[highlight_word]'); } if (!dlfUtils.exists(this.highlightLayer)) { diff --git a/Resources/Public/JavaScript/PageView/SearchInDocument.js b/Resources/Public/JavaScript/PageView/SearchInDocument.js index b4df74d4d..6890ca3b8 100644 --- a/Resources/Public/JavaScript/PageView/SearchInDocument.js +++ b/Resources/Public/JavaScript/PageView/SearchInDocument.js @@ -133,12 +133,12 @@ function getCurrentQueryParams(baseUrl) { function getNavigationButtons(start, numFound) { var buttons = ""; - if (start > 0) { - buttons += ''; + if(start > 0) { + buttons += ''; } - if (numFound > (start + 20)) { - buttons += ''; + if(numFound > (start + 20)) { + buttons += ''; } return buttons; } @@ -265,11 +265,14 @@ $(document).ready(function() { addImageHighlight(data); } else { - resultList += '

  • ' + $('#tx-dlf-search-in-document-label-noresult').text() + '
  • '; + resultList += '
  • '; } resultList += ''; resultList += getNavigationButtons(start, data['numFound']); $('#tx-dlf-search-in-document-results').html(resultList); + $('.noresult').text($('#tx-dlf-search-in-document-label-noresult').text()); + $('.button-previous').attr('value', $('#tx-dlf-search-in-document-label-previous').text()); + $('.button-next').attr('value', $('#tx-dlf-search-in-document-label-next').text()); }, "json" ) diff --git a/Resources/Public/JavaScript/PageView/Utility.js b/Resources/Public/JavaScript/PageView/Utility.js index 7354f8279..82ea85c3f 100644 --- a/Resources/Public/JavaScript/PageView/Utility.js +++ b/Resources/Public/JavaScript/PageView/Utility.js @@ -507,21 +507,14 @@ dlfUtils.getCookie = function (name) { /** * Returns url parameters - * @returns {Object|undefined} + * @returns {string|null} */ -dlfUtils.getUrlParams = function () { +dlfUtils.getUrlParam = function (param) { if (Object.prototype.hasOwnProperty.call(location, 'search')) { - var search = decodeURIComponent(location.search).slice(1).split('&'), - params = {}; - - search.forEach(function (item) { - var s = item.split('='); - params[s[0]] = s[1]; - }); - - return params; + const urlParams = new URLSearchParams(location.search); + return urlParams.get(param); } - return undefined; + return null; }; /** From 199ca9b3e6ea7cbf0203f42ef714c46f611cebea Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Mon, 23 Oct 2023 09:35:33 +0200 Subject: [PATCH 25/76] [BUGFIX] Fixes incorrect usage of getFileLocation() instead of getFileInfo() (#1051) --- Classes/Controller/PageViewController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Controller/PageViewController.php b/Classes/Controller/PageViewController.php index 10ac217d9..cd469d6c0 100644 --- a/Classes/Controller/PageViewController.php +++ b/Classes/Controller/PageViewController.php @@ -111,7 +111,7 @@ protected function getFulltext($page) $physicalStructureInfo = $this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$page]]; $fileId = $physicalStructureInfo['files'][$fileGrpFulltext]; if (!empty($fileId)) { - $file = $this->document->getCurrentDocument()->getFileLocation($fileId); + $file = $this->document->getCurrentDocument()->getFileInfo($fileId); $fulltext['url'] = $file['location']; if ($this->settings['useInternalProxy']) { $this->configureProxyUrl($fulltext['url']); From b25e5a49e506ab641d7875bcc10e637b8e117901 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Mon, 23 Oct 2023 10:09:48 +0200 Subject: [PATCH 26/76] [DOC] Fixes in docs of Solr classes (#1046) Co-authored-by: Sebastian Meyer --- Classes/Common/Solr/Solr.php | 6 ++---- Classes/Common/Solr/SolrSearch.php | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Classes/Common/Solr/Solr.php b/Classes/Common/Solr/Solr.php index 496837bce..2f6ab52c2 100644 --- a/Classes/Common/Solr/Solr.php +++ b/Classes/Common/Solr/Solr.php @@ -35,13 +35,10 @@ * @property array $config this holds the Solr configuration * @property-read string|null $core this holds the core name for the current instance * @property-write int $cPid this holds the PID for the configuration - * @property-read string $extKey the extension key - * @property array $fields the fields for SOLR index * @property int $limit this holds the max results * @property-read int $numberOfHits this holds the number of hits for last search * @property-write array $params this holds the additional query parameters * @property-read bool $ready flag if the Solr service is instantiated successfully - * @property array $registry this holds the singleton search objects with their core as array key * @property-read \Solarium\Client $service this holds the Solr service object */ class Solr implements LoggerAwareInterface @@ -75,6 +72,7 @@ class Solr implements LoggerAwareInterface /** * @access public + * @static * @var array The fields for SOLR index */ public static array $fields = []; @@ -286,7 +284,7 @@ public static function getFields(): array * * @return Solr Instance of this class */ - public static function getInstance($core = null) + public static function getInstance($core = null): Solr { // Get core name if UID is given. if (MathUtility::canBeInterpretedAsInteger($core)) { diff --git a/Classes/Common/Solr/SolrSearch.php b/Classes/Common/Solr/SolrSearch.php index d4cb96b33..ea3b826a9 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -56,7 +56,7 @@ class SolrSearch implements \Countable, \Iterator, \ArrayAccess, QueryResultInte /** * @access private - * @var QueryResult + * @var QueryResult|null */ private ?QueryResult $listedMetadata; @@ -157,7 +157,7 @@ public function key(): int * * @access public * - * @return int + * @return void */ public function next(): void { @@ -169,7 +169,7 @@ public function next(): void * * @access public * - * @return int + * @return void */ public function rewind(): void { From 2c4f231c077cc3b0eda964adea1dae2f1959030e Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Mon, 23 Oct 2023 10:20:40 +0200 Subject: [PATCH 27/76] [MAINTENANCE] Check object properties before using them (#1043) Co-authored-by: Sebastian Meyer --- .../Public/JavaScript/PageView/PageView.js | 8 ++++--- .../Public/JavaScript/PageView/Utility.js | 22 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Resources/Public/JavaScript/PageView/PageView.js b/Resources/Public/JavaScript/PageView/PageView.js index bf5b39186..269228e36 100644 --- a/Resources/Public/JavaScript/PageView/PageView.js +++ b/Resources/Public/JavaScript/PageView/PageView.js @@ -382,9 +382,11 @@ dlfViewer.prototype.createControls_ = function(controlNames, layers) { var controls = []; for (var i in controlNames) { - var control = this.createControl(controlNames[i], layers); - if (control !== null) { - controls.push(control); + if (controlNames.hasOwnProperty(i)) { + var control = this.createControl(controlNames[i], layers); + if (control !== null) { + controls.push(control); + } } } diff --git a/Resources/Public/JavaScript/PageView/Utility.js b/Resources/Public/JavaScript/PageView/Utility.js index 82ea85c3f..a3ffd05ad 100644 --- a/Resources/Public/JavaScript/PageView/Utility.js +++ b/Resources/Public/JavaScript/PageView/Utility.js @@ -626,19 +626,21 @@ dlfUtils.scaleToImageSize = function (features, imageObj, width, height, opt_off // do rescaling and set a id for (var i in features) { - var oldCoordinates = features[i].getGeometry().getCoordinates()[0], - newCoordinates = []; + if (features.hasOwnProperty(i)) { + var oldCoordinates = features[i].getGeometry().getCoordinates()[0], + newCoordinates = []; - for (var j = 0; j < oldCoordinates.length; j++) { - newCoordinates.push( - [offset + scale * oldCoordinates[j][0], 0 - scale * oldCoordinates[j][1]]); - } + for (var j = 0; j < oldCoordinates.length; j++) { + newCoordinates.push( + [offset + scale * oldCoordinates[j][0], 0 - scale * oldCoordinates[j][1]]); + } - features[i].setGeometry(new ol.geom.Polygon([newCoordinates])); + features[i].setGeometry(new ol.geom.Polygon([newCoordinates])); - // set index - dlfUtils.RUNNING_INDEX += 1; - features[i].setId('' + dlfUtils.RUNNING_INDEX); + // set index + dlfUtils.RUNNING_INDEX += 1; + features[i].setId('' + dlfUtils.RUNNING_INDEX); + } } return features; From 7533fbfac14ec456fbef9b3aca8a4690edc9538d Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Mon, 23 Oct 2023 10:36:43 +0200 Subject: [PATCH 28/76] [MAINTENANCE] Fixes ESLint_camelcase warnings (#1044) Co-authored-by: Sebastian Meyer --- .../Public/JavaScript/PageView/AltoParser.js | 18 ++++++------ .../JavaScript/PageView/AnnotationParser.js | 18 ++++++------ .../PageView/ImageManipulationControl.js | 28 +++++++++---------- Resources/Public/JavaScript/PageView/OL.js | 6 ++-- .../Public/JavaScript/PageView/PageView.js | 18 ++++++------ .../Public/JavaScript/PageView/Utility.js | 6 ++-- 6 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Resources/Public/JavaScript/PageView/AltoParser.js b/Resources/Public/JavaScript/PageView/AltoParser.js index f25e3b327..81a79cb86 100644 --- a/Resources/Public/JavaScript/PageView/AltoParser.js +++ b/Resources/Public/JavaScript/PageView/AltoParser.js @@ -18,36 +18,36 @@ /** * @constructor - * @param {Object=} opt_imageObj - * @param {number=} opt_width - * @param {number=} opt_height - * @param {number=} opt_offset + * @param {Object=} optImageObj + * @param {number=} optWidth + * @param {number=} optHeight + * @param {number=} optOffset */ -var dlfAltoParser = function(opt_imageObj, opt_width, opt_height, opt_offset) { +var dlfAltoParser = function(optImageObj, optWidth, optHeight, optOffset) { /** * @type {Object|undefined} * @private */ - this.image_ = dlfUtils.exists(opt_imageObj) ? opt_imageObj : undefined; + this.image_ = dlfUtils.exists(optImageObj) ? optImageObj : undefined; /** * @type {number|undefined} * @private */ - this.width_ = dlfUtils.exists(opt_width) ? opt_width : undefined; + this.width_ = dlfUtils.exists(optWidth) ? optWidth : undefined; /** * @type {number|undefined} * @private */ - this.height_ = dlfUtils.exists(opt_height) ? opt_height : undefined; + this.height_ = dlfUtils.exists(optHeight) ? optHeight : undefined; /** * @type {number|undefined} * @private */ - this.offset_ = dlfUtils.exists(opt_offset) ? opt_offset : undefined; + this.offset_ = dlfUtils.exists(optOffset) ? optOffset : undefined; }; /** diff --git a/Resources/Public/JavaScript/PageView/AnnotationParser.js b/Resources/Public/JavaScript/PageView/AnnotationParser.js index ecf807e3a..a009abc82 100644 --- a/Resources/Public/JavaScript/PageView/AnnotationParser.js +++ b/Resources/Public/JavaScript/PageView/AnnotationParser.js @@ -10,12 +10,12 @@ /** * @constructor - * @param {Object=} opt_imageObj - * @param {number=} opt_width - * @param {number=} opt_height - * @param {number=} opt_offset + * @param {Object=} optImageObj + * @param {number=} optWidth + * @param {number=} optHeight + * @param {number=} optOffset */ -var DlfIiifAnnotationParser = function(opt_imageObj, opt_width, opt_height, opt_offset) { +var DlfIiifAnnotationParser = function(optImageObj, optWidth, optHeight, optOffset) { // get width and height either from image info.json or from canvas information @@ -23,25 +23,25 @@ var DlfIiifAnnotationParser = function(opt_imageObj, opt_width, opt_height, opt_ * @type {Object|undefined} * @private */ - this.image_ = dlfUtils.exists(opt_imageObj) ? opt_imageObj : undefined; + this.image_ = dlfUtils.exists(optImageObj) ? optImageObj : undefined; /** * @type {number|undefined} * @private */ - this.width_ = dlfUtils.exists(opt_width) ? opt_width : undefined; + this.width_ = dlfUtils.exists(optWidth) ? optWidth : undefined; /** * @type {number|undefined} * @private */ - this.height_ = dlfUtils.exists(opt_height) ? opt_height : undefined; + this.height_ = dlfUtils.exists(optHeight) ? optHeight : undefined; /** * @type {number|undefined} * @private */ - this.offset_ = dlfUtils.exists(opt_offset) ? opt_offset : undefined; + this.offset_ = dlfUtils.exists(optOffset) ? optOffset : undefined; }; /** diff --git a/Resources/Public/JavaScript/PageView/ImageManipulationControl.js b/Resources/Public/JavaScript/PageView/ImageManipulationControl.js index d5265cc66..bb764d5a9 100644 --- a/Resources/Public/JavaScript/PageView/ImageManipulationControl.js +++ b/Resources/Public/JavaScript/PageView/ImageManipulationControl.js @@ -231,19 +231,19 @@ dlfViewerImageManipulationControl.prototype.createFilters_ = function() { * @param {string} orientation * @param {string} key * @param {Array.|undefined} opt_baseValue - * @param {string=} opt_title - * @param {Function=} opt_labelFn + * @param {string=} optTitle + * @param {Function=} optLabelFn * @return {Element} * @private */ -dlfViewerImageManipulationControl.prototype.createSlider_ = function(className, orientation, key, opt_baseValues, opt_title, opt_labelFn){ - var title = dlfUtils.exists('opt_title') ? opt_title : '', +dlfViewerImageManipulationControl.prototype.createSlider_ = function(className, orientation, key, optBaseValues, optTitle, optLabelFn){ + var title = dlfUtils.exists('optTitle') ? optTitle : '', sliderEl = $('
    '), - baseMin = dlfUtils.exists(opt_baseValues) ? opt_baseValues[1] : 0, - baseMax = dlfUtils.exists(opt_baseValues) ? opt_baseValues[2] : 100, - steps = dlfUtils.exists(opt_baseValues) ? opt_baseValues[3] : 1, - startValue = dlfUtils.exists(opt_baseValues) ? opt_baseValues[0] : 100; + baseMin = dlfUtils.exists(optBaseValues) ? optBaseValues[1] : 0, + baseMax = dlfUtils.exists(optBaseValues) ? optBaseValues[2] : 100, + steps = dlfUtils.exists(optBaseValues) ? optBaseValues[3] : 1, + startValue = dlfUtils.exists(optBaseValues) ? optBaseValues[0] : 100; /** * @param {Object} event @@ -252,17 +252,17 @@ dlfViewerImageManipulationControl.prototype.createSlider_ = function(className, var update = $.proxy(function(event, ui){ var value = ui['value'], element = valueEl[0], - labelValue = dlfUtils.exists(opt_labelFn) ? opt_labelFn(value) : value + '%'; + labelValue = dlfUtils.exists(optLabelFn) ? optLabelFn(value) : value + '%'; if (orientation === 'vertical') { - var style_top = 100 - ((value - baseMin) / (baseMax - baseMin) * 100); - element.style.top = style_top + '%'; + var styleTop = 100 - ((value - baseMin) / (baseMax - baseMin) * 100); + element.style.top = styleTop + '%'; element.innerHTML = labelValue; return; } - var style_left = (value - baseMin) / (baseMax - baseMin) * 100; - element.style.left = style_left + '%'; + var styleLeft = (value - baseMin) / (baseMax - baseMin) * 100; + element.style.left = styleLeft + '%'; element.innerHTML = labelValue; // update filters. @@ -281,7 +281,7 @@ dlfViewerImageManipulationControl.prototype.createSlider_ = function(className, }); // append tooltips - var innerHtml = dlfUtils.exists(opt_labelFn) && dlfUtils.exists(opt_baseValues) ? opt_labelFn(opt_baseValues[0]) : '100%', + var innerHtml = dlfUtils.exists(optLabelFn) && dlfUtils.exists(optBaseValues) ? optLabelFn(optBaseValues[0]) : '100%', valueEl = $('
    ' + innerHtml + '
    '); $(sliderEl).append(valueEl); diff --git a/Resources/Public/JavaScript/PageView/OL.js b/Resources/Public/JavaScript/PageView/OL.js index 4a7f3ea7b..f9667d907 100644 --- a/Resources/Public/JavaScript/PageView/OL.js +++ b/Resources/Public/JavaScript/PageView/OL.js @@ -65,11 +65,11 @@ ol.Map.prototype.zoomOut = function() { * Zooms to given point * @param {Array.} center * @param {number} zoomLevel - * @param {number=} opt_duration + * @param {number=} optDuration */ -ol.Map.prototype.zoomTo = function(center, zoomLevel, opt_duration) { +ol.Map.prototype.zoomTo = function(center, zoomLevel, optDuration) { var view = this.getView(), - duration = opt_duration !== undefined ? opt_duration : 500; + duration = optDuration !== undefined ? optDuration : 500; view.animate({ center, 'zoom': zoomLevel, diff --git a/Resources/Public/JavaScript/PageView/PageView.js b/Resources/Public/JavaScript/PageView/PageView.js index 269228e36..7c968ef2e 100644 --- a/Resources/Public/JavaScript/PageView/PageView.js +++ b/Resources/Public/JavaScript/PageView/PageView.js @@ -169,7 +169,7 @@ var dlfViewer = function(settings){ * @type {Object|null} * @private */ - this.ov_view = null; + this.ovView = null; /** * @type {Boolean|false} @@ -778,7 +778,7 @@ dlfViewer.prototype.addMagnifier = function (rotation) { extent: extent }); - this.ov_view = new ol.View({ + this.ovView = new ol.View({ constrainRotation: false, projection: layerProj, center: ol.extent.getCenter(extent), @@ -786,22 +786,22 @@ dlfViewer.prototype.addMagnifier = function (rotation) { rotation: rotation, }); - this.ov_map = new ol.Map({ + this.ovMap = new ol.Map({ target: 'ov_map', - view: this.ov_view, + view: this.ovView, controls: [], interactions: [] }); - this.ov_map.addLayer(dlfUtils.cloneOlLayer(this.map.getLayers().getArray()[0])); + this.ovMap.addLayer(dlfUtils.cloneOlLayer(this.map.getLayers().getArray()[0])); var mousePosition = null; var dlfViewer = this; - var ov_map = this.ov_map; + var ovMap = this.ovMap; this.map.on('pointermove', function (evt) { mousePosition = dlfViewer.map.getEventCoordinate(evt.originalEvent); - dlfViewer.ov_view.setCenter(mousePosition); + dlfViewer.ovView.setCenter(mousePosition); }); var adjustViews = function(sourceView, destMap) { @@ -813,11 +813,11 @@ dlfViewer.prototype.addMagnifier = function (rotation) { } }, adjustViewHandler = function(event) { - adjustViews(event.target, ov_map); + adjustViews(event.target, ovMap); }; this.map.getView().on('change:rotation', adjustViewHandler, this.map); - adjustViews(this.map.getView(), this.ov_map); + adjustViews(this.map.getView(), this.ovMap); this.initMagnifier = true; }; diff --git a/Resources/Public/JavaScript/PageView/Utility.js b/Resources/Public/JavaScript/PageView/Utility.js index a3ffd05ad..bd30ff3cc 100644 --- a/Resources/Public/JavaScript/PageView/Utility.js +++ b/Resources/Public/JavaScript/PageView/Utility.js @@ -599,11 +599,11 @@ dlfUtils.setCookie = function (name, value, samesite) { * @param {Object} imageObj * @param {number} width * @param {number} height - * @param {number=} opt_offset + * @param {number=} optOffset * @deprecated * @return {Array.} */ -dlfUtils.scaleToImageSize = function (features, imageObj, width, height, opt_offset) { +dlfUtils.scaleToImageSize = function (features, imageObj, width, height, optOffset) { // update size / scale settings of imageObj var image = void 0; @@ -621,7 +621,7 @@ dlfUtils.scaleToImageSize = function (features, imageObj, width, height, opt_off } var scale = image.scale, - offset = opt_offset !== undefined ? opt_offset : 0; + offset = optOffset !== undefined ? optOffset : 0; // do rescaling and set a id for (var i in features) { From fadb32af5c10aee9082b584a324e3420e596923f Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Mon, 23 Oct 2023 10:54:57 +0200 Subject: [PATCH 29/76] [MAINTENANCE] Fix docs and types in AbstractDocument and its child classes (#1047) Co-authored-by: Sebastian Meyer --- Classes/Common/AbstractDocument.php | 11 +++++------ Classes/Common/IiifManifest.php | 12 +++++------- Classes/Common/MetsDocument.php | 22 ++++++---------------- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/Classes/Common/AbstractDocument.php b/Classes/Common/AbstractDocument.php index 6d3bf2465..2c98f062d 100644 --- a/Classes/Common/AbstractDocument.php +++ b/Classes/Common/AbstractDocument.php @@ -47,7 +47,6 @@ * @property array $rawTextArray this holds the documents' raw text pages with their corresponding structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key * @property-read bool $ready Is the document instantiated successfully? * @property-read string $recordId the METS file's / IIIF manifest's record identifier - * @property array $registry this holds the singleton object of the document * @property-read int $rootId this holds the UID of the root document or zero if not multi-volumed * @property-read array $smLinks this holds the smLinks between logical and physical structMap * @property bool $smLinksLoaded flag with information if the smLinks are loaded @@ -83,7 +82,7 @@ abstract class AbstractDocument * @access protected * @var array Additional information about files (e.g., ADMID), indexed by ID. */ - protected $fileInfos = []; + protected array $fileInfos = []; /** * @access protected @@ -311,11 +310,11 @@ public static function clearRegistry(): void * * @abstract * - * @param int $pid: ID of the configuration page with the recordId config + * @param int $pid ID of the configuration page with the recordId config * * @return void */ - protected abstract function establishRecordId(int $pid); + protected abstract function establishRecordId(int $pid): void; /** * Source document PHP object which is represented by a Document instance @@ -392,9 +391,9 @@ public abstract function getFileMimeType(string $id): string; * @param array $settings * @param bool $forceReload Force reloading the document instead of returning the cached instance * - * @return AbstractDocument|null Instance of this class, either MetsDocument or IiifManifest + * @return MetsDocument|IiifManifest|null Instance of this class, either MetsDocument or IiifManifest */ - public static function &getInstance(string $location, array $settings = [], bool $forceReload = false): ?AbstractDocument + public static function &getInstance(string $location, array $settings = [], bool $forceReload = false) { // Create new instance depending on format (METS or IIIF) ... $documentFormat = null; diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index f5d2dbe13..9a1dd3a6b 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -88,13 +88,13 @@ final class IiifManifest extends AbstractDocument /** * @access protected - * @var ManifestInterface A PHP object representation of a IIIF manifest + * @var ManifestInterface|null A PHP object representation of a IIIF manifest */ - protected ManifestInterface $iiif; + protected ?ManifestInterface $iiif; /** * @access protected - * @var string 'IIIF1', 'IIIF2' or 'IIIF3', depending on the API $this->iiif confrms to: IIIF Metadata API 1, IIIF Presentation API 2 or 3 + * @var string 'IIIF1', 'IIIF2' or 'IIIF3', depending on the API $this->iiif conforms to: IIIF Metadata API 1, IIIF Presentation API 2 or 3 */ protected string $iiifVersion; @@ -369,7 +369,6 @@ protected function _getPhysicalStructure(): array } /** - * {@inheritDoc} * @see AbstractDocument::getDownloadLocation() */ public function getDownloadLocation(string $id): string @@ -417,9 +416,8 @@ public function getFileLocation(string $id): string } elseif ($resource instanceof AnnotationContainerInterface) { return $id; } - } else { - return $id; } + return $id; } /** @@ -986,7 +984,7 @@ public function __wakeup(): void */ public function __sleep(): array { - // TODO implement serializiation in IIIF library + // TODO implement serialization in IIIF library $jsonArray = $this->iiif->getOriginalJsonArray(); $this->asJson = json_encode($jsonArray); return ['uid', 'pid', 'recordId', 'parentId', 'asJson']; diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index 851fe11b0..ec050d8d3 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -299,6 +299,7 @@ public function getLogicalStructure(string $id, bool $recursive = false): array */ protected function getLogicalStructureInfo(\SimpleXMLElement $structure, bool $recursive = false): array { + $attributes = []; // Get attributes. foreach ($structure->attributes() as $attribute => $value) { $attributes[$attribute] = (string) $value; @@ -942,16 +943,6 @@ protected function _getFileGrps(): array return $this->fileGrps; } - /** - * @access protected - * @return array - */ - protected function _getFileInfos() - { - $this->_getFileGrps(); - return $this->fileInfos; - } - /** * @see AbstractDocument::prepareMetadataArray() */ @@ -1029,12 +1020,11 @@ protected function _getPhysicalStructure(): array } } // Sort array by keys (= @ORDER). - if (ksort($elements)) { - // Set total number of pages/tracks. - $this->numPages = count($elements); - // Merge and re-index the array to get nice numeric indexes. - $this->physicalStructure = array_merge($physSeq, $elements); - } + ksort($elements); + // Set total number of pages/tracks. + $this->numPages = count($elements); + // Merge and re-index the array to get numeric indexes. + $this->physicalStructure = array_merge($physSeq, $elements); } $this->physicalStructureLoaded = true; } From 1f4a32343cc259ed0a6bdec30da12e7aee8fdda5 Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Mon, 23 Oct 2023 11:07:44 +0200 Subject: [PATCH 30/76] [MAINTENANCE] Fixes Phpmd CamelCaseParameterName Warnings (#1048) Co-authored-by: Sebastian Meyer --- Classes/Common/Helper.php | 12 ++++---- Classes/Common/Indexer.php | 14 ++++----- Classes/Controller/BasketController.php | 38 ++++++++++++------------- Classes/Hooks/KitodoProductionHacks.php | 8 +++--- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index 60a0ce1ca..5f475f2cc 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -699,13 +699,13 @@ public static function renderFlashMessages(string $queue = 'kitodo.default.flash * * @static * - * @param string $index_name The internal "index_name" to translate + * @param string $indexName The internal "index_name" to translate * @param string $table Get the translation from this table * @param string $pid Get the translation from this page * - * @return string Localized label for $index_name + * @return string Localized label for $indexName */ - public static function translate(string $index_name, string $table, string $pid): string + public static function translate(string $indexName, string $table, string $pid): string { // Load labels into static variable for future use. static $labels = []; @@ -713,7 +713,7 @@ public static function translate(string $index_name, string $table, string $pid) $pid = max(intval($pid), 0); if (!$pid) { self::log('Invalid PID ' . $pid . ' for translation', LOG_SEVERITY_WARNING); - return $index_name; + return $indexName; } /** @var PageRepository $pageRepository */ $pageRepository = GeneralUtility::makeInstance(PageRepository::class); @@ -722,8 +722,8 @@ public static function translate(string $index_name, string $table, string $pid) $languageContentId = $languageAspect->getContentId(); // Check if "index_name" is an UID. - if (MathUtility::canBeInterpretedAsInteger($index_name)) { - $index_name = self::getIndexNameFromUid($index_name, $table, $pid); + if (MathUtility::canBeInterpretedAsInteger($indexName)) { + $indexName = self::getIndexNameFromUid($indexName, $table, $pid); } /* $labels already contains the translated content element, but with the index_name of the translated content element itself * and not with the $index_name of the original that we receive here. So we have to determine the index_name of the diff --git a/Classes/Common/Indexer.php b/Classes/Common/Indexer.php index 53bda4773..083550ffb 100644 --- a/Classes/Common/Indexer.php +++ b/Classes/Common/Indexer.php @@ -202,12 +202,12 @@ public static function add(Document $document, DocumentRepository $documentRepos * * @static * - * @param string $index_name The metadata field's name in database + * @param string $indexName The metadata field's name in database * @param int $pid UID of the configuration page * * @return string The field's dynamic index name */ - public static function getIndexFieldName(string $index_name, int $pid = 0): string + public static function getIndexFieldName(string $indexName, int $pid = 0): string { // Sanitize input. $pid = max(intval($pid), 0); @@ -218,11 +218,11 @@ public static function getIndexFieldName(string $index_name, int $pid = 0): stri // Load metadata configuration. self::loadIndexConf($pid); // Build field's suffix. - $suffix = (in_array($index_name, self::$fields['tokenized']) ? 't' : 'u'); - $suffix .= (in_array($index_name, self::$fields['stored']) ? 's' : 'u'); - $suffix .= (in_array($index_name, self::$fields['indexed']) ? 'i' : 'u'); - $index_name .= '_' . $suffix; - return $index_name; + $suffix = (in_array($indexName, self::$fields['tokenized']) ? 't' : 'u'); + $suffix .= (in_array($indexName, self::$fields['stored']) ? 's' : 'u'); + $suffix .= (in_array($indexName, self::$fields['indexed']) ? 'i' : 'u'); + $indexName .= '_' . $suffix; + return $indexName; } /** diff --git a/Classes/Controller/BasketController.php b/Classes/Controller/BasketController.php index 36cabf723..94d4a4580 100644 --- a/Classes/Controller/BasketController.php +++ b/Classes/Controller/BasketController.php @@ -390,30 +390,30 @@ protected function getDocumentData($id, $data) * * @access protected * - * @param array $_piVars piVars + * @param array $piVars piVars * @param Basket $basket basket object * * @return array Basket data and JavaScript output */ - protected function addToBasket($_piVars, $basket) + protected function addToBasket($piVars, $basket) { $output = ''; - if (!$_piVars['startpage']) { + if (!$piVars['startpage']) { $page = 0; } else { - $page = (int) $_piVars['startpage']; + $page = (int) $piVars['startpage']; } - if ($page != null || $_piVars['addToBasket'] == 'list') { + if ($page != null || $piVars['addToBasket'] == 'list') { $documentItem = [ - 'id' => (int) $_piVars['id'], - 'startpage' => (int) $_piVars['startpage'], - 'endpage' => !isset($_piVars['endpage']) || $_piVars['endpage'] === "" ? "" : (int) $_piVars['endpage'], - 'startX' => !isset($_piVars['startX']) || $_piVars['startX'] === "" ? "" : (int) $_piVars['startX'], - 'startY' => !isset($_piVars['startY']) || $_piVars['startY'] === "" ? "" : (int) $_piVars['startY'], - 'endX' => !isset($_piVars['endX']) || $_piVars['endX'] === "" ? "" : (int) $_piVars['endX'], - 'endY' => !isset($_piVars['endY']) || $_piVars['endY'] === "" ? "" : (int) $_piVars['endY'], - 'rotation' => !isset($_piVars['rotation']) || $_piVars['rotation'] === "" ? "" : (int) $_piVars['rotation'] + 'id' => (int) $piVars['id'], + 'startpage' => (int) $piVars['startpage'], + 'endpage' => !isset($piVars['endpage']) || $piVars['endpage'] === "" ? "" : (int) $piVars['endpage'], + 'startX' => !isset($piVars['startX']) || $piVars['startX'] === "" ? "" : (int) $piVars['startX'], + 'startY' => !isset($piVars['startY']) || $piVars['startY'] === "" ? "" : (int) $piVars['startY'], + 'endX' => !isset($piVars['endX']) || $piVars['endX'] === "" ? "" : (int) $piVars['endX'], + 'endY' => !isset($piVars['endY']) || $piVars['endY'] === "" ? "" : (int) $piVars['endY'], + 'rotation' => !isset($piVars['rotation']) || $piVars['rotation'] === "" ? "" : (int) $piVars['rotation'] ]; // update basket @@ -430,13 +430,13 @@ protected function addToBasket($_piVars, $basket) return; } // set endpage for toc and subentry based on logid - if (($_piVars['addToBasket'] == 'subentry') or ($_piVars['addToBasket'] == 'toc')) { + if (($piVars['addToBasket'] == 'subentry') or ($piVars['addToBasket'] == 'toc')) { $smLinks = $this->document->getCurrentDocument()->smLinks; - $pageCounter = sizeof($smLinks['l2p'][$_piVars['logId']]); + $pageCounter = sizeof($smLinks['l2p'][$piVars['logId']]); $documentItem['endpage'] = ($documentItem['startpage'] + $pageCounter) - 1; } // add whole document - if ($_piVars['addToBasket'] == 'list') { + if ($piVars['addToBasket'] == 'list') { $documentItem['endpage'] = $this->document->getCurrentDocument()->numPages; } $arrayKey = $documentItem['id'] . '_' . $page; @@ -495,18 +495,18 @@ protected function addToBasket($_piVars, $basket) * * @access protected * - * @param array $_piVars plugin variables + * @param array $piVars plugin variables * @param Basket $basket basket object * * @return Basket basket */ - protected function removeFromBasket($_piVars, $basket) + protected function removeFromBasket($piVars, $basket) { if (!empty($basket->getDocIds())) { $items = json_decode($basket->getDocIds()); $items = get_object_vars($items); } - foreach ($_piVars['selected'] as $value) { + foreach ($piVars['selected'] as $value) { if (isset($value['id'])) { $arrayKey = $value['id'] . '_' . $value['startpage']; if (!empty($value['startX'])) { diff --git a/Classes/Hooks/KitodoProductionHacks.php b/Classes/Hooks/KitodoProductionHacks.php index 3faab53d5..374b0ef3c 100644 --- a/Classes/Hooks/KitodoProductionHacks.php +++ b/Classes/Hooks/KitodoProductionHacks.php @@ -30,13 +30,13 @@ class KitodoProductionHacks * @access public * * @param \SimpleXMLElement &$xml The XML object - * @param mixed $record_id The record identifier + * @param mixed $recordId The record identifier * * @return void */ - public function construct_postProcessRecordId(\SimpleXMLElement &$xml, &$record_id): void + public function construct_postProcessRecordId(\SimpleXMLElement &$xml, &$recordId): void { - if (!$record_id) { + if (!$recordId) { $xml->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); // Get all logical structure nodes with metadata, but without associated METS-Pointers. if (($divs = $xml->xpath('//mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'))) { @@ -59,7 +59,7 @@ public function construct_postProcessRecordId(\SimpleXMLElement &$xml, &$record_ foreach ($dmdIds as $dmdId) { $recordIds = $xml->xpath('//mets:dmdSec[@ID="' . $dmdId . '"]//mods:mods/mods:recordInfo/mods:recordIdentifier'); if (!empty($recordIds)) { - $record_id = (string) $recordIds[0]; + $recordId = (string) $recordIds[0]; break; } } From bc6252e3233446d4709f1445918fe07937d52c66 Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Mon, 23 Oct 2023 11:23:58 +0200 Subject: [PATCH 31/76] [MAINTENANCE] Fixes Phpmd CamelCaseMethodName warnings (#1049) Co-authored-by: Sebastian Meyer --- Classes/Common/MetsDocument.php | 4 ++-- Classes/Common/Solr/Solr.php | 2 +- Classes/Controller/CollectionController.php | 4 ++-- Classes/Controller/OaiPmhController.php | 2 +- Classes/Hooks/KitodoProductionHacks.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index ec050d8d3..613c32440 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -170,8 +170,8 @@ protected function establishRecordId(int $pid): void $hookObjects = Helper::getHookObjects('Classes/Common/MetsDocument.php'); // Apply hooks. foreach ($hookObjects as $hookObj) { - if (method_exists($hookObj, 'construct_postProcessRecordId')) { - $hookObj->construct_postProcessRecordId($this->xml, $this->recordId); + if (method_exists($hookObj, 'postProcessRecordId')) { + $hookObj->postProcessRecordId($this->xml, $this->recordId); } } } diff --git a/Classes/Common/Solr/Solr.php b/Classes/Common/Solr/Solr.php index 2f6ab52c2..97703a9cd 100644 --- a/Classes/Common/Solr/Solr.php +++ b/Classes/Common/Solr/Solr.php @@ -385,7 +385,7 @@ protected function loadSolrConnectionInfo(): void * * @return array The Apache Solr Documents that were fetched */ - public function search_raw(array $parameters = []): array + public function searchRaw(array $parameters = []): array { // Set additional query parameters. $parameters['start'] = 0; diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index 83153bca2..d8e7174cd 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -116,10 +116,10 @@ public function listAction() } else { $params['query'] = $solr_query . ' AND partof:0 AND toplevel:true'; } - $partOfNothing = $solr->search_raw($params); + $partOfNothing = $solr->searchRaw($params); $params['query'] = $solr_query . ' AND NOT partof:0 AND toplevel:true'; - $partOfSomething = $solr->search_raw($params); + $partOfSomething = $solr->searchRaw($params); // Titles are all documents that are "root" elements i.e. partof == 0 $collectionInfo['titles'] = []; foreach ($partOfNothing as $doc) { diff --git a/Classes/Controller/OaiPmhController.php b/Classes/Controller/OaiPmhController.php index edb567ff5..a5cc90e3d 100644 --- a/Classes/Controller/OaiPmhController.php +++ b/Classes/Controller/OaiPmhController.php @@ -685,7 +685,7 @@ protected function fetchDocumentUIDs() ] ]; $parameters['query'] = $solr_query; - $result = $solr->search_raw($parameters); + $result = $solr->searchRaw($parameters); if (empty($result)) { $this->error = 'noRecordsMatch'; return; diff --git a/Classes/Hooks/KitodoProductionHacks.php b/Classes/Hooks/KitodoProductionHacks.php index 374b0ef3c..e0b247e01 100644 --- a/Classes/Hooks/KitodoProductionHacks.php +++ b/Classes/Hooks/KitodoProductionHacks.php @@ -34,7 +34,7 @@ class KitodoProductionHacks * * @return void */ - public function construct_postProcessRecordId(\SimpleXMLElement &$xml, &$recordId): void + public function postProcessRecordId(\SimpleXMLElement &$xml, &$recordId): void { if (!$recordId) { $xml->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); From 8d21297d63114205803033c1b84017d00c0f7391 Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Mon, 23 Oct 2023 12:01:22 +0200 Subject: [PATCH 32/76] [BUGFIX] Fixes wrong type and missing initialization of $recordId (#1050) Co-authored-by: Sebastian Meyer --- Classes/Common/AbstractDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Common/AbstractDocument.php b/Classes/Common/AbstractDocument.php index 2c98f062d..bc13d3ef7 100644 --- a/Classes/Common/AbstractDocument.php +++ b/Classes/Common/AbstractDocument.php @@ -209,7 +209,7 @@ abstract class AbstractDocument * @access protected * @var string The METS file's / IIIF manifest's record identifier */ - protected ?string $recordId; + protected string $recordId = ''; /** * @access protected From ef3d4585eed041baed9ef1912537559d44f1e295 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Mon, 23 Oct 2023 13:34:17 +0200 Subject: [PATCH 33/76] [MAINTENANCE] Consistently use type declaration for parameters and return values - part 2 (#1045) Co-authored-by: Sebastian Meyer --- Classes/Controller/AbstractController.php | 36 +++++----- Classes/Controller/AudioPlayerController.php | 6 +- .../Backend/NewTenantController.php | 40 +++++------ Classes/Controller/BasketController.php | 60 ++++++++-------- Classes/Controller/CalendarController.php | 19 +++-- Classes/Controller/CollectionController.php | 14 ++-- Classes/Controller/FeedsController.php | 8 +-- Classes/Controller/ListViewController.php | 10 +-- Classes/Controller/MetadataController.php | 34 ++++----- Classes/Controller/NavigationController.php | 5 +- Classes/Controller/PageGridController.php | 6 +- Classes/Controller/PageViewController.php | 18 ++--- Classes/Controller/SearchController.php | 44 ++++++------ Classes/Controller/StatisticsController.php | 2 +- .../Controller/TableOfContentsController.php | 28 +++++--- Classes/Controller/ToolboxController.php | 72 ++++++++++--------- Classes/Controller/View3DController.php | 2 +- Classes/Domain/Model/Document.php | 4 +- Classes/Domain/Model/Metadata.php | 2 +- .../Repository/CollectionRepository.php | 20 +++--- Classes/Domain/Repository/MailRepository.php | 7 +- .../Domain/Repository/MetadataRepository.php | 4 +- Classes/Domain/Repository/TokenRepository.php | 2 +- 23 files changed, 226 insertions(+), 217 deletions(-) diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 5ff09d569..2d9d11058 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -43,7 +43,7 @@ abstract class AbstractController extends ActionController implements LoggerAwar * @access protected * @var DocumentRepository */ - protected $documentRepository; + protected DocumentRepository $documentRepository; /** * @access public @@ -52,7 +52,7 @@ abstract class AbstractController extends ActionController implements LoggerAwar * * @return void */ - public function injectDocumentRepository(DocumentRepository $documentRepository) + public function injectDocumentRepository(DocumentRepository $documentRepository): void { $this->documentRepository = $documentRepository; } @@ -61,25 +61,25 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) * @access protected * @var Document This holds the current document */ - protected $document; + protected Document $document; /** * @access protected * @var array */ - protected $extConf; + protected array $extConf; /** * @access protected * @var array This holds the request parameter */ - protected $requestData; + protected array $requestData; /** * @access protected * @var array This holds some common data for the fluid view */ - protected $viewData; + protected array $viewData; /** * Initialize the plugin controller @@ -88,7 +88,7 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) * * @return void */ - protected function initialize() + protected function initialize(): void { $this->requestData = GeneralUtility::_GPmerged('tx_dlf'); @@ -114,7 +114,7 @@ protected function initialize() * * @return void */ - protected function loadDocument(int $documentId = 0) + protected function loadDocument(int $documentId = 0): void { // Get document ID from request data if not passed as parameter. if ($documentId === 0 && !empty($this->requestData['id'])) { @@ -189,7 +189,7 @@ protected function loadDocument(int $documentId = 0) * * @return void */ - protected function configureProxyUrl(&$url) { + protected function configureProxyUrl(string &$url): void { $this->uriBuilder->reset() ->setTargetPageUid($GLOBALS['TSFE']->id) ->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl'])) @@ -206,9 +206,9 @@ protected function configureProxyUrl(&$url) { * * @access protected * - * @return boolean + * @return bool */ - protected function isDocMissingOrEmpty() + protected function isDocMissingOrEmpty(): bool { return $this->isDocMissing() || $this->document->getCurrentDocument()->numPages < 1; } @@ -218,9 +218,9 @@ protected function isDocMissingOrEmpty() * * @access protected * - * @return boolean + * @return bool */ - protected function isDocMissing() + protected function isDocMissing(): bool { return $this->document === null || $this->document->getCurrentDocument() === null; } @@ -246,7 +246,7 @@ protected function getLanguageService(): LanguageService * * @return null|string|array */ - protected function getParametersSafely($parameterName) + protected function getParametersSafely(string $parameterName) { if ($this->request->hasArgument($parameterName)) { return $this->request->getArgument($parameterName); @@ -261,7 +261,7 @@ protected function getParametersSafely($parameterName) * * @return void */ - protected function sanitizeRequestData() + protected function sanitizeRequestData(): void { // tx_dlf[id] may only be an UID or URI. if ( @@ -293,7 +293,7 @@ protected function sanitizeRequestData() * * @return void */ - protected function setPage() { + protected function setPage(): void { if (!empty($this->requestData['logicalPage'])) { $this->requestData['page'] = $this->document->getCurrentDocument()->getPhysicalPage($this->requestData['logicalPage']); // The logical page parameter should not appear again @@ -310,7 +310,7 @@ protected function setPage() { * * @return void */ - protected function setDefaultPage() { + protected function setDefaultPage(): void { // Set default values if not set. // $this->requestData['page'] may be integer or string (physical structure @ID) if ( @@ -344,7 +344,7 @@ public function __construct() * @param PaginatorInterface $paginator * @return array */ - protected function buildSimplePagination(PaginationInterface $pagination, PaginatorInterface $paginator) + protected function buildSimplePagination(PaginationInterface $pagination, PaginatorInterface $paginator): array { $firstPage = $pagination->getFirstPageNumber(); $lastPage = $pagination->getLastPageNumber(); diff --git a/Classes/Controller/AudioPlayerController.php b/Classes/Controller/AudioPlayerController.php index 49c4023e1..c546cd5b7 100644 --- a/Classes/Controller/AudioPlayerController.php +++ b/Classes/Controller/AudioPlayerController.php @@ -32,7 +32,7 @@ class AudioplayerController extends AbstractController * @access protected * @var array Holds the current audio file's URL, MIME type and optional label */ - protected $audio = []; + protected array $audio = []; /** * Adds Player javascript @@ -41,7 +41,7 @@ class AudioplayerController extends AbstractController * * @return void */ - protected function addPlayerJS() + protected function addPlayerJS(): void { // Inline CSS. $inlineCSS = '#tx-dlf-audio { width: 100px; height: 100px; }'; @@ -73,7 +73,7 @@ protected function addPlayerJS() * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); diff --git a/Classes/Controller/Backend/NewTenantController.php b/Classes/Controller/Backend/NewTenantController.php index b6b13989e..c85b941c5 100644 --- a/Classes/Controller/Backend/NewTenantController.php +++ b/Classes/Controller/Backend/NewTenantController.php @@ -47,25 +47,25 @@ class NewTenantController extends AbstractController * @access protected * @var int */ - protected $pid; + protected int $pid; /** * @access protected * @var array */ - protected $pageInfo; + protected array $pageInfo; /** * @access protected * @var array All configured site languages */ - protected $siteLanguages; + protected array $siteLanguages; /** * @access protected * @var LocalizationFactory Language factory to get language key/values by our own. */ - protected $languageFactory; + protected LocalizationFactory $languageFactory; /** * @access protected @@ -77,7 +77,7 @@ class NewTenantController extends AbstractController * @access protected * @var FormatRepository */ - protected $formatRepository; + protected FormatRepository $formatRepository; /** * @access public @@ -86,7 +86,7 @@ class NewTenantController extends AbstractController * * @return void */ - public function injectFormatRepository(FormatRepository $formatRepository) + public function injectFormatRepository(FormatRepository $formatRepository): void { $this->formatRepository = $formatRepository; } @@ -95,7 +95,7 @@ public function injectFormatRepository(FormatRepository $formatRepository) * @access protected * @var MetadataRepository */ - protected $metadataRepository; + protected MetadataRepository $metadataRepository; /** * @access public @@ -104,7 +104,7 @@ public function injectFormatRepository(FormatRepository $formatRepository) * * @return void */ - public function injectMetadataRepository(MetadataRepository $metadataRepository) + public function injectMetadataRepository(MetadataRepository $metadataRepository): void { $this->metadataRepository = $metadataRepository; } @@ -113,7 +113,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * @access protected * @var StructureRepository */ - protected $structureRepository; + protected StructureRepository $structureRepository; /** * @access public @@ -122,7 +122,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @return void */ - public function injectStructureRepository(StructureRepository $structureRepository) + public function injectStructureRepository(StructureRepository $structureRepository): void { $this->structureRepository = $structureRepository; } @@ -131,7 +131,7 @@ public function injectStructureRepository(StructureRepository $structureReposito * @access protected * @var SolrCoreRepository */ - protected $solrCoreRepository; + protected SolrCoreRepository $solrCoreRepository; /** * @access public @@ -140,7 +140,7 @@ public function injectStructureRepository(StructureRepository $structureReposito * * @return void */ - public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository) + public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository): void { $this->solrCoreRepository = $solrCoreRepository; } @@ -152,7 +152,7 @@ public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository) * * @return void */ - protected function initializeAction() + protected function initializeAction(): void { $this->pid = (int) GeneralUtility::_GP('id'); @@ -178,7 +178,7 @@ protected function initializeAction() * * @return void */ - public function addFormatAction() + public function addFormatAction(): void { // Include formats definition file. $formatsDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/FormatDefaults.php'); @@ -220,7 +220,7 @@ public function addFormatAction() * * @return void */ - public function addMetadataAction() + public function addMetadataAction(): void { // Include metadata definition file. $metadataDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/MetadataDefaults.php'); @@ -299,7 +299,7 @@ public function addMetadataAction() * * @return void */ - public function addSolrCoreAction() + public function addSolrCoreAction(): void { $doPersist = false; @@ -335,7 +335,7 @@ public function addSolrCoreAction() * * @return void */ - public function addStructureAction() + public function addStructureAction(): void { // Include structure definition file. $structureDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/StructureDefaults.php'); @@ -391,7 +391,7 @@ public function addStructureAction() * * @return void */ - protected function initializeView(ViewInterface $view) + protected function initializeView(ViewInterface $view): void { /** @var BackendTemplateView $view */ parent::initializeView($view); @@ -411,7 +411,7 @@ protected function initializeView(ViewInterface $view) * * @return void */ - public function indexAction() + public function indexAction(): void { $recordInfos = []; @@ -458,7 +458,7 @@ public function errorAction() * * @return string */ - protected function getLLL($index, $lang, $langArray) + protected function getLLL(string $index, string $lang, array $langArray): string { if (isset($langArray[$lang][$index][0]['target'])) { return $langArray[$lang][$index][0]['target']; diff --git a/Classes/Controller/BasketController.php b/Classes/Controller/BasketController.php index 94d4a4580..d5242e439 100644 --- a/Classes/Controller/BasketController.php +++ b/Classes/Controller/BasketController.php @@ -39,7 +39,7 @@ class BasketController extends AbstractController * @access protected * @var BasketRepository */ - protected $basketRepository; + protected BasketRepository $basketRepository; /** * @access public @@ -48,7 +48,7 @@ class BasketController extends AbstractController * * @return void */ - public function injectBasketRepository(BasketRepository $basketRepository) + public function injectBasketRepository(BasketRepository $basketRepository): void { $this->basketRepository = $basketRepository; } @@ -57,7 +57,7 @@ public function injectBasketRepository(BasketRepository $basketRepository) * @access protected * @var MailRepository */ - protected $mailRepository; + protected MailRepository $mailRepository; /** * @access public @@ -66,7 +66,7 @@ public function injectBasketRepository(BasketRepository $basketRepository) * * @return void */ - public function injectMailRepository(MailRepository $mailRepository) + public function injectMailRepository(MailRepository $mailRepository): void { $this->mailRepository = $mailRepository; } @@ -75,7 +75,7 @@ public function injectMailRepository(MailRepository $mailRepository) * @access protected * @var PrinterRepository */ - protected $printerRepository; + protected PrinterRepository $printerRepository; /** * @access public @@ -84,7 +84,7 @@ public function injectMailRepository(MailRepository $mailRepository) * * @return void */ - public function injectPrinterRepository(PrinterRepository $printerRepository) + public function injectPrinterRepository(PrinterRepository $printerRepository): void { $this->printerRepository = $printerRepository; } @@ -93,7 +93,7 @@ public function injectPrinterRepository(PrinterRepository $printerRepository) * @access protected * @var ActionLogRepository */ - protected $actionLogRepository; + protected ActionLogRepository $actionLogRepository; /** * @access public @@ -102,7 +102,7 @@ public function injectPrinterRepository(PrinterRepository $printerRepository) * * @return void */ - public function injectActionLogRepository(ActionLogRepository $actionLogRepository) + public function injectActionLogRepository(ActionLogRepository $actionLogRepository): void { $this->actionLogRepository = $actionLogRepository; } @@ -114,7 +114,7 @@ public function injectActionLogRepository(ActionLogRepository $actionLogReposito * * @return void */ - public function basketAction() + public function basketAction(): void { $basket = $this->getBasketData(); @@ -132,7 +132,7 @@ public function basketAction() $pdfUrl = $this->settings['pdfgenerate']; foreach ($this->requestData['selected'] as $docValue) { if ($docValue['id']) { - $docData = $this->getDocumentData($docValue['id'], $docValue); + $docData = $this->getDocumentData((int) $docValue['id'], $docValue); $pdfUrl .= $docData['urlParams'] . $this->settings['pdfparamseparator']; $this->redirectToUri($pdfUrl); } @@ -143,7 +143,7 @@ public function basketAction() if ($this->requestData['print_action']) { // open selected documents if (isset($this->requestData['selected'])) { - $this->printDocument($basket); + $this->printDocument(); } } // action send mail @@ -163,7 +163,7 @@ public function basketAction() * * @return void */ - public function addAction() + public function addAction(): void { $basket = $this->getBasketData(); @@ -184,7 +184,7 @@ public function addAction() * * @return void */ - public function mainAction() + public function mainAction(): void { $basket = $this->getBasketData(); @@ -233,7 +233,7 @@ public function mainAction() * * @return Basket The found data from user session. */ - protected function getBasketData() + protected function getBasketData(): Basket { // get user session $userSession = $GLOBALS['TSFE']->fe_user->getSession(); @@ -270,9 +270,9 @@ protected function getBasketData() * * @param array $data DocumentData * - * @return string One basket entry + * @return array One basket entry */ - protected function getEntry($data) + protected function getEntry(array $data): array { if (is_object($data)) { $data = get_object_vars($data); @@ -286,7 +286,7 @@ protected function getEntry($data) $endY = $data['endY']; $rotation = $data['rotation']; - $docData = $this->getDocumentData($id, $data); + $docData = $this->getDocumentData((int) $id, $data); $entryArray['BASKETDATA'] = $docData; @@ -324,9 +324,9 @@ protected function getEntry($data) * @param int $id Document id * @param array $data DocumentData * - * @return string|false download url or false + * @return array|false download url or false */ - protected function getDocumentData($id, $data) + protected function getDocumentData(int $id, array $data) { // get document instance to load further information $this->loadDocument((int) $id); @@ -386,16 +386,16 @@ protected function getDocumentData($id, $data) } /** - * Adds documents to the basket + * Adds documents to the basket and includes JS * * @access protected * * @param array $piVars piVars * @param Basket $basket basket object * - * @return array Basket data and JavaScript output + * @return Basket|null Basket data */ - protected function addToBasket($piVars, $basket) + protected function addToBasket(array $piVars, Basket $basket): ?Basket { $output = ''; @@ -427,7 +427,7 @@ protected function addToBasket($piVars, $basket) $this->loadDocument((int) $documentItem['id']); if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. - return; + return null; } // set endpage for toc and subentry based on logid if (($piVars['addToBasket'] == 'subentry') or ($piVars['addToBasket'] == 'toc')) { @@ -500,7 +500,7 @@ protected function addToBasket($piVars, $basket) * * @return Basket basket */ - protected function removeFromBasket($piVars, $basket) + protected function removeFromBasket(array $piVars, Basket $basket): Basket { if (!empty($basket->getDocIds())) { $items = json_decode($basket->getDocIds()); @@ -539,7 +539,7 @@ protected function removeFromBasket($piVars, $basket) * * @return void */ - protected function sendMail() + protected function sendMail(): void { // send mail $mailId = $this->requestData['mail_action']; @@ -553,7 +553,7 @@ protected function sendMail() foreach ($this->requestData['selected'] as $docValue) { if ($docValue['id']) { $explodeId = explode("_", $docValue['id']); - $docData = $this->getDocumentData($explodeId[0], $docValue); + $docData = $this->getDocumentData((int) $explodeId[0], $docValue); $pdfUrl .= $docData['urlParams'] . $this->settings['pdfparamseparator']; $pages = (abs(intval($docValue['startpage']) - intval($docValue['endpage']))); if ($pages === 0) { @@ -614,17 +614,15 @@ protected function sendMail() * * @access protected * - * @param Basket basket object - * * @return void */ - protected function printDocument($basket) + protected function printDocument(): void { $pdfUrl = $this->settings['pdfprint']; $numberOfPages = 0; foreach ($this->requestData['selected'] as $docId => $docValue) { if ($docValue['id']) { - $docData = $this->getDocumentData($docValue['id'], $docValue); + $docData = $this->getDocumentData((int) $docValue['id'], $docValue); $pdfUrl .= $docData['urlParams'] . $this->settings['pdfparamseparator']; $numberOfPages += $docData['pageNums']; } @@ -642,7 +640,7 @@ protected function printDocument($basket) foreach ($this->requestData['selected'] as $docId => $docValue) { if ($docValue['id']) { $explodeId = explode("_", $docId); - $docData = $this->getDocumentData($explodeId[0], $docValue); + $docData = $this->getDocumentData((int) $explodeId[0], $docValue); $pdfUrl .= $docData['urlParams'] . $this->settings['pdfparamseparator']; $numberOfPages += $docData['pageNums']; } diff --git a/Classes/Controller/CalendarController.php b/Classes/Controller/CalendarController.php index 97900de8f..c19596039 100644 --- a/Classes/Controller/CalendarController.php +++ b/Classes/Controller/CalendarController.php @@ -29,7 +29,7 @@ class CalendarController extends AbstractController * @access protected * @var StructureRepository */ - protected $structureRepository; + protected StructureRepository $structureRepository; /** * @access public @@ -38,7 +38,7 @@ class CalendarController extends AbstractController * * @return void */ - public function injectStructureRepository(StructureRepository $structureRepository) + public function injectStructureRepository(StructureRepository $structureRepository): void { $this->structureRepository = $structureRepository; } @@ -47,7 +47,7 @@ public function injectStructureRepository(StructureRepository $structureReposito * @access protected * @var array This holds all issues for the list view. */ - protected $allIssues = []; + protected array $allIssues = []; /** * The main method of the plugin @@ -56,7 +56,7 @@ public function injectStructureRepository(StructureRepository $structureReposito * * @return void */ - public function mainAction() + public function mainAction(): void { // Set initial document (anchor or year file) if configured. if (empty($this->requestData['id']) && !empty($this->settings['initialDocument'])) { @@ -97,12 +97,9 @@ public function mainAction() * * @access public * - * @param string $content The PlugIn content - * @param array $conf The PlugIn configuration - * * @return void */ - public function calendarAction() + public function calendarAction(): void { // access arguments passed by the mainAction() $mainRequestData = $this->request->getArguments(); @@ -231,7 +228,7 @@ public function calendarAction() * * @return void */ - public function yearsAction() + public function yearsAction(): void { // access arguments passed by the mainAction() $mainRequestData = $this->request->getArguments(); @@ -320,9 +317,9 @@ public function yearsAction() * @param int $firstMonth 1 for January, 2 for February, ... 12 for December * @param int $lastMonth 1 for January, 2 for February, ... 12 for December * - * @return string Content for template subpart + * @return void */ - protected function getCalendarYear(&$calendarData, $calendarIssuesByMonth, $year, $firstMonth = 1, $lastMonth = 12) + protected function getCalendarYear(array &$calendarData, array $calendarIssuesByMonth, int $year, int $firstMonth = 1, int $lastMonth = 12): void { for ($i = $firstMonth; $i <= $lastMonth; $i++) { $key = $year . '-' . $i; diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index d8e7174cd..4d332d98f 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -32,7 +32,7 @@ class CollectionController extends AbstractController * @access protected * @var CollectionRepository */ - protected $collectionRepository; + protected CollectionRepository $collectionRepository; /** * @access public @@ -41,7 +41,7 @@ class CollectionController extends AbstractController * * @return void */ - public function injectCollectionRepository(CollectionRepository $collectionRepository) + public function injectCollectionRepository(CollectionRepository $collectionRepository): void { $this->collectionRepository = $collectionRepository; } @@ -50,7 +50,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * @access protected * @var MetadataRepository */ - protected $metadataRepository; + protected MetadataRepository $metadataRepository; /** * @access public @@ -59,7 +59,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * * @return void */ - public function injectMetadataRepository(MetadataRepository $metadataRepository) + public function injectMetadataRepository(MetadataRepository $metadataRepository): void { $this->metadataRepository = $metadataRepository; } @@ -71,7 +71,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @return void */ - public function listAction() + public function listAction(): void { $solr = Solr::getInstance($this->settings['solrcore']); @@ -161,7 +161,7 @@ public function listAction() * * @return void */ - public function showAction(Collection $collection) + public function showAction(Collection $collection): void { $searchParams = $this->getParametersSafely('searchParameter'); @@ -214,7 +214,7 @@ public function showAction(Collection $collection) * * @return void */ - public function showSortedAction() + public function showSortedAction(): void { // if search was triggered, get search parameters from POST variables $searchParams = $this->getParametersSafely('searchParameter'); diff --git a/Classes/Controller/FeedsController.php b/Classes/Controller/FeedsController.php index 363cc123e..4fc137f3f 100644 --- a/Classes/Controller/FeedsController.php +++ b/Classes/Controller/FeedsController.php @@ -31,12 +31,12 @@ class FeedsController extends AbstractController * @access protected * @var LibraryRepository */ - protected $libraryRepository; + protected LibraryRepository $libraryRepository; /** * @param LibraryRepository $libraryRepository */ - public function injectLibraryRepository(LibraryRepository $libraryRepository) + public function injectLibraryRepository(LibraryRepository $libraryRepository): void { $this->libraryRepository = $libraryRepository; } @@ -48,7 +48,7 @@ public function injectLibraryRepository(LibraryRepository $libraryRepository) * * @return void */ - public function initializeAction() + public function initializeAction(): void { $this->request->setFormat('xml'); } @@ -60,7 +60,7 @@ public function initializeAction() * * @return void */ - public function mainAction() + public function mainAction(): void { // access to GET parameter tx_dlf_feeds['collection'] $requestData = $this->request->getArguments(); diff --git a/Classes/Controller/ListViewController.php b/Classes/Controller/ListViewController.php index 75d24d1af..fc882db5e 100644 --- a/Classes/Controller/ListViewController.php +++ b/Classes/Controller/ListViewController.php @@ -30,7 +30,7 @@ class ListViewController extends AbstractController * @access protected * @var CollectionRepository */ - protected $collectionRepository; + protected CollectionRepository $collectionRepository; /** * @access public @@ -39,7 +39,7 @@ class ListViewController extends AbstractController * * @return void */ - public function injectCollectionRepository(CollectionRepository $collectionRepository) + public function injectCollectionRepository(CollectionRepository $collectionRepository): void { $this->collectionRepository = $collectionRepository; } @@ -48,7 +48,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * @access protected * @var MetadataRepository */ - protected $metadataRepository; + protected MetadataRepository $metadataRepository; /** * @access public @@ -57,7 +57,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * * @return void */ - public function injectMetadataRepository(MetadataRepository $metadataRepository) + public function injectMetadataRepository(MetadataRepository $metadataRepository): void { $this->metadataRepository = $metadataRepository; } @@ -75,7 +75,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @return void */ - public function mainAction() + public function mainAction(): void { $this->searchParams = $this->getParametersSafely('searchParameter'); diff --git a/Classes/Controller/MetadataController.php b/Classes/Controller/MetadataController.php index cc8a03fc0..ec49faf99 100644 --- a/Classes/Controller/MetadataController.php +++ b/Classes/Controller/MetadataController.php @@ -39,7 +39,7 @@ class MetadataController extends AbstractController * @access protected * @var CollectionRepository */ - protected $collectionRepository; + protected CollectionRepository $collectionRepository; /** * @access public @@ -48,7 +48,7 @@ class MetadataController extends AbstractController * * @return void */ - public function injectCollectionRepository(CollectionRepository $collectionRepository) + public function injectCollectionRepository(CollectionRepository $collectionRepository): void { $this->collectionRepository = $collectionRepository; } @@ -57,7 +57,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * @access protected * @var MetadataRepository */ - protected $metadataRepository; + protected MetadataRepository $metadataRepository; /** * @access public @@ -66,7 +66,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * * @return void */ - public function injectMetadataRepository(MetadataRepository $metadataRepository) + public function injectMetadataRepository(MetadataRepository $metadataRepository): void { $this->metadataRepository = $metadataRepository; } @@ -75,7 +75,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * @access protected * @var StructureRepository */ - protected $structureRepository; + protected StructureRepository $structureRepository; /** * @access public @@ -84,7 +84,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @return void */ - public function injectStructureRepository(StructureRepository $structureRepository) + public function injectStructureRepository(StructureRepository $structureRepository): void { $this->structureRepository = $structureRepository; } @@ -94,7 +94,7 @@ public function injectStructureRepository(StructureRepository $structureReposito * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); @@ -138,9 +138,9 @@ public function mainAction() * @param array $metadata The metadata array * @param bool $useOriginalIiifManifestMetadata Output IIIF metadata as simple key/value pairs? * - * @return string The metadata array ready for output + * @return void */ - protected function printMetadata(array $metadata, $useOriginalIiifManifestMetadata = false) + protected function printMetadata(array $metadata, bool $useOriginalIiifManifestMetadata = false): void { if ($useOriginalIiifManifestMetadata) { $iiifData = $this->buildIiifData($metadata); @@ -254,7 +254,7 @@ private function buildIiifDataGroup(string $label, string $value): array * * @return array The raw metadata array ready for output */ - private function buildMetaCObjData(array $metadata) + private function buildMetaCObjData(array $metadata): array { $metaCObjData = []; @@ -280,7 +280,7 @@ private function buildMetaCObjData(array $metadata) * * @return array URLs */ - private function buildUrlFromMetadata(array $metadata) + private function buildUrlFromMetadata(array $metadata): array { $buildUrl = []; @@ -307,7 +307,7 @@ private function buildUrlFromMetadata(array $metadata) * * @return array external URLs */ - private function buildExternalUrlFromMetadata(array $metadata) + private function buildExternalUrlFromMetadata(array $metadata): array { $externalUrl = []; @@ -339,7 +339,8 @@ private function buildExternalUrlFromMetadata(array $metadata) * * @return void */ - private function parseMetadata(int $i, string $name, $value, array &$metadata) : void { + private function parseMetadata(int $i, string $name, $value, array &$metadata) : void + { if ($name == 'title') { // Get title of parent document if needed. if (empty(implode('', $value)) && $this->settings['getTitle'] && $this->document->getPartof()) { @@ -385,7 +386,7 @@ private function parseMetadata(int $i, string $name, $value, array &$metadata) : * * @return array metadata */ - private function getMetadata() + private function getMetadata(): array { $metadata = []; if ($this->settings['rootline'] < 2) { @@ -425,7 +426,7 @@ private function getMetadata() * * @return array metadata */ - private function getMetadataForIds($id, $metadata) + private function getMetadataForIds(array $id, array $metadata): array { $useOriginalIiifManifestMetadata = $this->settings['originalIiifMetadata'] == 1 && $this->currentDocument instanceof IiifManifest; foreach ($id as $sid) { @@ -452,7 +453,8 @@ private function getMetadataForIds($id, $metadata) * * @return void */ - private function setDefault($setting, $value) { + private function setDefault(string $setting, int $value): void + { if (!isset($this->settings[$setting])) { $this->settings[$setting] = $value; } diff --git a/Classes/Controller/NavigationController.php b/Classes/Controller/NavigationController.php index 2f95d7576..19b873720 100644 --- a/Classes/Controller/NavigationController.php +++ b/Classes/Controller/NavigationController.php @@ -33,7 +33,8 @@ class NavigationController extends AbstractController * * @return void */ - public function pageSelectAction(PageSelectForm $pageSelectForm = NULL) { + public function pageSelectAction(PageSelectForm $pageSelectForm = NULL): void + { if ($pageSelectForm) { $uri = $this->uriBuilder->reset() ->setArguments( @@ -57,7 +58,7 @@ public function pageSelectAction(PageSelectForm $pageSelectForm = NULL) { * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); diff --git a/Classes/Controller/PageGridController.php b/Classes/Controller/PageGridController.php index 63265cf16..e0b864b1d 100644 --- a/Classes/Controller/PageGridController.php +++ b/Classes/Controller/PageGridController.php @@ -11,10 +11,8 @@ namespace Kitodo\Dlf\Controller; -use TYPO3\CMS\Core\Pagination\ArrayPaginator; use Kitodo\Dlf\Pagination\PageGridPagination; use Kitodo\Dlf\Pagination\PageGridPaginator; -use TYPO3\CMS\Core\Pagination\SimplePagination; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -34,7 +32,7 @@ class PageGridController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { $this->loadDocument(); if ( @@ -85,7 +83,7 @@ public function mainAction() * * @return array The rendered entry ready for fluid */ - protected function getEntry($number, $fileGrpThumbs) + protected function getEntry(int $number, string $fileGrpThumbs): array { // Set pagination. $entry['pagination'] = htmlspecialchars($this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$number]]['orderlabel']); diff --git a/Classes/Controller/PageViewController.php b/Classes/Controller/PageViewController.php index cd469d6c0..dc7d0089b 100644 --- a/Classes/Controller/PageViewController.php +++ b/Classes/Controller/PageViewController.php @@ -31,19 +31,19 @@ class PageViewController extends AbstractController * @access protected * @var array Holds the controls to add to the map */ - protected $controls = []; + protected array $controls = []; /** * @access protected * @var array Holds the current images' URLs and MIME types */ - protected $images = []; + protected array $images = []; /** * @access protected * @var array Holds the current full texts' URLs */ - protected $fulltexts = []; + protected array $fulltexts = []; /** * Holds the current AnnotationLists / AnnotationPages @@ -51,7 +51,7 @@ class PageViewController extends AbstractController * @access protected * @var array Holds the current AnnotationLists / AnnotationPages */ - protected $annotationContainers = []; + protected array $annotationContainers = []; /** * The main method of the plugin @@ -60,7 +60,7 @@ class PageViewController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); @@ -102,7 +102,7 @@ public function mainAction() * * @return array URL and MIME type of fulltext file */ - protected function getFulltext($page) + protected function getFulltext(int $page): array { $fulltext = []; // Get fulltext link. @@ -135,7 +135,7 @@ protected function getFulltext($page) * * @return void */ - protected function addViewerJS() + protected function addViewerJS(): void { // Viewer configuration. $viewerConfiguration = '$(document).ready(function() { @@ -162,7 +162,7 @@ protected function addViewerJS() * @param int $page Page number * @return array An array containing the IRIs of the AnnotationLists / AnnotationPages as well as some information about the canvas. */ - protected function getAnnotationContainers($page) + protected function getAnnotationContainers(int $page): array { if ($this->document->getCurrentDocument() instanceof IiifManifest) { $canvasId = $this->document->getCurrentDocument()->physicalStructure[$page]; @@ -219,7 +219,7 @@ protected function getAnnotationContainers($page) * * @return array URL and MIME type of image file */ - protected function getImage($page) + protected function getImage(int $page): array { $image = []; // Get @USE value of METS fileGrp. diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index 7006f13dd..d6b508a62 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -15,11 +15,13 @@ use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\Indexer; use Kitodo\Dlf\Common\Solr\Solr; +use Kitodo\Dlf\Domain\Model\Collection; +use Kitodo\Dlf\Domain\Repository\CollectionRepository; +use Kitodo\Dlf\Domain\Repository\MetadataRepository; +use Solarium\Component\Result\FacetSet; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Utility\GeneralUtility; -use Kitodo\Dlf\Domain\Repository\CollectionRepository; -use Kitodo\Dlf\Domain\Repository\MetadataRepository; /** * Controller class for the plugin 'Search'. @@ -35,7 +37,7 @@ class SearchController extends AbstractController * @access protected * @var CollectionRepository */ - protected $collectionRepository; + protected CollectionRepository $collectionRepository; /** * @access public @@ -44,7 +46,7 @@ class SearchController extends AbstractController * * @return void */ - public function injectCollectionRepository(CollectionRepository $collectionRepository) + public function injectCollectionRepository(CollectionRepository $collectionRepository): void { $this->collectionRepository = $collectionRepository; } @@ -53,7 +55,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * @access protected * @var MetadataRepository */ - protected $metadataRepository; + protected MetadataRepository $metadataRepository; /** * @access public @@ -62,7 +64,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * * @return void */ - public function injectMetadataRepository(MetadataRepository $metadataRepository) + public function injectMetadataRepository(MetadataRepository $metadataRepository): void { $this->metadataRepository = $metadataRepository; } @@ -71,7 +73,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * @access protected * @var array The current search parameter */ - protected $searchParams; + protected ?array $searchParams; /** * Search Action @@ -80,7 +82,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @return void */ - public function searchAction() + public function searchAction(): void { // if search was triggered, get search parameters from POST variables $this->searchParams = $this->getParametersSafely('searchParameter'); @@ -98,7 +100,7 @@ public function searchAction() * * @return void */ - public function mainAction() + public function mainAction(): void { $listViewSearch = false; // Quit without doing anything if required variables are not set. @@ -198,10 +200,8 @@ public function mainAction() * Adds the facets menu to the search form * * @access protected - * - * @return string HTML output of facets menu */ - protected function addFacetsMenu() + protected function addFacetsMenu(): void { // Quit without doing anything if no facets are configured. if (empty($this->settings['facets']) && empty($this->settings['facetCollections'])) { @@ -226,7 +226,7 @@ protected function addFacetsMenu() * * @return array HMENU array */ - public function makeFacetsMenuArray($facets) + public function makeFacetsMenuArray(array $facets): array { // Set default value for facet search. $search = [ @@ -367,7 +367,8 @@ public function makeFacetsMenuArray($facets) * * @return string The collection query string */ - private function addCollectionsQuery($query) { + private function addCollectionsQuery(string $query): string + { // if collections are given, we prepare the collections query string // extract collections from collection parameter $collections = null; @@ -421,7 +422,7 @@ private function addCollectionsQuery($query) { * * @return array The array for the facet's menu entry */ - private function getFacetsMenuEntry($field, $value, $count, $search, &$state) + private function getFacetsMenuEntry(string $field, string $value, int $count, array $search, string &$state): array { $entryArray = []; $entryArray['title'] = $this->translateValue($field, $value); @@ -456,13 +457,14 @@ private function getFacetsMenuEntry($field, $value, $count, $search, &$state) * * @access private * - * @param array $facet + * @param FacetSet|null $facet * @param array $facetCollectionArray * @param array $search * * @return array menu array */ - private function processResults($facet, $facetCollectionArray, $search) { + private function processResults($facet, array $facetCollectionArray, array $search): array + { $menuArray = []; if ($facet) { @@ -510,7 +512,7 @@ private function processResults($facet, $facetCollectionArray, $search) { * * @return string */ - private function translateValue($field, $value) + private function translateValue(string $field, string $value): string { switch ($field) { case 'owner_faceting': @@ -535,16 +537,16 @@ private function translateValue($field, $value) * * @access private * - * @return string The extended search form or an empty string + * @return void */ - private function addExtendedSearch() + private function addExtendedSearch(): void { // Quit without doing anything if no fields for extended search are selected. if ( empty($this->settings['extendedSlotCount']) || empty($this->settings['extendedFields']) ) { - return ''; + return; } // Get field selector options. diff --git a/Classes/Controller/StatisticsController.php b/Classes/Controller/StatisticsController.php index 336caeab3..779648e6e 100644 --- a/Classes/Controller/StatisticsController.php +++ b/Classes/Controller/StatisticsController.php @@ -30,7 +30,7 @@ class StatisticsController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { $foundNumbers = $this->documentRepository->getStatisticsForSelectedCollection($this->settings); diff --git a/Classes/Controller/TableOfContentsController.php b/Classes/Controller/TableOfContentsController.php index 209c4b7da..e15428d9a 100644 --- a/Classes/Controller/TableOfContentsController.php +++ b/Classes/Controller/TableOfContentsController.php @@ -31,7 +31,7 @@ class TableOfContentsController extends AbstractController * @access protected * @var array This holds the active entries according to the currently selected page */ - protected $activeEntries = []; + protected array $activeEntries = []; /** * The main method of the plugin @@ -40,7 +40,7 @@ class TableOfContentsController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); @@ -61,7 +61,7 @@ public function mainAction() * * @return array HMENU array */ - private function makeMenuArray() + private function makeMenuArray(): array { $menuArray = []; // Does the document have physical elements or is it an external file? @@ -115,7 +115,7 @@ private function makeMenuArray() * * @return array HMENU array for menu entry */ - private function getMenuEntry(array $entry, $recursive = false) + private function getMenuEntry(array $entry, bool $recursive = false): array { $entry = $this->resolveMenuEntry($entry); @@ -215,7 +215,7 @@ private function getMenuEntry(array $entry, $recursive = false) * * @return array */ - private function resolveMenuEntry($entry) + private function resolveMenuEntry(array $entry): array { // If the menu entry points to the parent document, // resolve to the parent UID set on indexation. @@ -239,7 +239,8 @@ private function resolveMenuEntry($entry) * * @return void */ - private function getAllLogicalUnits() { + private function getAllLogicalUnits(): void + { if ( !empty($this->requestData['page']) && !empty($this->document->getCurrentDocument()->physicalStructure) @@ -265,7 +266,8 @@ private function getAllLogicalUnits() { * * @return string */ - private function getTranslatedType($type) { + private function getTranslatedType(string $type): string + { return Helper::translate($type, 'tx_dlf_structures', $this->settings['storagePid']); } @@ -285,7 +287,8 @@ private function getTranslatedType($type) { * * @return bool */ - private function isMultiElement($type) { + private function isMultiElement(string $type): bool + { return $type === 'multivolume_work' || $type === 'multipart_manuscript'; } /** @@ -297,7 +300,8 @@ private function isMultiElement($type) { * * @return string */ - private function setTitle($entry) { + private function setTitle(array $entry): string + { if (empty($entry['label']) && empty($entry['orderlabel'])) { foreach ($this->settings['titleReplacements'] as $titleReplacement) { if ($entry['type'] == $titleReplacement['type']) { @@ -327,7 +331,8 @@ private function setTitle($entry) { * * @return void */ - private function sortMenu(&$menu) { + private function sortMenu(array &$menu): void + { if ($menu[0]['type'] == $this->getTranslatedType("newspaper")) { $this->sortSubMenu($menu); } @@ -345,7 +350,8 @@ private function sortMenu(&$menu) { * * @return void */ - private function sortSubMenu(&$menu) { + private function sortSubMenu(array &$menu): void + { usort($menu[0]['_SUB_MENU'], function ($firstElement, $secondElement) { if (!empty($firstElement['orderlabel'])) { return $firstElement['orderlabel'] <=> $secondElement['orderlabel']; diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index 8b090c820..6f51c377d 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -11,6 +11,7 @@ namespace Kitodo\Dlf\Controller; +use Kitodo\Dlf\Common\AbstractDocument; use Kitodo\Dlf\Common\Helper; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -28,9 +29,9 @@ class ToolboxController extends AbstractController /** * @access private - * @var \Kitodo\Dlf\Common\AbstractDocument This holds the current document + * @var AbstractDocument This holds the current document */ - private $doc; + private AbstractDocument $currentDocument; /** * The main method of the plugin @@ -39,7 +40,7 @@ class ToolboxController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); @@ -47,7 +48,7 @@ public function mainAction() $this->view->assign('double', $this->requestData['double']); if (!$this->isDocMissingOrEmpty()) { - $this->doc = $this->document->getCurrentDocument(); + $this->currentDocument = $this->document->getCurrentDocument(); } $this->renderTool(); @@ -61,7 +62,8 @@ public function mainAction() * * @return void */ - private function renderTool() { + private function renderTool(): void + { if (!empty($this->settings['tool'])) { switch ($this->settings['tool']) { case 'tx_dlf_annotationtool': @@ -107,7 +109,8 @@ private function renderTool() { * * @return void */ - private function renderToolByName(string $tool) { + private function renderToolByName(string $tool): void + { $this->$tool(); $this->view->assign($tool, true); } @@ -119,7 +122,7 @@ private function renderToolByName(string $tool) { * * @return void */ - private function renderAnnotationTool() + private function renderAnnotationTool(): void { if ($this->isDocMissingOrEmpty()) { // Quit without doing anything if required variables are not set. @@ -128,7 +131,7 @@ private function renderAnnotationTool() $this->setPage(); - $annotationContainers = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->requestData['page']]]['annotationContainers']; + $annotationContainers = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$this->requestData['page']]]['annotationContainers']; if ( $annotationContainers != null && sizeof($annotationContainers) > 0 @@ -146,7 +149,7 @@ private function renderAnnotationTool() * * @return void */ - private function renderFulltextDownloadTool() + private function renderFulltextDownloadTool(): void { if ( $this->isDocMissingOrEmpty() @@ -169,7 +172,7 @@ private function renderFulltextDownloadTool() * * @return void */ - private function renderFulltextTool() + private function renderFulltextTool(): void { if ( $this->isDocMissingOrEmpty() @@ -196,7 +199,7 @@ private function renderFulltextTool() * * @return void */ - private function renderImageDownloadTool() + private function renderImageDownloadTool(): void { if ( $this->isDocMissingOrEmpty() @@ -226,18 +229,18 @@ private function renderImageDownloadTool() * * @return array Array of image links and image format information */ - private function getImage($page) + private function getImage(int $page): array { $image = []; // Get @USE value of METS fileGrp. $fileGrps = GeneralUtility::trimExplode(',', $this->settings['fileGrpsImageDownload']); while ($fileGrp = @array_pop($fileGrps)) { // Get image link. - $physicalStructureInfo = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]; + $physicalStructureInfo = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$page]]; $fileId = $physicalStructureInfo['files'][$fileGrp]; - if (!empty($fileGroup)) { - $image['url'] = $this->doc->getDownloadLocation($fileId); - $image['mimetype'] = $this->doc->getFileMimeType($fileId); + if (!empty($fileId)) { + $image['url'] = $this->currentDocument->getDownloadLocation($fileId); + $image['mimetype'] = $this->currentDocument->getFileMimeType($fileId); switch ($image['mimetype']) { case 'image/jpeg': $image['mimetypeLabel'] = ' (JPG)'; @@ -263,7 +266,7 @@ private function getImage($page) * * @return void */ - private function renderImageManipulationTool() + private function renderImageManipulationTool(): void { // Set parent element for initialization. $parentContainer = !empty($this->settings['parentContainer']) ? $this->settings['parentContainer'] : '.tx-dlf-imagemanipulationtool'; @@ -279,7 +282,7 @@ private function renderImageManipulationTool() * * @return void */ - private function renderPdfDownloadTool() + private function renderPdfDownloadTool(): void { if ( $this->isDocMissingOrEmpty() @@ -304,7 +307,7 @@ private function renderPdfDownloadTool() * * @return array Link to downloadable page */ - private function getPageLink() + private function getPageLink(): array { $firstPageLink = ''; $secondPageLink = ''; @@ -313,17 +316,17 @@ private function getPageLink() $fileGrpsDownload = GeneralUtility::trimExplode(',', $this->extConf['fileGrpDownload']); // Get image link. while ($fileGrpDownload = array_shift($fileGrpsDownload)) { - $firstFileGroupDownload = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber]]['files'][$fileGrpDownload]; + $firstFileGroupDownload = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$pageNumber]]['files'][$fileGrpDownload]; if (!empty($firstFileGroupDownload)) { - $firstPageLink = $this->doc->getFileLocation($firstFileGroupDownload); + $firstPageLink = $this->currentDocument->getFileLocation($firstFileGroupDownload); // Get second page, too, if double page view is activated. - $secondFileGroupDownload = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber + 1]]['files'][$fileGrpDownload]; + $secondFileGroupDownload = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$pageNumber + 1]]['files'][$fileGrpDownload]; if ( $this->requestData['double'] - && $pageNumber < $this->doc->numPages + && $pageNumber < $this->currentDocument->numPages && !empty($secondFileGroupDownload) ) { - $secondPageLink = $this->doc->getFileLocation($secondFileGroupDownload); + $secondPageLink = $this->currentDocument->getFileLocation($secondFileGroupDownload); } break; } @@ -351,20 +354,20 @@ private function getPageLink() * * @return string Link to downloadable work */ - private function getWorkLink() + private function getWorkLink(): string { $workLink = ''; $fileGrpsDownload = GeneralUtility::trimExplode(',', $this->extConf['fileGrpDownload']); // Get work link. while ($fileGrpDownload = array_shift($fileGrpsDownload)) { - $fileGroupDownload = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[0]]['files'][$fileGrpDownload]; + $fileGroupDownload = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[0]]['files'][$fileGrpDownload]; if (!empty($fileGroupDownload)) { - $workLink = $this->doc->getFileLocation($fileGroupDownload); + $workLink = $this->currentDocument->getFileLocation($fileGroupDownload); break; } else { - $details = $this->doc->getLogicalStructure($this->doc->toplevelId); + $details = $this->currentDocument->getLogicalStructure($this->currentDocument->toplevelId); if (!empty($details['files'][$fileGrpDownload])) { - $workLink = $this->doc->getFileLocation($details['files'][$fileGrpDownload]); + $workLink = $this->currentDocument->getFileLocation($details['files'][$fileGrpDownload]); break; } } @@ -382,7 +385,7 @@ private function getWorkLink() * * @return void */ - private function renderSearchInDocumentTool() + private function renderSearchInDocumentTool(): void { if ( $this->isDocMissingOrEmpty() @@ -425,7 +428,7 @@ private function renderSearchInDocumentTool() * * @return string with current document id */ - private function getCurrentDocumentId() + private function getCurrentDocumentId(): string { $id = $this->document->getUid(); @@ -461,7 +464,7 @@ private function getCurrentDocumentId() * * @return string with encrypted core name */ - private function getEncryptedCoreName() + private function getEncryptedCoreName(): string { // Get core name. $name = Helper::getIndexNameFromUid($this->settings['solrcore'], 'tx_dlf_solrcores'); @@ -479,10 +482,11 @@ private function getEncryptedCoreName() * * @return bool true if empty, false otherwise */ - private function isFullTextEmpty() { + private function isFullTextEmpty(): bool + { $fileGrpsFulltext = GeneralUtility::trimExplode(',', $this->extConf['fileGrpFulltext']); while ($fileGrpFulltext = array_shift($fileGrpsFulltext)) { - $fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->requestData['page']]]['files'][$fileGrpFulltext]; + $fullTextFile = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$this->requestData['page']]]['files'][$fileGrpFulltext]; if (!empty($fullTextFile)) { break; } diff --git a/Classes/Controller/View3DController.php b/Classes/Controller/View3DController.php index 3c8fae78f..ba9f1c5be 100644 --- a/Classes/Controller/View3DController.php +++ b/Classes/Controller/View3DController.php @@ -26,7 +26,7 @@ class View3DController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); diff --git a/Classes/Domain/Model/Document.php b/Classes/Domain/Model/Document.php index 1737c393d..8533f5475 100644 --- a/Classes/Domain/Model/Document.php +++ b/Classes/Domain/Model/Document.php @@ -638,9 +638,9 @@ public function addCollection(Collection $collection): void * * @param Collection $collection * - * @return ObjectStorage collections + * @return void */ - public function removeCollection(Collection $collection) + public function removeCollection(Collection $collection): void { $this->collections->detach($collection); } diff --git a/Classes/Domain/Model/Metadata.php b/Classes/Domain/Model/Metadata.php index 1e2eeb4e3..74910e0d6 100644 --- a/Classes/Domain/Model/Metadata.php +++ b/Classes/Domain/Model/Metadata.php @@ -52,7 +52,7 @@ class Metadata extends AbstractEntity /** * @access protected - * @var ObjectStorage The formats that encode this metadatum (local IRRE field to ``tx_dlf_metadataformat``). + * @var ObjectStorage The formats that encode this metadata (local IRRE field to ``tx_dlf_metadataformat``). * * @Extbase\ORM\Lazy * @Extbase\ORM\Cascade("remove") diff --git a/Classes/Domain/Repository/CollectionRepository.php b/Classes/Domain/Repository/CollectionRepository.php index b6c373788..6774f00d0 100644 --- a/Classes/Domain/Repository/CollectionRepository.php +++ b/Classes/Domain/Repository/CollectionRepository.php @@ -12,6 +12,7 @@ namespace Kitodo\Dlf\Domain\Repository; +use Doctrine\DBAL\ForwardCompatibility\Result; use Kitodo\Dlf\Common\Helper; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -42,11 +43,11 @@ class CollectionRepository extends Repository * * @access public * - * @param string $uids separated by comma + * @param array $uids * * @return QueryResultInterface */ - public function findAllByUids($uids) + public function findAllByUids(array $uids): QueryResultInterface { $query = $this->createQuery(); @@ -69,7 +70,7 @@ public function findAllByUids($uids) * * @return QueryResultInterface */ - public function getCollectionForMetadata($pages) + public function getCollectionForMetadata(string $pages): QueryResultInterface { // Get list of collections to show. $query = $this->createQuery(); @@ -86,9 +87,9 @@ public function getCollectionForMetadata($pages) * * @param array $settings * - * @return array|QueryResultInterface + * @return QueryResultInterface */ - public function findCollectionsBySettings($settings = []) + public function findCollectionsBySettings(array $settings = []): QueryResultInterface { $query = $this->createQuery(); @@ -134,9 +135,9 @@ public function findCollectionsBySettings($settings = []) * @param array $settings * @param mixed $set * - * @return array|QueryResultInterface + * @return Result */ - public function getIndexNameForSolr($settings, $set) + public function getIndexNameForSolr(array $settings, $set): Result { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tx_dlf_collections'); @@ -161,10 +162,9 @@ public function getIndexNameForSolr($settings, $set) $where, Helper::whereExpression('tx_dlf_collections') ) - ->setMaxResults(1) - ->execute(); + ->setMaxResults(1); - return $result; + return $result->execute(); } } diff --git a/Classes/Domain/Repository/MailRepository.php b/Classes/Domain/Repository/MailRepository.php index 31c666549..e17a9ca22 100644 --- a/Classes/Domain/Repository/MailRepository.php +++ b/Classes/Domain/Repository/MailRepository.php @@ -15,6 +15,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; use TYPO3\CMS\Extbase\Persistence\Repository; +use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; /** * Mail repository. @@ -32,11 +33,11 @@ class MailRepository extends Repository * * @access public * - * @param int @pid + * @param int $pid * - * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface + * @return array|QueryResultInterface */ - public function findAllWithPid($pid) + public function findAllWithPid(int $pid) { /** @var Typo3QuerySettings $querySettings */ $querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class); diff --git a/Classes/Domain/Repository/MetadataRepository.php b/Classes/Domain/Repository/MetadataRepository.php index e5beecc9b..dc38aa20b 100644 --- a/Classes/Domain/Repository/MetadataRepository.php +++ b/Classes/Domain/Repository/MetadataRepository.php @@ -33,9 +33,9 @@ class MetadataRepository extends Repository * * @param array $settings * - * @return array|QueryResultInterface + * @return QueryResultInterface */ - public function findBySettings($settings = []) + public function findBySettings(array $settings = []): QueryResultInterface { $query = $this->createQuery(); diff --git a/Classes/Domain/Repository/TokenRepository.php b/Classes/Domain/Repository/TokenRepository.php index b8799baa5..fcc1fc194 100644 --- a/Classes/Domain/Repository/TokenRepository.php +++ b/Classes/Domain/Repository/TokenRepository.php @@ -33,7 +33,7 @@ class TokenRepository extends Repository * * @return void */ - public function deleteExpiredTokens($expireTime) + public function deleteExpiredTokens(int $expireTime): void { $query = $this->createQuery(); From 4dd358c4e2d5b473fe7dd9570e0c603589d381f4 Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Tue, 24 Oct 2023 13:29:48 +0200 Subject: [PATCH 34/76] [BUGFIX] Fixes incomplete renaming $index_name to $indexName of #1048 (#1058) --- Classes/Common/Helper.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index 5f475f2cc..b3c9698d7 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -726,8 +726,8 @@ public static function translate(string $indexName, string $table, string $pid): $indexName = self::getIndexNameFromUid($indexName, $table, $pid); } /* $labels already contains the translated content element, but with the index_name of the translated content element itself - * and not with the $index_name of the original that we receive here. So we have to determine the index_name of the - * associated translated content element. E.g. $labels['title0'] != $index_name = title. */ + * and not with the $indexName of the original that we receive here. So we have to determine the index_name of the + * associated translated content element. E.g. $labels['title0'] != $indexName = title. */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable($table); @@ -741,7 +741,7 @@ public static function translate(string $indexName, string $table, string $pid): ->from($table) ->where( $queryBuilder->expr()->eq($table . '.pid', $pid), - $queryBuilder->expr()->eq($table . '.index_name', $queryBuilder->expr()->literal($index_name)), + $queryBuilder->expr()->eq($table . '.index_name', $queryBuilder->expr()->literal($indexName)), self::whereExpression($table, true) ) ->setMaxResults(1) @@ -766,13 +766,13 @@ public static function translate(string $indexName, string $table, string $pid): $row = $result->fetchAssociative(); if ($row) { - // If there is an translated content element, overwrite the received $index_name. - $index_name = $row['index_name']; + // If there is an translated content element, overwrite the received $indexName. + $indexName = $row['index_name']; } } // Check if we already got a translation. - if (empty($labels[$table][$pid][$languageContentId][$index_name])) { + if (empty($labels[$table][$pid][$languageContentId][$indexName])) { // Check if this table is allowed for translation. if (in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'])) { $additionalWhere = $queryBuilder->expr()->in($table . '.sys_language_uid', [-1, 0]); @@ -816,10 +816,10 @@ public static function translate(string $indexName, string $table, string $pid): } } - if (!empty($labels[$table][$pid][$languageContentId][$index_name])) { - return $labels[$table][$pid][$languageContentId][$index_name]; + if (!empty($labels[$table][$pid][$languageContentId][$indexName])) { + return $labels[$table][$pid][$languageContentId][$indexName]; } else { - return $index_name; + return $indexName; } } From f9c339cb71a6080aad60d5f93368887d4d2e6e89 Mon Sep 17 00:00:00 2001 From: Bernd Fallert Date: Tue, 24 Oct 2023 14:18:41 +0200 Subject: [PATCH 35/76] [BUGFIX] Type must be string, null given in Classes/Controller/SearchController.php (#1056) Co-authored-by: BFallert Co-authored-by: Sebastian Meyer --- Classes/Controller/SearchController.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index d6b508a62..74c45f9c7 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -236,15 +236,11 @@ public function makeFacetsMenuArray(array $facets): array 'facetset' => [ 'facet' => [] ] - ] + ], + 'filterquery' => [] ] ]; - // Set needed parameters for facet search. - if (empty($search['params']['filterquery'])) { - $search['params']['filterquery'] = []; - } - $fields = Solr::getFields(); // Set search query. @@ -256,7 +252,7 @@ public function makeFacetsMenuArray(array $facets): array // If the query already is a fulltext query e.g using the facets $searchParams['query'] = empty($matches[1]) ? $searchParams['query'] : $matches[1]; // Search in fulltext field if applicable. Query must not be empty! - if (!empty($this->searchParams['query'])) { + if (!empty($searchParams['query'])) { $search['query'] = $fields['fulltext'] . ':(' . Solr::escapeQuery(trim($searchParams['query'])) . ')'; } } else { @@ -266,7 +262,7 @@ public function makeFacetsMenuArray(array $facets): array } } - $collectionsQuery = $this->addCollectionsQuery($searchParams['query']); + $collectionsQuery = $this->addCollectionsQuery($search['query']); if (!empty($collectionsQuery)) { $search['params']['filterquery'][]['query'] = $collectionsQuery; } From 18aeeb9e0fc5f6af78bca16382b64491ac552993 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Tue, 24 Oct 2023 14:47:11 +0200 Subject: [PATCH 36/76] [BUGFIX] Fix getOaiDocumentList() (#1057) Co-authored-by: Sebastian Meyer --- Classes/Controller/OaiPmhController.php | 2 +- Classes/Domain/Repository/DocumentRepository.php | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Classes/Controller/OaiPmhController.php b/Classes/Controller/OaiPmhController.php index a5cc90e3d..6901a2423 100644 --- a/Classes/Controller/OaiPmhController.php +++ b/Classes/Controller/OaiPmhController.php @@ -714,7 +714,7 @@ protected function generateOutputForDocumentList(array $documentListSet) } $verb = $this->parameters['verb']; - $documents = $this->documentRepository->getOaiDocumentList($this->settings, $documentsToProcess); + $documents = $this->documentRepository->getOaiDocumentList($documentsToProcess); $records = []; while ($resArray = $documents->fetchAssociative()) { diff --git a/Classes/Domain/Repository/DocumentRepository.php b/Classes/Domain/Repository/DocumentRepository.php index 5afd9de8f..58cc653bf 100644 --- a/Classes/Domain/Repository/DocumentRepository.php +++ b/Classes/Domain/Repository/DocumentRepository.php @@ -464,12 +464,11 @@ public function getOaiRecord($settings, $parameters) * * @access public * - * @param array $settings * @param array $documentsToProcess * - * @return array The found document objects + * @return Result The found document objects */ - public function getOaiDocumentList($settings, $documentsToProcess) + public function getOaiDocumentList($documentsToProcess): Result { $connection = GeneralUtility::makeInstance(ConnectionPool::class) ->getConnectionForTable('tx_dlf_documents'); @@ -492,9 +491,7 @@ public function getOaiDocumentList($settings, $documentsToProcess) ]; // Create a prepared statement for the passed SQL query, bind the given params with their binding types and execute the query - $documents = $connection->executeQuery($sql, $values, $types); - - return $documents; + return $connection->executeQuery($sql, $values, $types); } /** From 03fdba933dfdcd6141f74983ceef4f06f675e64a Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 24 Oct 2023 15:30:15 +0200 Subject: [PATCH 37/76] [BUGFIX] Do not assume that return value from `Extbase\Persistence\Repository::findOneByRecordId` is not null (#1062) Signed-off-by: Christos Sidiropoulos Co-authored-by: Sebastian Meyer --- Classes/Controller/AbstractController.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 2d9d11058..d946e2cc2 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -140,12 +140,14 @@ protected function loadDocument(int $documentId = 0): void if ($doc !== null) { if ($doc->recordId) { - $this->document = $this->documentRepository->findOneByRecordId($doc->recordId); - } - - if ($this->document === null) { - // create new dummy Document object - $this->document = GeneralUtility::makeInstance(Document::class); + // find document from repository by recordId + $docFromRepository = $this->documentRepository->findOneByRecordId($doc->recordId); + if ($docFromRepository !== null) { + $this->document = $docFromRepository; + } else { + // create new dummy Document object + $this->document = GeneralUtility::makeInstance(Document::class); + } } // Make sure configuration PID is set when applicable From 5578856bf6acf60988a091da8372525e4df7ca0d Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Tue, 24 Oct 2023 16:51:01 +0200 Subject: [PATCH 38/76] [BUGFIX] Make Toolbox render again (#1024) Co-authored-by: Sebastian Meyer --- Classes/Controller/ToolboxController.php | 73 +++++++++++++----------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index 6f51c377d..7455cbc15 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -51,7 +51,7 @@ public function mainAction(): void $this->currentDocument = $this->document->getCurrentDocument(); } - $this->renderTool(); + $this->renderTools(); $this->view->assign('viewData', $this->viewData); } @@ -62,40 +62,45 @@ public function mainAction(): void * * @return void */ - private function renderTool(): void + private function renderTools(): void { - if (!empty($this->settings['tool'])) { - switch ($this->settings['tool']) { - case 'tx_dlf_annotationtool': - case 'annotationtool': - $this->renderToolByName('renderAnnotationTool'); - break; - case 'tx_dlf_fulltextdownloadtool': - case 'fulltextdownloadtool': - $this->renderToolByName('renderFulltextDownloadTool'); - break; - case 'tx_dlf_fulltexttool': - case 'fulltexttool': - $this->renderToolByName('renderFulltextTool'); - break; - case 'tx_dlf_imagedownloadtool': - case 'imagedownloadtool': - $this->renderToolByName('renderImageDownloadTool'); - break; - case 'tx_dlf_imagemanipulationtool': - case 'imagemanipulationtool': - $this->renderToolByName('renderImageManipulationTool'); - break; - case 'tx_dlf_pdfdownloadtool': - case 'pdfdownloadtool': - $this->renderToolByName('renderPdfDownloadTool'); - break; - case 'tx_dlf_searchindocumenttool': - case 'searchindocumenttool': - $this->renderToolByName('renderSearchInDocumentTool'); - break; - default: - $this->logger->warning('Incorrect tool configuration: "' . $this->settings['tool'] . '". This tool does not exist.'); + if (!empty($this->settings['tools'])) { + + $tools = explode(',', $this->settings['tools']); + + foreach ($tools as $tool) { + switch ($tool) { + case 'tx_dlf_annotationtool': + case 'annotationtool': + $this->renderToolByName('renderAnnotationTool'); + break; + case 'tx_dlf_fulltextdownloadtool': + case 'fulltextdownloadtool': + $this->renderToolByName('renderFulltextDownloadTool'); + break; + case 'tx_dlf_fulltexttool': + case 'fulltexttool': + $this->renderToolByName('renderFulltextTool'); + break; + case 'tx_dlf_imagedownloadtool': + case 'imagedownloadtool': + $this->renderToolByName('renderImageDownloadTool'); + break; + case 'tx_dlf_imagemanipulationtool': + case 'imagemanipulationtool': + $this->renderToolByName('renderImageManipulationTool'); + break; + case 'tx_dlf_pdfdownloadtool': + case 'pdfdownloadtool': + $this->renderToolByName('renderPdfDownloadTool'); + break; + case 'tx_dlf_searchindocumenttool': + case 'searchindocumenttool': + $this->renderToolByName('renderSearchInDocumentTool'); + break; + default: + $this->logger->warning('Incorrect tool configuration: "' . $this->settings['tools'] . '". Tool "' . $tool . '" does not exist.'); + } } } } From 9c799c6e5da72d082518071da4fb693753df44a1 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Tue, 24 Oct 2023 16:57:52 +0200 Subject: [PATCH 39/76] [FEATURE] Display ORDERLABEL as year in the search results if the structure type is year (#1005) Co-authored-by: Sebastian Meyer --- Resources/Private/Partials/ListView/Results.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Resources/Private/Partials/ListView/Results.html b/Resources/Private/Partials/ListView/Results.html index c098b37dc..d75a8cdb8 100644 --- a/Resources/Private/Partials/ListView/Results.html +++ b/Resources/Private/Partials/ListView/Results.html @@ -40,16 +40,16 @@ - + - + + + + +

    No metadata for document with uid={document.uid}

    From 0be9160a566e093c0b8394454e52a38186549300 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Tue, 24 Oct 2023 18:37:33 +0200 Subject: [PATCH 40/76] [MAINTENANCE] Introduce usage of PHPStan checks for new PR (#1052) Co-authored-by: Sebastian Meyer --- .github/phpstan.neon | 31 +++++++++++++++++++ .github/workflows/phpstan.yml | 25 +++++++++++++++ Classes/Api/Orcid/Client.php | 4 +-- Classes/Api/Viaf/Client.php | 4 +-- Classes/Command/BaseCommand.php | 2 +- Classes/Command/HarvestCommand.php | 8 ++++- Classes/Common/AbstractDocument.php | 20 +++++++----- Classes/Common/Helper.php | 12 +++---- Classes/Common/IiifManifest.php | 14 +++++++-- Classes/Common/Indexer.php | 2 +- Classes/Common/MetadataInterface.php | 3 +- Classes/Common/MetsDocument.php | 13 ++++++-- .../Common/Solr/SearchResult/Highlight.php | 9 ++---- Classes/Common/Solr/Solr.php | 2 +- Classes/Common/Solr/SolrSearch.php | 6 +++- Classes/Common/Solr/SolrSearchQuery.php | 24 +++++++++++++- Classes/Controller/AbstractController.php | 4 +-- .../Backend/NewTenantController.php | 11 ------- Classes/Controller/BasketController.php | 10 +++++- Classes/Controller/CalendarController.php | 6 ++-- Classes/Controller/CollectionController.php | 2 ++ Classes/Controller/ListViewController.php | 5 ++- Classes/Controller/MetadataController.php | 9 ++++-- Classes/Controller/NavigationController.php | 2 ++ Classes/Controller/SearchController.php | 2 +- Classes/Domain/Model/Metadata.php | 2 +- Classes/Domain/Model/Structure.php | 2 +- .../Repository/CollectionRepository.php | 2 ++ .../Domain/Repository/DocumentRepository.php | 4 +-- .../DocumentTypeFunctionProvider.php | 6 ++-- Classes/Format/AudioVideoMD.php | 13 ++++++-- Classes/Format/Mods.php | 14 +++++++-- Classes/Format/TeiHeader.php | 3 +- Classes/Hooks/DataHandler.php | 4 +-- Classes/Hooks/ItemsProcFunc.php | 8 ++--- Classes/Middleware/SearchInDocument.php | 7 +++-- Classes/Pagination/PageGridPagination.php | 1 + Classes/Updates/FileLocationUpdater.php | 2 ++ Tests/Functional/Common/MetsDocumentTest.php | 2 +- Tests/Functional/Common/SolrIndexingTest.php | 2 +- Tests/Functional/FunctionalTestCase.php | 1 + composer.json | 1 + 42 files changed, 219 insertions(+), 85 deletions(-) create mode 100644 .github/phpstan.neon create mode 100644 .github/workflows/phpstan.yml diff --git a/.github/phpstan.neon b/.github/phpstan.neon new file mode 100644 index 000000000..fa63a3481 --- /dev/null +++ b/.github/phpstan.neon @@ -0,0 +1,31 @@ +parameters: + ignoreErrors: + - '#Call to an undefined method Kitodo\\Dlf\\Domain\\Repository\\[a-zA-Z]+Repository::countByPid\(\)\.#' + - '#Call to an undefined method Kitodo\\Dlf\\Domain\\Repository\\[a-zA-Z]+Repository::findByIsListed\(\)\.#' + - '#Call to an undefined method Kitodo\\Dlf\\Domain\\Repository\\[a-zA-Z]+Repository::findByIsSortable\(\)\.#' + - '#Call to an undefined method Kitodo\\Dlf\\Domain\\Repository\\[a-zA-Z]+Repository::findOneByFeUserId\(\)\.#' + - '#Call to an undefined method Kitodo\\Dlf\\Domain\\Repository\\[a-zA-Z]+Repository::findOneByIndexName\(\)\.#' + - '#Call to an undefined method Kitodo\\Dlf\\Domain\\Repository\\[a-zA-Z]+Repository::findOneByPid\(\)\.#' + - '#Call to an undefined method Kitodo\\Dlf\\Domain\\Repository\\[a-zA-Z]+Repository::findOneByRecordId\(\)\.#' + - '#Call to an undefined method Kitodo\\Dlf\\Domain\\Repository\\[a-zA-Z]+Repository::findOneByRoot\(\)\.#' + - '#Call to an undefined method Kitodo\\Dlf\\Domain\\Repository\\[a-zA-Z]+Repository::findOneBySessionId\(\)\.#' + - '#Call to an undefined method Kitodo\\Dlf\\Domain\\Repository\\[a-zA-Z]+Repository::findOneByType\(\)\.#' + - '#Call to an undefined method Kitodo\\Dlf\\Domain\\Repository\\[a-zA-Z]+Repository::findOneByUid\(\)\.#' + - '#Call to an undefined method Psr\\Http\\Message\\RequestFactoryInterface::request\(\)\.#' + - '#Call to an undefined method Solarium\\Core\\Query\\DocumentInterface::setField\(\)\.#' + - '#Call to an undefined method Ubl\\Iiif\\Presentation\\Common\\Model\\Resources\\IiifResourceInterface::getHeight\(\)\.#' + - '#Call to an undefined method Ubl\\Iiif\\Presentation\\Common\\Model\\Resources\\IiifResourceInterface::getWidth\(\)\.#' + - '#Call to an undefined method Ubl\\Iiif\\Presentation\\Common\\Model\\Resources\\IiifResourceInterface::getPossibleTextAnnotationContainers\(\)\.#' + - '#Call to an undefined method Ubl\\Iiif\\Presentation\\Common\\Model\\Resources\\IiifResourceInterface::getTextAnnotations\(\)\.#' + - '#Call to an undefined method Ubl\\Iiif\\Presentation\\Common\\Model\\Resources\\ManifestInterface::getOriginalJsonArray\(\)\.#' + - '#Call to an undefined method Ubl\\Iiif\\Presentation\\Common\\Model\\Resources\\RangeInterface::getMemberRangesAndRanges\(\)\.#' + - '#Constant LOG_SEVERITY_ERROR not found\.#' + - '#Constant LOG_SEVERITY_NOTICE not found\.#' + - '#Constant LOG_SEVERITY_WARNING not found\.#' + - '#Constant TYPO3_MODE not found\.#' + level: 5 + paths: + - ../Classes/ + excludePaths: + - ../Classes/Controller/OaiPmhController.php + treatPhpDocTypesAsCertain: false diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 000000000..8d8861501 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,25 @@ +name: PHPStan + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + phpstan: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install dependencies + 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 diff --git a/Classes/Api/Orcid/Client.php b/Classes/Api/Orcid/Client.php index b2cb38c10..3c814b70c 100644 --- a/Classes/Api/Orcid/Client.php +++ b/Classes/Api/Orcid/Client.php @@ -31,12 +31,12 @@ class Client /** * @var string constant for API hostname **/ - const HOSTNAME = 'orcid.org'; + const HOSTNAME = 'orcid.org'; /** * @var string constant for API version **/ - const VERSION = '3.0'; + const VERSION = '3.0'; /** * @access protected diff --git a/Classes/Api/Viaf/Client.php b/Classes/Api/Viaf/Client.php index b4f82e01f..dbe13163c 100644 --- a/Classes/Api/Viaf/Client.php +++ b/Classes/Api/Viaf/Client.php @@ -35,8 +35,6 @@ class Client protected Logger $logger; /** - * The VIAF API endpoint - * * @access private * @var string The VIAF API endpoint **/ @@ -110,7 +108,7 @@ public function getData() * * @return string **/ - private function getApiEndpoint(): string + private function getApiEndpoint(): string { return $this->viafUrl . '/' . $this->endpoint; } diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index 24e1108e6..922cea9c4 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -191,7 +191,7 @@ protected function getSolrCores(int $pageId): array * * @access protected * - * @param Document $doc The document instance + * @param Document $document The document instance * * @return bool true on success, false otherwise */ diff --git a/Classes/Command/HarvestCommand.php b/Classes/Command/HarvestCommand.php index c9293e62f..e62fa04df 100644 --- a/Classes/Command/HarvestCommand.php +++ b/Classes/Command/HarvestCommand.php @@ -187,6 +187,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ( !is_array($input->getOption('set')) && !empty($input->getOption('set')) + && !empty($oai) ) { $setsAvailable = $oai->listSets(); foreach ($setsAvailable as $setAvailable) { @@ -201,9 +202,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } + $identifiers = []; // Get OAI record identifiers to process. try { - $identifiers = $oai->listIdentifiers('mets', $from, $until, $set); + if (!empty($oai)) { + $identifiers = $oai->listIdentifiers('mets', $from, $until, $set); + } else { + $io->error('ERROR: OAI interface does not exist.'); + } } catch (BaseoaipmhException $exception) { $this->handleOaiError($exception, $io); } diff --git a/Classes/Common/AbstractDocument.php b/Classes/Common/AbstractDocument.php index bc13d3ef7..3876d53cb 100644 --- a/Classes/Common/AbstractDocument.php +++ b/Classes/Common/AbstractDocument.php @@ -391,7 +391,7 @@ public abstract function getFileMimeType(string $id): string; * @param array $settings * @param bool $forceReload Force reloading the document instead of returning the cached instance * - * @return MetsDocument|IiifManifest|null Instance of this class, either MetsDocument or IiifManifest + * @return AbstractDocument|null Instance of this class, either MetsDocument or IiifManifest */ public static function &getInstance(string $location, array $settings = [], bool $forceReload = false) { @@ -441,9 +441,11 @@ public static function &getInstance(string $location, array $settings = [], bool // Sanitize input. $pid = max(intval($settings['storagePid']), 0); if ($documentFormat == 'METS') { - $instance = new MetsDocument($location, $pid, $xml); + $instance = new MetsDocument($pid, $location, $xml, $settings); } elseif ($documentFormat == 'IIIF') { - $instance = new IiifManifest($location, $pid, $iiif); + // TODO: Parameter $preloadedDocument of class Kitodo\Dlf\Common\IiifManifest constructor expects SimpleXMLElement|Ubl\Iiif\Presentation\Common\Model\Resources\IiifResourceInterface, Ubl\Iiif\Presentation\Common\Model\AbstractIiifEntity|null given. + // @phpstan-ignore-next-line + $instance = new IiifManifest($pid, $location, $iiif); } if (!is_null($instance)) { @@ -750,10 +752,11 @@ public function getStructureDepth(string $logId) * @abstract * * @param string $location The location URL of the XML file to parse + * @param array $settings The extension settings * * @return void */ - protected abstract function init(string $location): void; + abstract protected function init(string $location, array $settings): void; /** * Reuse any document object that might have been already loaded to determine whether document is METS or IIIF @@ -1086,6 +1089,8 @@ protected function _getRootId(): int { if (!$this->rootIdLoaded) { if ($this->parentId) { + // TODO: Parameter $location of static method AbstractDocument::getInstance() expects string, int|int<1, max> given. + // @phpstan-ignore-next-line $parent = self::getInstance($this->parentId, ['storagePid' => $this->pid]); $this->rootId = $parent->rootId; } @@ -1168,20 +1173,19 @@ protected function _setCPid(int $value): void * * @access protected * - * @param string $location The location URL of the XML file to parse * @param int $pid If > 0, then only document with this PID gets loaded + * @param string $location The location URL of the XML file to parse * @param \SimpleXMLElement|IiifResourceInterface $preloadedDocument Either null or the \SimpleXMLElement * or IiifResourceInterface that has been loaded to determine the basic document format. * * @return void */ - protected function __construct(string $location, int $pid, $preloadedDocument) + protected function __construct(int $pid, string $location, $preloadedDocument, array $settings = []) { $this->pid = $pid; $this->setPreloadedDocument($preloadedDocument); - $this->init($location); + $this->init($location, $settings); $this->establishRecordId($pid); - return; } /** diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index b3c9698d7..1f32b452a 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -24,9 +24,6 @@ use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; -use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Core\Domain\Repository\PageRepository; @@ -149,6 +146,8 @@ public static function checkIdentifier(string $id, string $type): bool if (!preg_match('/\d{8}-\d{1}/i', $id)) { return false; } elseif ($checksum == 10) { + //TODO: Binary operation "+" between string and 1 results in an error. + // @phpstan-ignore-next-line return self::checkIdentifier(($digits + 1) . substr($id, -2, 2), 'SWD'); } elseif (substr($id, -1, 1) != $checksum) { return false; @@ -218,11 +217,10 @@ public static function decrypt(string $encrypted) * * @static * - * @param string $content: content of file to read + * @param mixed $content content of file to read * * @return \SimpleXMLElement|false */ - //TODO: make sure that this is called only with string then update public static function getXmlFileAsString($content) { // Don't make simplexml_load_string throw (when $content is an array @@ -605,7 +603,7 @@ public static function getURN(string $base, string $id): string for ($i = 0, $j = strlen($digits); $i < $j; $i++) { $checksum += ($i + 1) * intval(substr($digits, $i, 1)); } - $checksum = substr(intval($checksum / intval(substr($digits, -1, 1))), -1, 1); + $checksum = substr((string) floor($checksum / (int) substr($digits, -1, 1)), -1, 1); return $base . $id . $checksum; } @@ -723,7 +721,7 @@ public static function translate(string $indexName, string $table, string $pid): // Check if "index_name" is an UID. if (MathUtility::canBeInterpretedAsInteger($indexName)) { - $indexName = self::getIndexNameFromUid($indexName, $table, $pid); + $indexName = self::getIndexNameFromUid((int) $indexName, $table, $pid); } /* $labels already contains the translated content element, but with the index_name of the translated content element itself * and not with the $indexName of the original that we receive here. So we have to determine the index_name of the diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index 9a1dd3a6b..4554d75a8 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -408,6 +408,8 @@ public function getFileLocation(string $id): string $resource = $this->iiif->getContainedResourceById($id); if (isset($resource)) { if ($resource instanceof CanvasInterface) { + // TODO: Cannot call method getSingleService() on array. + // @phpstan-ignore-next-line return (!empty($resource->getImageAnnotations()) && $resource->getImageAnnotations()->getSingleService() != null) ? $resource->getImageAnnotations()[0]->getSingleService()->getId() : $id; } elseif ($resource instanceof ContentResourceInterface) { return $resource->getSingleService() != null && $resource->getSingleService() instanceof Service ? $resource->getSingleService()->getId() : $id; @@ -458,6 +460,8 @@ public function getLogicalStructure(string $id, bool $recursive = false): array } else { $logUnits[] = $this->iiif; } + // TODO: Variable $logUnits in empty() always exists and is not falsy. + // @phpstan-ignore-next-line if (!empty($logUnits)) { if (!$recursive) { $details = $this->getLogicalStructureInfo($logUnits[0]); @@ -504,7 +508,7 @@ protected function getLogicalStructureInfo(IiifResourceInterface $resource, bool } $details['thumbnailId'] = $resource->getThumbnailUrl(); $details['points'] = ''; - // Load strucural mapping + // Load structural mapping $this->_getSmLinks(); // Load physical structure. $this->_getPhysicalStructure(); @@ -516,7 +520,7 @@ protected function getLogicalStructureInfo(IiifResourceInterface $resource, bool $startCanvas = $resource->getStartCanvasOrFirstCanvas(); $canvases = $resource->getAllCanvases(); } - if ($startCanvas != null) { + if (isset($startCanvas)) { $details['pagination'] = $startCanvas->getLabel(); $startCanvasIndex = array_search($startCanvas, $this->iiif->getDefaultCanvases()); if ($startCanvasIndex !== false) { @@ -681,8 +685,12 @@ public function getMetadata(string $id, int $cPid = 0): array $resArray['format'] > 0 && !empty($resArray['xpath_sorting']) && ($values = $iiifResource->jsonPath($resArray['xpath_sorting']) != null) ) { + // TODO: Call to function is_string() with true will always evaluate to false. + // @phpstan-ignore-next-line if (is_string($values)) { $metadata[$resArray['index_name'] . '_sorting'][0] = [trim((string) $values)]; + // TODO: Instanceof between true and Flow\JSONPath\JSONPath will always evaluate to false. + // @phpstan-ignore-next-line } elseif ($values instanceof JSONPath && is_array($values->data()) && count($values->data()) > 1) { $metadata[$resArray['index_name']] = []; foreach ($values->data() as $value) { @@ -836,7 +844,7 @@ public function getIiif(): IiifResourceInterface /** * @see AbstractDocument::init() */ - protected function init(string $location): void + protected function init(string $location, array $settings = []): void { $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class); } diff --git a/Classes/Common/Indexer.php b/Classes/Common/Indexer.php index 083550ffb..f7102281d 100644 --- a/Classes/Common/Indexer.php +++ b/Classes/Common/Indexer.php @@ -532,8 +532,8 @@ protected static function processPhysical(Document $document, int $page, array $ protected static function solrConnect(int $core, int $pid = 0): bool { // Get Solr instance. - // Connect to Solr server. $solr = Solr::getInstance($core); + // Connect to Solr server. if ($solr->ready) { self::$solr = $solr; // Load indexing configuration if needed. diff --git a/Classes/Common/MetadataInterface.php b/Classes/Common/MetadataInterface.php index 5ff6f624e..1de7ca723 100644 --- a/Classes/Common/MetadataInterface.php +++ b/Classes/Common/MetadataInterface.php @@ -31,8 +31,9 @@ interface MetadataInterface * * @param \SimpleXMLElement $xml The XML to extract the metadata from * @param array &$metadata The metadata array to fill + * @param bool $useExternalApis true if external APIs should be called, false otherwise * * @return void */ - public function extractMetadata(\SimpleXMLElement $xml, array &$metadata): void; + public function extractMetadata(\SimpleXMLElement $xml, array &$metadata, bool $useExternalApis): void; } diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index 613c32440..8886ef4e5 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -137,6 +137,12 @@ final class MetsDocument extends AbstractDocument */ protected string $parentHref = ''; + /** + * @access protected + * @var array the extension settings + */ + protected array $settings = []; + /** * This adds metadata from METS structural map to metadata array. * @@ -467,7 +473,7 @@ public function getMetadata(string $id, int $cPid = 0): array class_exists($class) && ($obj = GeneralUtility::makeInstance($class)) instanceof MetadataInterface ) { - $obj->extractMetadata($this->mdSec[$dmdId]['xml'], $metadata); + $obj->extractMetadata($this->mdSec[$dmdId]['xml'], $metadata, $this->settings['useExternalApisForMetadata']); } else { $this->logger->warning('Invalid class/method "' . $class . '->extractMetadata()" for metadata format "' . $this->mdSec[$dmdId]['type'] . '"'); } @@ -711,9 +717,10 @@ public function getStructureDepth(string $logId) /** * @see AbstractDocument::init() */ - protected function init(string $location): void + protected function init(string $location, array $settings): void { $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(get_class($this)); + $this->settings = $settings; // Get METS node from XML file. $this->registerNamespaces($this->xml); $mets = $this->xml->xpath('//mets:mets'); @@ -1221,7 +1228,7 @@ public function __wakeup(): void $this->asXML = ''; $this->xml = $xml; // Rebuild the unserializable properties. - $this->init(''); + $this->init('', $this->settings); } else { $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class); $this->logger->error('Could not load XML after deserialization'); diff --git a/Classes/Common/Solr/SearchResult/Highlight.php b/Classes/Common/Solr/SearchResult/Highlight.php index a484c5ac4..b3d5da963 100644 --- a/Classes/Common/Solr/SearchResult/Highlight.php +++ b/Classes/Common/Solr/SearchResult/Highlight.php @@ -29,12 +29,6 @@ class Highlight */ private string $id; - /** - * @access private - * @var int The parent region's identifier - */ - private int $parentRegionId; - /** * @access private * @var int The horizontal beginning position of found highlight @@ -70,7 +64,8 @@ class Highlight */ public function __construct(array $highlight) { - $this->parentRegionId = $highlight['parentRegionIdx']; + // there is also possibility to access parentRegionIdx + // $this->parentRegionId = $highlight['parentRegionIdx']; $this->xBeginPosition = $highlight['ulx']; $this->xEndPosition = $highlight['lrx']; $this->yBeginPosition = $highlight['uly']; diff --git a/Classes/Common/Solr/Solr.php b/Classes/Common/Solr/Solr.php index 97703a9cd..c3bb6e0d6 100644 --- a/Classes/Common/Solr/Solr.php +++ b/Classes/Common/Solr/Solr.php @@ -528,7 +528,7 @@ public function __get(string $var) || !method_exists($this, $method) ) { $this->logger->warning('There is no getter function for property "' . $var . '"'); - return; + return null; } else { return $this->$method(); } diff --git a/Classes/Common/Solr/SolrSearch.php b/Classes/Common/Solr/SolrSearch.php index ea3b826a9..a76a78f4f 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -210,6 +210,7 @@ public function offsetExists($offset): bool * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { $idx = $this->result['document_keys'][$offset]; @@ -361,6 +362,7 @@ public function prepare() $params = []; $matches = []; $fields = Solr::getFields(); + $query = ''; // Set search query. if ( @@ -724,7 +726,7 @@ protected function searchSolr($parameters = [], $enableCache = true) // return the coordinates of highlighted search as absolute coordinates $solrRequest->addParam('hl.ocr.absoluteHighlights', 'on'); // max amount of snippets for a single page - $solrRequest->addParam('hl.snippets', 20); + $solrRequest->addParam('hl.snippets', '20'); // we store the fulltext on page level and can disable this option $solrRequest->addParam('hl.ocr.trackPages', 'off'); } @@ -737,6 +739,8 @@ protected function searchSolr($parameters = [], $enableCache = true) } $result = $solr->service->createResult($selectQuery, $response); + // TODO: Call to an undefined method Solarium\Core\Query\Result\ResultInterface::getGrouping(). + // @phpstan-ignore-next-line $uidGroup = $result->getGrouping()->getGroup('uid'); $resultSet['numberOfToplevels'] = $uidGroup->getNumberOfGroups(); $resultSet['numFound'] = $uidGroup->getMatches(); diff --git a/Classes/Common/Solr/SolrSearchQuery.php b/Classes/Common/Solr/SolrSearchQuery.php index 1ab24a327..33419e226 100644 --- a/Classes/Common/Solr/SolrSearchQuery.php +++ b/Classes/Common/Solr/SolrSearchQuery.php @@ -55,6 +55,8 @@ public function __construct($solrSearch) $this->limit = count($solrSearch); } + // this class contains a lot of methods which are inherited but not implemented + // @phpstan-ignore-next-line public function getSource() {} /** @@ -66,6 +68,8 @@ public function getSource() {} * * @return array */ + // TODO: Return type (array) of method SolrSearchQuery::execute() should be compatible with return type (iterable&TYPO3\CMS\Extbase\Persistence\QueryResultInterface) of method TYPO3\CMS\Extbase\Persistence\QueryInterface::execute() + // @phpstan-ignore-next-line public function execute($returnRawQueryResult = false) { $this->solrSearch->submit($this->offset, $this->limit); @@ -79,6 +83,7 @@ public function execute($returnRawQueryResult = false) return $result; } + // @phpstan-ignore-next-line public function setOrderings(array $orderings) {} /** @@ -111,27 +116,42 @@ public function setOffset($offset): SolrSearchQuery return $this; } + // @phpstan-ignore-next-line public function matching($constraint) {} + // @phpstan-ignore-next-line public function logicalAnd($constraint1) {} + // @phpstan-ignore-next-line public function logicalOr($constraint1) {} + // @phpstan-ignore-next-line public function logicalNot(ConstraintInterface $constraint) {} + // @phpstan-ignore-next-line public function equals($propertyName, $operand, $caseSensitive = true) {} + // @phpstan-ignore-next-line public function like($propertyName, $operand) {} + // @phpstan-ignore-next-line public function contains($propertyName, $operand) {} + // @phpstan-ignore-next-line public function in($propertyName, $operand) {} + // @phpstan-ignore-next-line public function lessThan($propertyName, $operand) {} + // @phpstan-ignore-next-line public function lessThanOrEqual($propertyName, $operand) {} + // @phpstan-ignore-next-line public function greaterThan($propertyName, $operand) {} + // @phpstan-ignore-next-line public function greaterThanOrEqual($propertyName, $operand) {} + // @phpstan-ignore-next-line public function getType() {} public function setQuerySettings(QuerySettingsInterface $querySettings) {} + // @phpstan-ignore-next-line public function getQuerySettings() {} public function count() - { + {// @phpstan-ignore-next-line // TODO? } + // @phpstan-ignore-next-line public function getOrderings() {} /** @@ -158,8 +178,10 @@ public function getOffset(): int return $this->offset; } + // @phpstan-ignore-next-line public function getConstraint() {} public function isEmpty($propertyName) {} public function setSource(SourceInterface $source) {} + // @phpstan-ignore-next-line public function getStatement() {} } diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index d946e2cc2..5baf989c1 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -59,9 +59,9 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) /** * @access protected - * @var Document This holds the current document + * @var Document|null This holds the current document */ - protected Document $document; + protected ?Document $document; /** * @access protected diff --git a/Classes/Controller/Backend/NewTenantController.php b/Classes/Controller/Backend/NewTenantController.php index c85b941c5..3d461878f 100644 --- a/Classes/Controller/Backend/NewTenantController.php +++ b/Classes/Controller/Backend/NewTenantController.php @@ -436,17 +436,6 @@ public function indexAction(): void $this->view->assign('recordInfos', $recordInfos); } - /** - * Error function - there is nothing to do at the moment. - * - * @access public - * - * @return void - */ - public function errorAction() - { - } - /** * Get language label for given key and language. * diff --git a/Classes/Controller/BasketController.php b/Classes/Controller/BasketController.php index d5242e439..e1ba0f8dc 100644 --- a/Classes/Controller/BasketController.php +++ b/Classes/Controller/BasketController.php @@ -274,6 +274,8 @@ protected function getBasketData(): Basket */ protected function getEntry(array $data): array { + // TODO: Call to function is_object() with array will always evaluate to false. + // @phpstan-ignore-next-line if (is_object($data)) { $data = get_object_vars($data); } @@ -330,10 +332,14 @@ protected function getDocumentData(int $id, array $data) { // get document instance to load further information $this->loadDocument((int) $id); - if ($this->document) { + if (isset($this->document)) { // replace url param placeholder + // TODO: Parameter #2 $replace of function str_replace expects array|string, int given. + // @phpstan-ignore-next-line $urlParams = str_replace("##page##", (int) $data['page'], $this->settings['pdfparams']); $urlParams = str_replace("##docId##", $this->document->getRecordId(), $urlParams); + // TODO: Parameter #2 $replace of function str_replace expects array|string, int given. + // @phpstan-ignore-next-line $urlParams = str_replace("##startpage##", (int) $data['startpage'], $urlParams); if ($data['startpage'] != $data['endpage']) { $urlParams = str_replace("##endpage##", $data['endpage'] === "" ? "" : (int) $data['endpage'], $urlParams); @@ -450,6 +456,8 @@ protected function addToBasket(array $piVars, Basket $basket): ?Basket if (!in_array($arrayKey, $items)) { $items[$arrayKey] = $documentItem; // replace url param placeholder + // TODO: Parameter #2 $replace of function str_replace expects array|string, int given. + // @phpstan-ignore-next-line $pdfParams = str_replace("##startpage##", $documentItem['startpage'], $this->settings['pdfparams']); $pdfParams = str_replace("##docId##", $this->document->getRecordId(), $pdfParams); $pdfParams = str_replace("##startx##", $documentItem['startX'], $pdfParams); diff --git a/Classes/Controller/CalendarController.php b/Classes/Controller/CalendarController.php index c19596039..fea47290d 100644 --- a/Classes/Controller/CalendarController.php +++ b/Classes/Controller/CalendarController.php @@ -81,10 +81,8 @@ public function mainAction(): void case 'newspaper': case 'ephemera': $this->forward('years', null, null, $this->requestData); - break; case 'year': $this->forward('calendar', null, null, $this->requestData); - break; case 'issue': default: break; @@ -289,10 +287,14 @@ public function yearsAction(): void $max = $yearArray[count($yearArray) - 1]['title']; // if we have an actual documentId it should be used, otherwise leave empty for ($i = 0; $i < $max - $min + 1; $i++) { + // TODO: Binary operation "+" between (array|string) and int<0, max> results in an error. + // @phpstan-ignore-next-line $key = array_search($min + $i, array_column($yearArray, 'title')); if (is_int($key)) { $yearFilled[] = $yearArray[$key]; } else { + // TODO: Binary operation "+" between (array|string) and int<0, max> results in an error. + // @phpstan-ignore-next-line $yearFilled[] = ['title' => $min+$i, 'documentId' => '']; } } diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index 4d332d98f..d329ffac1 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -137,6 +137,8 @@ public function listAction(): void // Generate random but unique array key taking priority into account. do { + //TODO: Offset 'priority' does not exist on array{titles: array, volumes: array}. + // @phpstan-ignore-next-line $_key = ($collectionInfo['priority'] * 1000) + mt_rand(0, 1000); } while (!empty($processedCollections[$_key])); diff --git a/Classes/Controller/ListViewController.php b/Classes/Controller/ListViewController.php index fc882db5e..6a7e497e2 100644 --- a/Classes/Controller/ListViewController.php +++ b/Classes/Controller/ListViewController.php @@ -83,7 +83,7 @@ public function mainAction(): void $collection = null; if ($this->searchParams['collection']) { foreach(explode(',', $this->searchParams['collection']) as $collectionEntry) { - $collection[] = $this->collectionRepository->findByUid($collectionEntry); + $collection[] = $this->collectionRepository->findByUid((int) $collectionEntry); } } @@ -92,6 +92,8 @@ public function mainAction(): void if (empty($currentPage)) { $currentPage = 1; } + //TODO: Undefined variable: $widgetPage + // @phpstan-ignore-next-line $GLOBALS['TSFE']->fe_user->setKey('ses', 'widgetPage', $widgetPage); // get all sortable metadata records @@ -103,6 +105,7 @@ public function mainAction(): void $solrResults = null; $numResults = 0; if (is_array($this->searchParams) && !empty($this->searchParams)) { + // @phpstan-ignore-next-line $solrResults = $this->documentRepository->findSolrByCollection($collection ? : null, $this->settings, $this->searchParams, $listedMetadata); $numResults = $solrResults->getNumFound(); diff --git a/Classes/Controller/MetadataController.php b/Classes/Controller/MetadataController.php index ec49faf99..008ebf024 100644 --- a/Classes/Controller/MetadataController.php +++ b/Classes/Controller/MetadataController.php @@ -116,12 +116,14 @@ public function mainAction(): void $metadata = $this->getMetadata(); $topLevelId = $this->currentDocument->toplevelId; // Get titledata? - if (empty($metadata) || ($this->settings['rootline'] == 1 && $metadata[0]['_id'] != $topLevelId)) { + if (!$metadata || ($this->settings['rootline'] == 1 && $metadata[0]['_id'] != $topLevelId)) { + // @phpstan-ignore-next-line $data = $useOriginalIiifManifestMetadata ? $this->currentDocument->getManifestMetadata($topLevelId, $this->settings['storagePid']) : $this->currentDocument->getTitledata($this->settings['storagePid']); $data['_id'] = $topLevelId; array_unshift($metadata, $data); } - if (empty($metadata)) { + // @phpstan-ignore-next-line + if (!$metadata) { $this->logger->warning('No metadata found for document with UID ' . $this->document->getUid()); return; } @@ -229,6 +231,8 @@ private function buildIiifData(array $metadata): array private function buildIiifDataGroup(string $label, string $value): array { // NOTE: Labels are to be escaped in Fluid template + // TODO: Variable $scheme might not be defined. + // @phpstan-ignore-next-line if (IRI::isAbsoluteIri($value) && ($scheme = (new IRI($value))->getScheme()) == 'http' || $scheme == 'https') { //TODO: should really label be converted to empty string if equal to value? $label = $value == $label ? '' : $label; @@ -431,6 +435,7 @@ private function getMetadataForIds(array $id, array $metadata): array $useOriginalIiifManifestMetadata = $this->settings['originalIiifMetadata'] == 1 && $this->currentDocument instanceof IiifManifest; foreach ($id as $sid) { if ($useOriginalIiifManifestMetadata) { + // @phpstan-ignore-next-line $data = $this->currentDocument->getManifestMetadata($sid, $this->settings['storagePid']); } else { $data = $this->currentDocument->getMetadata($sid, $this->settings['storagePid']); diff --git a/Classes/Controller/NavigationController.php b/Classes/Controller/NavigationController.php index 19b873720..219e4eb7a 100644 --- a/Classes/Controller/NavigationController.php +++ b/Classes/Controller/NavigationController.php @@ -87,6 +87,8 @@ public function mainAction(): void $searchSessionParameters = $GLOBALS['TSFE']->fe_user->getKey('ses', 'search'); $widgetPage = $GLOBALS['TSFE']->fe_user->getKey('ses', 'widgetPage'); + //TODO: If condition is always true. + // @phpstan-ignore-next-line if ($searchSessionParameters) { $lastSearchArguments = [ 'tx_dlf_listview' => [ diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index 74c45f9c7..feffa9cb9 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -370,7 +370,7 @@ private function addCollectionsQuery(string $query): string $collections = null; if ($this->searchParams['collection']) { foreach (explode(',', $this->searchParams['collection']) as $collectionEntry) { - $collections[] = $this->collectionRepository->findByUid($collectionEntry); + $collections[] = $this->collectionRepository->findByUid((int) $collectionEntry); } } if ($collections) { diff --git a/Classes/Domain/Model/Metadata.php b/Classes/Domain/Model/Metadata.php index 74910e0d6..a61b0dcd1 100644 --- a/Classes/Domain/Model/Metadata.php +++ b/Classes/Domain/Model/Metadata.php @@ -148,7 +148,7 @@ public function getL18nParent(): Metadata } /** - * @param int $l18nParent + * @param Metadata $l18nParent */ public function setL18nParent(Metadata $l18nParent): void { diff --git a/Classes/Domain/Model/Structure.php b/Classes/Domain/Model/Structure.php index 3bea2568c..1a3145bdb 100644 --- a/Classes/Domain/Model/Structure.php +++ b/Classes/Domain/Model/Structure.php @@ -75,7 +75,7 @@ public function getL18nParent(): Structure } /** - * @param int $l18nParent + * @param Structure $l18nParent */ public function setL18nParent(Structure $l18nParent): void { diff --git a/Classes/Domain/Repository/CollectionRepository.php b/Classes/Domain/Repository/CollectionRepository.php index 6774f00d0..c57e0eebd 100644 --- a/Classes/Domain/Repository/CollectionRepository.php +++ b/Classes/Domain/Repository/CollectionRepository.php @@ -34,6 +34,8 @@ class CollectionRepository extends Repository * @access protected * @var array Set the default ordering. This is applied to findAll(), too. */ + // TODO: PHPDoc type array of property CollectionRepository::$defaultOrderings is not covariant with 'ASC'|'DESC'> of overridden property TYPO3\CMS\Extbase\Persistence\Repository::$defaultOrderings. + // @phpstan-ignore-next-line protected $defaultOrderings = [ 'label' => QueryInterface::ORDER_ASCENDING, ]; diff --git a/Classes/Domain/Repository/DocumentRepository.php b/Classes/Domain/Repository/DocumentRepository.php index 58cc653bf..6544b57dc 100644 --- a/Classes/Domain/Repository/DocumentRepository.php +++ b/Classes/Domain/Repository/DocumentRepository.php @@ -500,7 +500,7 @@ public function getOaiDocumentList($documentsToProcess): Result * @access public * * @param array $uids - * @param array $checkPartof Whether or not to also match $uids against partof. + * @param bool $checkPartof Whether or not to also match $uids against partof. * * @return array */ @@ -572,7 +572,7 @@ public function findChildrenOfEach(array $uids) * * @access public * - * @param QueryResult|Collection $collection + * @param QueryResult|Collection|null $collection * @param array $settings * @param array $searchParams * @param QueryResult $listedMetadata diff --git a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php index ee27d4c59..fbeabb655 100644 --- a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php +++ b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php @@ -43,7 +43,7 @@ class DocumentTypeFunctionProvider implements ExpressionFunctionProviderInterfac * * @return ExpressionFunction[] An array of Function instances */ - public function getFunctions() + public function getFunctions(): array { return [ $this->getDocumentTypeFunction(), @@ -53,10 +53,10 @@ public function getFunctions() /** * This holds the current document * - * @var Document + * @var Document|null * @access protected */ - protected Document $document; + protected ?Document $document; /** * @var ConfigurationManager diff --git a/Classes/Format/AudioVideoMD.php b/Classes/Format/AudioVideoMD.php index 3cd4ec93a..9ac90132f 100644 --- a/Classes/Format/AudioVideoMD.php +++ b/Classes/Format/AudioVideoMD.php @@ -34,22 +34,29 @@ class AudioVideoMD implements MetadataInterface * * @param \SimpleXMLElement $xml The XML to extract the metadata from * @param array &$metadata The metadata array to fill + * @param bool $useExternalApis true if external APIs should be called, false otherwise * * @return void */ - public function extractMetadata(\SimpleXMLElement $xml, array &$metadata): void + public function extractMetadata(\SimpleXMLElement $xml, array &$metadata, bool $useExternalApis = false): void { $xml->registerXPathNamespace('audiomd', 'http://www.loc.gov/audioMD/'); $xml->registerXPathNamespace('videomd', 'http://www.loc.gov/videoMD/'); - if (!empty($audioDuration = (string) $xml->xpath('./audiomd:audioInfo/audiomd:duration')[0])) { + $audioDuration = (string) $xml->xpath('./audiomd:audioInfo/audiomd:duration')[0]; + if (!empty($audioDuration)) { $metadata['audio_duration'] = [$audioDuration]; } - if (!empty($videoDuration = (string) $xml->xpath('./videomd:videoInfo/videomd:duration')[0])) { + $videoDuration = (string) $xml->xpath('./videomd:videoInfo/videomd:duration')[0]; + if (!empty($videoDuration)) { $metadata['video_duration'] = [$videoDuration]; } $metadata['duration'] = $metadata['video_duration'] ?: $metadata['audio_duration'] ?: []; + + if ($useExternalApis) { + // TODO? + } } } diff --git a/Classes/Format/Mods.php b/Classes/Format/Mods.php index eca0b2764..cc63962e9 100644 --- a/Classes/Format/Mods.php +++ b/Classes/Format/Mods.php @@ -38,6 +38,12 @@ class Mods implements MetadataInterface **/ private $metadata; + /** + * @access private + * @var bool The metadata array + **/ + private $useExternalApis; + /** * This extracts the essential MODS metadata from XML * @@ -45,13 +51,15 @@ class Mods implements MetadataInterface * * @param \SimpleXMLElement $xml The XML to extract the metadata from * @param array &$metadata The metadata array to fill + * @param bool $useExternalApis true if external APIs should be called, false otherwise * * @return void */ - public function extractMetadata(\SimpleXMLElement $xml, array &$metadata): void + public function extractMetadata(\SimpleXMLElement $xml, array &$metadata, bool $useExternalApis): void { $this->xml = $xml; $this->metadata = $metadata; + $this->useExternalApis = $useExternalApis; $this->xml->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); @@ -84,7 +92,7 @@ private function getAuthors(): void $authors[$i]->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); $identifier = $authors[$i]->xpath('./mods:name/mods:nameIdentifier[@type="orcid"]'); - if ($this->settings['useExternalApisForMetadata'] && !empty((string) $identifier[0])) { + if ($this->useExternalApis && !empty((string) $identifier[0])) { $this->getAuthorFromOrcidApi((string) $identifier[0], $authors, $i); } else { $this->getAuthorFromXml($authors, $i); @@ -207,7 +215,7 @@ private function getHolders(): void $holders[$i]->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); $identifier = $holders[$i]->xpath('./mods:name/mods:nameIdentifier[@type="viaf"]'); - if ($this->settings['useExternalApisForMetadata'] && !empty((string) $identifier[0])) { + if ($this->useExternalApis && !empty((string) $identifier[0])) { $this->getHolderFromViafApi((string) $identifier[0], $holders, $i); } else { $this->getHolderFromXml($holders, $i); diff --git a/Classes/Format/TeiHeader.php b/Classes/Format/TeiHeader.php index 0dcb05719..37680ac49 100644 --- a/Classes/Format/TeiHeader.php +++ b/Classes/Format/TeiHeader.php @@ -31,10 +31,11 @@ class TeiHeader implements MetadataInterface * * @param \SimpleXMLElement $xml The XML to extract the metadata from * @param array &$metadata The metadata array to fill + * @param bool $useExternalApis true if external APIs should be called, false otherwise * * @return void */ - public function extractMetadata(\SimpleXMLElement $xml, array &$metadata): void + public function extractMetadata(\SimpleXMLElement $xml, array &$metadata, bool $useExternalApis = false): void { $xml->registerXPathNamespace('teihdr', 'http://www.tei-c.org/ns/1.0'); } diff --git a/Classes/Hooks/DataHandler.php b/Classes/Hooks/DataHandler.php index b61dca4aa..605af0b84 100644 --- a/Classes/Hooks/DataHandler.php +++ b/Classes/Hooks/DataHandler.php @@ -39,9 +39,9 @@ class DataHandler implements LoggerAwareInterface /** * @access protected - * @var DocumentRepository + * @var DocumentRepository|null */ - protected DocumentRepository $documentRepository; + protected ?DocumentRepository $documentRepository; /** * Gets document repository diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php index 84482667a..3e0d6dca7 100644 --- a/Classes/Hooks/ItemsProcFunc.php +++ b/Classes/Hooks/ItemsProcFunc.php @@ -86,6 +86,8 @@ public function getTyposcriptConfigFromPluginSiteRoot(array $params): void $this->logger->error($e->getMessage()); } + // TODO: Variable $ts might not be defined. + // @phpstan-ignore-next-line $typoScriptConfig = $ts->setup; $this->storagePid = $typoScriptConfig['plugin.']['tx_dlf.']['persistence.']['storagePid']; @@ -161,10 +163,8 @@ protected function generateList(array &$params, string $fields, string $table, s ->orderBy($sorting) ->execute(); - while ($resArray = $result->fetch(\PDO::FETCH_NUM)) { - if ($resArray) { - $params['items'][] = $resArray; - } + while ($resArray = $result->fetchNumeric()) { + $params['items'][] = $resArray; } } } diff --git a/Classes/Middleware/SearchInDocument.php b/Classes/Middleware/SearchInDocument.php index bc0803792..bf9b3029d 100644 --- a/Classes/Middleware/SearchInDocument.php +++ b/Classes/Middleware/SearchInDocument.php @@ -57,7 +57,7 @@ class SearchInDocument implements MiddlewareInterface * @param ServerRequestInterface $request * @param RequestHandlerInterface $handler * - * @return ResponseInterface JSON response of documents + * @return ResponseInterface JSON response of search suggestions */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { @@ -88,13 +88,14 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface if ($this->solr->ready) { $result = $this->executeSolrQuery($parameters); /** @scrutinizer ignore-call */ - $output['numFound'] = $result->getNumFound(); + $output['numFound'] = $result->getNumFound(); // @phpstan-ignore-line $data = $result->getData(); $highlighting = $data['ocrHighlighting']; $siteFinder = GeneralUtility::makeInstance(SiteFinder::class); $site = $siteFinder->getSiteByPageId($parameters['pid']); + // @phpstan-ignore-next-line foreach ($result as $record) { $resultDocument = new ResultDocument($record, $highlighting, $this->fields); @@ -154,7 +155,7 @@ private function executeSolrQuery($parameters) // return the coordinates of highlighted search as absolute coordinates $solrRequest->addParam('hl.ocr.absoluteHighlights', 'on'); // max amount of snippets for a single page - $solrRequest->addParam('hl.snippets', 40); + $solrRequest->addParam('hl.snippets', '40'); // we store the fulltext on page level and can disable this option $solrRequest->addParam('hl.ocr.trackPages', 'off'); diff --git a/Classes/Pagination/PageGridPagination.php b/Classes/Pagination/PageGridPagination.php index 5cdeb65b5..c42c78e60 100644 --- a/Classes/Pagination/PageGridPagination.php +++ b/Classes/Pagination/PageGridPagination.php @@ -27,6 +27,7 @@ final class PageGridPagination implements PaginationInterface public function __construct(PaginatorInterface $paginator) { + // @phpstan-ignore-next-line $this->paginator = $paginator; } diff --git a/Classes/Updates/FileLocationUpdater.php b/Classes/Updates/FileLocationUpdater.php index 086a2e83c..044dcf348 100644 --- a/Classes/Updates/FileLocationUpdater.php +++ b/Classes/Updates/FileLocationUpdater.php @@ -104,6 +104,7 @@ public function getDescription(): string */ public function updateNecessary(): bool { + /** @var int */ $numRecords = $this->getRecordsFromTable(true); if ($numRecords > 0) { return true; @@ -146,6 +147,7 @@ public function executeUpdate(): bool { $result = true; try { + /** @var int */ $numRecords = $this->getRecordsFromTable(true); if ($numRecords > 0) { $this->performUpdate(); diff --git a/Tests/Functional/Common/MetsDocumentTest.php b/Tests/Functional/Common/MetsDocumentTest.php index 2dd222e16..4cfaeef88 100644 --- a/Tests/Functional/Common/MetsDocumentTest.php +++ b/Tests/Functional/Common/MetsDocumentTest.php @@ -18,7 +18,7 @@ public function setUp(): void protected function doc(string $file) { $url = 'http://web:8001/Tests/Fixtures/MetsDocument/' . $file; - $doc = AbstractDocument::getInstance($url); + $doc = AbstractDocument::getInstance($url, ['useExternalApisForMetadata' => 0]); $this->assertNotNull($doc); return $doc; } diff --git a/Tests/Functional/Common/SolrIndexingTest.php b/Tests/Functional/Common/SolrIndexingTest.php index 559d69df5..faf2e8c70 100644 --- a/Tests/Functional/Common/SolrIndexingTest.php +++ b/Tests/Functional/Common/SolrIndexingTest.php @@ -73,7 +73,7 @@ public function canIndexAndSearchDocument() $document->setSolrcore($core->model->getUid()); $this->persistenceManager->persistAll(); - $doc = AbstractDocument::getInstance($document->getLocation()); + $doc = AbstractDocument::getInstance($document->getLocation(), ['useExternalApisForMetadata' => 0]); $document->setCurrentDocument($doc); $indexingSuccessful = Indexer::add($document, $this->documentRepository); diff --git a/Tests/Functional/FunctionalTestCase.php b/Tests/Functional/FunctionalTestCase.php index 2a7a6523d..869d9a5b1 100644 --- a/Tests/Functional/FunctionalTestCase.php +++ b/Tests/Functional/FunctionalTestCase.php @@ -104,6 +104,7 @@ public function setUp(): void protected function getDlfConfiguration() { return [ + 'useExternalApisForMetadata' => 0, 'fileGrpImages' => 'DEFAULT,MAX', 'fileGrpThumbs' => 'THUMBS', 'fileGrpDownload' => 'DOWNLOAD', diff --git a/composer.json b/composer.json index 9cb43d99e..9cbe60ab1 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,7 @@ "solarium/solarium": "^5.2.0" }, "require-dev": { + "phpstan/phpstan": "^1.10.0", "spatie/phpunit-watcher": "^1.23.0", "typo3/cms-backend": "^10.4.36|^11.5.30", "typo3/cms-fluid": "^10.4.36|^11.5.30", From 8ba4471966649dbe34b85bc728ac10e3c60d3bed Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Tue, 24 Oct 2023 18:41:21 +0200 Subject: [PATCH 41/76] [BUGFIX] Rename tool to tools in typoscript setup (#1063) Co-authored-by: Sebastian Meyer --- Configuration/TypoScript/Toolbox/setup.typoscript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Configuration/TypoScript/Toolbox/setup.typoscript b/Configuration/TypoScript/Toolbox/setup.typoscript index f29e440b0..e3ad80a42 100644 --- a/Configuration/TypoScript/Toolbox/setup.typoscript +++ b/Configuration/TypoScript/Toolbox/setup.typoscript @@ -1,6 +1,6 @@ plugin.tx_dlf_fulltexttool { settings { - tool = fulltexttool + tools = fulltexttool activateFullTextInitially = 0 fullTextScrollElement = html, body searchHlParameters = tx_dlf[highlight_word] @@ -9,7 +9,7 @@ plugin.tx_dlf_fulltexttool { plugin.tx_dlf_searchindocumenttool { settings { - tool = searchindocumenttool + tools = searchindocumenttool searchUrl = documentIdUrlSchema = idInputName = tx_dlf[id] From c4aaf4f62f2e33a73965589e77aefc565be8ab61 Mon Sep 17 00:00:00 2001 From: haogatyp Date: Thu, 26 Oct 2023 08:01:51 +0200 Subject: [PATCH 42/76] [MAINTENANCE] Added format unit tests. (#894) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Oliver Stöhr --- Tests/Fixtures/Format/alto.xml | 66 ++++++ Tests/Fixtures/Format/altoNoString.xml | 59 +++++ Tests/Fixtures/Format/altoNoTextBlock.xml | 38 ++++ Tests/Fixtures/Format/altoNoTextLine.xml | 48 ++++ Tests/Fixtures/Format/audioVideo.xml | 36 +++ .../Format/modsAuthorNoAutRoleTerm.xml | 126 +++++++++++ .../Format/modsAuthorWithAutRoleTerm.xml | 151 ++++++++++++ Tests/Fixtures/Format/modsOriginInfo.xml | 134 +++++++++++ .../modsOriginInfoWithEditionElectronicEd.xml | 138 +++++++++++ Tests/Unit/Format/AltoTest.php | 116 ++++++++++ Tests/Unit/Format/AudioVideoMDTest.php | 55 +++++ Tests/Unit/Format/ModsTest.php | 214 ++++++++++++++++++ Tests/Unit/Format/TeiHeaderTest.php | 37 +++ 13 files changed, 1218 insertions(+) create mode 100644 Tests/Fixtures/Format/alto.xml create mode 100644 Tests/Fixtures/Format/altoNoString.xml create mode 100644 Tests/Fixtures/Format/altoNoTextBlock.xml create mode 100644 Tests/Fixtures/Format/altoNoTextLine.xml create mode 100644 Tests/Fixtures/Format/audioVideo.xml create mode 100644 Tests/Fixtures/Format/modsAuthorNoAutRoleTerm.xml create mode 100644 Tests/Fixtures/Format/modsAuthorWithAutRoleTerm.xml create mode 100644 Tests/Fixtures/Format/modsOriginInfo.xml create mode 100644 Tests/Fixtures/Format/modsOriginInfoWithEditionElectronicEd.xml create mode 100644 Tests/Unit/Format/AltoTest.php create mode 100644 Tests/Unit/Format/AudioVideoMDTest.php create mode 100644 Tests/Unit/Format/ModsTest.php create mode 100644 Tests/Unit/Format/TeiHeaderTest.php diff --git a/Tests/Fixtures/Format/alto.xml b/Tests/Fixtures/Format/alto.xml new file mode 100644 index 000000000..3cc47e12e --- /dev/null +++ b/Tests/Fixtures/Format/alto.xml @@ -0,0 +1,66 @@ + + + + pixel + + + 2020-05-14 + + ABBYY + ABBYY FineReader Engine + 12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/Fixtures/Format/altoNoString.xml b/Tests/Fixtures/Format/altoNoString.xml new file mode 100644 index 000000000..7cde52caf --- /dev/null +++ b/Tests/Fixtures/Format/altoNoString.xml @@ -0,0 +1,59 @@ + + + + pixel + + + 2020-05-14 + + ABBYY + ABBYY FineReader Engine + 12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/Fixtures/Format/altoNoTextBlock.xml b/Tests/Fixtures/Format/altoNoTextBlock.xml new file mode 100644 index 000000000..e10292809 --- /dev/null +++ b/Tests/Fixtures/Format/altoNoTextBlock.xml @@ -0,0 +1,38 @@ + + + + pixel + + + 2020-05-14 + + ABBYY + ABBYY FineReader Engine + 12 + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/Fixtures/Format/altoNoTextLine.xml b/Tests/Fixtures/Format/altoNoTextLine.xml new file mode 100644 index 000000000..5468cf712 --- /dev/null +++ b/Tests/Fixtures/Format/altoNoTextLine.xml @@ -0,0 +1,48 @@ + + + + pixel + + + 2020-05-14 + + ABBYY + ABBYY FineReader Engine + 12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/Fixtures/Format/audioVideo.xml b/Tests/Fixtures/Format/audioVideo.xml new file mode 100644 index 000000000..f4eb1b941 --- /dev/null +++ b/Tests/Fixtures/Format/audioVideo.xml @@ -0,0 +1,36 @@ + + + + + + + Color + + Phoenix Finish + Apple ProRes 4444 + + 24 + Yes + + + 1.375:1 + + 00:01:30.07 + + 24 + + + + 01:10:35.08 + + + + + diff --git a/Tests/Fixtures/Format/modsAuthorNoAutRoleTerm.xml b/Tests/Fixtures/Format/modsAuthorNoAutRoleTerm.xml new file mode 100644 index 000000000..645502e81 --- /dev/null +++ b/Tests/Fixtures/Format/modsAuthorNoAutRoleTerm.xml @@ -0,0 +1,126 @@ + + + + Odol-Mundwasser, 3 Werbespots + + + + SAVE: Beispiel-Kollektion + + + + 2180770-X + + Stiftung Deutsches Hygiene-Museum + + oth + + + + AnonymousGiven1 AnonymousFamily1 + + + AnonymousGiven2 + AnonymousFamily2 + + Film + Werbefilm + + + Dresden + + SLUB + Filmverband Sachsen + Stiftung Deutsches Hygiene-Museum + 2019 + + + ger + + + positiv, farbig, 24 fps, Bildseitenverhältnis 1,375:1, 2048 px horizontal, Codec: Apple ProRes (HQ) + 4444, Container: Quicktime .mov + + access + video/quicktime + 1 Online-Ressource (1 min, 30 s) + reformatted digital + + [Inhaltsbeschreibung] + + + Odol-Mundwasser, 3 Werbespots + + + 2180770-X + + Stiftung Deutsches Hygiene-Museum + + oth + + + Film + Werbefilm + + + Dresden + + SLUB + Filmverband Sachsen + Stiftung Deutsches Hygiene-Museum + 1965 + 1975 + + + ger + + + Nativ-Scan mit Overscan, Videocodec FFV1 Version 3, Container: Matroska + preservation + video/quicktime + 1 Online-Ressource (1 min, 16 s) + digitized other analog + Acetat mit Lichtton, Umkehr-Positiv, farbig ; 16 mm + + Bearbeitete digitale Ausgabe eines Exemplars aus dem Bestand der Stiftung + Deutsches Hygiene-Museum Dresden + + Die Digitalisierung des Films erfolgte im Rahmen des Programms „Sicherung des + audiovisuellen Erbes in Sachsen“ des Filmverband Sachsen (2019) und der Sächsischen Landesbibliothek – + Staats- und Universitätsbibliothek Dresden in Kooperation mit: Stiftung Deutsches Hygiene-Museum Dresden, + gefördert durch: Sächsisches Staatsministerium für Wissenschaft und Kunst + + 1703800354 + + DE-14 + + Odol 2915 (Rolle 2) + + + 1703800435 + http://digital.slub-dresden.de/id1703800435 + urn:nbn:de:bsz:14-db-id17038004351 + + DE-14 + + https://digital.slub-dresden.de/id1703800435 + + + Public Domain Mark 1.0 + + Open Access + + + + + oai:de:slub-dresden:db:id-1703800435 + + + + diff --git a/Tests/Fixtures/Format/modsAuthorWithAutRoleTerm.xml b/Tests/Fixtures/Format/modsAuthorWithAutRoleTerm.xml new file mode 100644 index 000000000..2f6d26f8c --- /dev/null +++ b/Tests/Fixtures/Format/modsAuthorWithAutRoleTerm.xml @@ -0,0 +1,151 @@ + + + + + Jack + May + I + District Commissioner + Préfet de région + + aut + + + + + John Paul + II + Pope + 1920-2005 + + aut + + + + + Mattox + Douglas E. + 1947- + + aut + + + + + Woolf, Virginia + 1882-1941 + + aut + + + + + Alterman, Eric + Eric Alterman + + aut + + + + Film + Werbefilm + + + Dresden + + SLUB + Filmverband Sachsen + Stiftung Deutsches Hygiene-Museum + 2019 + + + + ger + + + positiv, farbig, 24 fps, Bildseitenverhältnis 1,375:1, 2048 px horizontal, Codec: Apple ProRes (HQ) + 4444, Container: Quicktime .mov + + access + video/quicktime + 1 Online-Ressource (1 min, 30 s) + reformatted digital + + [Inhaltsbeschreibung] + + + Odol-Mundwasser, 3 Werbespots + + + 2180770-X + + Stiftung Deutsches Hygiene-Museum + + oth + + + Film + Werbefilm + + + Dresden + + SLUB + Filmverband Sachsen + Stiftung Deutsches Hygiene-Museum + 1965 + 1975 + + + ger + + + Nativ-Scan mit Overscan, Videocodec FFV1 Version 3, Container: Matroska + preservation + video/quicktime + 1 Online-Ressource (1 min, 16 s) + digitized other analog + Acetat mit Lichtton, Umkehr-Positiv, farbig ; 16 mm + + Bearbeitete digitale Ausgabe eines Exemplars aus dem Bestand der Stiftung + Deutsches Hygiene-Museum Dresden + + Die Digitalisierung des Films erfolgte im Rahmen des Programms „Sicherung des + audiovisuellen Erbes in Sachsen“ des Filmverband Sachsen (2019) und der Sächsischen Landesbibliothek – + Staats- und Universitätsbibliothek Dresden in Kooperation mit: Stiftung Deutsches Hygiene-Museum Dresden, + gefördert durch: Sächsisches Staatsministerium für Wissenschaft und Kunst + + 1703800354 + + DE-14 + + Odol 2915 (Rolle 2) + + + 1703800435 + http://digital.slub-dresden.de/id1703800435 + urn:nbn:de:bsz:14-db-id17038004351 + + DE-14 + + https://digital.slub-dresden.de/id1703800435 + + + Public Domain Mark 1.0 + + Open Access + + + + + oai:de:slub-dresden:db:id-1703800435 + + + + diff --git a/Tests/Fixtures/Format/modsOriginInfo.xml b/Tests/Fixtures/Format/modsOriginInfo.xml new file mode 100644 index 000000000..987d3fd95 --- /dev/null +++ b/Tests/Fixtures/Format/modsOriginInfo.xml @@ -0,0 +1,134 @@ + + + + + Alterman, Eric + Eric Alterman + + aut + + + + Film + Werbefilm + + + Dresden + + SLUB + Filmverband Sachsen + Stiftung Deutsches Hygiene-Museum + 2019 + + + + + Hamburg + + 2018 + + + + + Berlin + + 2021 + + + + + München + + 2020 + + + + ger + + + positiv, farbig, 24 fps, Bildseitenverhältnis 1,375:1, 2048 px horizontal, Codec: Apple ProRes (HQ) + 4444, Container: Quicktime .mov + + access + video/quicktime + 1 Online-Ressource (1 min, 30 s) + reformatted digital + + [Inhaltsbeschreibung] + + + Odol-Mundwasser, 3 Werbespots + + + 2180770-X + + Stiftung Deutsches Hygiene-Museum + + oth + + + Film + Werbefilm + + + Dresden + + SLUB + Filmverband Sachsen + Stiftung Deutsches Hygiene-Museum + 1965 + 1975 + + + ger + + + Nativ-Scan mit Overscan, Videocodec FFV1 Version 3, Container: Matroska + preservation + video/quicktime + 1 Online-Ressource (1 min, 16 s) + digitized other analog + Acetat mit Lichtton, Umkehr-Positiv, farbig ; 16 mm + + Bearbeitete digitale Ausgabe eines Exemplars aus dem Bestand der Stiftung + Deutsches Hygiene-Museum Dresden + + Die Digitalisierung des Films erfolgte im Rahmen des Programms „Sicherung des + audiovisuellen Erbes in Sachsen“ des Filmverband Sachsen (2019) und der Sächsischen Landesbibliothek – + Staats- und Universitätsbibliothek Dresden in Kooperation mit: Stiftung Deutsches Hygiene-Museum Dresden, + gefördert durch: Sächsisches Staatsministerium für Wissenschaft und Kunst + + 1703800354 + + DE-14 + + Odol 2915 (Rolle 2) + + + 1703800435 + http://digital.slub-dresden.de/id1703800435 + urn:nbn:de:bsz:14-db-id17038004351 + + DE-14 + + https://digital.slub-dresden.de/id1703800435 + + + Public Domain Mark 1.0 + + Open Access + + + + + oai:de:slub-dresden:db:id-1703800435 + + + + diff --git a/Tests/Fixtures/Format/modsOriginInfoWithEditionElectronicEd.xml b/Tests/Fixtures/Format/modsOriginInfoWithEditionElectronicEd.xml new file mode 100644 index 000000000..d1f9ffe4f --- /dev/null +++ b/Tests/Fixtures/Format/modsOriginInfoWithEditionElectronicEd.xml @@ -0,0 +1,138 @@ + + + + + Alterman, Eric + Eric Alterman + + aut + + + + Film + Werbefilm + + + Dresden + + SLUB + Filmverband Sachsen + Stiftung Deutsches Hygiene-Museum + 2019 + [Electronic ed.] + + + + + Hamburg + + 2018 + [Electronic ed.] + + + + + Berlin + + 2021 + [Electronic ed.] + + + + + München + + 2020 + [Electronic ed.] + + + + ger + + + positiv, farbig, 24 fps, Bildseitenverhältnis 1,375:1, 2048 px horizontal, Codec: Apple ProRes (HQ) + 4444, Container: Quicktime .mov + + access + video/quicktime + 1 Online-Ressource (1 min, 30 s) + reformatted digital + + [Inhaltsbeschreibung] + + + Odol-Mundwasser, 3 Werbespots + + + 2180770-X + + Stiftung Deutsches Hygiene-Museum + + oth + + + Film + Werbefilm + + + Dresden + + SLUB + Filmverband Sachsen + Stiftung Deutsches Hygiene-Museum + 1965 + 1975 + + + ger + + + Nativ-Scan mit Overscan, Videocodec FFV1 Version 3, Container: Matroska + preservation + video/quicktime + 1 Online-Ressource (1 min, 16 s) + digitized other analog + Acetat mit Lichtton, Umkehr-Positiv, farbig ; 16 mm + + Bearbeitete digitale Ausgabe eines Exemplars aus dem Bestand der Stiftung + Deutsches Hygiene-Museum Dresden + + Die Digitalisierung des Films erfolgte im Rahmen des Programms „Sicherung des + audiovisuellen Erbes in Sachsen“ des Filmverband Sachsen (2019) und der Sächsischen Landesbibliothek – + Staats- und Universitätsbibliothek Dresden in Kooperation mit: Stiftung Deutsches Hygiene-Museum Dresden, + gefördert durch: Sächsisches Staatsministerium für Wissenschaft und Kunst + + 1703800354 + + DE-14 + + Odol 2915 (Rolle 2) + + + 1703800435 + http://digital.slub-dresden.de/id1703800435 + urn:nbn:de:bsz:14-db-id17038004351 + + DE-14 + + https://digital.slub-dresden.de/id1703800435 + + + Public Domain Mark 1.0 + + Open Access + + + + + oai:de:slub-dresden:db:id-1703800435 + + + + diff --git a/Tests/Unit/Format/AltoTest.php b/Tests/Unit/Format/AltoTest.php new file mode 100644 index 000000000..89d8655d9 --- /dev/null +++ b/Tests/Unit/Format/AltoTest.php @@ -0,0 +1,116 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Unit\Format; + +use Kitodo\Dlf\Format\Alto; +use TYPO3\TestingFramework\Core\Unit\UnitTestCase; + +class AltoTest extends UnitTestCase +{ + /** + * @test + * @group extract data + */ + public function getRawData(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/alto.xml'); + $alto = new Alto(); + + $rawText = $alto->getRawText($xml); + + $this->assertEquals('Bürgertum und Bürgerlichkeit in Dresden DRESDNER HEFTE', $rawText); + } + + /** + * @test + * @group extract data + */ + public function getTextAsMiniOcr(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/alto.xml'); + $alto = new Alto(); + + $rawText = $alto->getTextAsMiniOcr($xml); + + $miniOCR = << + + + Bürgertum + und + + + Bürgerlichkeit + in + Dresden + + + + + DRESDNER + + + HEFTE + + + + XML; + + $this->assertXmlStringEqualsXmlString($miniOCR, $rawText); + } + + /** + * @test + * @group extract data + */ + public function getTextAsMiniOcrNoTextBlock(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/altoNoTextBlock.xml'); + $alto = new Alto(); + + $rawText = $alto->getTextAsMiniOcr($xml); + + $this->assertEquals('', $rawText); + } + + /** + * @test + * @group extract data + */ + public function getTextAsMiniOcrNoTextline(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/altoNoTextLine.xml'); + $alto = new Alto(); + + $rawText = $alto->getTextAsMiniOcr($xml); + + $this->assertXmlStringEqualsXmlString('', $rawText); + } + + /** + * @test + * @group extract data + */ + public function getTextAsMiniOcrNoString(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/altoNoString.xml'); + $alto = new Alto(); + + $rawText = $alto->getTextAsMiniOcr($xml); + + $this->assertXmlStringEqualsXmlString( + '', + $rawText + ); + } +} diff --git a/Tests/Unit/Format/AudioVideoMDTest.php b/Tests/Unit/Format/AudioVideoMDTest.php new file mode 100644 index 000000000..6fe510e5d --- /dev/null +++ b/Tests/Unit/Format/AudioVideoMDTest.php @@ -0,0 +1,55 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Unit\Format; + +use Kitodo\Dlf\Format\AudioVideoMD; +use TYPO3\TestingFramework\Core\Unit\UnitTestCase; + +class AudioVideoMDTest extends UnitTestCase +{ + protected $metadata = []; + + public function setUp(): void + { + parent::setUp(); + + $this->metadata = [ + 'duration' => [], + 'video_duration' => [], + 'audio_duration' => [] + ]; + } + + /** + * @test + * @group extractMetadata + */ + public function canExtractDuration(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/audioVideo.xml'); + $audioVideoMD = new AudioVideoMD(); + + $videoXml = $xml->xpath('//mets:xmlData')[0]; + + $audioVideoMD->extractMetadata($videoXml, $this->metadata); + + $this->assertEquals( + [ + 'duration' => ["00:01:30.07"], + 'video_duration' => ["00:01:30.07"], + 'audio_duration' => ["01:10:35.08"] + ], + $this->metadata + ); + } +} diff --git a/Tests/Unit/Format/ModsTest.php b/Tests/Unit/Format/ModsTest.php new file mode 100644 index 000000000..84f23172d --- /dev/null +++ b/Tests/Unit/Format/ModsTest.php @@ -0,0 +1,214 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Unit\Format; + +use Kitodo\Dlf\Format\Mods; +use TYPO3\TestingFramework\Core\Unit\UnitTestCase; + +class ModsTest extends UnitTestCase +{ + protected $metadata = []; + + public function setUp(): void + { + parent::setUp(); + + $this->metadata = [ + 'title' => [], + 'title_sorting' => [], + 'author' => [], + 'place' => [], + 'place_sorting' => [0 => []], + 'year' => [], + 'prod_id' => [], + 'record_id' => [], + 'opac_id' => [], + 'union_id' => [], + 'urn' => [], + 'purl' => [], + 'type' => [], + 'volume' => [], + 'volume_sorting' => [], + 'license' => [], + 'terms' => [], + 'restrictions' => [], + 'out_of_print' => [], + 'rights_info' => [], + 'collection' => [], + 'owner' => [], + 'mets_label' => [], + 'mets_orderlabel' => [], + 'document_format' => ['METS'], + 'year_sorting' => [0 => []], + ]; + + } + + /** + * @test + * @group extractMetadata + */ + public function extractAuthorsIfNoAutRoleTermAssigned(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/modsAuthorNoAutRoleTerm.xml'); + $mods = new Mods(); + + $mods->extractMetadata($xml, $this->metadata, false); + + $this->assertEquals( + [ + "AnonymousGiven1 AnonymousFamily1", + "AnonymousFamily2, AnonymousGiven2" + ], + $this->metadata['author'] + ); + } + + /** + * @test + * @group extractMetadata + */ + public function extractAuthorsWithAutRoleTermAssigned(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/modsAuthorWithAutRoleTerm.xml'); + $mods = new Mods(); + + $mods->extractMetadata($xml, $this->metadata, false); + $this->assertEquals( + [ + 'May, Jack, I', + 'John Paul, Pope, 1920-2005', + 'Mattox, Douglas E., 1947-', + '1882-1941, Woolf, Virginia', + 'Eric Alterman' + ], + $this->metadata['author'] + ); + } + + /** + * @test + * @group extractMetadata + */ + public function extractPlaces(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/modsOriginInfo.xml'); + $mods = new Mods(); + + $mods->extractMetadata($xml, $this->metadata, false); + + $this->assertEquals( + [ + "Dresden", + "Hamburg", + "Berlin", + "München", + ], + $this->metadata['place'] + ); + + $this->assertEquals( + [ + "Dresden", + ], + $this->metadata['place_sorting'] + ); + } + + /** + * @test + * @group extractMetadata + */ + public function extractYears(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/modsOriginInfo.xml'); + $mods = new Mods(); + + $mods->extractMetadata($xml, $this->metadata, false); + + $this->assertEquals( + [ + "2019", + "2018", + "2021", + "2020", + ], + $this->metadata['year'] + ); + + $this->assertEquals( + [ + "2019", + ], + $this->metadata['year_sorting'] + ); + } + + /** + * @test + * @group extractMetadata + */ + public function extractPlacesWithElectronicEdInside(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/modsOriginInfoWithEditionElectronicEd.xml'); + $mods = new Mods(); + + $mods->extractMetadata($xml, $this->metadata, false); + + $this->assertEquals( + [ + "Dresden", + "Hamburg", + "Berlin", + "München", + ], + $this->metadata['place'] + ); + + $this->assertEquals( + [ + "Dresden", + ], + $this->metadata['place_sorting'] + ); + } + + /** + * @test + * @group extractMetadata + */ + public function extractYearsWithElectronicEdInside(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Format/modsOriginInfoWithEditionElectronicEd.xml'); + $mods = new Mods(); + + $mods->extractMetadata($xml, $this->metadata, false); + + $this->assertEquals( + [ + "2019", + "2018", + "2021", + "2020", + ], + $this->metadata['year'] + ); + + $this->assertEquals( + [ + "2019", + ], + $this->metadata['year_sorting'] + ); + } +} diff --git a/Tests/Unit/Format/TeiHeaderTest.php b/Tests/Unit/Format/TeiHeaderTest.php new file mode 100644 index 000000000..38cf2d572 --- /dev/null +++ b/Tests/Unit/Format/TeiHeaderTest.php @@ -0,0 +1,37 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Unit\Format; + +use TYPO3\TestingFramework\Core\Unit\UnitTestCase; + +class TeiHeaderTest extends UnitTestCase +{ + protected $metadata = []; + + public function setUp(): void + { + parent::setUp(); + + $this->metadata = []; + } + + /** + * @test + * @group extractMetadata + */ + public function extract(): void + { + //TODO: TeiHeader class has no useful implementation. + $this->markTestSkipped('Implement test when TeiHeader class is implemented.'); + } +} From 5310a15b1ca1a0c2b780e777688794795e423da9 Mon Sep 17 00:00:00 2001 From: haogatyp Date: Thu, 26 Oct 2023 13:53:52 +0200 Subject: [PATCH 43/76] [MAINTENANCE] Added additional repository functional test instead of unit tests. (#895) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Oliver Stöhr --- Tests/Fixtures/Repository/collections.xml | 116 +++++++++ Tests/Fixtures/Repository/mail.xml | 39 +++ Tests/Fixtures/Repository/metadata.xml | 223 ++++++++++++++++++ Tests/Fixtures/Repository/token.xml | 35 +++ .../Repository/CollectionRepositoryTest.php | 200 ++++++++++++++++ .../Repository/MailRepositoryTest.php | 56 +++++ .../Repository/MetatdataRepositoryTest.php | 95 ++++++++ .../Repository/TokenRepositoryTest.php | 88 +++++++ 8 files changed, 852 insertions(+) create mode 100644 Tests/Fixtures/Repository/collections.xml create mode 100644 Tests/Fixtures/Repository/mail.xml create mode 100644 Tests/Fixtures/Repository/metadata.xml create mode 100644 Tests/Fixtures/Repository/token.xml create mode 100644 Tests/Functional/Repository/CollectionRepositoryTest.php create mode 100644 Tests/Functional/Repository/MailRepositoryTest.php create mode 100644 Tests/Functional/Repository/MetatdataRepositoryTest.php create mode 100644 Tests/Functional/Repository/TokenRepositoryTest.php diff --git a/Tests/Fixtures/Repository/collections.xml b/Tests/Fixtures/Repository/collections.xml new file mode 100644 index 000000000..cb42c2339 --- /dev/null +++ b/Tests/Fixtures/Repository/collections.xml @@ -0,0 +1,116 @@ + + + + + 1101 + 20000 + 1631279509 + 1631279509 + 2 + 0 + 0 + 0 + + a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;} + + 0 + + 0 + 0 + + Musik + + music + + + 3 + 0 + 0 + 0 + + + + 1102 + 20000 + 1631279509 + 1631279509 + 2 + 0 + 0 + 0 + + a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;} + + 0 + + 0 + 0 + + collection-with-single-document + + collection-with-single-document + + + 4 + 0 + 0 + 0 + + + + 1103 + 20000 + 1631279509 + 1631279509 + 2 + 0 + 0 + 0 + + a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;} + + 0 + + 1 + 0 + + Geschichte + *:* + history + + + 3 + 0 + 0 + 0 + + + + 1104 + 20000 + 1631279509 + 1631279509 + 2 + 0 + 0 + 0 + + a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;} + + 0 + + 1 + 0 + + bildende-kunst + + + + + 4 + 0 + 0 + 0 + + + diff --git a/Tests/Fixtures/Repository/mail.xml b/Tests/Fixtures/Repository/mail.xml new file mode 100644 index 000000000..6cfb51dad --- /dev/null +++ b/Tests/Fixtures/Repository/mail.xml @@ -0,0 +1,39 @@ + + + + 101 + 30000 + 0 + 10 + Mail + Name + + + + 102 + 30000 + 0 + 10 + Mail + Name + + + + 103 + 20000 + 0 + 10 + Mail + Name + + + + 104 + 20000 + 0 + 10 + Mail + Name + + + diff --git a/Tests/Fixtures/Repository/metadata.xml b/Tests/Fixtures/Repository/metadata.xml new file mode 100644 index 000000000..5c012c908 --- /dev/null +++ b/Tests/Fixtures/Repository/metadata.xml @@ -0,0 +1,223 @@ + + + + 5001 + 20000 + 1638557803 + 1631532810 + 1 + 0 + 0 + 0 + + 0 + 32 + + title + 1 + + + 0 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + + + + 5002 + 20000 + 1638557803 + 1631532810 + 1 + 0 + 0 + 0 + + 0 + 31 + + collection + 1 + + + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 1 + 0 + + + + 5003 + 20000 + 1638557803 + 1631532810 + 1 + 0 + 0 + 0 + + 0 + 30 + + untertitel + 1 + + + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + + + + 5004 + 20000 + 1638557803 + 1631532810 + 1 + 0 + 0 + 0 + + 0 + 29 + + ort + 1 + + + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + + + + 5005 + 20000 + 1638557803 + 1631532810 + 1 + 0 + 0 + 0 + + 0 + 30 + + autor + 1 + + + 0 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + + + + 5006 + 20000 + 1638557803 + 1631532810 + 1 + 0 + 0 + 0 + + 0 + 30 + + institution + 1 + + + 0 + 1 + 1 + 1 + 0 + 0 + 1 + 1 + 0 + + + + 5101 + 20000 + 1638557803 + 1631532810 + 1 + 0 + 5001 + 5202 + concat(./mods:titleInfo/mods:nonSort," ",./mods:titleInfo/mods:title) + ./mods:titleInfo/mods:title + 0 + + + + 5102 + 20000 + 1638557803 + 1631532810 + 1 + 0 + 5002 + 5202 + ./mods:relatedItem[@type="series"]/mods:titleInfo/mods:title[@lang="ger"] + + 0 + + + + 5201 + 0 + 1638557803 + 1631532810 + 1 + 0 + ALTO + alto + http://www.loc.gov/standards/alto/ns-v2# + Kitodo\Dlf\Format\Alto + + + 5202 + 0 + 1638557803 + 1631532810 + 1 + 0 + MODS + mods + http://www.loc.gov/mods/v3 + Kitodo\Dlf\Format\Mods + + diff --git a/Tests/Fixtures/Repository/token.xml b/Tests/Fixtures/Repository/token.xml new file mode 100644 index 000000000..1d226f25b --- /dev/null +++ b/Tests/Fixtures/Repository/token.xml @@ -0,0 +1,35 @@ + + + + 101 + 20000 + 1631279509 + token101 + Options text 101 + ident1 + + + 102 + 20000 + 1631289509 + token102 + Options text 102 + ident1 + + + 103 + 20000 + 1631279509 + token103 + Options text 103 + ident1 + + + 104 + 20000 + 1631281509 + token104 + Options text 104 + ident1 + + diff --git a/Tests/Functional/Repository/CollectionRepositoryTest.php b/Tests/Functional/Repository/CollectionRepositoryTest.php new file mode 100644 index 000000000..ac7149e6b --- /dev/null +++ b/Tests/Functional/Repository/CollectionRepositoryTest.php @@ -0,0 +1,200 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Functional\Repository; + +use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult; +use Kitodo\Dlf\Domain\Repository\CollectionRepository; +use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; + +class CollectionRepositoryTest extends FunctionalTestCase +{ + /** + * @var CollectionRepository + */ + protected $collectionRepository; + + public function setUp(): void + { + parent::setUp(); + + $this->collectionRepository = $this->initializeRepository( + CollectionRepository::class, + 20000 + ); + + $this->importDataSet(__DIR__ . '/../../Fixtures/Repository/collections.xml'); + } + + /** + * + * @group find + */ + public function canFindAllByUids(): void + { + $collections = $this->collectionRepository->findAllByUids([1101, 1102]); + $this->assertNotNull($collections); + $this->assertInstanceOf(QueryResult::class, $collections); + + $collectionsByLabel = []; + foreach ($collections as $collection) { + $collectionsByLabel[$collection->getLabel()] = $collection; + } + + $this->assertArrayHasKey('Musik', $collectionsByLabel); + $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + } + + /** + * @test + * @group find + */ + public function canGetCollectionForMetadata(): void + { + $collections = $this->collectionRepository->getCollectionForMetadata("20000"); + $this->assertNotNull($collections); + $this->assertInstanceOf(QueryResult::class, $collections); + + $collectionsByLabel = []; + foreach ($collections as $collection) { + $collectionsByLabel[$collection->getLabel()] = $collection; + } + + $this->assertArrayHasKey('Musik', $collectionsByLabel); + $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + $this->assertArrayHasKey('Geschichte', $collectionsByLabel); + $this->assertArrayHasKey('Bildende Kunst', $collectionsByLabel); + } + + /** + * @param $settings + * @return array + */ + protected function findCollectionsBySettings($settings): array + { + $collections = $this->collectionRepository->findCollectionsBySettings($settings); + $this->assertNotNull($collections); + $this->assertInstanceOf(QueryResult::class, $collections); + + $collectionsByLabel = []; + foreach ($collections as $collection) { + $collectionsByLabel[$collection->getLabel()] = $collection; + } + + return $collectionsByLabel; + } + + /** + * @test + * @group find + */ + public function canFindCollectionsBySettings(): void + { + $collectionsByLabel = $this->findCollectionsBySettings(['collections' => '1101, 1102']); + $this->assertCount(2, $collectionsByLabel); + $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + $this->assertArrayHasKey('Musik', $collectionsByLabel); + + $collectionsByLabel = $this->findCollectionsBySettings( + [ + 'index_name' => ['Geschichte', 'collection-with-single-document'], + 'show_userdefined' => true + ] + ); + $this->assertCount(2, $collectionsByLabel); + $this->assertArrayHasKey('Geschichte', $collectionsByLabel); + $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + + $collectionsByLabel = $this->findCollectionsBySettings(['show_userdefined' => true]); + $this->assertCount(4, $collectionsByLabel); + $this->assertArrayHasKey('Musik', $collectionsByLabel); + $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + $this->assertArrayHasKey('Geschichte', $collectionsByLabel); + $this->assertArrayHasKey('Bildende Kunst', $collectionsByLabel); + $this->assertEquals( + 'Bildende Kunst, Collection with single document, Geschichte, Musik', + implode(', ', array_keys($collectionsByLabel)) + ); + + $collectionsByLabel = $this->findCollectionsBySettings(['show_userdefined' => false]); + $this->assertCount(2, $collectionsByLabel); + $this->assertArrayHasKey('Musik', $collectionsByLabel); + $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + + $collectionsByLabel = $this->findCollectionsBySettings(['hideEmptyOaiNames' => true]); + $this->assertCount(2, $collectionsByLabel); + $this->assertArrayHasKey('Musik', $collectionsByLabel); + $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + + $collectionsByLabel = $this->findCollectionsBySettings( + [ + 'hideEmptyOaiNames' => true, + 'show_userdefined' => true + ] + ); + $this->assertCount(3, $collectionsByLabel); + $this->assertArrayHasKey('Musik', $collectionsByLabel); + $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + $this->assertArrayHasKey('Geschichte', $collectionsByLabel); + + $collectionsByLabel = $this->findCollectionsBySettings( + [ + 'hideEmptyOaiNames' => false, + 'show_userdefined' => true + ] + ); + $this->assertCount(4, $collectionsByLabel); + $this->assertArrayHasKey('Musik', $collectionsByLabel); + $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + $this->assertArrayHasKey('Geschichte', $collectionsByLabel); + $this->assertArrayHasKey('Bildende Kunst', $collectionsByLabel); + + $collectionsByLabel = $this->findCollectionsBySettings( + [ + 'collections' => '1101, 1102, 1103, 1104', + 'show_userdefined' => true, + 'hideEmptyOaiNames' => false, + 'index_name' => ['Geschichte', 'collection-with-single-document'] + ] + ); + + $this->assertCount(2, $collectionsByLabel); + $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + $this->assertArrayHasKey('Geschichte', $collectionsByLabel); + } + + /** + * @test + * @group find + */ + public function canGetIndexNameForSolr(): void + { + $indexName = $this->collectionRepository->getIndexNameForSolr( + ['show_userdefined' => true, 'storagePid' => '20000'], 'history' + ); + $result = $indexName->fetchAllAssociative(); + $this->assertEquals(1, $indexName->rowCount()); + $this->assertEquals('Geschichte', $result[0]['index_name']); + $this->assertEquals('*:*', $result[0]['index_query']); + $this->assertEquals('1103', $result[0]['uid']); + + $indexName = $this->collectionRepository->getIndexNameForSolr( + ['show_userdefined' => false, 'storagePid' => '20000'], 'history' + ); + $this->assertEquals(0, $indexName->rowCount()); + + $indexName = $this->collectionRepository->getIndexNameForSolr( + ['show_userdefined' => false, 'storagePid' => '20000'], 'collection-with-single-document' + ); + $this->assertEquals(1, $indexName->rowCount()); + $this->assertEquals('collection-with-single-document', $indexName->fetchOne()); + } +} diff --git a/Tests/Functional/Repository/MailRepositoryTest.php b/Tests/Functional/Repository/MailRepositoryTest.php new file mode 100644 index 000000000..5aff084f7 --- /dev/null +++ b/Tests/Functional/Repository/MailRepositoryTest.php @@ -0,0 +1,56 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Functional\Repository; + +use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult; +use Kitodo\Dlf\Domain\Repository\MailRepository; +use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; + +class MailRepositoryTest extends FunctionalTestCase +{ + /** + * @var MailRepository + */ + protected $mailRepository; + + public function setUp(): void + { + parent::setUp(); + + $this->mailRepository = $this->initializeRepository( + MailRepository::class, + 20000 + ); + + $this->importDataSet(__DIR__ . '/../../Fixtures/Repository/mail.xml'); + } + + /** + * @test + * @group find + */ + public function canFindAllWithPid(): void + { + $mails = $this->mailRepository->findAllWithPid(30000); + $this->assertNotNull($mails); + $this->assertInstanceOf(QueryResult::class, $mails); + + $mailByLabel = []; + foreach ($mails as $mail) { + $mailByLabel[$mail->getLabel()] = $mail; + } + + $this->assertEquals(2, $mails->count()); + $this->assertArrayHasKey('Mail-Label-1', $mailByLabel); + $this->assertArrayHasKey('Mail-Label-2', $mailByLabel); + } +} diff --git a/Tests/Functional/Repository/MetatdataRepositoryTest.php b/Tests/Functional/Repository/MetatdataRepositoryTest.php new file mode 100644 index 000000000..0e78feec0 --- /dev/null +++ b/Tests/Functional/Repository/MetatdataRepositoryTest.php @@ -0,0 +1,95 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Functional\Repository; + +use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult; +use Kitodo\Dlf\Domain\Repository\MetadataRepository; +use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; + +class MetadataRepositoryTest extends FunctionalTestCase +{ + /** + * @var MetadataRepository + */ + protected $metadataRepository; + + public function setUp(): void + { + parent::setUp(); + + $this->metadataRepository = $this->initializeRepository( + MetadataRepository::class, + 20000 + ); + + $this->importDataSet(__DIR__ . '/../../Fixtures/Repository/metadata.xml'); + } + + + /** + * @param $settings + * @return array + */ + protected function findBySettings($settings) + { + $metadata = $this->metadataRepository->findBySettings($settings); + $this->assertNotNull($metadata); + $this->assertInstanceOf(QueryResult::class, $metadata); + + $metadataByLabel = []; + foreach ($metadata as $mdata) { + $metadataByLabel[$mdata->getLabel()] = $mdata; + } + + return $metadataByLabel; + } + + /** + * @test + * @group find + */ + public function canFindBySettings(): void + { + $metadataByLabel = $this->findBySettings([]); + $this->assertCount(6, $metadataByLabel); + $this->assertEquals( + 'Ort, Untertitel, Autor, Institution, Sammlungen, Titel', + implode(', ', array_keys($metadataByLabel)) + ); + + $metadataByLabel = $this->findBySettings(['is_listed' => true]); + $this->assertCount(3, $metadataByLabel); + $this->assertEquals( + 'Autor, Institution, Titel', + implode(', ', array_keys($metadataByLabel)) + ); + + $metadataByLabel = $this->findBySettings(['is_sortable' => true]); + $this->assertCount(4, $metadataByLabel); + $this->assertEquals( + 'Ort, Untertitel, Autor, Titel', + implode(', ', array_keys($metadataByLabel)) + ); + + $metadataByLabel = $this->findBySettings( + [ + 'is_sortable' => true, + 'is_listed' => true + ] + ); + $this->assertCount(2, $metadataByLabel); + $this->assertEquals( + 'Autor, Titel', + implode(', ', array_keys($metadataByLabel)) + ); + } +} diff --git a/Tests/Functional/Repository/TokenRepositoryTest.php b/Tests/Functional/Repository/TokenRepositoryTest.php new file mode 100644 index 000000000..f30957a1e --- /dev/null +++ b/Tests/Functional/Repository/TokenRepositoryTest.php @@ -0,0 +1,88 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Functional\Repository; + +use Kitodo\Dlf\Domain\Repository\TokenRepository; +use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; +use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; + +class TokenRepositoryTest extends FunctionalTestCase +{ + /** + * @var TokenRepository + */ + protected $tokenRepository; + + /** + * @var PersistenceManager + */ + protected $persistenceManager; + + public function setUp(): void + { + parent::setUp(); + + $this->persistenceManager = $this->objectManager->get(PersistenceManager::class); + + $this->tokenRepository = $this->initializeRepository( + TokenRepository::class, + 20000 + ); + } + + public function tearDown(): void + { + parent::tearDown(); + + unlink(__DIR__ . '/../../Fixtures/Repository/tokenTemp.xml'); + } + + /** + * @test + * @group delete + */ + public function deleteExpiredTokens(): void + { + $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Repository/token.xml'); + + $expireTime = 3600; + $i = 1; + foreach ($xml as $node) { + if ($i % 2 == 0) { + $node->tstamp = time() - $expireTime - random_int(10, 3600); + } else { + $node->tstamp = time() - $expireTime + random_int(10, 3600); + } + $i++; + } + + $xml->saveXML(__DIR__ . '/../../Fixtures/Repository/tokenTemp.xml'); + + $this->importDataSet(__DIR__ . '/../../Fixtures/Repository/tokenTemp.xml'); + + $this->tokenRepository->deleteExpiredTokens($expireTime); + + $this->persistenceManager->persistAll(); + + $tokens = $this->tokenRepository->findAll(); + + $this->assertEquals(2, $tokens->count()); + + $tokenUids = []; + foreach ($tokens as $token) { + $tokenUids[$token->getUid()] = $token; + } + + $this->assertArrayHasKey('101', $tokenUids); + $this->assertArrayHasKey('103', $tokenUids); + } +} From 2bcf1809f526232f0d24f7bcc6c1c812e8783c3d Mon Sep 17 00:00:00 2001 From: haogatyp Date: Thu, 26 Oct 2023 14:42:08 +0200 Subject: [PATCH 44/76] [MAINTENANCE] Add ViewHelper functional tests instead of unit tests. (#902) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Oliver Stöhr --- .../ViewHelpers/JsFooterViewHelperTest.php | 52 +++++++++++ .../MetadataWrapVariableViewHelperTest.php | 60 +++++++++++++ .../ViewHelpers/StdWrapViewHelperTest.php | 87 +++++++++++++++++++ 3 files changed, 199 insertions(+) create mode 100644 Tests/Functional/ViewHelpers/JsFooterViewHelperTest.php create mode 100644 Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php create mode 100644 Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php diff --git a/Tests/Functional/ViewHelpers/JsFooterViewHelperTest.php b/Tests/Functional/ViewHelpers/JsFooterViewHelperTest.php new file mode 100644 index 000000000..560dcac5e --- /dev/null +++ b/Tests/Functional/ViewHelpers/JsFooterViewHelperTest.php @@ -0,0 +1,52 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Unit\ViewHelpers; + +use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; +use Kitodo\Dlf\ViewHelpers\JsFooterViewHelper; +use TYPO3\CMS\Core\Page\PageRenderer; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Fluid\View\StandaloneView; + +/** + * @covers JsFooterViewHelper + */ +class JsFooterViewHelperTest extends FunctionalTestCase +{ + /** + * @var bool Speed up this test case, it needs no database + */ + protected $initializeDatabase = false; + + /** + * @test + */ + public function pageRendererCallsAddJsFooterInlineCode(): void + { + $pageRendererProphecy = $this->getMockBuilder(PageRenderer::class)->getMock(); + + $pageRendererProphecy->expects(self::once())->method('addJsFooterInlineCode')->with( + 'js-dlf-inline-footer', '$(document).ready(function() {});' + ); + + GeneralUtility::setSingletonInstance(PageRenderer::class, $pageRendererProphecy); + + $view = new StandaloneView(); + $view->setTemplateSource( + ' + + ' + ); + + $view->render(); + } +} diff --git a/Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php b/Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php new file mode 100644 index 000000000..e82a37000 --- /dev/null +++ b/Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php @@ -0,0 +1,60 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Unit\ViewHelpers; + +use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; +use Kitodo\Dlf\ViewHelpers\MetadataWrapVariableViewHelper; +use TYPO3\CMS\Fluid\View\StandaloneView; +use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory; + +/** + * @covers MetadataWrapVariableViewHelper + */ +class MetadataWrapVariableViewHelperTest extends FunctionalTestCase +{ + /** + * @var bool Speed up this test case, it needs no database + */ + protected $initializeDatabase = false; + + /** + * @test + */ + public function renderingContextCallsGetVariableProviderAdd(): void + { + $view = new StandaloneView(); + + $view->assign( + 'configObject', + [ 'wrap' => 'all.wrap = + key.wrap = + value.required = 1 + value.wrap =
  • |
  • ' + ] + ); + $view->setTemplateSource( + ' + {configObject.wrap -> kitodo:metadataWrapVariable(name: \'metadataWrap\')} + ' + ); + $view->render(); + + $this->assertEquals( + [ + 'key' => ['wrap' => ''], + 'value' => ['required' => 1, 'wrap' => '
  • |
  • '], + 'all' => ['wrap' => ''] + ], + $view->getRenderingContext()->getVariableProvider()->get('metadataWrap') + ); + } +} diff --git a/Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php b/Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php new file mode 100644 index 000000000..30191559a --- /dev/null +++ b/Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php @@ -0,0 +1,87 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Unit\ViewHelpers; + +use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; +use Kitodo\Dlf\ViewHelpers\StdWrapViewHelper; +use TYPO3\CMS\Fluid\View\StandaloneView; +use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory; + +/** + * @covers StdWrapViewHelper + */ +class StdWrapViewHelperTest extends FunctionalTestCase +{ + /** + * @var bool Speed up this test case, it needs no database + */ + protected $initializeDatabase = false; + + /** + * @test + */ + public function renderWithStdWrap(): void + { + $view = new StandaloneView(); + $view->assign( + 'metadataWrap', + [ + 'key' => ['wrap' => ''], + 'value' => ['required' => 1, 'wrap' => '
  • |
  • '], + 'all' => ['wrap' => ''] + ] + ); + + // A fully filled array with correct values does not make any difference. The rendering result + // is not been influenced by the viewhelpers data parameter. + $view->assign('metaSectionCObj', [0 => ['tilte' => 'A test title']]); + + $view->setTemplateSource( + ' + + Label +

    Title

    Text

    +
    + ' + ); + + $this->assertXmlStringEqualsXmlString( + ' + + ', + $view->render() + ); + + // Without using the data parameter the rendering result is the same as above. + $view->setTemplateSource( + ' + + Label +

    Title

    Text

    +
    + ' + ); + + $this->assertXmlStringEqualsXmlString( + ' + + ', + $view->render() + ); + } +} From 8b7880eda2e84472a34975d31287f8e0d10eb613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6hr?= Date: Thu, 26 Oct 2023 15:32:43 +0200 Subject: [PATCH 45/76] [MAINTENANCE] Add test for IiifUrlReader (#909) --- Tests/Fixtures/Common/correct.txt | 1 + Tests/Functional/Common/IiifUrlReaderTest.php | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 Tests/Fixtures/Common/correct.txt create mode 100644 Tests/Functional/Common/IiifUrlReaderTest.php diff --git a/Tests/Fixtures/Common/correct.txt b/Tests/Fixtures/Common/correct.txt new file mode 100644 index 000000000..e8795d19b --- /dev/null +++ b/Tests/Fixtures/Common/correct.txt @@ -0,0 +1 @@ +Correct result diff --git a/Tests/Functional/Common/IiifUrlReaderTest.php b/Tests/Functional/Common/IiifUrlReaderTest.php new file mode 100644 index 000000000..f9f0ab1b6 --- /dev/null +++ b/Tests/Functional/Common/IiifUrlReaderTest.php @@ -0,0 +1,34 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Functional\Common; + +use Kitodo\Dlf\Common\IiifUrlReader; +use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; + +class IiifUrlReaderTest extends FunctionalTestCase +{ + /** + * @test + * @group getContent + */ + public function getContentCheck() + { + $iiifUrlReader = new IiifUrlReader(); + + $correctUrl = 'http://web:8001/Tests/Fixtures/Common/correct.txt'; + $expected = "Correct result\n"; + $this->assertSame($expected, $iiifUrlReader->getContent($correctUrl)); + + $incorrectUrl = 'http://web:8001/incorrectPath'; + $this->assertSame('', $iiifUrlReader->getContent($incorrectUrl)); + } +} From fe70610f04716c7bac26f0c838ab05635811f814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6hr?= Date: Fri, 27 Oct 2023 11:10:42 +0200 Subject: [PATCH 46/76] [MAINTENANCE] Complete tests for MetsDocument (#919) --- Tests/Fixtures/MetsDocument/fulltext_0003.xml | 66 ++++++++++ .../Fixtures/MetsDocument/mets_with_pages.xml | 73 +++++++++++ Tests/Fixtures/MetsDocument/two_dmdsec.xml | 5 + Tests/Functional/Common/MetsDocumentTest.php | 115 ++++++++++++++++++ 4 files changed, 259 insertions(+) create mode 100644 Tests/Fixtures/MetsDocument/fulltext_0003.xml create mode 100644 Tests/Fixtures/MetsDocument/mets_with_pages.xml diff --git a/Tests/Fixtures/MetsDocument/fulltext_0003.xml b/Tests/Fixtures/MetsDocument/fulltext_0003.xml new file mode 100644 index 000000000..f78f3f33e --- /dev/null +++ b/Tests/Fixtures/MetsDocument/fulltext_0003.xml @@ -0,0 +1,66 @@ + + + + pixel + + + 2020-05-14 + + ABBYY + ABBYY FineReader Engine + 12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/Fixtures/MetsDocument/mets_with_pages.xml b/Tests/Fixtures/MetsDocument/mets_with_pages.xml new file mode 100644 index 000000000..176deaade --- /dev/null +++ b/Tests/Fixtures/MetsDocument/mets_with_pages.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/Fixtures/MetsDocument/two_dmdsec.xml b/Tests/Fixtures/MetsDocument/two_dmdsec.xml index 61836b6d6..6a9f70a1f 100644 --- a/Tests/Fixtures/MetsDocument/two_dmdsec.xml +++ b/Tests/Fixtures/MetsDocument/two_dmdsec.xml @@ -49,6 +49,11 @@ + + + + + diff --git a/Tests/Functional/Common/MetsDocumentTest.php b/Tests/Functional/Common/MetsDocumentTest.php index 4cfaeef88..a4f91e663 100644 --- a/Tests/Functional/Common/MetsDocumentTest.php +++ b/Tests/Functional/Common/MetsDocumentTest.php @@ -1,4 +1,13 @@ + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ namespace Kitodo\Dlf\Tests\Functional\Common; @@ -11,6 +20,7 @@ public function setUp(): void { parent::setUp(); + $this->importDataSet(__DIR__ . '/../../Fixtures/Common/documents_1.xml'); $this->importDataSet(__DIR__ . '/../../Fixtures/Common/metadata.xml'); $this->importDataSet(__DIR__ . '/../../Fixtures/MetsDocument/metadata_mets.xml'); } @@ -128,4 +138,109 @@ public function returnsEmptyMetadataWhenNoDmdSec() $metadata = $doc->getMetadata('LOG_0002', 20000); $this->assertEquals([], $metadata); } + + /** + * @test + */ + public function canGetDownloadLocation() + { + $doc = $this->doc('two_dmdsec.xml'); + + $correct = $doc->getDownloadLocation('FILE_0000_DOWNLOAD'); + $this->assertEquals('https://example.com/download?&CVT=jpeg', $correct); + + /* + * The method `getDownloadLocation` should return a string, but returns null in some cases. + * Therefor, a TypeError must be expected here. + */ + $this->expectException('TypeError'); + $doc->getDownloadLocation('ID_DOES_NOT_EXIST'); + } + + + /** + * @test + */ + public function canGetFileLocation() + { + $doc = $this->doc('two_dmdsec.xml'); + + $correct = $doc->getFileLocation('FILE_0000_DEFAULT'); + $this->assertEquals('https://digital.slub-dresden.de/data/kitodo/1703800435/video.mov', $correct); + + $incorrect = $doc->getFileLocation('ID_DOES_NOT_EXIST'); + $this->assertEquals('', $incorrect); + } + + /** + * @test + */ + public function canGetFileMimeType() + { + $doc = $this->doc('two_dmdsec.xml'); + + $correct = $doc->getFileMimeType('FILE_0000_DEFAULT'); + $this->assertEquals('video/quicktime', $correct); + + $incorrect = $doc->getFileMimeType('ID_DOES_NOT_EXIST'); + $this->assertEquals('', $incorrect); + } + + // FIXME: Method getPhysicalPage does not work as expected + /** + * @test + */ + public function canGetPhysicalPage() + { + $doc = $this->doc('mets_with_pages.xml'); + + // pass orderlabel and retrieve order + $physicalPage = $doc->getPhysicalPage('1'); + $this->assertEquals(1, $physicalPage); + } + + /** + * @test + */ + public function canGetTitle() + { + $doc = $this->doc('mets_with_pages.xml'); + + $correct = $doc->getTitle(1001); + $this->assertEquals('10 Keyboard pieces - Go. S. 658', $correct); + + $incorrect = $doc->getTitle(1234); + $this->assertEquals('', $incorrect); + } + + /** + * @test + */ + public function canGetFullText() + { + $doc = $this->doc('mets_with_pages.xml'); + + $fulltext = $doc->getFullText('PHYS_0003'); + $expected = ' + +'; + $this->assertEquals($expected, $fulltext); + + $incorrect = $doc->getFullText('ID_DOES_NOT_EXIST'); + $this->assertEquals('', $incorrect); + } + + /** + * @test + */ + public function canGetStructureDepth() + { + $doc = $this->doc('mets_with_pages.xml'); + + $correct = $doc->getStructureDepth('LOG_0001'); + $this->assertEquals(3, $correct); + + $incorrect = $doc->getStructureDepth('ID_DOES_NOT_EXIST'); + $this->assertEquals(0, $incorrect); + } } From 2e6d3d9913e3a8dd2283deb4b345cf42e930bed2 Mon Sep 17 00:00:00 2001 From: Bernd Fallert Date: Tue, 31 Oct 2023 16:31:01 +0100 Subject: [PATCH 47/76] [BUGFIX] Fix a typo in a condition, {{ insted of { (#1066) --- Resources/Private/Partials/ListView/SortingForm.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Private/Partials/ListView/SortingForm.html b/Resources/Private/Partials/ListView/SortingForm.html index e3ca28aca..ea78a48af 100644 --- a/Resources/Private/Partials/ListView/SortingForm.html +++ b/Resources/Private/Partials/ListView/SortingForm.html @@ -12,7 +12,7 @@ - + From fafc47a1fb192530af6efc38def902a47dae8153 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Tue, 31 Oct 2023 16:39:14 +0100 Subject: [PATCH 48/76] [MAINTENANCE] Convert database XML fixtures into CSV format (#1064) Co-authored-by: Sebastian Meyer --- Tests/Fixtures/Common/documents_1.csv | 15 ++ Tests/Fixtures/Common/documents_1.xml | 220 ----------------- Tests/Fixtures/Common/documents_fulltext.csv | 11 + Tests/Fixtures/Common/documents_fulltext.xml | 114 --------- Tests/Fixtures/Common/libraries.csv | 3 + Tests/Fixtures/Common/libraries.xml | 25 -- Tests/Fixtures/Common/metadata.csv | 12 + Tests/Fixtures/Common/metadata.xml | 111 --------- Tests/Fixtures/MetsDocument/metadata_mets.csv | 17 ++ Tests/Fixtures/MetsDocument/metadata_mets.xml | 110 --------- Tests/Fixtures/OaiPmh/solrcores.csv | 3 + Tests/Fixtures/OaiPmh/solrcores.xml | 13 - Tests/Fixtures/Repository/collections.csv | 6 + Tests/Fixtures/Repository/collections.xml | 116 --------- Tests/Fixtures/Repository/mail.csv | 6 + Tests/Fixtures/Repository/mail.xml | 39 --- Tests/Fixtures/Repository/metadata.csv | 16 ++ Tests/Fixtures/Repository/metadata.xml | 223 ------------------ Tests/Fixtures/Repository/token.csv | 6 + Tests/Fixtures/Repository/token.xml | 35 --- Tests/Functional/Api/OaiPmhTest.php | 21 +- Tests/Functional/Common/HelperTest.php | 5 +- Tests/Functional/Common/MetsDocumentTest.php | 6 +- Tests/Functional/Common/SolrIndexingTest.php | 8 +- .../Repository/CollectionRepositoryTest.php | 2 +- .../Repository/DocumentRepositoryTest.php | 4 +- .../Repository/MailRepositoryTest.php | 2 +- .../Repository/MetatdataRepositoryTest.php | 2 +- .../Repository/TokenRepositoryTest.php | 31 ++- 29 files changed, 145 insertions(+), 1037 deletions(-) create mode 100644 Tests/Fixtures/Common/documents_1.csv delete mode 100644 Tests/Fixtures/Common/documents_1.xml create mode 100644 Tests/Fixtures/Common/documents_fulltext.csv delete mode 100644 Tests/Fixtures/Common/documents_fulltext.xml create mode 100644 Tests/Fixtures/Common/libraries.csv delete mode 100644 Tests/Fixtures/Common/libraries.xml create mode 100644 Tests/Fixtures/Common/metadata.csv delete mode 100644 Tests/Fixtures/Common/metadata.xml create mode 100644 Tests/Fixtures/MetsDocument/metadata_mets.csv delete mode 100644 Tests/Fixtures/MetsDocument/metadata_mets.xml create mode 100644 Tests/Fixtures/OaiPmh/solrcores.csv delete mode 100644 Tests/Fixtures/OaiPmh/solrcores.xml create mode 100644 Tests/Fixtures/Repository/collections.csv delete mode 100644 Tests/Fixtures/Repository/collections.xml create mode 100644 Tests/Fixtures/Repository/mail.csv delete mode 100644 Tests/Fixtures/Repository/mail.xml create mode 100644 Tests/Fixtures/Repository/metadata.csv delete mode 100644 Tests/Fixtures/Repository/metadata.xml create mode 100644 Tests/Fixtures/Repository/token.csv delete mode 100644 Tests/Fixtures/Repository/token.xml diff --git a/Tests/Fixtures/Common/documents_1.csv b/Tests/Fixtures/Common/documents_1.csv new file mode 100644 index 000000000..756701392 --- /dev/null +++ b/Tests/Fixtures/Common/documents_1.csv @@ -0,0 +1,15 @@ +"tx_dlf_documents",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","hidden","starttime","endtime","fe_group","prod_id","location","record_id","opac_id","union_id","urn","purl","title","title_sorting","author","year","place","thumbnail","structure","partof","volume","volume_sorting","license","terms","restrictions","out_of_print","rights_info","collections","mets_label","mets_orderlabel","owner","solrcore","status","document_format" +,1001,20000,1631775000,1631775000,2,0,0,0,0,,,"https://digital.slub-dresden.de/data/kitodo/10Kepi_476251419/10Kepi_476251419_mets.xml","oai:de:slub-dresden:db:id-476251419","476251419","476251419","urn:nbn:de:bsz:14-db-id476251419","http://digital.slub-dresden.de/id476251419","10 Keyboard pieces - Go. S. 658","10 Keyboard pieces - Go. S. 658",,"[1759-1800]","[S.l.]","https://digital.slub-dresden.de/data/kitodo/10Kepi_476251419/10Kepi_476251419_tif/jpegs/00000003.tif.thumbnail.jpg",59,0,,,,,,,,2,"10 Keyboard pieces - Go. S. 658","10 Keyboard pieces - Go. S. 658",10001,1,0,"METS" +,1002,20000,1631774000,1631774000,2,0,0,0,0,,,"https://digital.slub-dresden.de/data/kitodo/6Saso_476248086/6Saso_476248086_mets.xml","oai:de:slub-dresden:db:id-476248086","476248086","476248086","urn:nbn:de:bsz:14-db-id4762480864","http://digital.slub-dresden.de/id476248086","6 Sacred songs - Go. S. 591","6 Sacred songs - Go. S. 591",,"[1840-1860]","[S.l.]","https://digital.slub-dresden.de/data/kitodo/6Saso_476248086/6Saso_476248086_tif/jpegs/00000001.tif.thumbnail.jpg",59,0,,,,,,,,2,"6 Sacred songs - Go. S. 591","6 Sacred songs - Go. S. 591",10001,1,0,"METS" +,1003,20000,1631776000,1631776000,2,0,0,0,0,,,"https://digital.slub-dresden.de/data/kitodo/6FuG_476251729/6FuG_476251729_mets.xml","oai:de:slub-dresden:db:id-476251729","476251729","476251729","urn:nbn:de:bsz:14-db-id4762517292","http://digital.slub-dresden.de/id476251729","6 Fugues - Go. S. 317","6 Fugues - Go. S. 317",,"[um 1820]","[S.l.]","https://digital.slub-dresden.de/data/kitodo/6FuG_476251729/6FuG_476251729_tif/jpegs/00000001.tif.thumbnail.jpg",59,0,,,,,,,,2,"6 Fugues - Go. S. 317","6 Fugues - Go. S. 317",10001,1,0,"METS" +"tx_dlf_collections",,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","sys_language_uid","l18n_parent","l18n_diffsource","hidden","fe_group","fe_cruser_id","fe_admin_lock","label","index_name","index_search","oai_name","description","thumbnail","priority","documents","owner","status" +,1101,20000,1631279509,1631279509,2,0,0,0,"a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;}",0,,0,0,"Musik","Musik",,"music",,,3,0,0,0 +,1102,20000,1631279509,1631279509,2,0,0,0,"a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;}",0,,0,0,"Collection with single document","collection-with-single-document",,"collection-with-single-document",,,4,0,0,0 +"tx_dlf_relations",,,,,,,,, +,"uid","uid_local","uid_foreign","tablenames","sorting","sorting_foreign","ident" +,1201,1001,1101,,,,"docs_colls" +,1202,1002,1101,,,,"docs_colls" +,1203,1003,1101,,,,"docs_colls" +,1204,1001,1102,,,,"docs_colls" diff --git a/Tests/Fixtures/Common/documents_1.xml b/Tests/Fixtures/Common/documents_1.xml deleted file mode 100644 index d718f2d96..000000000 --- a/Tests/Fixtures/Common/documents_1.xml +++ /dev/null @@ -1,220 +0,0 @@ - - - - 1001 - 20000 - 1631775000 - 1631775000 - 2 - 0 - 0 - 0 - 0 - - - https://digital.slub-dresden.de/data/kitodo/10Kepi_476251419/10Kepi_476251419_mets.xml - oai:de:slub-dresden:db:id-476251419 - 476251419 - 476251419 - urn:nbn:de:bsz:14-db-id4762514197 - http://digital.slub-dresden.de/id476251419 - 10 Keyboard pieces - Go. S. 658 - 10 Keyboard pieces - Go. S. 658 - - [1759-1800] - [S.l.] - https://digital.slub-dresden.de/data/kitodo/10Kepi_476251419/10Kepi_476251419_tif/jpegs/00000003.tif.thumbnail.jpg - 59 - 0 - - - - - - - - - 10 Keyboard pieces - Go. S. 658 - 10 Keyboard pieces - Go. S. 658 - 10001 - 1 - 0 - METS - - - - 1002 - 20000 - 1631774000 - 1631774000 - 2 - 0 - 0 - 0 - 0 - - - https://digital.slub-dresden.de/data/kitodo/6Saso_476248086/6Saso_476248086_mets.xml - oai:de:slub-dresden:db:id-476248086 - 476248086 - 476248086 - urn:nbn:de:bsz:14-db-id4762480864 - http://digital.slub-dresden.de/id476248086 - 6 Sacred songs - Go. S. 591 - 6 Sacred songs - Go. S. 591 - - [1840-1860] - [S.l.] - https://digital.slub-dresden.de/data/kitodo/6Saso_476248086/6Saso_476248086_tif/jpegs/00000001.tif.thumbnail.jpg - 59 - 0 - - - - - - - - - 6 Sacred songs - Go. S. 591 - 6 Sacred songs - Go. S. 591 - 10001 - 1 - 0 - METS - - - - 1003 - 20000 - 1631776000 - 1631776000 - 2 - 0 - 0 - 0 - 0 - - - https://digital.slub-dresden.de/data/kitodo/6FuG_476251729/6FuG_476251729_mets.xml - oai:de:slub-dresden:db:id-476251729 - 476251729 - 476251729 - urn:nbn:de:bsz:14-db-id4762517292 - http://digital.slub-dresden.de/id476251729 - 6 Fugues - Go. S. 317 - 6 Fugues - Go. S. 317 - - [um 1820] - [S.l.] - https://digital.slub-dresden.de/data/kitodo/6FuG_476251729/6FuG_476251729_tif/jpegs/00000001.tif.thumbnail.jpg - 59 - 0 - - - - - - - - 3 - 6 Fugues - Go. S. 317 - 6 Fugues - Go. S. 317 - 10001 - 1 - 0 - METS - - - - 1101 - 20000 - 1631279509 - 1631279509 - 2 - 0 - 0 - 0 - a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;} - 0 - - 0 - 0 - - Musik - - music - - - 3 - 0 - 0 - 0 - - - - 1102 - 20000 - 1631279509 - 1631279509 - 2 - 0 - 0 - 0 - a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;} - 0 - - 0 - 0 - - collection-with-single-document - - collection-with-single-document - - - 4 - 0 - 0 - 0 - - - - 1201 - 1001 - 1101 - - - - docs_colls - - - - 1202 - 1002 - 1101 - - - - docs_colls - - - - 1203 - 1003 - 1101 - - - - docs_colls - - - - 1204 - 1001 - 1102 - - - - docs_colls - - diff --git a/Tests/Fixtures/Common/documents_fulltext.csv b/Tests/Fixtures/Common/documents_fulltext.csv new file mode 100644 index 000000000..0faf7a49e --- /dev/null +++ b/Tests/Fixtures/Common/documents_fulltext.csv @@ -0,0 +1,11 @@ +"tx_dlf_documents",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","hidden","starttime","endtime","fe_group","prod_id","location","record_id","opac_id","union_id","urn","purl","title","title_sorting","author","year","place","thumbnail","structure","partof","volume","volume_sorting","license","terms","restrictions","out_of_print","rights_info","collections","mets_label","mets_orderlabel","owner","solrcore","status","document_format" +,533223312,20000,1652331576,1652331576,0,0,0,0,0,,,"https://digital.slub-dresden.de/data/kitodo/aufdesun_351357262/aufdesun_351357262_mets.xml","oai:de:slub-dresden:db:id-351357262","351357262","351357262","urn:nbn:de:bsz:14-db-id3513572628","http://digital.slub-dresden.de/id351357262","Auf der Suche nach Zukunft: Das Beispiel Pieschen","Auf der Suche nach Zukunft: Das Beispiel Pieschen",,1990,"Dresden","https://digital.slub-dresden.de/data/kitodo/aufdesun_351357262/aufdesun_351357262_tif/jpegs/00000001.tif.small.jpg",40,0,,,,,,,,2,"Auf der Suche nach Zukunft: Das Beispiel Pieschen","Auf der Suche nach Zukunft: Das Beispiel Pieschen",3,1,0,"METS" +"tx_dlf_collections",,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","sys_language_uid","l18n_parent","l18n_diffsource","hidden","fe_group","fe_cruser_id","fe_admin_lock","label","index_name","index_search","oai_name","description","thumbnail","priority","documents","owner","status" +,119128558,20000,1631522234,1631522234,2,0,0,0,"...",0,,0,0,"Saxonica","Saxonica",,"saxonica",,,3,0,0,0 +,332405524,20000,1652331460,1652331460,0,0,0,0,,0,,0,0,"Projekt: Dresdner Hefte","Projekt: Dresdner Hefte",,"projekt-dresdner-hefte",,0,3,0,0,0 +"tx_dlf_relations",,,,,,,,, +,"uid_local","uid_foreign","tablenames","sorting","sorting_foreign","ident" +,533223312,119128558,,,,"docs_colls" +,533223312,332405524,,,,"docs_colls" diff --git a/Tests/Fixtures/Common/documents_fulltext.xml b/Tests/Fixtures/Common/documents_fulltext.xml deleted file mode 100644 index 162b097fb..000000000 --- a/Tests/Fixtures/Common/documents_fulltext.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - 533223312 - 20000 - 1652331576 - 1652331576 - 0 - 0 - 0 - 0 - 0 - - - https://digital.slub-dresden.de/data/kitodo/aufdesun_351357262/aufdesun_351357262_mets.xml - oai:de:slub-dresden:db:id-351357262 - 351357262 - 351357262 - urn:nbn:de:bsz:14-db-id3513572628 - http://digital.slub-dresden.de/id351357262 - Auf der Suche nach Zukunft: Das Beispiel Pieschen - Auf der Suche nach Zukunft: Das Beispiel Pieschen - - 1990 - Dresden - https://digital.slub-dresden.de/data/kitodo/aufdesun_351357262/aufdesun_351357262_tif/jpegs/00000001.tif.small.jpg - 40 - 0 - - - - - - - - 2 - Auf der Suche nach Zukunft: Das Beispiel Pieschen - Auf der Suche nach Zukunft: Das Beispiel Pieschen - 3 - 1 - 0 - METS - - - - 119128558 - 20000 - 1631522234 - 1631522234 - 2 - 0 - 0 - 0 - ... - 0 - - 0 - 0 - - Saxonica - - saxonica - - - 3 - 0 - 0 - 0 - - - - 332405524 - 20000 - 1652331460 - 1652331460 - 0 - 0 - 0 - 0 - - 0 - - 0 - 0 - - Projekt: Dresdner Hefte - - projekt-dresdner-hefte - - 0 - 3 - 0 - 0 - 0 - - - - 533223312 - 119128558 - - - - docs_colls - - - - 533223312 - 332405524 - - - - docs_colls - - diff --git a/Tests/Fixtures/Common/libraries.csv b/Tests/Fixtures/Common/libraries.csv new file mode 100644 index 000000000..d2c77d6ae --- /dev/null +++ b/Tests/Fixtures/Common/libraries.csv @@ -0,0 +1,3 @@ +"tx_dlf_libraries",,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","sys_language_uid","l18n_parent","l18n_diffsource","label","index_name","website","contact","image","oai_label","oai_base","opac_label","opac_base","union_label","union_base" +,10001,20000,1631193108,1631193108,2,0,0,0,a:12:{s:5:"label";N;s:10:"index_name";N;s:7:"website";N;s:7:"contact";N;s:5:"image";N;s:9:"oai_label";N;s:8:"oai_base";N;s:10:"opac_label";N;s:9:"opac_base";N;s:11:"union_label";N;s:10:"union_base";N;s:16:"sys_language_uid";N;},"Default Library","default",,"default-library@example.com",,"Default Library - OAI Repository",,,,, diff --git a/Tests/Fixtures/Common/libraries.xml b/Tests/Fixtures/Common/libraries.xml deleted file mode 100644 index 3e6fe9594..000000000 --- a/Tests/Fixtures/Common/libraries.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - 10001 - 20000 - 1631193108 - 1631193108 - 2 - 0 - 0 - 0 - a:12:{s:5:"label";N;s:10:"index_name";N;s:7:"website";N;s:7:"contact";N;s:5:"image";N;s:9:"oai_label";N;s:8:"oai_base";N;s:10:"opac_label";N;s:9:"opac_base";N;s:11:"union_label";N;s:10:"union_base";N;s:16:"sys_language_uid";N;} - - default - - default-library@example.com - - Default Library - OAI Repository - - - - - - - diff --git a/Tests/Fixtures/Common/metadata.csv b/Tests/Fixtures/Common/metadata.csv new file mode 100644 index 000000000..02c3e2237 --- /dev/null +++ b/Tests/Fixtures/Common/metadata.csv @@ -0,0 +1,12 @@ +"tx_dlf_metadata",,,,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","sys_language_uid","l18n_parent","l18n_diffsource","hidden","sorting","label","index_name","format","default_value","wrap","index_tokenized","index_stored","index_indexed","index_boost","is_sortable","is_facet","is_listed","index_autocomplete","status" +,5001,20000,1638557803,1631532810,1,0,0,0,,0,32,"Titel","title",1,,,0,1,1,1,1,0,1,1,0 +,5002,20000,1638557803,1631532810,1,0,0,0,,0,32,"Sammlungen","collection",1,,,1,0,1,1,0,1,0,1,0 +"tx_dlf_metadataformat",,,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","parent_id","encoded","xpath","xpath_sorting","mandatory" +,5101,20000,1638557803,1631532810,1,0,5001,5202,"concat(./mods:titleInfo/mods:nonSort,"" "",./mods:titleInfo/mods:title)","./mods:titleInfo/mods:title",0 +,5102,20000,1638557803,1631532810,1,0,5002,5202,"./mods:relatedItem[@type=""series""]/mods:titleInfo/mods:title[@lang=""ger""]",,0 +"tx_dlf_formats",,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","type","root","namespace","class" +,5201,0,1638557803,1631532810,1,0,"ALTO","alto","http://www.loc.gov/standards/alto/ns-v2#","Kitodo\Dlf\Format\Alto" +,5202,0,1638557803,1631532810,1,0,"MODS","mods","http://www.loc.gov/mods/v3","Kitodo\Dlf\Format\Mods" diff --git a/Tests/Fixtures/Common/metadata.xml b/Tests/Fixtures/Common/metadata.xml deleted file mode 100644 index d4f2be8b5..000000000 --- a/Tests/Fixtures/Common/metadata.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - 5001 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 0 - 0 - - 0 - 32 - - title - 1 - - - 0 - 1 - 1 - 1 - 1 - 0 - 1 - 1 - 0 - - - - 5002 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 0 - 0 - - 0 - 32 - - collection - 1 - - - 1 - 0 - 1 - 1 - 0 - 1 - 0 - 1 - 0 - - - - 5101 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 5001 - 5202 - concat(./mods:titleInfo/mods:nonSort," ",./mods:titleInfo/mods:title) - ./mods:titleInfo/mods:title - 0 - - - - 5102 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 5002 - 5202 - ./mods:relatedItem[@type="series"]/mods:titleInfo/mods:title[@lang="ger"] - - 0 - - - - 5201 - 0 - 1638557803 - 1631532810 - 1 - 0 - ALTO - alto - http://www.loc.gov/standards/alto/ns-v2# - Kitodo\Dlf\Format\Alto - - - 5202 - 0 - 1638557803 - 1631532810 - 1 - 0 - MODS - mods - http://www.loc.gov/mods/v3 - Kitodo\Dlf\Format\Mods - - diff --git a/Tests/Fixtures/MetsDocument/metadata_mets.csv b/Tests/Fixtures/MetsDocument/metadata_mets.csv new file mode 100644 index 000000000..49bc25d2f --- /dev/null +++ b/Tests/Fixtures/MetsDocument/metadata_mets.csv @@ -0,0 +1,17 @@ +"tx_dlf_metadata",,,,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","sys_language_uid","l18n_parent","l18n_diffsource","hidden","sorting","label","index_name","format","default_value","wrap","index_tokenized","index_stored","index_indexed","index_boost","is_sortable","is_facet","is_listed","index_autocomplete","status" +,613174853,20000,,,1,0,0,0,,0,,"Frame Rate","frame_rate",1,,,0,1,1,1,1,0,1,1,0 +,321913049,20000,,,1,0,0,0,,0,,"Owner","dvrights_owner",1,,,0,1,1,1,1,0,1,1,0 +,249506784,20000,,,1,0,0,0,,0,,"Reference","dvlinks_reference",1,,,0,1,1,1,1,0,1,1,0 +,793462399,20000,,,1,0,0,0,,0,,"Test Value","test_value",1,,,0,1,1,1,1,0,1,1,0 +"tx_dlf_metadataformat",,,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","parent_id","encoded","xpath","xpath_sorting","mandatory" +,525104468,20000,,,1,0,613174853,689522348,"./videomd:videoInfo/videomd:frame/videomd:frameRate",,0 +,403181441,20000,,,1,0,321913049,142585035,"./dv:owner",,0 +,257842913,20000,,,1,0,249506784,933594800,"./dv:reference",,0 +,569124173,20000,,,1,0,793462399,5202,"./dv:test",,0 +"tx_dlf_formats",,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","type","root","namespace","class" +,689522348,0,,,1,0,"VIDEOMD","VIDEOMD","http://www.loc.gov/videoMD/","Kitodo\Dlf\Format\Mods" +,142585035,0,,,1,0,"DVRIGHTS","rights","http://dfg-viewer.de/","Kitodo\Dlf\Format\Mods" +,933594800,0,,,1,0,"DVLINKS","links","http://dfg-viewer.de/","Kitodo\Dlf\Format\Mods" diff --git a/Tests/Fixtures/MetsDocument/metadata_mets.xml b/Tests/Fixtures/MetsDocument/metadata_mets.xml deleted file mode 100644 index cc233035f..000000000 --- a/Tests/Fixtures/MetsDocument/metadata_mets.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - 613174853 - 20000 - 0 - 0 - - - frame_rate - 1 - - - - - 321913049 - 20000 - 0 - 0 - - - dvrights_owner - 1 - - - - - 249506784 - 20000 - 0 - 0 - - - dvlinks_reference - 1 - - - - - 793462399 - 20000 - 0 - 0 - - - test_value - 1 - - - - - 525104468 - 20000 - 613174853 - 689522348 - ./videomd:videoInfo/videomd:frame/videomd:frameRate - - - - - 403181441 - 20000 - 321913049 - 142585035 - ./dv:owner - - - - - 257842913 - 20000 - 249506784 - 933594800 - ./dv:reference - - - - - 569124173 - 20000 - 793462399 - 5202 - ./dv:test - - - - - 689522348 - 0 - VIDEOMD - VIDEOMD - http://www.loc.gov/videoMD/ - - - - 142585035 - 0 - DVRIGHTS - rights - http://dfg-viewer.de/ - - - - 933594800 - 0 - DVLINKS - links - http://dfg-viewer.de/ - - diff --git a/Tests/Fixtures/OaiPmh/solrcores.csv b/Tests/Fixtures/OaiPmh/solrcores.csv new file mode 100644 index 000000000..cc25634dd --- /dev/null +++ b/Tests/Fixtures/OaiPmh/solrcores.csv @@ -0,0 +1,3 @@ +"tx_dlf_solrcores",,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","label","index_name" +,11001,20000,1631254345,1631186030,1,0,"OAI-PMH Solr Testing Core", diff --git a/Tests/Fixtures/OaiPmh/solrcores.xml b/Tests/Fixtures/OaiPmh/solrcores.xml deleted file mode 100644 index 9901eabb5..000000000 --- a/Tests/Fixtures/OaiPmh/solrcores.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - 11001 - 20000 - 1631254345 - 1631186030 - 1 - 0 - - - - diff --git a/Tests/Fixtures/Repository/collections.csv b/Tests/Fixtures/Repository/collections.csv new file mode 100644 index 000000000..8135ee908 --- /dev/null +++ b/Tests/Fixtures/Repository/collections.csv @@ -0,0 +1,6 @@ +"tx_dlf_collections",,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","sys_language_uid","l18n_parent","l18n_diffsource","hidden","fe_group","fe_cruser_id","fe_admin_lock","label","index_name","index_search","oai_name","description","thumbnail","priority","documents","owner","status" +,1101,20000,1631279509,1631279509,2,0,0,0,"a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;}",0,0,0,0,"Musik","Musik",,"music",,,3,0,0,0 +,1102,20000,1631279509,1631279509,2,0,0,0,"a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;}",,0,0,0,"Collection with single document","collection-with-single-document",,"collection-with-single-document",,,4,0,0,0 +,1103,20000,1631279509,1631279509,2,0,0,0,"a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;}",0,,1,0,"Geschichte","Geschichte","*:*","history",,,4,0,0,0 +,1104,20000,1631279509,1631279509,2,0,0,0,"a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;}",0,,1,0,"Bildende Kunst","bildende-kunst",,,,,4,0,0,0 diff --git a/Tests/Fixtures/Repository/collections.xml b/Tests/Fixtures/Repository/collections.xml deleted file mode 100644 index cb42c2339..000000000 --- a/Tests/Fixtures/Repository/collections.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - 1101 - 20000 - 1631279509 - 1631279509 - 2 - 0 - 0 - 0 - - a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;} - - 0 - - 0 - 0 - - Musik - - music - - - 3 - 0 - 0 - 0 - - - - 1102 - 20000 - 1631279509 - 1631279509 - 2 - 0 - 0 - 0 - - a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;} - - 0 - - 0 - 0 - - collection-with-single-document - - collection-with-single-document - - - 4 - 0 - 0 - 0 - - - - 1103 - 20000 - 1631279509 - 1631279509 - 2 - 0 - 0 - 0 - - a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;} - - 0 - - 1 - 0 - - Geschichte - *:* - history - - - 3 - 0 - 0 - 0 - - - - 1104 - 20000 - 1631279509 - 1631279509 - 2 - 0 - 0 - 0 - - a:8:{s:5:"label";N;s:10:"index_name";N;s:8:"oai_name";N;s:11:"description";N;s:9:"documents";N;s:5:"owner";N;s:6:"status";N;s:16:"sys_language_uid";N;} - - 0 - - 1 - 0 - - bildende-kunst - - - - - 4 - 0 - 0 - 0 - - - diff --git a/Tests/Fixtures/Repository/mail.csv b/Tests/Fixtures/Repository/mail.csv new file mode 100644 index 000000000..6ae08e682 --- /dev/null +++ b/Tests/Fixtures/Repository/mail.csv @@ -0,0 +1,6 @@ +"tx_dlf_mail",,,,,,, +,"uid","pid","deleted","sorting","mail","name","label" +,101,30000,0,10,"Mail","Name","Mail-Label-1" +,102,30000,0,10,"Mail","Name","Mail-Label-2" +,103,20000,0,10,"Mail","Name","Mail-Label-3" +,104,20000,0,10,"Mail","Name","Mail-Label-4" diff --git a/Tests/Fixtures/Repository/mail.xml b/Tests/Fixtures/Repository/mail.xml deleted file mode 100644 index 6cfb51dad..000000000 --- a/Tests/Fixtures/Repository/mail.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - 101 - 30000 - 0 - 10 - Mail - Name - - - - 102 - 30000 - 0 - 10 - Mail - Name - - - - 103 - 20000 - 0 - 10 - Mail - Name - - - - 104 - 20000 - 0 - 10 - Mail - Name - - - diff --git a/Tests/Fixtures/Repository/metadata.csv b/Tests/Fixtures/Repository/metadata.csv new file mode 100644 index 000000000..4abadbe15 --- /dev/null +++ b/Tests/Fixtures/Repository/metadata.csv @@ -0,0 +1,16 @@ +"tx_dlf_metadata",,,,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","sys_language_uid","l18n_parent","l18n_diffsource","hidden","sorting","label","index_name","format","default_value","wrap","index_tokenized","index_stored","index_indexed","index_boost","is_sortable","is_facet","is_listed","index_autocomplete","status" +,5001,20000,1638557803,1631532810,1,0,0,0,,0,32,"Titel","title",1,,,0,1,1,1,1,0,1,1,0 +,5002,20000,1638557803,1631532810,1,0,0,0,,0,31,"Sammlungen","collection",1,,,1,0,1,1,0,1,0,1,0 +,5003,20000,1638557803,1631532810,1,0,0,0,,0,30,"Untertitel","untertitel",1,,,0,1,1,1,1,0,0,1,0 +,5004,20000,1638557803,1631532810,1,0,0,0,,0,29,"Ort","ort",1,,,0,1,1,1,1,0,0,1,0 +,5005,20000,1638557803,1631532810,1,0,0,0,,0,30,"Autor","autor",1,,,0,1,1,1,1,0,1,1,0 +,5006,20000,1638557803,1631532810,1,0,0,0,,0,30,"Institution","institution",1,,,0,1,1,1,0,0,1,1,0 +"tx_dlf_metadataformat",,,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","parent_id","encoded","xpath","xpath_sorting","mandatory" +,5101,20000,1638557803,1631532810,1,0,5001,5202,"concat(./mods:titleInfo/mods:nonSort,"" "",./mods:titleInfo/mods:title)","./mods:titleInfo/mods:title",0 +,5102,20000,1638557803,1631532810,1,0,5002,5202,""./mods:relatedItem[@type="series"]/mods:titleInfo/mods:title[@lang="ger"]",,0 +"tx_dlf_formats",,,,,,,,,, +,"uid","pid","tstamp","crdate","cruser_id","deleted","type","root","namespace","class" +,5201,0,1638557803,1631532810,1,0,"ALTO","alto","http://www.loc.gov/standards/alto/ns-v2#","Kitodo\Dlf\Format\Alto" +,5202,0,1638557803,1631532810,1,0,"MODS","mods","http://www.loc.gov/mods/v3","Kitodo\Dlf\Format\Mods" diff --git a/Tests/Fixtures/Repository/metadata.xml b/Tests/Fixtures/Repository/metadata.xml deleted file mode 100644 index 5c012c908..000000000 --- a/Tests/Fixtures/Repository/metadata.xml +++ /dev/null @@ -1,223 +0,0 @@ - - - - 5001 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 0 - 0 - - 0 - 32 - - title - 1 - - - 0 - 1 - 1 - 1 - 1 - 0 - 1 - 1 - 0 - - - - 5002 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 0 - 0 - - 0 - 31 - - collection - 1 - - - 1 - 0 - 1 - 1 - 0 - 1 - 0 - 1 - 0 - - - - 5003 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 0 - 0 - - 0 - 30 - - untertitel - 1 - - - 0 - 1 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - - - - 5004 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 0 - 0 - - 0 - 29 - - ort - 1 - - - 0 - 1 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - - - - 5005 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 0 - 0 - - 0 - 30 - - autor - 1 - - - 0 - 1 - 1 - 1 - 1 - 0 - 1 - 1 - 0 - - - - 5006 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 0 - 0 - - 0 - 30 - - institution - 1 - - - 0 - 1 - 1 - 1 - 0 - 0 - 1 - 1 - 0 - - - - 5101 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 5001 - 5202 - concat(./mods:titleInfo/mods:nonSort," ",./mods:titleInfo/mods:title) - ./mods:titleInfo/mods:title - 0 - - - - 5102 - 20000 - 1638557803 - 1631532810 - 1 - 0 - 5002 - 5202 - ./mods:relatedItem[@type="series"]/mods:titleInfo/mods:title[@lang="ger"] - - 0 - - - - 5201 - 0 - 1638557803 - 1631532810 - 1 - 0 - ALTO - alto - http://www.loc.gov/standards/alto/ns-v2# - Kitodo\Dlf\Format\Alto - - - 5202 - 0 - 1638557803 - 1631532810 - 1 - 0 - MODS - mods - http://www.loc.gov/mods/v3 - Kitodo\Dlf\Format\Mods - - diff --git a/Tests/Fixtures/Repository/token.csv b/Tests/Fixtures/Repository/token.csv new file mode 100644 index 000000000..41302cda3 --- /dev/null +++ b/Tests/Fixtures/Repository/token.csv @@ -0,0 +1,6 @@ +"tx_dlf_tokens",,,,,, +,"uid","pid","tstamp","token","options","ident" +,101,20000,1631279509,"token101","Options text 101","ident1" +,102,20000,1631289509,"token102","Options text 102","ident1" +,103,20000,1631279509,"token103","Options text 103","ident1" +,104,20000,1631281509,"token104","Options text 104","ident1" diff --git a/Tests/Fixtures/Repository/token.xml b/Tests/Fixtures/Repository/token.xml deleted file mode 100644 index 1d226f25b..000000000 --- a/Tests/Fixtures/Repository/token.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - 101 - 20000 - 1631279509 - token101 - Options text 101 - ident1 - - - 102 - 20000 - 1631289509 - token102 - Options text 102 - ident1 - - - 103 - 20000 - 1631279509 - token103 - Options text 103 - ident1 - - - 104 - 20000 - 1631281509 - token104 - Options text 104 - ident1 - - diff --git a/Tests/Functional/Api/OaiPmhTest.php b/Tests/Functional/Api/OaiPmhTest.php index 2e7f09d99..8dbd45825 100644 --- a/Tests/Functional/Api/OaiPmhTest.php +++ b/Tests/Functional/Api/OaiPmhTest.php @@ -11,6 +11,7 @@ use Phpoaipmh\Exception\OaipmhException; use SimpleXMLElement; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; +use TYPO3\CMS\Core\Utility\GeneralUtility; class OaiPmhTest extends FunctionalTestCase { @@ -33,6 +34,16 @@ class OaiPmhTest extends FunctionalTestCase /** @var string */ protected $oaiUrlNoStoragePid; + /** + * @var PersistenceManager + */ + protected $persistenceManager; + + /** + * @var SolrCoreRepository + */ + protected $solrCoreRepository; + public function setUp(): void { parent::setUp(); @@ -40,14 +51,14 @@ public function setUp(): void $this->oaiUrl = $this->baseUrl . 'index.php?id=' . $this->oaiPage; $this->oaiUrlNoStoragePid = $this->baseUrl . 'index.php?id=' . $this->oaiPageNoStoragePid; - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/documents_1.xml'); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/metadata.xml'); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/libraries.xml'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/documents_1.csv'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/metadata.csv'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/libraries.csv'); $this->importDataSet(__DIR__ . '/../../Fixtures/Common/pages.xml'); $this->importDataSet(__DIR__ . '/../../Fixtures/OaiPmh/pages.xml'); - $this->importDataSet(__DIR__ . '/../../Fixtures/OaiPmh/solrcores.xml'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/OaiPmh/solrcores.csv'); - $this->persistenceManager = $this->objectManager->get(PersistenceManager::class); + $this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); $this->solrCoreRepository = $this->initializeRepository(SolrCoreRepository::class, 20000); $this->setUpOaiSolr(); diff --git a/Tests/Functional/Common/HelperTest.php b/Tests/Functional/Common/HelperTest.php index 136f690e1..fe0d12bb2 100644 --- a/Tests/Functional/Common/HelperTest.php +++ b/Tests/Functional/Common/HelperTest.php @@ -4,7 +4,6 @@ use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; -use TYPO3\CMS\Core\Localization\LanguageService; class HelperTest extends FunctionalTestCase { @@ -12,8 +11,8 @@ public function setUp(): void { parent::setUp(); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/libraries.xml'); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/metadata.xml'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/libraries.csv'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/metadata.csv'); } /** diff --git a/Tests/Functional/Common/MetsDocumentTest.php b/Tests/Functional/Common/MetsDocumentTest.php index a4f91e663..8f3947ca3 100644 --- a/Tests/Functional/Common/MetsDocumentTest.php +++ b/Tests/Functional/Common/MetsDocumentTest.php @@ -20,9 +20,9 @@ public function setUp(): void { parent::setUp(); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/documents_1.xml'); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/metadata.xml'); - $this->importDataSet(__DIR__ . '/../../Fixtures/MetsDocument/metadata_mets.xml'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/documents_1.csv'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/metadata.csv'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/MetsDocument/metadata_mets.csv'); } protected function doc(string $file) diff --git a/Tests/Functional/Common/SolrIndexingTest.php b/Tests/Functional/Common/SolrIndexingTest.php index faf2e8c70..404a27416 100644 --- a/Tests/Functional/Common/SolrIndexingTest.php +++ b/Tests/Functional/Common/SolrIndexingTest.php @@ -41,9 +41,9 @@ public function setUp(): void $this->documentRepository = $this->initializeRepository(DocumentRepository::class, 20000); $this->solrCoreRepository = $this->initializeRepository(SolrCoreRepository::class, 20000); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/documents_1.xml'); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/libraries.xml'); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/metadata.xml'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/documents_1.csv'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/libraries.csv'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/metadata.csv'); } /** @@ -124,7 +124,7 @@ public function canSearchInCollections() { $core = $this->createSolrCore(); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/documents_fulltext.xml'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/documents_fulltext.csv'); $this->importSolrDocuments($core->solr, __DIR__ . '/../../Fixtures/Common/documents_1.solr.json'); $this->importSolrDocuments($core->solr, __DIR__ . '/../../Fixtures/Common/documents_fulltext.solr.json'); diff --git a/Tests/Functional/Repository/CollectionRepositoryTest.php b/Tests/Functional/Repository/CollectionRepositoryTest.php index ac7149e6b..9e64cfd37 100644 --- a/Tests/Functional/Repository/CollectionRepositoryTest.php +++ b/Tests/Functional/Repository/CollectionRepositoryTest.php @@ -31,7 +31,7 @@ public function setUp(): void 20000 ); - $this->importDataSet(__DIR__ . '/../../Fixtures/Repository/collections.xml'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Repository/collections.csv'); } /** diff --git a/Tests/Functional/Repository/DocumentRepositoryTest.php b/Tests/Functional/Repository/DocumentRepositoryTest.php index 8d9de065f..41e481ac9 100644 --- a/Tests/Functional/Repository/DocumentRepositoryTest.php +++ b/Tests/Functional/Repository/DocumentRepositoryTest.php @@ -21,9 +21,9 @@ public function setUp(): void $this->documentRepository = $this->initializeRepository(DocumentRepository::class, 20000); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/documents_1.xml'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/documents_1.csv'); $this->importDataSet(__DIR__ . '/../../Fixtures/Common/pages.xml'); - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/libraries.xml'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Common/libraries.csv'); } /** diff --git a/Tests/Functional/Repository/MailRepositoryTest.php b/Tests/Functional/Repository/MailRepositoryTest.php index 5aff084f7..dd983cc31 100644 --- a/Tests/Functional/Repository/MailRepositoryTest.php +++ b/Tests/Functional/Repository/MailRepositoryTest.php @@ -31,7 +31,7 @@ public function setUp(): void 20000 ); - $this->importDataSet(__DIR__ . '/../../Fixtures/Repository/mail.xml'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Repository/mail.csv'); } /** diff --git a/Tests/Functional/Repository/MetatdataRepositoryTest.php b/Tests/Functional/Repository/MetatdataRepositoryTest.php index 0e78feec0..d56467bdd 100644 --- a/Tests/Functional/Repository/MetatdataRepositoryTest.php +++ b/Tests/Functional/Repository/MetatdataRepositoryTest.php @@ -31,7 +31,7 @@ public function setUp(): void 20000 ); - $this->importDataSet(__DIR__ . '/../../Fixtures/Repository/metadata.xml'); + $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Repository/metadata.csv'); } diff --git a/Tests/Functional/Repository/TokenRepositoryTest.php b/Tests/Functional/Repository/TokenRepositoryTest.php index f30957a1e..0a2fac65d 100644 --- a/Tests/Functional/Repository/TokenRepositoryTest.php +++ b/Tests/Functional/Repository/TokenRepositoryTest.php @@ -43,7 +43,7 @@ public function tearDown(): void { parent::tearDown(); - unlink(__DIR__ . '/../../Fixtures/Repository/tokenTemp.xml'); + unlink(__DIR__ . '/../../Fixtures/Repository/tokenTemp.csv'); } /** @@ -52,23 +52,32 @@ public function tearDown(): void */ public function deleteExpiredTokens(): void { - $xml = simplexml_load_file(__DIR__ . '/../../Fixtures/Repository/token.xml'); + $inputCsvFile = __DIR__ . '/../../Fixtures/Repository/token.csv'; + $outputCsvFile = __DIR__ . '/../../Fixtures/Repository/tokenTemp.csv'; + + $inputCsvData = file_get_contents($inputCsvFile); + $csvData = str_getcsv($inputCsvData, "\n"); $expireTime = 3600; $i = 1; - foreach ($xml as $node) { - if ($i % 2 == 0) { - $node->tstamp = time() - $expireTime - random_int(10, 3600); - } else { - $node->tstamp = time() - $expireTime + random_int(10, 3600); + + foreach ($csvData as $key => &$row) { + if ($key > 1) { + $columns = str_getcsv($row, ","); + if ($i % 2 == 0) { + $columns[3] = time() - $expireTime - rand(10, 3600); + } else { + $columns[3] = time() - $expireTime + rand(10, 3600); + } + $row = implode(",", $columns); + $i++; } - $i++; } - $xml->saveXML(__DIR__ . '/../../Fixtures/Repository/tokenTemp.xml'); - - $this->importDataSet(__DIR__ . '/../../Fixtures/Repository/tokenTemp.xml'); + $outputCsvData = implode("\n", $csvData); + file_put_contents($outputCsvFile, $outputCsvData); + $this->importCSVDataSet($outputCsvFile); $this->tokenRepository->deleteExpiredTokens($expireTime); $this->persistenceManager->persistAll(); From b8949f9228bd02e15d307789cbc5dc17a224c9c0 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 1 Nov 2023 15:52:27 +0100 Subject: [PATCH 49/76] [MAINTENANCE] Additional fixes in the test classes (#1065) --- Tests/Functional/Api/OaiPmhTest.php | 60 +++++------- .../Api/PageViewProxyDisabledTest.php | 2 +- Tests/Functional/Api/PageViewProxyTest.php | 22 ++--- Tests/Functional/Common/HelperTest.php | 32 +++--- Tests/Functional/Common/IiifUrlReaderTest.php | 4 +- Tests/Functional/Common/MetsDocumentTest.php | 52 +++++----- Tests/Functional/Common/SolrIndexingTest.php | 46 ++++----- Tests/Functional/FunctionalTestCase.php | 15 ++- .../Repository/CollectionRepositoryTest.php | 98 +++++++++---------- .../Repository/DocumentRepositoryTest.php | 18 ++-- .../Repository/MailRepositoryTest.php | 10 +- .../Repository/MetatdataRepositoryTest.php | 20 ++-- .../Repository/TokenRepositoryTest.php | 14 +-- .../MetadataWrapVariableViewHelperTest.php | 2 +- .../ViewHelpers/StdWrapViewHelperTest.php | 4 +- Tests/Unit/Common/HelperTest.php | 22 ++--- Tests/Unit/Format/AltoTest.php | 10 +- Tests/Unit/Format/AudioVideoMDTest.php | 2 +- Tests/Unit/Format/ModsTest.php | 20 ++-- 19 files changed, 220 insertions(+), 233 deletions(-) diff --git a/Tests/Functional/Api/OaiPmhTest.php b/Tests/Functional/Api/OaiPmhTest.php index 8dbd45825..ed5a3550a 100644 --- a/Tests/Functional/Api/OaiPmhTest.php +++ b/Tests/Functional/Api/OaiPmhTest.php @@ -10,8 +10,6 @@ use Phpoaipmh\Endpoint; use Phpoaipmh\Exception\OaipmhException; use SimpleXMLElement; -use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; -use TYPO3\CMS\Core\Utility\GeneralUtility; class OaiPmhTest extends FunctionalTestCase { @@ -34,11 +32,6 @@ class OaiPmhTest extends FunctionalTestCase /** @var string */ protected $oaiUrlNoStoragePid; - /** - * @var PersistenceManager - */ - protected $persistenceManager; - /** * @var SolrCoreRepository */ @@ -58,7 +51,6 @@ public function setUp(): void $this->importDataSet(__DIR__ . '/../../Fixtures/OaiPmh/pages.xml'); $this->importCSVDataSet(__DIR__ . '/../../Fixtures/OaiPmh/solrcores.csv'); - $this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); $this->solrCoreRepository = $this->initializeRepository(SolrCoreRepository::class, 20000); $this->setUpOaiSolr(); @@ -96,16 +88,16 @@ public function correctlyRespondsOnBadVerb() ]); $xml = new SimpleXMLElement((string) $response->getBody()); - $this->assertEquals('badVerb', (string) $xml->error['code']); + self::assertEquals('badVerb', (string) $xml->error['code']); // The base URL may be different from the one used that we actually used, // but it shouldn't contain the verb argument - $this->assertStringNotContainsString('nastyVerb', (string) $xml->request); + self::assertStringNotContainsString('nastyVerb', (string) $xml->request); // For bad verbs, the element must not contain any attributes // - http://www.openarchives.org/OAI/openarchivesprotocol.html#XMLResponse // - http://www.openarchives.org/OAI/openarchivesprotocol.html#ErrorConditions - $this->assertEmpty($xml->request->attributes()); + self::assertEmpty($xml->request->attributes()); } /** @@ -116,10 +108,10 @@ public function canIdentify() $oai = Endpoint::build($this->oaiUrl); $identity = $oai->identify(); - $this->assertEquals('Identify', (string) $identity->request['verb']); - $this->assertEquals('Default Library - OAI Repository', (string) $identity->Identify->repositoryName); - $this->assertUtcDateString((string) $identity->Identify->earliestDatestamp); - $this->assertEquals('default-library@example.com', (string) $identity->Identify->adminEmail); + self::assertEquals('Identify', (string) $identity->request['verb']); + self::assertEquals('Default Library - OAI Repository', (string) $identity->Identify->repositoryName); + self::assertUtcDateString((string) $identity->Identify->earliestDatestamp); + self::assertEquals('default-library@example.com', (string) $identity->Identify->adminEmail); } /** @@ -130,7 +122,7 @@ public function identifyGivesFallbackDatestampWhenNoDocuments() $oai = Endpoint::build($this->oaiUrlNoStoragePid); $identity = $oai->identify(); - $this->assertUtcDateString((string) $identity->Identify->earliestDatestamp); + self::assertUtcDateString((string) $identity->Identify->earliestDatestamp); } /** @@ -146,7 +138,7 @@ public function canListMetadataFormats() $formatMap[(string) $format->metadataPrefix] = $format; } - $this->assertEquals('http://www.loc.gov/METS/', (string) $formatMap['mets']->metadataNamespace); + self::assertEquals('http://www.loc.gov/METS/', (string) $formatMap['mets']->metadataNamespace); } /** @@ -159,8 +151,8 @@ public function canListRecords() $record = $result->current(); $metsRoot = $record->metadata->children('http://www.loc.gov/METS/')[0]; - $this->assertNotNull($metsRoot); - $this->assertEquals('mets', $metsRoot->getName()); + self::assertNotNull($metsRoot); + self::assertEquals('mets', $metsRoot->getName()); } /** @@ -200,13 +192,13 @@ public function canUseResumptionToken() $xml = new SimpleXMLElement((string) $response->getBody()); $resumptionToken = $xml->$verb->resumptionToken; - $this->assertEquals('0', (string) $resumptionToken['cursor']); - $this->assertInFuture((string) $resumptionToken['expirationDate']); - $this->assertNotEmpty((string) $resumptionToken); + self::assertEquals('0', (string) $resumptionToken['cursor']); + self::assertInFuture((string) $resumptionToken['expirationDate']); + self::assertNotEmpty((string) $resumptionToken); // Store list size to check that it remains constant (and check its sanity) $completeListSize = (int) $resumptionToken['completeListSize']; - $this->assertGreaterThan(2, $completeListSize); // we have more than two documents in document set + self::assertGreaterThan(2, $completeListSize); // we have more than two documents in document set // Check that we can resume and get a proper cursor value $cursor = 1; @@ -223,13 +215,13 @@ public function canUseResumptionToken() $resumptionToken = $xml->$verb->resumptionToken; $tokenStr = (string) $resumptionToken; - $this->assertEquals($cursor, (string) $resumptionToken['cursor']); // settings.limit = 1 - $this->assertEquals($completeListSize, (string) $resumptionToken['completeListSize']); + self::assertEquals($cursor, (string) $resumptionToken['cursor']); // settings.limit = 1 + self::assertEquals($completeListSize, (string) $resumptionToken['completeListSize']); // The last resumptionToken is empty and doesn't have expirationDate $isLastBatch = $cursor + 1 >= $completeListSize; - $this->assertEquals($isLastBatch, empty((string) $resumptionToken['expirationDate'])); - $this->assertEquals($isLastBatch, empty($tokenStr)); + self::assertEquals($isLastBatch, empty((string) $resumptionToken['expirationDate'])); + self::assertEquals($isLastBatch, empty($tokenStr)); $cursor++; } while ($tokenStr); @@ -254,8 +246,8 @@ public function noResumptionTokenForCompleteList() ]); $xml = new SimpleXMLElement((string) $response->getBody()); - $this->assertEquals(1, count($xml->$verb->children())); - $this->assertEmpty($xml->$verb->resumptionToken); + self::assertEquals(1, count($xml->$verb->children())); + self::assertEmpty($xml->$verb->resumptionToken); } } @@ -268,12 +260,12 @@ public function canListAndResumeIdentifiers() $result = $oai->listIdentifiers('mets'); $record = $result->current(); - $this->assertEquals('oai:de:slub-dresden:db:id-476251419', $record->identifier); - $this->assertEquals(['collection-with-single-document', 'music'], (array) $record->setSpec); + self::assertEquals('oai:de:slub-dresden:db:id-476251419', $record->identifier); + self::assertEquals(['collection-with-single-document', 'music'], (array) $record->setSpec); // This should use a resumption token because settings.limit is 1 $record = $result->next(); - $this->assertEquals('oai:de:slub-dresden:db:id-476248086', $record->identifier); + self::assertEquals('oai:de:slub-dresden:db:id-476248086', $record->identifier); } protected function parseUtc(string $dateTime) @@ -283,11 +275,11 @@ protected function parseUtc(string $dateTime) protected function assertUtcDateString(string $dateTime) { - $this->assertInstanceOf(DateTime::class, $this->parseUtc($dateTime)); + self::assertInstanceOf(DateTime::class, $this->parseUtc($dateTime)); } protected function assertInFuture(string $dateTime) { - $this->assertGreaterThan(new DateTime(), $this->parseUtc($dateTime)); + self::assertGreaterThan(new DateTime(), $this->parseUtc($dateTime)); } } diff --git a/Tests/Functional/Api/PageViewProxyDisabledTest.php b/Tests/Functional/Api/PageViewProxyDisabledTest.php index 160c5c0a0..f71a924bb 100644 --- a/Tests/Functional/Api/PageViewProxyDisabledTest.php +++ b/Tests/Functional/Api/PageViewProxyDisabledTest.php @@ -31,6 +31,6 @@ public function cannotAccessPageWhenProxyIsDisabled(): void 'uHash' => $uHash, ]); - $this->assertEquals(404, $response->getStatusCode()); + self::assertEquals(404, $response->getStatusCode()); } } diff --git a/Tests/Functional/Api/PageViewProxyTest.php b/Tests/Functional/Api/PageViewProxyTest.php index c4767eb3b..c5a71a92c 100644 --- a/Tests/Functional/Api/PageViewProxyTest.php +++ b/Tests/Functional/Api/PageViewProxyTest.php @@ -35,7 +35,7 @@ public function cannotAccessFileUrl(): void 'url' => 'file:///etc/passwd', ]); - $this->assertEquals(400, $response->getStatusCode()); + self::assertEquals(400, $response->getStatusCode()); } /** @@ -47,7 +47,7 @@ public function cannotAccessUrlWithoutUrlHash(): void 'url' => 'http://web:8001/Tests/Fixtures/PageViewProxy/test.txt', ]); - $this->assertEquals(401, $response->getStatusCode()); + self::assertEquals(401, $response->getStatusCode()); } /** @@ -60,7 +60,7 @@ public function cannotAccessUrlWithInvalidUrlHash(): void 'uHash' => 'nottherealhash', ]); - $this->assertEquals(401, $response->getStatusCode()); + self::assertEquals(401, $response->getStatusCode()); } /** @@ -76,8 +76,8 @@ public function canAccessPageWithUrlHash(): void 'uHash' => $uHash, ]); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('This is some plain text test file.' . "\n", (string) $response->getBody()); + self::assertEquals(200, $response->getStatusCode()); + self::assertEquals('This is some plain text test file.' . "\n", (string) $response->getBody()); } /** @@ -93,7 +93,7 @@ public function cannotSendPostRequest(): void 'uHash' => $uHash, ], 'POST'); - $this->assertEquals(405, $response->getStatusCode()); + self::assertEquals(405, $response->getStatusCode()); } /** @@ -109,8 +109,8 @@ public function sendsUserAgentToTarget(): void 'uHash' => $uHash, ]); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('Kitodo.Presentation Proxy', (string) $response->getBody()); + self::assertEquals(200, $response->getStatusCode()); + self::assertEquals('Kitodo.Presentation Proxy', (string) $response->getBody()); } /** @@ -120,9 +120,9 @@ public function canQueryOptions(): void { $response = $this->queryProxy([], 'OPTIONS'); - $this->assertGreaterThanOrEqual(200, $response->getStatusCode()); - $this->assertLessThan(300, $response->getStatusCode()); + self::assertGreaterThanOrEqual(200, $response->getStatusCode()); + self::assertLessThan(300, $response->getStatusCode()); - $this->assertNotEmpty($response->getHeader('Access-Control-Allow-Methods')); + self::assertNotEmpty($response->getHeader('Access-Control-Allow-Methods')); } } diff --git a/Tests/Functional/Common/HelperTest.php b/Tests/Functional/Common/HelperTest.php index fe0d12bb2..ebd8528e0 100644 --- a/Tests/Functional/Common/HelperTest.php +++ b/Tests/Functional/Common/HelperTest.php @@ -23,41 +23,41 @@ public function canGetIndexNameFromUid() // Repeat to make sure caching isn't broken for ($n = 0; $n < 2; $n++) { // Good UID, no PID - $this->assertEquals( + self::assertEquals( 'default', Helper::getIndexNameFromUid(10001, 'tx_dlf_libraries') ); - $this->assertEquals( + self::assertEquals( 'title', Helper::getIndexNameFromUid(5001, 'tx_dlf_metadata') ); - $this->assertEquals( + self::assertEquals( 'collection', Helper::getIndexNameFromUid(5002, 'tx_dlf_metadata') ); // Good UID, good PID - $this->assertEquals( + self::assertEquals( 'default', Helper::getIndexNameFromUid(10001, 'tx_dlf_libraries', 20000) ); - $this->assertEquals( + self::assertEquals( 'title', Helper::getIndexNameFromUid(5001, 'tx_dlf_metadata', 20000) ); - $this->assertEquals( + self::assertEquals( 'collection', Helper::getIndexNameFromUid(5002, 'tx_dlf_metadata', 20000) ); // Good UID, bad PID - $this->assertEquals( + self::assertEquals( '', Helper::getIndexNameFromUid(10001, 'tx_dlf_libraries', 123456) ); // Bad UID, no PID - $this->assertEquals( + self::assertEquals( '', Helper::getIndexNameFromUid(123456, 'tx_dlf_libraries') ); @@ -73,10 +73,10 @@ public function canTranslateLanguageNameToEnglish() // NOTE: This only tests in BE mode $this->initLanguageService('default'); - $this->assertEquals('German', Helper::getLanguageName('de')); // ISO 639-1 - $this->assertEquals('German', Helper::getLanguageName('ger')); // ISO 639-2 - $this->assertEquals('abcde', Helper::getLanguageName('abcde')); // doesn't match ISO code regex - $this->assertEquals('abc', Helper::getLanguageName('abc')); // matches ISO code regex, but not an ISO code + self::assertEquals('German', Helper::getLanguageName('de')); // ISO 639-1 + self::assertEquals('German', Helper::getLanguageName('ger')); // ISO 639-2 + self::assertEquals('abcde', Helper::getLanguageName('abcde')); // doesn't match ISO code regex + self::assertEquals('abc', Helper::getLanguageName('abc')); // matches ISO code regex, but not an ISO code } /** @@ -88,9 +88,9 @@ public function canTranslateLanguageNameToGerman() // NOTE: This only tests in BE mode $this->initLanguageService('de'); - $this->assertEquals('Deutsch', Helper::getLanguageName('de')); // ISO 639-1 - $this->assertEquals('Deutsch', Helper::getLanguageName('ger')); // ISO 639-2 - $this->assertEquals('abcde', Helper::getLanguageName('abcde')); // doesn't match ISO code regex - $this->assertEquals('abc', Helper::getLanguageName('abc')); // matches ISO code regex, but not an ISO code + self::assertEquals('Deutsch', Helper::getLanguageName('de')); // ISO 639-1 + self::assertEquals('Deutsch', Helper::getLanguageName('ger')); // ISO 639-2 + self::assertEquals('abcde', Helper::getLanguageName('abcde')); // doesn't match ISO code regex + self::assertEquals('abc', Helper::getLanguageName('abc')); // matches ISO code regex, but not an ISO code } } diff --git a/Tests/Functional/Common/IiifUrlReaderTest.php b/Tests/Functional/Common/IiifUrlReaderTest.php index f9f0ab1b6..fff94cf72 100644 --- a/Tests/Functional/Common/IiifUrlReaderTest.php +++ b/Tests/Functional/Common/IiifUrlReaderTest.php @@ -26,9 +26,9 @@ public function getContentCheck() $correctUrl = 'http://web:8001/Tests/Fixtures/Common/correct.txt'; $expected = "Correct result\n"; - $this->assertSame($expected, $iiifUrlReader->getContent($correctUrl)); + self::assertSame($expected, $iiifUrlReader->getContent($correctUrl)); $incorrectUrl = 'http://web:8001/incorrectPath'; - $this->assertSame('', $iiifUrlReader->getContent($incorrectUrl)); + self::assertSame('', $iiifUrlReader->getContent($incorrectUrl)); } } diff --git a/Tests/Functional/Common/MetsDocumentTest.php b/Tests/Functional/Common/MetsDocumentTest.php index 8f3947ca3..072cd5be4 100644 --- a/Tests/Functional/Common/MetsDocumentTest.php +++ b/Tests/Functional/Common/MetsDocumentTest.php @@ -29,7 +29,7 @@ protected function doc(string $file) { $url = 'http://web:8001/Tests/Fixtures/MetsDocument/' . $file; $doc = AbstractDocument::getInstance($url, ['useExternalApisForMetadata' => 0]); - $this->assertNotNull($doc); + self::assertNotNull($doc); return $doc; } @@ -42,12 +42,12 @@ public function canParseDmdAndAmdSec() $titledata = $doc->getTitledata(20000); - $this->assertEquals(['Odol-Mundwasser, 3 Werbespots'], $titledata['title']); - $this->assertEquals(['24'], $titledata['frame_rate']); - $this->assertEquals(['Sächsische Landesbibliothek - Staats- und Universitätsbibliothek Dresden'], $titledata['dvrights_owner']); - $this->assertEquals(['https://katalog.slub-dresden.de/id/0-1703800435'], $titledata['dvlinks_reference']); + self::assertEquals(['Odol-Mundwasser, 3 Werbespots'], $titledata['title']); + self::assertEquals(['24'], $titledata['frame_rate']); + self::assertEquals(['Sächsische Landesbibliothek - Staats- und Universitätsbibliothek Dresden'], $titledata['dvrights_owner']); + self::assertEquals(['https://katalog.slub-dresden.de/id/0-1703800435'], $titledata['dvlinks_reference']); - $this->assertEquals([ + self::assertEquals([ 'DMDLOG_0000' => $doc->mdSec['DMDLOG_0000'], ], $doc->dmdSec); } @@ -60,10 +60,10 @@ public function canReadFileMetadata() $doc = $this->doc('av_beispiel.xml'); $thumbsMeta = $doc->getMetadata('FILE_0000_THUMBS', 20000); - $this->assertEquals($thumbsMeta, []); + self::assertEquals($thumbsMeta, []); $videoMeta = $doc->getMetadata('FILE_0000_DEFAULT', 20000); - $this->assertArrayMatches([ + self::assertArrayMatches([ 'frame_rate' => ['24'], ], $videoMeta); } @@ -77,7 +77,7 @@ public function canGetLogicalStructure() $toc = $doc->tableOfContents[0] ?? []; - $this->assertArrayMatches([ + self::assertArrayMatches([ 'dmdId' => 'DMDLOG_0000', 'admId' => 'AMD', 'children' => [ @@ -115,8 +115,8 @@ public function doesNotOverwriteFirstDmdSec() $titledata = $doc->getTitledata(20000); $toc = $doc->tableOfContents[0] ?? []; - $this->assertEquals('DMDLOG_0000 DMDLOG_0000b', $toc['dmdId']); // TODO: Do we want the raw (non-split) value here? - $this->assertEquals('Test Value in DMDLOG_0000', $titledata['test_value'][0]); + self::assertEquals('DMDLOG_0000 DMDLOG_0000b', $toc['dmdId']); // TODO: Do we want the raw (non-split) value here? + self::assertEquals('Test Value in DMDLOG_0000', $titledata['test_value'][0]); } /** @@ -128,15 +128,15 @@ public function returnsEmptyMetadataWhenNoDmdSec() // DMD and AMD works $metadata = $doc->getMetadata('LOG_0000', 20000); - $this->assertEquals('Test Value in DMDLOG_0000', $metadata['test_value'][0]); + self::assertEquals('Test Value in DMDLOG_0000', $metadata['test_value'][0]); // DMD only works $metadata = $doc->getMetadata('LOG_0001', 20000); - $this->assertEquals(['Test Value in DMDLOG_0000b'], $metadata['test_value']); + self::assertEquals(['Test Value in DMDLOG_0000b'], $metadata['test_value']); // AMD only does not work $metadata = $doc->getMetadata('LOG_0002', 20000); - $this->assertEquals([], $metadata); + self::assertEquals([], $metadata); } /** @@ -147,7 +147,7 @@ public function canGetDownloadLocation() $doc = $this->doc('two_dmdsec.xml'); $correct = $doc->getDownloadLocation('FILE_0000_DOWNLOAD'); - $this->assertEquals('https://example.com/download?&CVT=jpeg', $correct); + self::assertEquals('https://example.com/download?&CVT=jpeg', $correct); /* * The method `getDownloadLocation` should return a string, but returns null in some cases. @@ -166,10 +166,10 @@ public function canGetFileLocation() $doc = $this->doc('two_dmdsec.xml'); $correct = $doc->getFileLocation('FILE_0000_DEFAULT'); - $this->assertEquals('https://digital.slub-dresden.de/data/kitodo/1703800435/video.mov', $correct); + self::assertEquals('https://digital.slub-dresden.de/data/kitodo/1703800435/video.mov', $correct); $incorrect = $doc->getFileLocation('ID_DOES_NOT_EXIST'); - $this->assertEquals('', $incorrect); + self::assertEquals('', $incorrect); } /** @@ -180,10 +180,10 @@ public function canGetFileMimeType() $doc = $this->doc('two_dmdsec.xml'); $correct = $doc->getFileMimeType('FILE_0000_DEFAULT'); - $this->assertEquals('video/quicktime', $correct); + self::assertEquals('video/quicktime', $correct); $incorrect = $doc->getFileMimeType('ID_DOES_NOT_EXIST'); - $this->assertEquals('', $incorrect); + self::assertEquals('', $incorrect); } // FIXME: Method getPhysicalPage does not work as expected @@ -196,7 +196,7 @@ public function canGetPhysicalPage() // pass orderlabel and retrieve order $physicalPage = $doc->getPhysicalPage('1'); - $this->assertEquals(1, $physicalPage); + self::assertEquals(1, $physicalPage); } /** @@ -207,10 +207,10 @@ public function canGetTitle() $doc = $this->doc('mets_with_pages.xml'); $correct = $doc->getTitle(1001); - $this->assertEquals('10 Keyboard pieces - Go. S. 658', $correct); + self::assertEquals('10 Keyboard pieces - Go. S. 658', $correct); $incorrect = $doc->getTitle(1234); - $this->assertEquals('', $incorrect); + self::assertEquals('', $incorrect); } /** @@ -224,10 +224,10 @@ public function canGetFullText() $expected = ' '; - $this->assertEquals($expected, $fulltext); + self::assertEquals($expected, $fulltext); $incorrect = $doc->getFullText('ID_DOES_NOT_EXIST'); - $this->assertEquals('', $incorrect); + self::assertEquals('', $incorrect); } /** @@ -238,9 +238,9 @@ public function canGetStructureDepth() $doc = $this->doc('mets_with_pages.xml'); $correct = $doc->getStructureDepth('LOG_0001'); - $this->assertEquals(3, $correct); + self::assertEquals(3, $correct); $incorrect = $doc->getStructureDepth('ID_DOES_NOT_EXIST'); - $this->assertEquals(0, $incorrect); + self::assertEquals(0, $incorrect); } } diff --git a/Tests/Functional/Common/SolrIndexingTest.php b/Tests/Functional/Common/SolrIndexingTest.php index 404a27416..aa29ccb63 100644 --- a/Tests/Functional/Common/SolrIndexingTest.php +++ b/Tests/Functional/Common/SolrIndexingTest.php @@ -12,13 +12,9 @@ use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; use TYPO3\CMS\Core\Core\Bootstrap; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; class SolrIndexingTest extends FunctionalTestCase { - /** @var PersistenceManager */ - protected $persistenceManager; - /** @var CollectionRepository */ protected $collectionRepository; @@ -35,8 +31,6 @@ public function setUp(): void // Needed for Indexer::add, which uses the language service Bootstrap::initializeLanguageObject(); - $this->persistenceManager = $this->objectManager->get(PersistenceManager::class); - $this->collectionRepository = $this->initializeRepository(CollectionRepository::class, 20000); $this->documentRepository = $this->initializeRepository(DocumentRepository::class, 20000); $this->solrCoreRepository = $this->initializeRepository(SolrCoreRepository::class, 20000); @@ -53,13 +47,13 @@ public function canCreateCore() { $coreName = uniqid('testCore'); $solr = Solr::getInstance($coreName); - $this->assertNull($solr->core); + self::assertNull($solr->core); $actualCoreName = Solr::createCore($coreName); - $this->assertEquals($actualCoreName, $coreName); + self::assertEquals($actualCoreName, $coreName); $solr = Solr::getInstance($coreName); - $this->assertNotNull($solr->core); + self::assertNotNull($solr->core); } /** @@ -77,7 +71,7 @@ public function canIndexAndSearchDocument() $document->setCurrentDocument($doc); $indexingSuccessful = Indexer::add($document, $this->documentRepository); - $this->assertTrue($indexingSuccessful); + self::assertTrue($indexingSuccessful); $solrSettings = [ 'solrcore' => $core->solr->core, @@ -86,35 +80,35 @@ public function canIndexAndSearchDocument() $solrSearch = $this->documentRepository->findSolrByCollection(null, $solrSettings, ['query' => '*']); $solrSearch->getQuery()->execute(); - $this->assertEquals(1, count($solrSearch)); - $this->assertEquals(15, $solrSearch->getNumFound()); + self::assertEquals(1, count($solrSearch)); + self::assertEquals(15, $solrSearch->getNumFound()); // Check that the title stored in Solr matches the title of database entry $docTitleInSolr = false; foreach ($solrSearch->getSolrResults()['documents'] as $solrDoc) { if ($solrDoc['toplevel'] && intval($solrDoc['uid']) === intval($document->getUid())) { - $this->assertEquals($document->getTitle(), $solrDoc['title']); + self::assertEquals($document->getTitle(), $solrDoc['title']); $docTitleInSolr = true; break; } } - $this->assertTrue($docTitleInSolr); + self::assertTrue($docTitleInSolr); // $solrSearch[0] is hydrated from the database model - $this->assertEquals($document->getTitle(), $solrSearch[0]['title']); + self::assertEquals($document->getTitle(), $solrSearch[0]['title']); // Test ArrayAccess and Iterator implementation - $this->assertTrue(isset($solrSearch[0])); - $this->assertFalse(isset($solrSearch[1])); - $this->assertNull($solrSearch[1]); - $this->assertFalse(isset($solrSearch[$document->getUid()])); + self::assertTrue(isset($solrSearch[0])); + self::assertFalse(isset($solrSearch[1])); + self::assertNull($solrSearch[1]); + self::assertFalse(isset($solrSearch[$document->getUid()])); $iter = []; foreach ($solrSearch as $key => $value) { $iter[$key] = $value; } - $this->assertEquals(1, count($iter)); - $this->assertEquals($solrSearch[0], $iter[0]); + self::assertEquals(1, count($iter)); + self::assertEquals($solrSearch[0], $iter[0]); } /** @@ -143,10 +137,10 @@ public function canSearchInCollections() $musikSearch = $this->documentRepository->findSolrByCollection($musik, $settings, []); $dresdnerHefteSearch = $this->documentRepository->findSolrByCollection($dresdnerHefte, $settings, []); $multiCollectionSearch = $this->documentRepository->findSolrByCollection($collections, $settings, []); - $this->assertGreaterThanOrEqual(1, $musikSearch->getNumFound()); - $this->assertGreaterThanOrEqual(1, $dresdnerHefteSearch->getNumFound()); - $this->assertEquals('533223312LOG_0000', $dresdnerHefteSearch->getSolrResults()['documents'][0]['id']); - $this->assertEquals( + self::assertGreaterThanOrEqual(1, $musikSearch->getNumFound()); + self::assertGreaterThanOrEqual(1, $dresdnerHefteSearch->getNumFound()); + self::assertEquals('533223312LOG_0000', $dresdnerHefteSearch->getSolrResults()['documents'][0]['id']); + self::assertEquals( // Assuming there's no overlap $dresdnerHefteSearch->getNumFound() + $musikSearch->getNumFound(), $multiCollectionSearch->getNumFound() @@ -155,7 +149,7 @@ public function canSearchInCollections() // With query: List all results $metadataSearch = $this->documentRepository->findSolrByCollection($dresdnerHefte, $settings, ['query' => 'Dresden']); $fulltextSearch = $this->documentRepository->findSolrByCollection($dresdnerHefte, $settings, ['query' => 'Dresden', 'fulltext' => '1']); - $this->assertGreaterThan($metadataSearch->getNumFound(), $fulltextSearch->getNumFound()); + self::assertGreaterThan($metadataSearch->getNumFound(), $fulltextSearch->getNumFound()); } protected function createSolrCore(): object diff --git a/Tests/Functional/FunctionalTestCase.php b/Tests/Functional/FunctionalTestCase.php index 869d9a5b1..21004e979 100644 --- a/Tests/Functional/FunctionalTestCase.php +++ b/Tests/Functional/FunctionalTestCase.php @@ -10,6 +10,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; /** @@ -60,9 +61,16 @@ class FunctionalTestCase extends \TYPO3\TestingFramework\Core\Functional\Functio */ protected $disableJsonWrappedResponse = false; - /** @var ObjectManager */ + /** + * @var ObjectManager + */ protected $objectManager; + /** + * @var PersistenceManager + */ + protected $persistenceManager; + /** * @var string */ @@ -91,6 +99,7 @@ public function setUp(): void parent::setUp(); $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); + $this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); $this->baseUrl = 'http://web:8000/public/typo3temp/var/tests/functional-' . $this->identifier . '/'; $this->httpClient = new HttpClient([ @@ -188,7 +197,7 @@ protected function initLanguageService(string $locale) $GLOBALS['LANG'] = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageServiceFactory::class)->create($locale); } else { $typo3MajorVersion = VersionNumberUtility::convertVersionStringToArray(VersionNumberUtility::getCurrentTypo3Version())['version_main']; - $this->assertEquals(9, $typo3MajorVersion); + self::assertEquals(9, $typo3MajorVersion); $lang = new LanguageService(); $lang->init($locale); @@ -201,6 +210,6 @@ protected function initLanguageService(string $locale) */ protected function assertArrayMatches(array $sub, array $super, string $message = '') { - $this->assertEquals($sub, ArrayUtility::intersectRecursive($super, $sub), $message); + self::assertEquals($sub, ArrayUtility::intersectRecursive($super, $sub), $message); } } diff --git a/Tests/Functional/Repository/CollectionRepositoryTest.php b/Tests/Functional/Repository/CollectionRepositoryTest.php index 9e64cfd37..263dec6c6 100644 --- a/Tests/Functional/Repository/CollectionRepositoryTest.php +++ b/Tests/Functional/Repository/CollectionRepositoryTest.php @@ -41,16 +41,16 @@ public function setUp(): void public function canFindAllByUids(): void { $collections = $this->collectionRepository->findAllByUids([1101, 1102]); - $this->assertNotNull($collections); - $this->assertInstanceOf(QueryResult::class, $collections); + self::assertNotNull($collections); + self::assertInstanceOf(QueryResult::class, $collections); $collectionsByLabel = []; foreach ($collections as $collection) { $collectionsByLabel[$collection->getLabel()] = $collection; } - $this->assertArrayHasKey('Musik', $collectionsByLabel); - $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + self::assertArrayHasKey('Musik', $collectionsByLabel); + self::assertArrayHasKey('Collection with single document', $collectionsByLabel); } /** @@ -60,18 +60,18 @@ public function canFindAllByUids(): void public function canGetCollectionForMetadata(): void { $collections = $this->collectionRepository->getCollectionForMetadata("20000"); - $this->assertNotNull($collections); - $this->assertInstanceOf(QueryResult::class, $collections); + self::assertNotNull($collections); + self::assertInstanceOf(QueryResult::class, $collections); $collectionsByLabel = []; foreach ($collections as $collection) { $collectionsByLabel[$collection->getLabel()] = $collection; } - $this->assertArrayHasKey('Musik', $collectionsByLabel); - $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); - $this->assertArrayHasKey('Geschichte', $collectionsByLabel); - $this->assertArrayHasKey('Bildende Kunst', $collectionsByLabel); + self::assertArrayHasKey('Musik', $collectionsByLabel); + self::assertArrayHasKey('Collection with single document', $collectionsByLabel); + self::assertArrayHasKey('Geschichte', $collectionsByLabel); + self::assertArrayHasKey('Bildende Kunst', $collectionsByLabel); } /** @@ -81,8 +81,8 @@ public function canGetCollectionForMetadata(): void protected function findCollectionsBySettings($settings): array { $collections = $this->collectionRepository->findCollectionsBySettings($settings); - $this->assertNotNull($collections); - $this->assertInstanceOf(QueryResult::class, $collections); + self::assertNotNull($collections); + self::assertInstanceOf(QueryResult::class, $collections); $collectionsByLabel = []; foreach ($collections as $collection) { @@ -99,9 +99,9 @@ protected function findCollectionsBySettings($settings): array public function canFindCollectionsBySettings(): void { $collectionsByLabel = $this->findCollectionsBySettings(['collections' => '1101, 1102']); - $this->assertCount(2, $collectionsByLabel); - $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); - $this->assertArrayHasKey('Musik', $collectionsByLabel); + self::assertCount(2, $collectionsByLabel); + self::assertArrayHasKey('Collection with single document', $collectionsByLabel); + self::assertArrayHasKey('Musik', $collectionsByLabel); $collectionsByLabel = $this->findCollectionsBySettings( [ @@ -109,30 +109,30 @@ public function canFindCollectionsBySettings(): void 'show_userdefined' => true ] ); - $this->assertCount(2, $collectionsByLabel); - $this->assertArrayHasKey('Geschichte', $collectionsByLabel); - $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + self::assertCount(2, $collectionsByLabel); + self::assertArrayHasKey('Geschichte', $collectionsByLabel); + self::assertArrayHasKey('Collection with single document', $collectionsByLabel); $collectionsByLabel = $this->findCollectionsBySettings(['show_userdefined' => true]); - $this->assertCount(4, $collectionsByLabel); - $this->assertArrayHasKey('Musik', $collectionsByLabel); - $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); - $this->assertArrayHasKey('Geschichte', $collectionsByLabel); - $this->assertArrayHasKey('Bildende Kunst', $collectionsByLabel); - $this->assertEquals( + self::assertCount(4, $collectionsByLabel); + self::assertArrayHasKey('Musik', $collectionsByLabel); + self::assertArrayHasKey('Collection with single document', $collectionsByLabel); + self::assertArrayHasKey('Geschichte', $collectionsByLabel); + self::assertArrayHasKey('Bildende Kunst', $collectionsByLabel); + self::assertEquals( 'Bildende Kunst, Collection with single document, Geschichte, Musik', implode(', ', array_keys($collectionsByLabel)) ); $collectionsByLabel = $this->findCollectionsBySettings(['show_userdefined' => false]); - $this->assertCount(2, $collectionsByLabel); - $this->assertArrayHasKey('Musik', $collectionsByLabel); - $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + self::assertCount(2, $collectionsByLabel); + self::assertArrayHasKey('Musik', $collectionsByLabel); + self::assertArrayHasKey('Collection with single document', $collectionsByLabel); $collectionsByLabel = $this->findCollectionsBySettings(['hideEmptyOaiNames' => true]); - $this->assertCount(2, $collectionsByLabel); - $this->assertArrayHasKey('Musik', $collectionsByLabel); - $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); + self::assertCount(2, $collectionsByLabel); + self::assertArrayHasKey('Musik', $collectionsByLabel); + self::assertArrayHasKey('Collection with single document', $collectionsByLabel); $collectionsByLabel = $this->findCollectionsBySettings( [ @@ -140,10 +140,10 @@ public function canFindCollectionsBySettings(): void 'show_userdefined' => true ] ); - $this->assertCount(3, $collectionsByLabel); - $this->assertArrayHasKey('Musik', $collectionsByLabel); - $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); - $this->assertArrayHasKey('Geschichte', $collectionsByLabel); + self::assertCount(3, $collectionsByLabel); + self::assertArrayHasKey('Musik', $collectionsByLabel); + self::assertArrayHasKey('Collection with single document', $collectionsByLabel); + self::assertArrayHasKey('Geschichte', $collectionsByLabel); $collectionsByLabel = $this->findCollectionsBySettings( [ @@ -151,11 +151,11 @@ public function canFindCollectionsBySettings(): void 'show_userdefined' => true ] ); - $this->assertCount(4, $collectionsByLabel); - $this->assertArrayHasKey('Musik', $collectionsByLabel); - $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); - $this->assertArrayHasKey('Geschichte', $collectionsByLabel); - $this->assertArrayHasKey('Bildende Kunst', $collectionsByLabel); + self::assertCount(4, $collectionsByLabel); + self::assertArrayHasKey('Musik', $collectionsByLabel); + self::assertArrayHasKey('Collection with single document', $collectionsByLabel); + self::assertArrayHasKey('Geschichte', $collectionsByLabel); + self::assertArrayHasKey('Bildende Kunst', $collectionsByLabel); $collectionsByLabel = $this->findCollectionsBySettings( [ @@ -166,9 +166,9 @@ public function canFindCollectionsBySettings(): void ] ); - $this->assertCount(2, $collectionsByLabel); - $this->assertArrayHasKey('Collection with single document', $collectionsByLabel); - $this->assertArrayHasKey('Geschichte', $collectionsByLabel); + self::assertCount(2, $collectionsByLabel); + self::assertArrayHasKey('Collection with single document', $collectionsByLabel); + self::assertArrayHasKey('Geschichte', $collectionsByLabel); } /** @@ -181,20 +181,20 @@ public function canGetIndexNameForSolr(): void ['show_userdefined' => true, 'storagePid' => '20000'], 'history' ); $result = $indexName->fetchAllAssociative(); - $this->assertEquals(1, $indexName->rowCount()); - $this->assertEquals('Geschichte', $result[0]['index_name']); - $this->assertEquals('*:*', $result[0]['index_query']); - $this->assertEquals('1103', $result[0]['uid']); + self::assertEquals(1, $indexName->rowCount()); + self::assertEquals('Geschichte', $result[0]['index_name']); + self::assertEquals('*:*', $result[0]['index_query']); + self::assertEquals('1103', $result[0]['uid']); $indexName = $this->collectionRepository->getIndexNameForSolr( ['show_userdefined' => false, 'storagePid' => '20000'], 'history' ); - $this->assertEquals(0, $indexName->rowCount()); + self::assertEquals(0, $indexName->rowCount()); $indexName = $this->collectionRepository->getIndexNameForSolr( ['show_userdefined' => false, 'storagePid' => '20000'], 'collection-with-single-document' ); - $this->assertEquals(1, $indexName->rowCount()); - $this->assertEquals('collection-with-single-document', $indexName->fetchOne()); + self::assertEquals(1, $indexName->rowCount()); + self::assertEquals('collection-with-single-document', $indexName->fetchOne()); } } diff --git a/Tests/Functional/Repository/DocumentRepositoryTest.php b/Tests/Functional/Repository/DocumentRepositoryTest.php index 41e481ac9..3bc4a2686 100644 --- a/Tests/Functional/Repository/DocumentRepositoryTest.php +++ b/Tests/Functional/Repository/DocumentRepositoryTest.php @@ -32,13 +32,13 @@ public function setUp(): void public function canRetrieveDocument(): void { $document = $this->documentRepository->findByUid(1001); - $this->assertNotNull($document); - $this->assertEquals('METS', $document->getDocumentFormat()); - $this->assertNotEmpty($document->getTitle()); - $this->assertEquals('Default Library', $document->getOwner()->getLabel()); + self::assertNotNull($document); + self::assertEquals('METS', $document->getDocumentFormat()); + self::assertNotEmpty($document->getTitle()); + self::assertEquals('Default Library', $document->getOwner()->getLabel()); $doc = AbstractDocument::getInstance($document->getLocation()); - $this->assertInstanceOf(MetsDocument::class, $doc); + self::assertInstanceOf(MetsDocument::class, $doc); } /** @@ -47,8 +47,8 @@ public function canRetrieveDocument(): void public function canFindOldestDocument(): void { $document = $this->documentRepository->findOldestDocument(); - $this->assertNotNull($document); - $this->assertEquals(1002, $document->getUid()); + self::assertNotNull($document); + self::assertEquals(1002, $document->getUid()); } /** @@ -58,13 +58,13 @@ public function canGetCollectionsOfDocument(): void { $document = $this->documentRepository->findByUid(1001); $collections = $document->getCollections(); - $this->assertInstanceOf(LazyObjectStorage::class, $collections); + self::assertInstanceOf(LazyObjectStorage::class, $collections); $collectionsByLabel = []; foreach ($collections as $collection) { $collectionsByLabel[$collection->getLabel()] = $collection; } - $this->assertArrayHasKey('Musik', $collectionsByLabel); + self::assertArrayHasKey('Musik', $collectionsByLabel); } } diff --git a/Tests/Functional/Repository/MailRepositoryTest.php b/Tests/Functional/Repository/MailRepositoryTest.php index dd983cc31..c9c91341d 100644 --- a/Tests/Functional/Repository/MailRepositoryTest.php +++ b/Tests/Functional/Repository/MailRepositoryTest.php @@ -41,16 +41,16 @@ public function setUp(): void public function canFindAllWithPid(): void { $mails = $this->mailRepository->findAllWithPid(30000); - $this->assertNotNull($mails); - $this->assertInstanceOf(QueryResult::class, $mails); + self::assertNotNull($mails); + self::assertInstanceOf(QueryResult::class, $mails); $mailByLabel = []; foreach ($mails as $mail) { $mailByLabel[$mail->getLabel()] = $mail; } - $this->assertEquals(2, $mails->count()); - $this->assertArrayHasKey('Mail-Label-1', $mailByLabel); - $this->assertArrayHasKey('Mail-Label-2', $mailByLabel); + self::assertEquals(2, $mails->count()); + self::assertArrayHasKey('Mail-Label-1', $mailByLabel); + self::assertArrayHasKey('Mail-Label-2', $mailByLabel); } } diff --git a/Tests/Functional/Repository/MetatdataRepositoryTest.php b/Tests/Functional/Repository/MetatdataRepositoryTest.php index d56467bdd..cb09cfdac 100644 --- a/Tests/Functional/Repository/MetatdataRepositoryTest.php +++ b/Tests/Functional/Repository/MetatdataRepositoryTest.php @@ -42,8 +42,8 @@ public function setUp(): void protected function findBySettings($settings) { $metadata = $this->metadataRepository->findBySettings($settings); - $this->assertNotNull($metadata); - $this->assertInstanceOf(QueryResult::class, $metadata); + self::assertNotNull($metadata); + self::assertInstanceOf(QueryResult::class, $metadata); $metadataByLabel = []; foreach ($metadata as $mdata) { @@ -60,22 +60,22 @@ protected function findBySettings($settings) public function canFindBySettings(): void { $metadataByLabel = $this->findBySettings([]); - $this->assertCount(6, $metadataByLabel); - $this->assertEquals( + self::assertCount(6, $metadataByLabel); + self::assertEquals( 'Ort, Untertitel, Autor, Institution, Sammlungen, Titel', implode(', ', array_keys($metadataByLabel)) ); $metadataByLabel = $this->findBySettings(['is_listed' => true]); - $this->assertCount(3, $metadataByLabel); - $this->assertEquals( + self::assertCount(3, $metadataByLabel); + self::assertEquals( 'Autor, Institution, Titel', implode(', ', array_keys($metadataByLabel)) ); $metadataByLabel = $this->findBySettings(['is_sortable' => true]); - $this->assertCount(4, $metadataByLabel); - $this->assertEquals( + self::assertCount(4, $metadataByLabel); + self::assertEquals( 'Ort, Untertitel, Autor, Titel', implode(', ', array_keys($metadataByLabel)) ); @@ -86,8 +86,8 @@ public function canFindBySettings(): void 'is_listed' => true ] ); - $this->assertCount(2, $metadataByLabel); - $this->assertEquals( + self::assertCount(2, $metadataByLabel); + self::assertEquals( 'Autor, Titel', implode(', ', array_keys($metadataByLabel)) ); diff --git a/Tests/Functional/Repository/TokenRepositoryTest.php b/Tests/Functional/Repository/TokenRepositoryTest.php index 0a2fac65d..e8e78bb5e 100644 --- a/Tests/Functional/Repository/TokenRepositoryTest.php +++ b/Tests/Functional/Repository/TokenRepositoryTest.php @@ -13,7 +13,6 @@ use Kitodo\Dlf\Domain\Repository\TokenRepository; use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; -use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; class TokenRepositoryTest extends FunctionalTestCase { @@ -22,17 +21,10 @@ class TokenRepositoryTest extends FunctionalTestCase */ protected $tokenRepository; - /** - * @var PersistenceManager - */ - protected $persistenceManager; - public function setUp(): void { parent::setUp(); - $this->persistenceManager = $this->objectManager->get(PersistenceManager::class); - $this->tokenRepository = $this->initializeRepository( TokenRepository::class, 20000 @@ -84,14 +76,14 @@ public function deleteExpiredTokens(): void $tokens = $this->tokenRepository->findAll(); - $this->assertEquals(2, $tokens->count()); + self::assertEquals(2, $tokens->count()); $tokenUids = []; foreach ($tokens as $token) { $tokenUids[$token->getUid()] = $token; } - $this->assertArrayHasKey('101', $tokenUids); - $this->assertArrayHasKey('103', $tokenUids); + self::assertArrayHasKey('101', $tokenUids); + self::assertArrayHasKey('103', $tokenUids); } } diff --git a/Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php b/Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php index e82a37000..26c45a011 100644 --- a/Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php @@ -48,7 +48,7 @@ public function renderingContextCallsGetVariableProviderAdd(): void ); $view->render(); - $this->assertEquals( + self::assertEquals( [ 'key' => ['wrap' => ''], 'value' => ['required' => 1, 'wrap' => '
  • |
  • '], diff --git a/Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php b/Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php index 30191559a..af9cdf16a 100644 --- a/Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php @@ -54,7 +54,7 @@ public function renderWithStdWrap(): void ' ); - $this->assertXmlStringEqualsXmlString( + self::assertXmlStringEqualsXmlString( '