Skip to content

Commit

Permalink
Merge branch 'test' into 34-number-of-volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Richter committed Nov 28, 2024
2 parents e3b8283 + cd8f048 commit 24f9476
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 33 deletions.
25 changes: 13 additions & 12 deletions Classes/Processing/BibEntryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
}
Expand Down
53 changes: 43 additions & 10 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,48 @@

# 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 = publicationTitle
type = terms
}
4 {
field = creators
type = nested
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();
)
}
}
}
}
}*/
}
}
25 changes: 14 additions & 11 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="EXT:publisher_db/Resources/Private/Language/locallang" date="2022-12-19T13:20:31Z" product-name="publisher_db">
<header/>
<body>
<trans-unit id="listing_title" resname="tx_publisherdb_domain_model_publishermikroitem">
<source>Bibliographie-Listing</source>
</trans-unit>
<trans-unit id="listing_description" resname="tx_publisherdb_domain_model_publishermikroitem">
<source>Eine Auflistung aller Einträge der Liszt-Bibliographie</source>
</trans-unit>
</body>
</file>
<file source-language="en" datatype="plaintext" original="EXT:publisher_db/Resources/Private/Language/locallang" date="2022-12-19T13:20:31Z" product-name="publisher_db">
<header/>
<body>
<trans-unit id="listing_title" resname="listing_title">
<source>Bibliographie-Listing</source>
</trans-unit>
<trans-unit id="listing_description" resname="listing_description">
<source>Eine Auflistung aller Einträge der Liszt-Bibliographie</source>
</trans-unit>
<trans-unit id="bibliography" resname="bibliography">
<source>Literatur</source>
</trans-unit>
</body>
</file>
</xliff>
24 changes: 24 additions & 0 deletions Tests/Unit/Processing/BibEntryProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand All @@ -40,6 +41,7 @@ final class BibEntryProcessorTest extends UnitTestCase

private string $exampleBook = '';
private string $exampleBookWithoutAuthor = '';
private string $exampleBookWithAnonymousAuthor = '';
private string $exampleArticle = '';
private string $exampleBookSection = '';

Expand Down Expand Up @@ -102,6 +104,24 @@ protected function setUp(): void
}
JSON;

$this->exampleBookWithAnonymousAuthor =
<<<JSON
{
"key": "key",
"itemType": "book",
"title": "$this->title",
"creators": [
{
"creatorType": "author",
"firstName": "",
"lastName": "$this->authorLastName"
}
],
"place": "$this->place",
"date": "$this->date"
}
JSON;

$this->exampleArticle =
<<<JSON
{
Expand Down Expand Up @@ -158,6 +178,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);
}
Expand All @@ -176,14 +197,17 @@ 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->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);

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);
}

/**
Expand Down

0 comments on commit 24f9476

Please sign in to comment.