From 5a833a41d700db70c04a6048652b001bf2c714bc Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Tue, 18 Jun 2024 18:54:11 +0200 Subject: [PATCH 1/9] [BUGFIX] Fix for potential security risk related to file include (#1261) Co-authored-by: Sebastian Meyer --- .../Backend/NewTenantController.php | 46 +- Resources/Private/Data/FormatDefaults.json | 32 + Resources/Private/Data/FormatDefaults.php | 44 - Resources/Private/Data/MetadataDefaults.json | 692 ++++++++++++++ Resources/Private/Data/MetadataDefaults.php | 846 ------------------ Resources/Private/Data/StructureDefaults.json | 370 ++++++++ Resources/Private/Data/StructureDefaults.php | 384 -------- 7 files changed, 1131 insertions(+), 1283 deletions(-) create mode 100644 Resources/Private/Data/FormatDefaults.json delete mode 100644 Resources/Private/Data/FormatDefaults.php create mode 100644 Resources/Private/Data/MetadataDefaults.json delete mode 100644 Resources/Private/Data/MetadataDefaults.php create mode 100644 Resources/Private/Data/StructureDefaults.json delete mode 100644 Resources/Private/Data/StructureDefaults.php diff --git a/Classes/Controller/Backend/NewTenantController.php b/Classes/Controller/Backend/NewTenantController.php index a913db121..2b5d0b64a 100644 --- a/Classes/Controller/Backend/NewTenantController.php +++ b/Classes/Controller/Backend/NewTenantController.php @@ -22,11 +22,12 @@ use Kitodo\Dlf\Domain\Repository\StructureRepository; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\BackendTemplateView; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Exception\SiteNotFoundException; use TYPO3\CMS\Core\Localization\LocalizationFactory; +use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Site\Entity\NullSite; use TYPO3\CMS\Core\Site\SiteFinder; -use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; @@ -179,7 +180,7 @@ protected function initializeAction(): void public function addFormatAction(): void { // Include formats definition file. - $formatsDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/FormatDefaults.php'); + $formatsDefaults = $this->getRecords('Format'); $frameworkConfiguration = $this->configurationManager->getConfiguration($this->configurationManager::CONFIGURATION_TYPE_FRAMEWORK); // tx_dlf_formats are stored on PID = 0 @@ -221,7 +222,7 @@ public function addFormatAction(): void public function addMetadataAction(): void { // Include metadata definition file. - $metadataDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/MetadataDefaults.php'); + $metadataDefaults = $this->getRecords('Metadata'); // load language file in own array $metadataLabels = $this->languageFactory->getParsedData('EXT:dlf/Resources/Private/Language/locallang_metadata.xlf', $this->siteLanguages[0]->getTypo3Language()); @@ -344,7 +345,7 @@ public function addSolrCoreAction(): void public function addStructureAction(): void { // Include structure definition file. - $structureDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/StructureDefaults.php'); + $structureDefaults = $this->getRecords('Structure'); // load language file in own array $structureLabels = $this->languageFactory->getParsedData('EXT:dlf/Resources/Private/Language/locallang_structure.xlf', $this->siteLanguages[0]->getTypo3Language()); @@ -426,15 +427,15 @@ public function indexAction(): void $this->forward('error'); } - $formatsDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/FormatDefaults.php'); + $formatsDefaults = $this->getRecords('Format'); $recordInfos['formats']['numCurrent'] = $this->formatRepository->countAll(); $recordInfos['formats']['numDefault'] = count($formatsDefaults); - $structuresDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/StructureDefaults.php'); + $structuresDefaults = $this->getRecords('Structure'); $recordInfos['structures']['numCurrent'] = $this->structureRepository->countByPid($this->pid); $recordInfos['structures']['numDefault'] = count($structuresDefaults); - $metadataDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/MetadataDefaults.php'); + $metadataDefaults = $this->getRecords('Metadata'); $recordInfos['metadata']['numCurrent'] = $this->metadataRepository->countByPid($this->pid); $recordInfos['metadata']['numDefault'] = count($metadataDefaults); @@ -459,7 +460,7 @@ public function errorAction(): void /** * Get language label for given key and language. * - * @access protected + * @access private * * @param string $index * @param string $lang @@ -467,7 +468,7 @@ public function errorAction(): void * * @return string */ - protected function getLLL(string $index, string $lang, array $langArray): string + private function getLLL(string $index, string $lang, array $langArray): string { if (isset($langArray[$lang][$index][0]['target'])) { return $langArray[$lang][$index][0]['target']; @@ -477,4 +478,31 @@ protected function getLLL(string $index, string $lang, array $langArray): string return 'Missing translation for ' . $index; } } + + /** + * Get records from file for given record type. + * + * @access private + * + * @param string $recordType + * + * @return array + */ + private function getRecords(string $recordType): array + { + $filePath = Environment::getPublicPath() . '/typo3conf/ext/dlf/Resources/Private/Data/' . $recordType . 'Defaults.json'; + + $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); + $fileObject = $resourceFactory->getFileObjectFromCombinedIdentifier($filePath); + + if ($fileObject !== null) { + $fileContents = $fileObject->getContents(); + $records = json_decode($fileContents, true); + + if (json_last_error() === JSON_ERROR_NONE) { + return $records; + } + } + return []; + } } diff --git a/Resources/Private/Data/FormatDefaults.json b/Resources/Private/Data/FormatDefaults.json new file mode 100644 index 000000000..a8493eb4e --- /dev/null +++ b/Resources/Private/Data/FormatDefaults.json @@ -0,0 +1,32 @@ +{ + "MODS": { + "root": "mods", + "namespace": "http://www.loc.gov/mods/v3", + "class": "Kitodo\\Dlf\\Format\\Mods" + }, + "TEIHDR": { + "root": "teiHeader", + "namespace": "http://www.tei-c.org/ns/1.0", + "class": "Kitodo\\Dlf\\Format\\TeiHeader" + }, + "ALTO": { + "root": "alto", + "namespace": "http://www.loc.gov/standards/alto/ns-v2#", + "class": "Kitodo\\Dlf\\Format\\Alto" + }, + "IIIF1": { + "root": "IIIF1", + "namespace": "http://www.shared-canvas.org/ns/context.json", + "class": "" + }, + "IIIF2": { + "root": "IIIF2", + "namespace": "http://iiif.io/api/presentation/2/context.json", + "class": "" + }, + "IIIF3": { + "root": "IIIF3", + "namespace": "http://iiif.io/api/presentation/3/context.json", + "class": "" + } +} diff --git a/Resources/Private/Data/FormatDefaults.php b/Resources/Private/Data/FormatDefaults.php deleted file mode 100644 index 30725a78e..000000000 --- a/Resources/Private/Data/FormatDefaults.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * 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. - */ - -return [ - 'MODS' => [ - 'root' => 'mods', - 'namespace' => 'http://www.loc.gov/mods/v3', - 'class' => Kitodo\Dlf\Format\Mods::class, - ], - 'TEIHDR' => [ - 'root' => 'teiHeader', - 'namespace' => 'http://www.tei-c.org/ns/1.0', - 'class' => Kitodo\Dlf\Format\TeiHeader::class, - ], - 'ALTO' => [ - 'root' => 'alto', - 'namespace' => 'http://www.loc.gov/standards/alto/ns-v2#', - 'class' => Kitodo\Dlf\Format\Alto::class, - ], - 'IIIF1' => [ - 'root' => 'IIIF1', - 'namespace' => 'http://www.shared-canvas.org/ns/context.json', - 'class' => '', - ], - 'IIIF2' => [ - 'root' => 'IIIF2', - 'namespace' => 'http://iiif.io/api/presentation/2/context.json', - 'class' => '', - ], - 'IIIF3' => [ - 'root' => 'IIIF3', - 'namespace' => 'http://iiif.io/api/presentation/3/context.json', - 'class' => '', - ], -]; diff --git a/Resources/Private/Data/MetadataDefaults.json b/Resources/Private/Data/MetadataDefaults.json new file mode 100644 index 000000000..a92b9ae95 --- /dev/null +++ b/Resources/Private/Data/MetadataDefaults.json @@ -0,0 +1,692 @@ +{ + "type": { + "format": [ + { + "format_root": "IIIF2", + "xpath": "$.metadata.[?(@.label=='Manifest Type')].value", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 1, + "index_indexed": 0, + "index_boost": 1.00, + "is_sortable": 1, + "is_facet": 1, + "is_listed": 1, + "index_autocomplete": 0, + "sorting": 1 + }, + "title": { + "format": [ + { + "format_root": "mods", + "xpath": "concat(./mods:titleInfo/mods:nonSort,' ',./mods:titleInfo/mods:title)", + "xpath_sorting": "./mods:titleInfo/mods:title" + }, + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:head/teihdr:note[@type=\"caption\"]", + "xpath_sorting": "" + }, + { + "format_root": "IIIF2", + "xpath": "$[label]", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap = \nvalue.required = 1\nvalue.wrap = ", + "index_tokenized": 1, + "index_stored": 1, + "index_indexed": 1, + "index_boost": 2.00, + "is_sortable": 1, + "is_facet": 0, + "is_listed": 1, + "index_autocomplete": 1, + "sorting": 2 + }, + "volume": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:part/mods:detail/mods:number", + "xpath_sorting": "./mods:part[@type=\"host\"]/@order" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 1, + "index_indexed": 0, + "index_boost": 1.00, + "is_sortable": 1, + "is_facet": 0, + "is_listed": 1, + "index_autocomplete": 0, + "sorting": 3 + }, + "date": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:originInfo/*[@encoding=\"iso8601\" or @encoding=\"w3cdtf\"][@keyDate=\"yes\"]", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 1, + "index_indexed": 1, + "index_boost": 1.00, + "is_sortable": 1, + "is_facet": 0, + "is_listed": 1, + "index_autocomplete": 0, + "sorting": 4 + }, + "author": { + "format": [ + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:head/teihdr:name", + "xpath_sorting": "" + }, + { + "format_root": "IIIF2", + "xpath": "$.metadata.[?(@.label=='Author')].value", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap = \nvalue.required = 1\nvalue.split.token.char = 31\nvalue.split.cObjNum = 1\nvalue.split.1.1 = CASE\nvalue.split.1.1.key.data = register:SPLIT_COUNT\nvalue.split.1.1.0 = LOAD_REGISTER\nvalue.split.1.1.0.tx_dlf_metadata_author_name.current = 1\nvalue.split.1.1.1 = LOAD_REGISTER\nvalue.split.1.1.1.tx_dlf_metadata_author_uri.current = 1\nvalue.postCObject = TEXT\nvalue.postCObject.value = {register:tx_dlf_metadata_author_name}\nvalue.postCObject.value.insertData = 1\nvalue.postCObject.value.stdWrap.typolink.parameter = {register:tx_dlf_metadata_author_uri} _blank external\nvalue.postCObject.value.stdWrap.typolink.parameter.insertData = 1\nvalue.postCObject.value.stdWrap.typolink.title = {register:tx_dlf_metadata_author_name}\nvalue.postCObject.value.stdWrap.typolink.ifNotEmpty = 1\nvalue.wrap = ", + "index_tokenized": 1, + "index_stored": 1, + "index_indexed": 1, + "index_boost": 2.00, + "is_sortable": 1, + "is_facet": 1, + "is_listed": 1, + "index_autocomplete": 1, + "sorting": 5 + }, + "place": { + "format": [ + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:head/teihdr:origPlace", + "xpath_sorting": "" + }, + { + "format_root": "IIIF2", + "xpath": "$.metadata.[?(@.label=='Place of publication')].value", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 1, + "index_stored": 1, + "index_indexed": 1, + "index_boost": 1.00, + "is_sortable": 1, + "is_facet": 1, + "is_listed": 1, + "index_autocomplete": 0, + "sorting": 6 + }, + "year": { + "format": [ + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:head/teihdr:origDate", + "xpath_sorting": "./teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:head/teihdr:origDate/@when" + }, + { + "format_root": "IIIF2", + "xpath": "$.metadata.[?(@.label=='Date of publication')].value", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 1, + "index_indexed": 1, + "index_boost": 1.00, + "is_sortable": 1, + "is_facet": 1, + "is_listed": 1, + "index_autocomplete": 0, + "sorting": 7 + }, + "language": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:language/mods:languageTerm", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 1, + "index_boost": 1.00, + "is_sortable": 0, + "is_facet": 1, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 8 + }, + "collection": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:classification", + "xpath_sorting": "" + }, + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:msIdentifier/teihdr:collection", + "xpath_sorting": "" + }, + { + "format_root": "IIIF2", + "xpath": "$.metadata.[?(@.label=='Collection')].value", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 1, + "index_stored": 0, + "index_indexed": 1, + "index_boost": 1.00, + "is_sortable": 0, + "is_facet": 1, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 9 + }, + "owner": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:name[./mods:role/mods:roleTerm=\"own\"]/mods:displayForm", + "xpath_sorting": "" + }, + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:publicationStmt/teihdr:publisher", + "xpath_sorting": "" + }, + { + "format_root": "IIIF2", + "xpath": "$.metadata.[?(@.label=='Owner')].value", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 1, + "index_boost": 1.00, + "is_sortable": 0, + "is_facet": 1, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 10 + }, + "purl": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:identifier[@type=\"purl\"]", + "xpath_sorting": "" + }, + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type=\"purl\"]", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap =
|
\nvalue.required = 1\nvalue.setContentToCurrent = 1\nvalue.typolink.parameter.current = 1\nvalue.wrap =
|
", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 0, + "index_boost": 0.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 11 + }, + "urn": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:identifier[@type=\"urn\"]", + "xpath_sorting": "" + }, + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type=\"urn\"]", + "xpath_sorting": "" + }, + { + "format_root": "IIIF2", + "xpath": "$.metadata.[?(@.label=='URN')].value", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap =
|
\nvalue.required = 1\nvalue.setContentToCurrent = 1\nvalue.typolink.parameter.current = 1\nvalue.typolink.parameter.prepend = TEXT\nvalue.typolink.parameter.prepend.value = http://nbn-resolving.de/\nvalue.wrap =
|
", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 1, + "index_boost": 1.00, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 12 + }, + "opac_id": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:identifier[@type=\"opac\"]", + "xpath_sorting": "" + }, + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type=\"opac\"]", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 1, + "index_boost": 1.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 13 + }, + "union_id": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:identifier[@type=\"ppn\"]", + "xpath_sorting": "" + }, + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type=\"mmid\"]", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 1, + "index_boost": 1.00, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 14 + }, + "record_id": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:recordInfo/mods:recordIdentifier", + "xpath_sorting": "" + }, + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type=\"recordIdentifier\"]", + "xpath_sorting": "" + }, + { + "format_root": "IIIF2", + "xpath": "$['@id']", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 1, + "index_boost": 1.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 15 + }, + "prod_id": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:identifier[@type=\"kitodo\"]", + "xpath_sorting": "" + }, + { + "format_root": "teiHeader", + "xpath": "./teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type=\"kitodo\"]", + "xpath_sorting": "" + }, + { + "format_root": "IIIF2", + "xpath": "$.metadata.[?(@.label=='Kitodo')].value", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 0, + "index_boost": 0.00, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 16 + }, + "coordinates": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:subject/mods:cartographics/mods:coordinates", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 1, + "index_indexed": 1, + "index_boost": 1.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 17 + }, + "license": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:accessCondition[@type=\"use and reproduction\"]/@xlink:href", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 1, + "index_indexed": 1, + "index_boost": 1.0, + "is_sortable": 0, + "is_facet": 1, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 18 + }, + "terms": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:accessCondition[@type=\"local terms of use\"]/@xlink:href", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 1, + "index_indexed": 1, + "index_boost": 1.00, + "is_sortable": 0, + "is_facet": 1, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 19 + }, + "restrictions": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:accessCondition[@type=\"restriction on access\"]/@xlink:href", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 1, + "index_indexed": 1, + "index_boost": 1.00, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 20 + }, + "out_of_print": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:accessCondition[@type=\"out of print work\"]", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 1, + "index_boost": 1.0, + "is_sortable": 0, + "is_facet": 1, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 21 + }, + "rights_info": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:accessCondition[@type=\"info\"]", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 0, + "index_boost": 0.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 22 + }, + "description": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:recordInfo/mods:recordInfoNote", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 0, + "index_boost": 0.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 23 + }, + "identifier": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:identifier", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 0, + "index_boost": 0.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 24 + }, + "object_name": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:relatedItem[@type=\"original\"]/mods:titleInfo[not(@type=\"alternative\")]/mods:title", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 0, + "index_boost": 0.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 25 + }, + "object_alternative_names": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:relatedItem[@type=\"original\"]/mods:titleInfo[@type=\"alternative\"]/mods:title", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 0, + "index_boost": 0.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 26 + }, + "object_location": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:relatedItem[@type=\"original\"]/mods:location/mods:physicalLocation", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 0, + "index_boost": 0.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 27 + }, + "geonames": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:relatedItem[@type=\"original\"]/mods:location/mods:physicalLocation[@authority=\"geonames\"]/@valueURI", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 0, + "index_boost": 0.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 28 + }, + "wikidata": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:relatedItem[@type=\"original\"]/mods:location/mods:url[@note=\"wikidata\"]", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 0, + "index_boost": 0.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 29 + }, + "wikipedia": { + "format": [ + { + "format_root": "mods", + "xpath": "./mods:relatedItem[@type=\"original\"]/mods:location/mods:url[@note=\"wikipedia\"]", + "xpath_sorting": "" + } + ], + "default_value": "", + "wrap": "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", + "index_tokenized": 0, + "index_stored": 0, + "index_indexed": 0, + "index_boost": 0.0, + "is_sortable": 0, + "is_facet": 0, + "is_listed": 0, + "index_autocomplete": 0, + "sorting": 30 + } +} diff --git a/Resources/Private/Data/MetadataDefaults.php b/Resources/Private/Data/MetadataDefaults.php deleted file mode 100644 index de8d572dd..000000000 --- a/Resources/Private/Data/MetadataDefaults.php +++ /dev/null @@ -1,846 +0,0 @@ - - * - * 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. - */ - -// Define metadata elements. -// @see http://dfg-viewer.de/en/profile-of-the-metadata/ -return [ - 'type' => [ - 'format' => [ - [ - 'format_root' => 'IIIF2', - 'xpath' => '$.metadata.[?(@.label==\'Manifest Type\')].value', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 1, - 'index_indexed' => 0, - 'index_boost' => 1.00, - 'is_sortable' => 1, - 'is_facet' => 1, - 'is_listed' => 1, - 'index_autocomplete' => 0, - 'sorting' => 1, - ], - 'title' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => 'concat(./mods:titleInfo/mods:nonSort," ",./mods:titleInfo/mods:title)', - 'xpath_sorting' => './mods:titleInfo/mods:title', - ], - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:head/teihdr:note[@type="caption"]', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'IIIF2', - 'xpath' => '$[label]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap = \nvalue.required = 1\nvalue.wrap = ", - 'index_tokenized' => 1, - 'index_stored' => 1, - 'index_indexed' => 1, - 'index_boost' => 2.00, - 'is_sortable' => 1, - 'is_facet' => 0, - 'is_listed' => 1, - 'index_autocomplete' => 1, - 'sorting' => 2, - ], - 'volume' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:part/mods:detail/mods:number', - 'xpath_sorting' => './mods:part[@type="host"]/@order', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 1, - 'index_indexed' => 0, - 'index_boost' => 1.00, - 'is_sortable' => 1, - 'is_facet' => 0, - 'is_listed' => 1, - 'index_autocomplete' => 0, - 'sorting' => 3, - ], - 'date' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:originInfo/*[@encoding="iso8601" or @encoding="w3cdtf"][@keyDate="yes"]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 1, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 1, - 'is_facet' => 0, - 'is_listed' => 1, - 'index_autocomplete' => 0, - 'sorting' => 4, - ], - 'author' => [ - 'format' => [ - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:head/teihdr:name', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'IIIF2', - 'xpath' => "$.metadata.[?(@.label=='Author')].value", - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap = \nvalue.required = 1\nvalue.split.token.char = 31\nvalue.split.cObjNum = 1\nvalue.split.1.1 = CASE\nvalue.split.1.1.key.data = register:SPLIT_COUNT\nvalue.split.1.1.0 = LOAD_REGISTER\nvalue.split.1.1.0.tx_dlf_metadata_author_name.current = 1\nvalue.split.1.1.1 = LOAD_REGISTER\nvalue.split.1.1.1.tx_dlf_metadata_author_uri.current = 1\nvalue.postCObject = TEXT\nvalue.postCObject.value = {register:tx_dlf_metadata_author_name}\nvalue.postCObject.value.insertData = 1\nvalue.postCObject.value.stdWrap.typolink.parameter = {register:tx_dlf_metadata_author_uri} _blank external\nvalue.postCObject.value.stdWrap.typolink.parameter.insertData = 1\nvalue.postCObject.value.stdWrap.typolink.title = {register:tx_dlf_metadata_author_name}\nvalue.postCObject.value.stdWrap.typolink.ifNotEmpty = 1\nvalue.wrap = ", - 'index_tokenized' => 1, - 'index_stored' => 1, - 'index_indexed' => 1, - 'index_boost' => 2.00, - 'is_sortable' => 1, - 'is_facet' => 1, - 'is_listed' => 1, - 'index_autocomplete' => 1, - 'sorting' => 5, - ], - 'place' => [ - 'format' => [ - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:head/teihdr:origPlace', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'IIIF2', - 'xpath' => "$.metadata.[?(@.label=='Place of publication')].value", - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 1, - 'index_stored' => 1, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 1, - 'is_facet' => 1, - 'is_listed' => 1, - 'index_autocomplete' => 0, - 'sorting' => 6, - ], - 'year' => [ - 'format' => [ - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:head/teihdr:origDate', - 'xpath_sorting' => './teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:head/teihdr:origDate/@when', - ], - [ - 'format_root' => 'IIIF2', - 'xpath' => "$.metadata.[?(@.label=='Date of publication')].value", - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 1, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 1, - 'is_facet' => 1, - 'is_listed' => 1, - 'index_autocomplete' => 0, - 'sorting' => 7, - ], - 'language' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:language/mods:languageTerm', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 1, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 8, - ], - 'collection' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:classification', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:sourceDesc/teihdr:msDesc/teihdr:msIdentifier/teihdr:collection', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'IIIF2', - 'xpath' => "$.metadata.[?(@.label=='Collection')].value", - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 1, - 'index_stored' => 0, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 1, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 9, - ], - 'owner' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:name[./mods:role/mods:roleTerm="own"]/mods:displayForm', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:publicationStmt/teihdr:publisher', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'IIIF2', - 'xpath' => "$.metadata.[?(@.label=='Owner')].value", - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 1, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 10, - ], - 'purl' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:identifier[@type="purl"]', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type="purl"]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap =
|
\nvalue.required = 1\nvalue.setContentToCurrent = 1\nvalue.typolink.parameter.current = 1\nvalue.wrap =
|
", - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 11, - ], - 'urn' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:identifier[@type="urn"]', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type="urn"]', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'IIIF2', - 'xpath' => "$.metadata.[?(@.label=='URN')].value", - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap =
|
\nvalue.required = 1\nvalue.setContentToCurrent = 1\nvalue.typolink.parameter.current = 1\nvalue.typolink.parameter.prepend = TEXT\nvalue.typolink.parameter.prepend.value = http://nbn-resolving.de/\nvalue.wrap =
|
", - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 12, - ], - 'opac_id' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:identifier[@type="opac"]', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type="opac"]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 13, - ], - 'union_id' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:identifier[@type="ppn"]', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type="mmid"]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 14, - ], - 'record_id' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:recordInfo/mods:recordIdentifier', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type="recordIdentifier"]', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'IIIF2', - 'xpath' => "$['@id']", - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 15, - ], - 'prod_id' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:identifier[@type="kitodo"]', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'teiHeader', - 'xpath' => './teihdr:fileDesc/teihdr:publicationStmt/teihdr:idno[@type="kitodo"]', - 'xpath_sorting' => '', - ], - [ - 'format_root' => 'IIIF2', - 'xpath' => "$.metadata.[?(@.label=='Kitodo')].value", - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 16, - ], - 'coordinates' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:subject/mods:cartographics/mods:coordinates', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 1, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 17, - ], - 'license' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:accessCondition[@type="use and reproduction"]/@xlink:href', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 1, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 1, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 18, - ], - 'terms' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:accessCondition[@type="local terms of use"]/@xlink:href', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 1, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 1, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 19, - ], - 'restrictions' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:accessCondition[@type="restriction on access"]/@xlink:href', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 1, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 20, - ], - 'out_of_print' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:accessCondition[@type="out of print work"]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 1, - 'index_boost' => 1.00, - 'is_sortable' => 0, - 'is_facet' => 1, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 21, - ], - 'rights_info' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:accessCondition[@type="info"]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 22, - ], - 'description' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:recordInfo/mods:recordInfoNote', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 23, - ], - 'identifier' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:identifier', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 24, - ], - 'object_name' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem[@type="original"]/mods:titleInfo[not(@type="alternative")]/mods:title', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 25, - ], - 'object_alternative_names' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem[@type="original"]/mods:titleInfo[@type="alternative"]/mods:title', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 26, - ], - 'object_location' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem[@type="original"]/mods:location/mods:physicalLocation', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 27, - ], - 'geonames' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem[@type="original"]/mods:location/mods:physicalLocation[@authority="geonames"]/@valueURI', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 28, - ], - 'wikidata' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem[@type="original"]/mods:location/mods:url[@note="wikidata"]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 29, - ], - 'wikipedia' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem[@type="original"]/mods:location/mods:url[@note="wikipedia"]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => "key.wrap =
|
\nvalue.required = 1\nvalue.wrap =
|
", - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 30, - ], - 'identifier' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:identifier', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 31, - ], - 'object_name' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem/mods:titleInfo[not(@displayLabel="alternative")]/mods:title', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 32, - ], - 'object_alternative_names' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem/mods:titleInfo[@displayLabel="alternative"]/mods:title', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 33, - ], - 'object_location' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem/mods:location/mods:physicalLocation', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 34, - ], - 'geonames' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem/mods:location/mods:url[@displayLabel="geonames"]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 35, - ], - 'wikidata' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem/mods:location/mods:url[@displayLabel="wikidata"]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 36, - ], - 'wikipedia' => [ - 'format' => [ - [ - 'format_root' => 'mods', - 'xpath' => './mods:relatedItem/mods:location/mods:url[@displayLabel="wikipedia"]', - 'xpath_sorting' => '', - ], - ], - 'default_value' => '', - 'wrap' => '', - 'index_tokenized' => 0, - 'index_stored' => 0, - 'index_indexed' => 0, - 'index_boost' => 0.00, - 'is_sortable' => 0, - 'is_facet' => 0, - 'is_listed' => 0, - 'index_autocomplete' => 0, - 'sorting' => 37, - ] -]; diff --git a/Resources/Private/Data/StructureDefaults.json b/Resources/Private/Data/StructureDefaults.json new file mode 100644 index 000000000..47a9bac80 --- /dev/null +++ b/Resources/Private/Data/StructureDefaults.json @@ -0,0 +1,370 @@ +{ + "act": { + "toplevel": 1, + "oai_name": "" + }, + "additional": { + "toplevel": 0, + "oai_name": "" + }, + "address": { + "toplevel": 0, + "oai_name": "" + }, + "album": { + "toplevel": 1, + "oai_name": "" + }, + "annotation": { + "toplevel": 0, + "oai_name": "" + }, + "article": { + "toplevel": 0, + "oai_name": "" + }, + "atlas": { + "toplevel": 1, + "oai_name": "" + }, + "bachelor_thesis": { + "toplevel": 1, + "oai_name": "" + }, + "binding": { + "toplevel": 0, + "oai_name": "" + }, + "bookplate": { + "toplevel": 0, + "oai_name": "" + }, + "cartulary": { + "toplevel": 1, + "oai_name": "" + }, + "chapter": { + "toplevel": 0, + "oai_name": "" + }, + "collation": { + "toplevel": 0, + "oai_name": "" + }, + "colophon": { + "toplevel": 0, + "oai_name": "" + }, + "contained_work": { + "toplevel": 0, + "oai_name": "" + }, + "contents": { + "toplevel": 0, + "oai_name": "" + }, + "corrigenda": { + "toplevel": 0, + "oai_name": "" + }, + "cover": { + "toplevel": 0, + "oai_name": "" + }, + "cover_front": { + "toplevel": 0, + "oai_name": "" + }, + "cover_back": { + "toplevel": 0, + "oai_name": "" + }, + "day": { + "toplevel": 0, + "oai_name": "" + }, + "dedication": { + "toplevel": 0, + "oai_name": "" + }, + "diploma_thesis": { + "toplevel": 1, + "oai_name": "" + }, + "doctoral_thesis": { + "toplevel": 1, + "oai_name": "" + }, + "document": { + "toplevel": 1, + "oai_name": "" + }, + "dossier": { + "toplevel": 1, + "oai_name": "" + }, + "edge": { + "toplevel": 0, + "oai_name": "" + }, + "endsheet": { + "toplevel": 0, + "oai_name": "" + }, + "engraved_titlepage": { + "toplevel": 0, + "oai_name": "" + }, + "entry": { + "toplevel": 0, + "oai_name": "" + }, + "ephemera": { + "toplevel": 1, + "oai_name": "" + }, + "fascicle": { + "toplevel": 0, + "oai_name": "" + }, + "figure": { + "toplevel": 0, + "oai_name": "" + }, + "file": { + "toplevel": 1, + "oai_name": "" + }, + "folder": { + "toplevel": 1, + "oai_name": "" + }, + "fragment": { + "toplevel": 1, + "oai_name": "" + }, + "ground_plan": { + "toplevel": 1, + "oai_name": "" + }, + "habilitation_thesis": { + "toplevel": 1, + "oai_name": "" + }, + "illustration": { + "toplevel": 0, + "oai_name": "" + }, + "image": { + "toplevel": 1, + "oai_name": "" + }, + "imprint": { + "toplevel": 0, + "oai_name": "" + }, + "index": { + "toplevel": 0, + "oai_name": "" + }, + "initial_decoration": { + "toplevel": 0, + "oai_name": "" + }, + "inventory": { + "toplevel": 1, + "oai_name": "" + }, + "issue": { + "toplevel": 1, + "oai_name": "" + }, + "judgement": { + "toplevel": 1, + "oai_name": "" + }, + "land_register": { + "toplevel": 1, + "oai_name": "" + }, + "leaflet": { + "toplevel": 1, + "oai_name": "" + }, + "lecture": { + "toplevel": 1, + "oai_name": "" + }, + "letter": { + "toplevel": 0, + "oai_name": "" + }, + "magister_thesis": { + "toplevel": 1, + "oai_name": "" + }, + "master_thesis": { + "toplevel": 1, + "oai_name": "" + }, + "manuscript": { + "toplevel": 1, + "oai_name": "" + }, + "map": { + "toplevel": 0, + "oai_name": "" + }, + "monograph": { + "toplevel": 1, + "oai_name": "" + }, + "month": { + "toplevel": 0, + "oai_name": "" + }, + "multivolume_work": { + "toplevel": 1, + "oai_name": "" + }, + "musical_notation": { + "toplevel": 0, + "oai_name": "" + }, + "newspaper": { + "toplevel": 1, + "oai_name": "" + }, + "note": { + "toplevel": 0, + "oai_name": "" + }, + "official_notification": { + "toplevel": 1, + "oai_name": "" + }, + "ornament": { + "toplevel": 0, + "oai_name": "" + }, + "page": { + "toplevel": 0, + "oai_name": "" + }, + "paper": { + "toplevel": 1, + "oai_name": "" + }, + "paste_down": { + "toplevel": 0, + "oai_name": "" + }, + "periodical": { + "toplevel": 1, + "oai_name": "" + }, + "photograph": { + "toplevel": 1, + "oai_name": "" + }, + "plan": { + "toplevel": 1, + "oai_name": "" + }, + "poster": { + "toplevel": 1, + "oai_name": "" + }, + "preface": { + "toplevel": 0, + "oai_name": "" + }, + "preprint": { + "toplevel": 1, + "oai_name": "" + }, + "printed_archives": { + "toplevel": 1, + "oai_name": "" + }, + "printers_mark": { + "toplevel": 0, + "oai_name": "" + }, + "privileges": { + "toplevel": 0, + "oai_name": "" + }, + "proceeding": { + "toplevel": 1, + "oai_name": "" + }, + "provenance": { + "toplevel": 0, + "oai_name": "" + }, + "register": { + "toplevel": 1, + "oai_name": "" + }, + "report": { + "toplevel": 1, + "oai_name": "" + }, + "research_paper": { + "toplevel": 1, + "oai_name": "" + }, + "scheme": { + "toplevel": 0, + "oai_name": "" + }, + "seal": { + "toplevel": 0, + "oai_name": "" + }, + "section": { + "toplevel": 0, + "oai_name": "" + }, + "spine": { + "toplevel": 0, + "oai_name": "" + }, + "stamp": { + "toplevel": 0, + "oai_name": "" + }, + "study": { + "toplevel": 1, + "oai_name": "" + }, + "subinventory": { + "toplevel": 0, + "oai_name": "" + }, + "table": { + "toplevel": 0, + "oai_name": "" + }, + "text": { + "toplevel": 0, + "oai_name": "" + }, + "title_page": { + "toplevel": 0, + "oai_name": "" + }, + "verse": { + "toplevel": 0, + "oai_name": "" + }, + "volume": { + "toplevel": 1, + "oai_name": "" + }, + "year": { + "toplevel": 1, + "oai_name": "" + } +} diff --git a/Resources/Private/Data/StructureDefaults.php b/Resources/Private/Data/StructureDefaults.php deleted file mode 100644 index 3c2178252..000000000 --- a/Resources/Private/Data/StructureDefaults.php +++ /dev/null @@ -1,384 +0,0 @@ - - * - * 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. - */ - -// Define structure elements. -// @see http://dfg-viewer.de/en/structural-data-set/ -return [ - 'act' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'additional' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'address' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'album' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'annotation' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'article' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'atlas' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'bachelor_thesis' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'binding' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'bookplate' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'cartulary' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'chapter' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'collation' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'colophon' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'contained_work' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'contents' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'corrigenda' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'cover' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'cover_front' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'cover_back' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'day' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'dedication' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'diploma_thesis' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'doctoral_thesis' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'document' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'dossier' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'edge' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'endsheet' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'engraved_titlepage' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'entry' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'ephemera' => [ - 'toplevel' => 1, - 'oai_name' => '' - ], - 'fascicle' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'figure' => [ - 'toplevel' => 0, - 'oai_name' => '', - ], - 'file' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'folder' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'fragment' => [ - 'toplevel' => 1, - 'oai_name' => '' - ], - 'ground_plan' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'habilitation_thesis' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'illustration' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'image' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'imprint' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'index' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'initial_decoration' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'inventory' => [ - 'toplevel' => 1, - 'oai_name' => '' - ], - 'issue' => [ - 'toplevel' => 1, - 'oai_name' => '' - ], - 'judgement' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'land_register' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'leaflet' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'lecture' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'letter' => [ - 'toplevel' => 0, - 'oai_name' => '', - ], - 'magister_thesis' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'master_thesis' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'manuscript' => [ - 'toplevel' => 1, - 'oai_name' => '' - ], - 'map' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'monograph' => [ - 'toplevel' => 1, - 'oai_name' => '' - ], - 'month' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'multivolume_work' => [ - 'toplevel' => 1, - 'oai_name' => '' - ], - 'musical_notation' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'newspaper' => [ - 'toplevel' => 1, - 'oai_name' => '' - ], - 'note' => [ - 'toplevel' => 0, - 'oai_name' => '', - ], - 'official_notification' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'ornament' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'page' => [ - 'toplevel' => 0, - 'oai_name' => '', - ], - 'paper' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'paste_down' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'periodical' => [ - 'toplevel' => 1, - 'oai_name' => '' - ], - 'photograph' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'plan' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'poster' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'preface' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'preprint' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'printed_archives' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'printers_mark' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'privileges' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'proceeding' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'provenance' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'register' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'report' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'research_paper' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'scheme' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'seal' => [ - 'toplevel' => 0, - 'oai_name' => '', - ], - 'section' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'spine' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'stamp' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'study' => [ - 'toplevel' => 1, - 'oai_name' => '', - ], - 'subinventory' => [ - 'toplevel' => 0, - 'oai_name' => '', - ], - 'table' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'text' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'title_page' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'verse' => [ - 'toplevel' => 0, - 'oai_name' => '' - ], - 'volume' => [ - 'toplevel' => 1, - 'oai_name' => '' - ], - 'year' => [ - 'toplevel' => 1, - 'oai_name' => '' - ] -]; From f6a06502b5eed57040c5f99d3152a0e7a1ffe1a1 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Tue, 18 Jun 2024 18:56:33 +0200 Subject: [PATCH 2/9] [BUGFIX] Check if language key exists in document metadata array (#1254) 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 f991f9ca4..4c38316af 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -837,7 +837,7 @@ private function getDocument(Document $record, array $highlighting, array $field */ private function translateLanguageCode(&$doc): void { - if ($doc['metadata']['language']) { + if (array_key_exists('language', $doc['metadata'])) { foreach($doc['metadata']['language'] as $indexName => $language) { $doc['metadata']['language'][$indexName] = Helper::getLanguageName($language); } From 84a35c049bea900a79ad8f666a88fe38b44677a0 Mon Sep 17 00:00:00 2001 From: frank-ulrich-weber Date: Mon, 1 Jul 2024 17:23:35 +0200 Subject: [PATCH 3/9] [FEATURE] Query time boosting (#1120) Co-authored-by: Sebastian Meyer --- .github/phpstan.neon | 1 + Classes/Common/Indexer.php | 18 +++++--------- Classes/Common/Solr/SolrSearch.php | 24 ++++++++++++++++++- Classes/Controller/CollectionController.php | 5 +++- Classes/Controller/ListViewController.php | 5 +++- Classes/Controller/SearchController.php | 5 +++- .../Domain/Repository/DocumentRepository.php | 19 ++++++++------- 7 files changed, 53 insertions(+), 24 deletions(-) diff --git a/.github/phpstan.neon b/.github/phpstan.neon index 7307b130f..86b7418e6 100644 --- a/.github/phpstan.neon +++ b/.github/phpstan.neon @@ -2,6 +2,7 @@ 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::findByIndexIndexed\(\)\.#' - '#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\(\)\.#' diff --git a/Classes/Common/Indexer.php b/Classes/Common/Indexer.php index dc6b194cd..98fa6885d 100644 --- a/Classes/Common/Indexer.php +++ b/Classes/Common/Indexer.php @@ -56,8 +56,7 @@ class Indexer 'sortables' => [], 'indexed' => [], 'stored' => [], - 'tokenized' => [], - 'fieldboost' => [] + 'tokenized' => [] ]; /** @@ -305,11 +304,6 @@ protected static function loadIndexConf(int $pid): void if ($indexing['index_autocomplete']) { self::$fields['autocomplete'][] = $indexing['index_name']; } - if ($indexing['index_boost'] > 0.0) { - self::$fields['fieldboost'][$indexing['index_name']] = floatval($indexing['index_boost']); - } else { - self::$fields['fieldboost'][$indexing['index_name']] = false; - } } self::$fieldsLoaded = true; } @@ -357,8 +351,8 @@ protected static function processLogical(Document $document, array $logicalUnit) } // There can be only one toplevel unit per UID, independently of backend configuration $solrDoc->setField('toplevel', $logicalUnit['id'] == $doc->toplevelId ? true : false); - $solrDoc->setField('title', $metadata['title'][0], self::$fields['fieldboost']['title']); - $solrDoc->setField('volume', $metadata['volume'][0], self::$fields['fieldboost']['volume']); + $solrDoc->setField('title', $metadata['title'][0]); + $solrDoc->setField('volume', $metadata['volume'][0]); // verify date formatting if(strtotime($metadata['date'][0])) { $solrDoc->setField('date', self::getFormattedDate($metadata['date'][0])); @@ -445,7 +439,7 @@ protected static function processPhysical(Document $document, int $page, array $ } } $solrDoc->setField('toplevel', false); - $solrDoc->setField('type', $physicalUnit['type'], self::$fields['fieldboost']['type']); + $solrDoc->setField('type', $physicalUnit['type']); $solrDoc->setField('collection', $doc->metadataArray[$doc->toplevelId]['collection']); $solrDoc->setField('location', $document->getLocation()); @@ -520,7 +514,7 @@ private static function processMetadata($document, $metadata, &$solrDoc): array !empty($data) && substr($indexName, -8) !== '_sorting' ) { - $solrDoc->setField(self::getIndexFieldName($indexName, $document->getPid()), $data, self::$fields['fieldboost'][$indexName]); + $solrDoc->setField(self::getIndexFieldName($indexName, $document->getPid()), $data); if (in_array($indexName, self::$fields['sortables'])) { // Add sortable fields to index. $solrDoc->setField($indexName . '_sorting', $metadata[$indexName . '_sorting'][0]); @@ -626,7 +620,7 @@ private static function getSolrDocument(Query $updateQuery, Document $document, $solrDoc->setField('partof', $document->getPartof()); $solrDoc->setField('root', $document->getCurrentDocument()->rootId); $solrDoc->setField('sid', $unit['id']); - $solrDoc->setField('type', $unit['type'], self::$fields['fieldboost']['type']); + $solrDoc->setField('type', $unit['type']); $solrDoc->setField('collection', $document->getCurrentDocument()->metadataArray[$document->getCurrentDocument()->toplevelId]['collection']); $solrDoc->setField('fulltext', $fullText); return $solrDoc; diff --git a/Classes/Common/Solr/SolrSearch.php b/Classes/Common/Solr/SolrSearch.php index 4c38316af..ee33c5367 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -59,6 +59,12 @@ class SolrSearch implements \Countable, \Iterator, \ArrayAccess, QueryResultInte */ private ?QueryResult $listedMetadata; + /** + * @access private + * @var QueryResult|null + */ + private ?QueryResult $indexedMetadata; + /** * @access private * @var array @@ -90,13 +96,14 @@ class SolrSearch implements \Countable, \Iterator, \ArrayAccess, QueryResultInte * * @return void */ - public function __construct(DocumentRepository $documentRepository, $collections, array $settings, array $searchParams, QueryResult $listedMetadata = null) + public function __construct(DocumentRepository $documentRepository, $collections, array $settings, array $searchParams, QueryResult $listedMetadata = null, QueryResult $indexedMetadata = null) { $this->documentRepository = $documentRepository; $this->collections = $collections; $this->settings = $settings; $this->searchParams = $searchParams; $this->listedMetadata = $listedMetadata; + $this->indexedMetadata = $indexedMetadata; } /** @@ -664,6 +671,21 @@ protected function searchSolr($parameters = [], $enableCache = true) if ($enableCache === false || ($entry = $cache->get($cacheIdentifier)) === false) { $selectQuery = $solr->service->createSelect($parameters); + $edismax = $selectQuery->getEDisMax(); + + $queryFields = ''; + + if ($this->indexedMetadata) { + foreach ($this->indexedMetadata as $metadata) { + if ($metadata->getIndexIndexed()) { + $listMetadataRecord = $metadata->getIndexName() . '_' . ($metadata->getIndexTokenized() ? 't' : 'u') . ($metadata->getIndexStored() ? 's' : 'u') . 'i'; + $queryFields .= $listMetadataRecord . '^' . $metadata->getIndexBoost() . ' '; + } + } + } + + $edismax->setQueryFields($queryFields); + $grouping = $selectQuery->getGrouping(); $grouping->addField('uid'); $grouping->setLimit(100); // Results in group (TODO: check) diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index c7ecb958b..c44822b5c 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -151,13 +151,16 @@ public function showAction(Collection $collection): void // get all metadata records to be shown in results $listedMetadata = $this->metadataRepository->findByIsListed(true); + // get all indexed metadata fields + $indexedMetadata = $this->metadataRepository->findByIndexIndexed(true); + // get all sortable metadata records $sortableMetadata = $this->metadataRepository->findByIsSortable(true); // get all documents of given collection $solrResults = null; if (is_array($searchParams) && !empty($searchParams)) { - $solrResults = $this->documentRepository->findSolrByCollection($collection, $this->settings, $searchParams, $listedMetadata); + $solrResults = $this->documentRepository->findSolrByCollection($collection, $this->settings, $searchParams, $listedMetadata, $indexedMetadata); $itemsPerPage = $this->settings['list']['paginate']['itemsPerPage']; if (empty($itemsPerPage)) { diff --git a/Classes/Controller/ListViewController.php b/Classes/Controller/ListViewController.php index 66bb47835..324e5585a 100644 --- a/Classes/Controller/ListViewController.php +++ b/Classes/Controller/ListViewController.php @@ -96,10 +96,13 @@ public function mainAction(): void // get all metadata records to be shown in results $listedMetadata = $this->metadataRepository->findByIsListed(true); + // get all indexed metadata fields + $indexedMetadata = $this->metadataRepository->findByIndexIndexed(true); + $solrResults = null; $numResults = 0; if (is_array($this->searchParams) && !empty($this->searchParams)) { - $solrResults = $this->documentRepository->findSolrByCollections($collections, $this->settings, $this->searchParams, $listedMetadata); + $solrResults = $this->documentRepository->findSolrByCollections($collections, $this->settings, $this->searchParams, $listedMetadata, $indexedMetadata); $numResults = $solrResults->getNumFound(); $itemsPerPage = $this->settings['list']['paginate']['itemsPerPage']; diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index ae69761d1..127943c54 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -172,11 +172,14 @@ public function mainAction(): void // get all metadata records to be shown in results $listedMetadata = $this->metadataRepository->findByIsListed(true); + // get all indexed metadata fields + $indexedMetadata = $this->metadataRepository->findByIndexIndexed(true); + $solrResults = null; $numResults = 0; // Do not execute the Solr search if used together with ListView plugin. if (!$listViewSearch) { - $solrResults = $this->documentRepository->findSolrWithoutCollection($this->settings, $this->searchParams, $listedMetadata); + $solrResults = $this->documentRepository->findSolrWithoutCollection($this->settings, $this->searchParams, $listedMetadata, $indexedMetadata); $numResults = $solrResults->getNumFound(); $itemsPerPage = $this->settings['list']['paginate']['itemsPerPage']; diff --git a/Classes/Domain/Repository/DocumentRepository.php b/Classes/Domain/Repository/DocumentRepository.php index 7e09a5df7..25785b878 100644 --- a/Classes/Domain/Repository/DocumentRepository.php +++ b/Classes/Domain/Repository/DocumentRepository.php @@ -579,12 +579,13 @@ public function findChildrenOfEach(array $uids) * @param array $settings * @param array $searchParams * @param QueryResult $listedMetadata + * @param QueryResult $indexedMetadata * * @return SolrSearch */ - public function findSolrByCollection(Collection $collection, $settings, $searchParams, $listedMetadata = null) + public function findSolrByCollection(Collection $collection, $settings, $searchParams, $listedMetadata = null, $indexedMetadata = null) { - return $this->findSolr([$collection], $settings, $searchParams, $listedMetadata); + return $this->findSolr([$collection], $settings, $searchParams, $listedMetadata, $indexedMetadata); } /** @@ -596,12 +597,13 @@ public function findSolrByCollection(Collection $collection, $settings, $searchP * @param array $settings * @param array $searchParams * @param QueryResult $listedMetadata + * @param QueryResult $indexedMetadata * * @return SolrSearch */ - public function findSolrByCollections($collections, $settings, $searchParams, $listedMetadata = null): SolrSearch + public function findSolrByCollections($collections, $settings, $searchParams, $listedMetadata = null, $indexedMetadata = null): SolrSearch { - return $this->findSolr($collections, $settings, $searchParams, $listedMetadata); + return $this->findSolr($collections, $settings, $searchParams, $listedMetadata, $indexedMetadata); } /** @@ -612,12 +614,13 @@ public function findSolrByCollections($collections, $settings, $searchParams, $l * @param array $settings * @param array $searchParams * @param QueryResult $listedMetadata + * @param QueryResult $indexedMetadata * * @return SolrSearch */ - public function findSolrWithoutCollection($settings, $searchParams, $listedMetadata = null): SolrSearch + public function findSolrWithoutCollection($settings, $searchParams, $listedMetadata = null, $indexedMetadata = null): SolrSearch { - return $this->findSolr([], $settings, $searchParams, $listedMetadata); + return $this->findSolr([], $settings, $searchParams, $listedMetadata, $indexedMetadata); } /** @@ -632,13 +635,13 @@ public function findSolrWithoutCollection($settings, $searchParams, $listedMetad * * @return SolrSearch */ - private function findSolr($collections, $settings, $searchParams, $listedMetadata = null): SolrSearch + private function findSolr($collections, $settings, $searchParams, $listedMetadata = null, $indexedMetadata = null): SolrSearch { // set settings global inside this repository // (may be necessary when SolrSearch calls back) $this->settings = $settings; - $search = new SolrSearch($this, $collections, $settings, $searchParams, $listedMetadata); + $search = new SolrSearch($this, $collections, $settings, $searchParams, $listedMetadata, $indexedMetadata); $search->prepare(); return $search; } From a6d244c1e8bbcf00fd1a054e8bbc218bc9fe3968 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 5 Jul 2024 15:19:33 +0200 Subject: [PATCH 4/9] [MAINTENANCE] Simplify usage of metadata sections (#1255) Co-authored-by: Sebastian Meyer --- Classes/Common/MetsDocument.php | 34 ++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index a26b4e837..b9c0b1313 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -502,8 +502,8 @@ private function processMetadataSections(string $id, int $cPid, array $metadata) // There is no metadata section for this structure node. return []; } - // Associative array used as set of available section types (dmdSec, techMD, ...) - $hasMetadataSection = []; + // Array used as set of available section types (dmdSec, techMD, ...) + $metadataSections = []; // Load available metadata formats and metadata sections. $this->loadFormats(); $this->magicGetMdSec(); @@ -513,19 +513,19 @@ private function processMetadataSections(string $id, int $cPid, array $metadata) foreach ($mdIds as $dmdId) { $mdSectionType = $this->mdSec[$dmdId]['section']; - if ($mdSectionType === 'dmdSec' && isset($hasMetadataSection['dmdSec'])) { + if ($this->hasMetadataSection($metadataSections, $mdSectionType, 'dmdSec')) { continue; } - if (!$this->extractAndProcessMetadata($dmdId, $mdSectionType, $metadata, $cPid, $hasMetadataSection)) { + if (!$this->extractAndProcessMetadata($dmdId, $mdSectionType, $metadata, $cPid, $metadataSections)) { continue; } - $hasMetadataSection[$mdSectionType] = true; + $metadataSections[] = $mdSectionType; } // Files are not expected to reference a dmdSec - if (isset($this->fileInfos[$id]) || isset($hasMetadataSection['dmdSec'])) { + if (isset($this->fileInfos[$id]) || in_array('dmdSec', $metadataSections)) { return $metadata; } else { $this->logger->warning('No supported descriptive metadata found for logical structure with @ID "' . $id . '"'); @@ -564,13 +564,13 @@ private function getLogicalUnitType(string $id): array * @param string $mdSectionType * @param array $metadata * @param integer $cPid - * @param array $hasMetadataSection + * @param array $metadataSections * * @return boolean */ - private function extractAndProcessMetadata(string $dmdId, string $mdSectionType, array &$metadata, int $cPid, array $hasMetadataSection): bool + private function extractAndProcessMetadata(string $dmdId, string $mdSectionType, array &$metadata, int $cPid, array $metadataSections): bool { - if ($mdSectionType === 'dmdSec' && isset($hasMetadataSection['dmdSec'])) { + if ($this->hasMetadataSection($metadataSections, $mdSectionType, 'dmdSec')) { return true; } @@ -591,6 +591,22 @@ private function extractAndProcessMetadata(string $dmdId, string $mdSectionType, return true; } + /** + * Check if searched metadata section is stored in the array. + * + * @access private + * + * @param array $metadataSections + * @param string $currentMetadataSection + * @param string $searchedMetadataSection + * + * @return boolean + */ + private function hasMetadataSection(array $metadataSections, string $currentMetadataSection, string $searchedMetadataSection): bool + { + return $currentMetadataSection === $searchedMetadataSection && in_array($searchedMetadataSection, $metadataSections); + } + /** * Process additional metadata. * From 3f45f2f6c0b76b3ae6fca716869e4ee6045ff0f9 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 5 Jul 2024 15:23:21 +0200 Subject: [PATCH 5/9] [MAINTENANCE] Adjust variable names to match naming standards (#1256) Co-authored-by: Sebastian Meyer --- Classes/Command/HarvestCommand.php | 10 +++++----- Classes/Command/IndexCommand.php | 10 +++++----- Classes/Command/ReindexCommand.php | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Classes/Command/HarvestCommand.php b/Classes/Command/HarvestCommand.php index f4ae394f7..5ddb9edc2 100644 --- a/Classes/Command/HarvestCommand.php +++ b/Classes/Command/HarvestCommand.php @@ -127,15 +127,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int } // Abort if solrCoreUid is empty or not in the array of allowed solr cores. if (empty($solrCoreUid) || !in_array($solrCoreUid, $allSolrCores)) { - $output_solrCores = []; - foreach ($allSolrCores as $index_name => $uid) { - $output_solrCores[] = $uid . ' : ' . $index_name; + $outputSolrCores = []; + foreach ($allSolrCores as $indexName => $uid) { + $outputSolrCores[] = $uid . ' : ' . $indexName; } - if (empty($output_solrCores)) { + if (empty($outputSolrCores)) { $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. No valid cores found on PID ' . $this->storagePid . ".\n"); return BaseCommand::FAILURE; } else { - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (:):\n" . implode("\n", $output_solrCores) . "\n"); + $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (:):\n" . implode("\n", $outputSolrCores) . "\n"); return BaseCommand::FAILURE; } } diff --git a/Classes/Command/IndexCommand.php b/Classes/Command/IndexCommand.php index 6120b0ed8..1a392e2e1 100644 --- a/Classes/Command/IndexCommand.php +++ b/Classes/Command/IndexCommand.php @@ -111,15 +111,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Abort if solrCoreUid is empty or not in the array of allowed solr cores. if (empty($solrCoreUid) || !in_array($solrCoreUid, $allSolrCores)) { - $output_solrCores = []; - foreach ($allSolrCores as $index_name => $uid) { - $output_solrCores[] = $uid . ' : ' . $index_name; + $outputSolrCores = []; + foreach ($allSolrCores as $indexName => $uid) { + $outputSolrCores[] = $uid . ' : ' . $indexName; } - if (empty($output_solrCores)) { + if (empty($outputSolrCores)) { $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. No valid cores found on PID ' . $this->storagePid . ".\n"); return BaseCommand::FAILURE; } else { - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (:):\n" . implode("\n", $output_solrCores) . "\n"); + $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (:):\n" . implode("\n", $outputSolrCores) . "\n"); return BaseCommand::FAILURE; } } diff --git a/Classes/Command/ReindexCommand.php b/Classes/Command/ReindexCommand.php index 177cf923c..828c26c37 100644 --- a/Classes/Command/ReindexCommand.php +++ b/Classes/Command/ReindexCommand.php @@ -127,15 +127,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Abort if solrCoreUid is empty or not in the array of allowed solr cores. if (empty($solrCoreUid) || !in_array($solrCoreUid, $allSolrCores)) { - $output_solrCores = []; - foreach ($allSolrCores as $index_name => $uid) { - $output_solrCores[] = $uid . ' : ' . $index_name; + $outputSolrCores = []; + foreach ($allSolrCores as $indexName => $uid) { + $outputSolrCores[] = $uid . ' : ' . $indexName; } - if (empty($output_solrCores)) { + if (empty($outputSolrCores)) { $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. No valid cores found on PID ' . $this->storagePid . ".\n"); return BaseCommand::FAILURE; } else { - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (:):\n" . implode("\n", $output_solrCores) . "\n"); + $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (:):\n" . implode("\n", $outputSolrCores) . "\n"); return BaseCommand::FAILURE; } } From 1c71e84c065216804f18e9355ceb7ab0c40a58bf Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 5 Jul 2024 15:27:24 +0200 Subject: [PATCH 6/9] [MAINTENANCE] Get encryption key using configuration manager instead of global access (#1257) Co-authored-by: Sebastian Meyer --- Classes/Common/Helper.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index 8ca41ea5a..ac03c1173 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -12,6 +12,7 @@ namespace Kitodo\Dlf\Common; +use TYPO3\CMS\Core\Configuration\ConfigurationManager; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Http\Uri; @@ -207,7 +208,7 @@ public static function decrypt(string $encrypted) self::log('OpenSSL library doesn\'t support cipher and/or hash algorithm', LOG_SEVERITY_ERROR); return false; } - if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { + if (empty(self::getEncryptionKey())) { self::log('No encryption key set in TYPO3 configuration', LOG_SEVERITY_ERROR); return false; } @@ -222,7 +223,7 @@ public static function decrypt(string $encrypted) $binary = base64_decode($encrypted); $iv = substr($binary, 0, openssl_cipher_iv_length(self::$cipherAlgorithm)); $data = substr($binary, openssl_cipher_iv_length(self::$cipherAlgorithm)); - $key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, true); + $key = openssl_digest(self::getEncryptionKey(), self::$hashAlgorithm, true); // Decrypt data. return openssl_decrypt($data, self::$cipherAlgorithm, $key, OPENSSL_RAW_DATA, $iv); } @@ -342,13 +343,13 @@ public static function encrypt(string $string) self::log('OpenSSL library doesn\'t support cipher and/or hash algorithm', LOG_SEVERITY_ERROR); return false; } - if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { + if (empty(self::getEncryptionKey())) { self::log('No encryption key set in TYPO3 configuration', LOG_SEVERITY_ERROR); return false; } // Generate random initialization vector. $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(self::$cipherAlgorithm)); - $key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, true); + $key = openssl_digest(self::getEncryptionKey(), self::$hashAlgorithm, true); // Encrypt data. $encrypted = openssl_encrypt($string, self::$cipherAlgorithm, $key, OPENSSL_RAW_DATA, $iv); // Merge initialization vector and encrypted data. @@ -1018,4 +1019,19 @@ public static function isValidXmlId($id): bool { return preg_match('/^[_a-z][_a-z0-9-.]*$/i', $id) === 1; } + + /** + * Get encryption key from configuration. + * + * @access private + * + * @static + * + * @return string|null + */ + private static function getEncryptionKey(): ?string + { + $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class); + return $configurationManager->getLocalConfigurationValueByPath('SYS/encryptionKey'); + } } From 583694a6fea2ad69a8d7de78518c1597318e47c6 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 5 Jul 2024 15:33:23 +0200 Subject: [PATCH 7/9] [MAINTENANCE] Get options for hooks from local configuration instead of global access (#1258) Co-authored-by: Sebastian Meyer --- Classes/Common/Helper.php | 38 ++++++++++++++++++++++--- Tests/Functional/FunctionalTestCase.php | 3 ++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index ac03c1173..315e706c3 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -413,8 +413,8 @@ public static function getCleanString(string $string): string public static function getHookObjects(string $scriptRelPath): array { $hookObjects = []; - if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'])) { - foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'] as $classRef) { + if (is_array(self::getOptions()[self::$extKey . '/' . $scriptRelPath]['hookClass'])) { + foreach (self::getOptions()[self::$extKey . '/' . $scriptRelPath]['hookClass'] as $classRef) { $hookObjects[] = GeneralUtility::makeInstance($classRef); } } @@ -1021,7 +1021,21 @@ public static function isValidXmlId($id): bool } /** - * Get encryption key from configuration. + * Get options from local configuration. + * + * @access private + * + * @static + * + * @return array + */ + private static function getOptions(): array + { + return self::getLocalConfigurationByPath('SC_OPTIONS'); + } + + /** + * Get encryption key from local configuration. * * @access private * @@ -1030,8 +1044,24 @@ public static function isValidXmlId($id): bool * @return string|null */ private static function getEncryptionKey(): ?string + { + return self::getLocalConfigurationByPath('SYS/encryptionKey'); + } + + /** + * Get local configuration for given path. + * + * @access private + * + * @static + * + * @param string $path + * + * @return mixed + */ + private static function getLocalConfigurationByPath(string $path) { $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class); - return $configurationManager->getLocalConfigurationValueByPath('SYS/encryptionKey'); + return $configurationManager->getLocalConfigurationValueByPath($path); } } diff --git a/Tests/Functional/FunctionalTestCase.php b/Tests/Functional/FunctionalTestCase.php index 7c3b021bb..c5631ed41 100644 --- a/Tests/Functional/FunctionalTestCase.php +++ b/Tests/Functional/FunctionalTestCase.php @@ -44,6 +44,9 @@ class FunctionalTestCase extends \TYPO3\TestingFramework\Core\Functional\Functio ], 'displayErrors' => '1' ], + 'SC_OPTIONS' => [ + 'dlf/Classes/Plugin/Toolbox.php' => [] + ], 'EXTENSIONS' => [ 'dlf' => [], // = $this->getDlfConfiguration(), set in constructor ], From 93f1ff00549dc5f6419f818a8b2ab1b3ecae9686 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 5 Jul 2024 15:36:56 +0200 Subject: [PATCH 8/9] [MAINTENANCE] Remove unused functions from `Helper` class (#1260) Co-authored-by: Sebastian Meyer --- Classes/Common/Helper.php | 127 -------------------------------------- 1 file changed, 127 deletions(-) diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index 315e706c3..4a5a76182 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -359,23 +359,6 @@ public static function encrypt(string $string) return $encrypted; } - /** - * Get the unqualified name of a class - * - * @access public - * - * @static - * - * @param string $qualifiedClassName The qualified class name from get_class() - * - * @return string The unqualified class name - */ - public static function getUnqualifiedClassName(string $qualifiedClassName): string - { - $nameParts = explode('\\', $qualifiedClassName); - return end($nameParts); - } - /** * Clean up a string to use in an URL. * @@ -557,94 +540,6 @@ public static function getDocumentStructures(int $pid = -1): array return array_column($allStructures, 'indexName', 'uid'); } - /** - * Get the URN of an object - * @see http://www.persistent-identifier.de/?link=316 - * - * @access public - * - * @static - * - * @param string $base The namespace and base URN - * @param string $id The object's identifier - * - * @return string Uniform Resource Name as string - */ - public static function getURN(string $base, string $id): string - { - $concordance = [ - '0' => 1, - '1' => 2, - '2' => 3, - '3' => 4, - '4' => 5, - '5' => 6, - '6' => 7, - '7' => 8, - '8' => 9, - '9' => 41, - 'a' => 18, - 'b' => 14, - 'c' => 19, - 'd' => 15, - 'e' => 16, - 'f' => 21, - 'g' => 22, - 'h' => 23, - 'i' => 24, - 'j' => 25, - 'k' => 42, - 'l' => 26, - 'm' => 27, - 'n' => 13, - 'o' => 28, - 'p' => 29, - 'q' => 31, - 'r' => 12, - 's' => 32, - 't' => 33, - 'u' => 11, - 'v' => 34, - 'w' => 35, - 'x' => 36, - 'y' => 37, - 'z' => 38, - '-' => 39, - ':' => 17, - ]; - $urn = strtolower($base . $id); - if (preg_match('/[^a-z\d:-]/', $urn)) { - self::log('Invalid chars in given parameters', LOG_SEVERITY_WARNING); - return ''; - } - $digits = ''; - for ($i = 0, $j = strlen($urn); $i < $j; $i++) { - $digits .= $concordance[substr($urn, $i, 1)]; - } - $checksum = 0; - for ($i = 0, $j = strlen($digits); $i < $j; $i++) { - $checksum += ($i + 1) * (int) substr($digits, $i, 1); - } - $checksum = substr((string) floor($checksum / (int) substr($digits, -1, 1)), -1, 1); - return $base . $id . $checksum; - } - - /** - * Check if given ID is a valid Pica Production Number (PPN) - * - * @access public - * - * @static - * - * @param string $id The identifier to check - * - * @return bool Is $id a valid PPN? - */ - public static function isPPN(string $id): bool - { - return self::checkIdentifier($id, 'PPN'); - } - /** * Determine whether or not $url is a valid URL using HTTP or HTTPS scheme. * @@ -671,28 +566,6 @@ public static function isValidHttpUrl(string $url): bool } } - /** - * Merges two arrays recursively and actually returns the modified array. - * @see ArrayUtility::mergeRecursiveWithOverrule() - * - * @access public - * - * @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 - */ - 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; - } - /** * Process a data and/or command map with TYPO3 core engine as admin. * From 16574093c736c55711222088e51dab6953016a04 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 5 Jul 2024 15:39:47 +0200 Subject: [PATCH 9/9] [BUGFIX] Fix params array for searching collections (#1262) Co-authored-by: Sebastian Meyer --- Classes/Controller/CollectionController.php | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index c44822b5c..ed1e2d44b 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -81,9 +81,7 @@ public function listAction(): void $this->logger->error('Apache Solr not available'); return; } - // We only care about the UID and partOf in the results and want them sorted - $params['fields'] = 'uid,partof'; - $params['sort'] = ['uid' => 'asc']; + $collections = []; // Sort collections according to order in plugin flexform configuration @@ -220,22 +218,29 @@ private function processCollections($collections, Solr $solr): array // Process results. foreach ($collections as $collection) { - $solr_query = ''; + $solrQuery = ''; if ($collection->getIndexSearch() != '') { - $solr_query .= '(' . $collection->getIndexSearch() . ')'; + $solrQuery .= '(' . $collection->getIndexSearch() . ')'; } else { - $solr_query .= 'collection:("' . Solr::escapeQuery($collection->getIndexName()) . '")'; + $solrQuery .= 'collection:("' . Solr::escapeQuery($collection->getIndexName()) . '")'; } + // We only care about the UID and partOf in the results and want them sorted + $params = [ + 'fields' => 'uid,partof', + 'sort' => [ + 'uid' => 'asc' + ] + ]; // virtual collection might yield documents, that are not toplevel true or partof anything if ($collection->getIndexSearch()) { - $params['query'] = $solr_query; + $params['query'] = $solrQuery; } else { - $params['query'] = $solr_query . ' AND partof:0 AND toplevel:true'; + $params['query'] = $solrQuery . ' AND partof:0 AND toplevel:true'; } $partOfNothing = $solr->searchRaw($params); - $params['query'] = $solr_query . ' AND NOT partof:0 AND toplevel:true'; + $params['query'] = $solrQuery . ' AND NOT partof:0 AND toplevel:true'; $partOfSomething = $solr->searchRaw($params); $collectionInfo = [];