From 7d44705df2630346ca6305d9c5c0b217a0259ed6 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Mon, 25 Nov 2024 17:33:21 +0100 Subject: [PATCH 1/5] Add config for search bar --- Configuration/TypoScript/setup.typoscript | 46 ++++++++++++++++++----- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 39b737a..5d0911c 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -24,15 +24,41 @@ # page.includeJSFooter.BibliographyController = EXT:liszt_bibliography/Resources/Public/JavaScript/Src/BibliographyController.js - -/* -plugin.tx_liszt_common { - settings { - searchBarSelectItems { - 1:{ - label = Literatur - href = # - } +plugin.tx_lisztcommon_searchlisting { + settings { + entityTypes { + 1 { + # the key which leads to the entity type name translation in the locallang file + labelKey = bibliography + # the current extension name, needed for translation of label key + extensionName = liszt_bibliography + # the name of the entity index + indexName = zotero + # the filter fields + filters { + 0 { + field = itemType + type = terms + } + 1 { + field = place + type = terms + } + 2 { + field = date + type = terms + } + 3 { + field = journalTitle + type = terms + } + 4 { + field = creator + type = nested + script = example + } } + } } -}*/ + } +} From ee29d6fd0c3e1669b7260f13ee381411d090547a Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Mon, 25 Nov 2024 17:34:50 +0100 Subject: [PATCH 2/5] Add search slot drop down label --- Resources/Private/Language/locallang.xlf | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index ac8e907..fe97052 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -1,14 +1,17 @@ - -
- - - Bibliographie-Listing - - - Eine Auflistung aller Einträge der Liszt-Bibliographie - - - + +
+ + + Bibliographie-Listing + + + Eine Auflistung aller Einträge der Liszt-Bibliographie + + + Literatur + + + From 9eed9460efec4d6d0fb66c0d98560803b578ec61 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Wed, 27 Nov 2024 15:16:36 +0100 Subject: [PATCH 3/5] Test one part authors --- Classes/Processing/BibEntryProcessor.php | 25 ++++++++++--------- .../Unit/Processing/BibEntryProcessorTest.php | 21 ++++++++++++++++ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Classes/Processing/BibEntryProcessor.php b/Classes/Processing/BibEntryProcessor.php index b062028..170d862 100644 --- a/Classes/Processing/BibEntryProcessor.php +++ b/Classes/Processing/BibEntryProcessor.php @@ -16,8 +16,9 @@ use Illuminate\Support\Stringable; use Illuminate\Support\Str; use Slub\LisztCommon\Common\Collection; +use Slub\LisztCommon\Processing\IndexProcessor; -class BibEntryProcessor +class BibEntryProcessor extends IndexProcessor { public static function process( @@ -32,28 +33,28 @@ public static function process( $bibliographyItem['localizedCitations'][$locale] = $localizedCitation->get($key)['citation']; } $bibliographyItem['tei'] = $teiDataSets->get($key); - $bibliographyItem['tx_lisztcommon_header'] = self::buildListingField($bibliographyItem, BibEntryConfig::getAuthorHeader()); - if ($bibliographyItem['tx_lisztcommon_header'] == '') { - $bibliographyItem['tx_lisztcommon_header'] = self::buildListingField($bibliographyItem, BibEntryConfig::getEditorHeader()); + $bibliographyItem[self::HEADER_FIELD] = self::buildListingField($bibliographyItem, BibEntryConfig::getAuthorHeader()); + if ($bibliographyItem[self::HEADER_FIELD] == '') { + $bibliographyItem[self::HEADER_FIELD] = self::buildListingField($bibliographyItem, BibEntryConfig::getEditorHeader()); } - $bibliographyItem['tx_lisztcommon_body'] = self::buildListingField($bibliographyItem, BibEntryConfig::getBody()); - switch($bibliographyItem['itemType']) { + $bibliographyItem[self::BODY_FIELD] = self::buildListingField($bibliographyItem, BibEntryConfig::getBody()); + switch($bibliographyItem[self::TYPE_FIELD]) { case 'book': - $bibliographyItem['tx_lisztcommon_footer'] = self::buildListingField($bibliographyItem, BibEntryConfig::getBookFooter()); + $bibliographyItem[self::FOOTER_FIELD] = self::buildListingField($bibliographyItem, BibEntryConfig::getBookFooter()); break; case 'bookSection': - $bibliographyItem['tx_lisztcommon_footer'] = self::buildListingField($bibliographyItem, BibEntryConfig::getBookSectionFooter()); + $bibliographyItem[self::FOOTER_FIELD] = self::buildListingField($bibliographyItem, BibEntryConfig::getBookSectionFooter()); break; case 'journalArticle': - $bibliographyItem['tx_lisztcommon_footer'] = self::buildListingField($bibliographyItem, BibEntryConfig::getArticleFooter()); + $bibliographyItem[self::FOOTER_FIELD] = self::buildListingField($bibliographyItem, BibEntryConfig::getArticleFooter()); break; case 'thesis': - $bibliographyItem['tx_lisztcommon_footer'] = self::buildListingField($bibliographyItem, BibEntryConfig::getThesisFooter()); + $bibliographyItem[self::FOOTER_FIELD] = self::buildListingField($bibliographyItem, BibEntryConfig::getThesisFooter()); break; } - $bibliographyItem['tx_lisztcommon_searchable'] = self::buildListingField($bibliographyItem, BibEntryConfig::SEARCHABLE_FIELDS); - $bibliographyItem['tx_lisztcommon_boosted'] = self::buildListingField($bibliographyItem, BibEntryConfig::BOOSTED_FIELDS); + $bibliographyItem[self::SEARCHABLE_FIELD] = self::buildListingField($bibliographyItem, BibEntryConfig::SEARCHABLE_FIELDS); + $bibliographyItem[self::BOOSTED_FIELD] = self::buildListingField($bibliographyItem, BibEntryConfig::BOOSTED_FIELDS); return $bibliographyItem; } diff --git a/Tests/Unit/Processing/BibEntryProcessorTest.php b/Tests/Unit/Processing/BibEntryProcessorTest.php index 0878387..6a05fb1 100644 --- a/Tests/Unit/Processing/BibEntryProcessorTest.php +++ b/Tests/Unit/Processing/BibEntryProcessorTest.php @@ -80,6 +80,24 @@ protected function setUp(): void } JSON; + $this->exampleBookWithAnonymousAuthor = + <<title", + "creators": [ + { + "creatorType": "editor", + "firstName": "", + "lastName": "$this->editorLastName" + } + ], + "place": "$this->place", + "date": "$this->date" + } + JSON; + $this->exampleArticle = <<subject->process($this->exampleBookSectionArray, new Collection(), new Collection()); $article = $this->subject->process($this->exampleArticleArray, new Collection(), new Collection()); $bookWithoutAuthor = $this->subject->process($this->exampleBookWithoutAuthorArray, new Collection(), new Collection()); + $bookWithAnonymousAuthor = $this->subject->process($this->exampleBookWithoutAuthorArray, new Collection(), new Collection()); $expected = Str::of($this->authorFirstName . ' ' . $this->authorLastName); $expectedWithoutAuthor = Str::of($this->editorFirstName . ' ' . $this->editorLastName . ' (Hg.)'); + $expectedWithAnonymousAuthor = Str::of($this->authorLastName . ' (Hg.)'); self::assertEquals($book['tx_lisztcommon_header'], $expected); self::assertEquals($bookSection['tx_lisztcommon_header'], $expected); self::assertEquals($article['tx_lisztcommon_header'], $expected); self::assertEquals($bookWithoutAuthor['tx_lisztcommon_header'], $expectedWithoutAuthor); + self::assertEquals($bookWithAnonymousAuthor['tx_lisztcommon_header'], $expectedWithAnonymousAuthor); } /** From 4885af1982f2f02e3d5eab80b808ae8ae233b7b0 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Wed, 27 Nov 2024 17:33:57 +0100 Subject: [PATCH 4/5] Add script --- Configuration/TypoScript/setup.typoscript | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 5d0911c..ce4a293 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -49,13 +49,20 @@ plugin.tx_lisztcommon_searchlisting { type = terms } 3 { - field = journalTitle + field = publicationTitle type = terms } 4 { - field = creator + field = creators type = nested - script = example + script ( + String firstName = doc['creators.firstName.keyword'].size() > 0 ? doc['creators.firstName.keyword'].value : ''; + String lastName = doc['creators.lastName.keyword'].size() > 0 ? doc['creators.lastName.keyword'].value : ''; + if (firstName == '' && lastName == '') { + return null; + } + return (firstName + ' ' + lastName).trim(); + ) } } } From 16242a8ca3fc358b274ca57c7d06c814dd9af120 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Thu, 28 Nov 2024 13:22:32 +0100 Subject: [PATCH 5/5] Fixes --- Tests/Unit/Processing/BibEntryProcessorTest.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Tests/Unit/Processing/BibEntryProcessorTest.php b/Tests/Unit/Processing/BibEntryProcessorTest.php index 6a05fb1..47b0d8f 100644 --- a/Tests/Unit/Processing/BibEntryProcessorTest.php +++ b/Tests/Unit/Processing/BibEntryProcessorTest.php @@ -20,6 +20,7 @@ final class BibEntryProcessorTest extends UnitTestCase private ?BibEntryProcessor $subject = null; private array $exampleBookArray = []; private array $exampleBookWithoutAuthorArray = []; + private array $exampleBookWithAnonymousAuthorArray = []; private array $exampleBookSectionArray = []; private array $exampleArticleArray = []; @@ -37,6 +38,7 @@ final class BibEntryProcessorTest extends UnitTestCase private string $exampleBook = ''; private string $exampleBookWithoutAuthor = ''; + private string $exampleBookWithAnonymousAuthor = ''; private string $exampleArticle = ''; private string $exampleBookSection = ''; @@ -88,9 +90,9 @@ protected function setUp(): void "title": "$this->title", "creators": [ { - "creatorType": "editor", + "creatorType": "author", "firstName": "", - "lastName": "$this->editorLastName" + "lastName": "$this->authorLastName" } ], "place": "$this->place", @@ -147,6 +149,7 @@ protected function setUp(): void $this->subject = GeneralUtility::makeInstance(BibEntryProcessor::class); $this->exampleBookArray = json_decode($this->exampleBook, true); $this->exampleBookWithoutAuthorArray = json_decode($this->exampleBookWithoutAuthor, true); + $this->exampleBookWithAnonymousAuthorArray = json_decode($this->exampleBookWithAnonymousAuthor, true); $this->exampleArticleArray = json_decode($this->exampleArticle, true); $this->exampleBookSectionArray = json_decode($this->exampleBookSection, true); } @@ -165,11 +168,11 @@ public function headerIsProcessedCorrectly(): void $bookSection = $this->subject->process($this->exampleBookSectionArray, new Collection(), new Collection()); $article = $this->subject->process($this->exampleArticleArray, new Collection(), new Collection()); $bookWithoutAuthor = $this->subject->process($this->exampleBookWithoutAuthorArray, new Collection(), new Collection()); - $bookWithAnonymousAuthor = $this->subject->process($this->exampleBookWithoutAuthorArray, new Collection(), new Collection()); + $bookWithAnonymousAuthor = $this->subject->process($this->exampleBookWithAnonymousAuthorArray, new Collection(), new Collection()); $expected = Str::of($this->authorFirstName . ' ' . $this->authorLastName); $expectedWithoutAuthor = Str::of($this->editorFirstName . ' ' . $this->editorLastName . ' (Hg.)'); - $expectedWithAnonymousAuthor = Str::of($this->authorLastName . ' (Hg.)'); + $expectedWithAnonymousAuthor = Str::of($this->authorLastName); self::assertEquals($book['tx_lisztcommon_header'], $expected); self::assertEquals($bookSection['tx_lisztcommon_header'], $expected);