Skip to content

Commit

Permalink
Merge pull request #30 from slub/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dikastes authored Nov 11, 2024
2 parents c001cad + 6bcb1b8 commit 1461895
Show file tree
Hide file tree
Showing 3 changed files with 246 additions and 101 deletions.
284 changes: 193 additions & 91 deletions Classes/Processing/BibEntryConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,28 @@

class BibEntryConfig
{
const HEADER_FIELDS = [
[
'compound' => [
'fields' => [
[
'field' => 'firstName',
'conditionField' => 'creatorType',
'conditionValue' => 'author',
'conditionRelation' => 'eq'
],
[
'field' => 'lastName',
'conditionField' => 'creatorType',
'conditionValue' => 'author',
'conditionRelation' => 'eq'
]
const AUTHOR = [
'compound' => [
'fields' => [
[
'field' => 'firstName',
'conditionField' => 'creatorType',
'conditionValue' => 'author',
'conditionRelation' => 'eq'
],
'field' => 'creators',
'separator' => ', ',
'reverseFirst' => true
]
[
'field' => 'lastName',
'conditionField' => 'creatorType',
'conditionValue' => 'author',
'conditionRelation' => 'eq'
]
],
'field' => 'creators',
'separator' => ', '
]
];
const BODY_FIELDS = [
[
'field' => 'title',
'postfix' => ' '
],
[
'field' => 'shortTitle',
'prefix' => '(',
'postfix' => ')'
],
];
const FOOTER_FIELDS = [
[ 'compound' => [
const EDITOR = [
'compound' => [
'fields' => [
[
'field' => 'firstName',
Expand All @@ -63,69 +49,185 @@ class BibEntryConfig
'conditionField' => 'creatorType',
'conditionValue' => 'editor',
'conditionRelation' => 'eq'
]
],
'field' => 'creators',
'separator' => ', '
]
];
const TRANSLATOR = [
'compound' => [
'fields' => [
[
'field' => 'firstName',
'conditionField' => 'creatorType',
'conditionValue' => 'translator',
'conditionRelation' => 'eq'
],
[
'field' => 'lastName',
'conditionField' => 'creatorType',
'conditionValue' => 'translator',
'conditionRelation' => 'eq'
]
],
'field' => 'creators',
'separator' => ', ',
'postfix' => ': '
]],
[
'field' => 'publicationTitle',
'conditionField' => 'publicationTitle',
'conditionValue' => '',
'conditionRelation' => 'neq',
'postfix' => ', '
],
[
'field' => 'bookTitle',
'conditionField' => 'bookTitle',
'conditionValue' => '',
'conditionRelation' => 'neq',
'postfix' => ', '
],
[
'field' => 'university',
'conditionField' => 'university',
'conditionValue' => '',
'conditionRelation' => 'neq',
'postfix' => ' '
],
[
'field' => 'volume',
'conditionField' => 'volume',
'conditionValue' => '',
'conditionRelation' => 'neq',
'postfix' => ' '
],
[
'field' => 'issue',
'conditionField' => 'issue',
'conditionValue' => '',
'conditionRelation' => 'neq',
'prefix' => '(',
'postfix' => ') '
],
[
'field' => 'place',
'conditionField' => 'place',
'conditionValue' => '',
'conditionRelation' => 'neq',
'postfix' => ' '
],
[
'field' => 'date',
'conditionField' => 'date',
'conditionValue' => '',
'conditionRelation' => 'neq',
],
[
'field' => 'pages',
'conditionField' => 'pages',
'conditionValue' => '',
'conditionRelation' => 'neq',
'prefix' => ', '
'separator' => ', '
]
];
const TITLE = [ 'field' => 'title' ];
const PUBLICATION_TITLE = [
'field' => 'publicationTitle',
'conditionField' => 'publicationTitle',
'conditionValue' => '',
'conditionRelation' => 'neq',
];
const BOOK_TITLE = [
'field' => 'bookTitle',
'conditionField' => 'bookTitle',
'conditionValue' => '',
'conditionRelation' => 'neq',
];
const UNIVERSITY = [
'field' => 'university',
'conditionField' => 'university',
'conditionValue' => '',
'conditionRelation' => 'neq',
];
const VOLUME = [
'field' => 'volume',
'conditionField' => 'volume',
'conditionValue' => '',
'conditionRelation' => 'neq',
];
const ISSUE = [
'field' => 'issue',
'conditionField' => 'issue',
'conditionValue' => '',
'conditionRelation' => 'neq'
];
const PLACE = [
'field' => 'place',
'conditionField' => 'place',
'conditionValue' => '',
'conditionRelation' => 'neq',
];
const DATE = [
'field' => 'date',
'conditionField' => 'date',
'conditionValue' => '',
'conditionRelation' => 'neq',
];
const PAGES = [
'field' => 'pages',
'conditionField' => 'pages',
'conditionValue' => '',
'conditionRelation' => 'neq',
];

public static function getAuthorHeader(): array
{
return [ self::AUTHOR ];
}

public static function getEditorHeader(): array
{
return [ self::postfix(self::EDITOR, ' (Hg.)') ];
}

public static function getBody(): array
{
return [ self::TITLE ];
}

public static function getArticleFooter(): array
{
return [
self::postfix(self::PUBLICATION_TITLE, ' '),
self::postfix(self::VOLUME, ' '),
self::circumfix(self::DATE, '(', '), '),
self::circumfix(self::ISSUE, 'Nr. ', ', '),
self::PAGES
];
}

public static function getBookSectionFooter(): array
{
return [
self::circumfix(self::BOOK_TITLE, 'In ', ', '),
self::postfix(self::VOLUME, ', '),
self::circumfix(self::EDITOR, 'hg. von ', ', '),
self::circumfix(self::TRANSLATOR, 'übers. von ', ', '),
self::postfix(self::PLACE, ' '),
self::postfix(self::DATE, ', '),
self::PAGES
];
}

public static function getBookFooter(): array
{
return [
self::circumfix(self::EDITOR, 'hg. von ', ', '),
self::circumfix(self::TRANSLATOR, 'übers. von ', ', '),
self::postfix(self::PLACE, ' '),
self::DATE
];
}

public static function getThesisFooter(): array
{
return [
self::postfix(self::UNIVERSITY, ' '),
self::DATE
];
}

private static function prefix(array $field, string $prefix): array
{
$field['prefix'] = $prefix;
return $field;
}

private static function postfix(array $field, string $postfix): array
{
$field['postfix'] = $postfix;
return $field;
}

private static function circumfix(array $field, string $prefix, string $postfix): array
{
return self::prefix(
self::postfix($field, $postfix),
$prefix);
}

private static function surround(array $field): array
{
return self::circumfix($field, '(', ')');
}

private static function space(array $field): array
{
$field['postfix'] = ' ';
return $field;
}

private static function surroundSpace(array $field): array
{
return self::space(self::surround($field));
}

private static function comma(array $field): array
{
$field['postfix'] = ', ';
return $field;
}

private static function surroundComma(array $field): array
{
return self::comma(self::surround($field));
}

const SEARCHABLE_FIELDS = [
[
'compound' => [
Expand Down
23 changes: 20 additions & 3 deletions Classes/Processing/BibEntryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,26 @@ public static function process(
$bibliographyItem['localizedCitations'][$locale] = $localizedCitation->get($key)['citation'];
}
$bibliographyItem['tei'] = $teiDataSets->get($key);
$bibliographyItem['tx_lisztcommon_header'] = self::buildListingField($bibliographyItem, BibEntryConfig::HEADER_FIELDS);
$bibliographyItem['tx_lisztcommon_body'] = self::buildListingField($bibliographyItem, BibEntryConfig::BODY_FIELDS);
$bibliographyItem['tx_lisztcommon_footer'] = self::buildListingField($bibliographyItem, BibEntryConfig::FOOTER_FIELDS);
$bibliographyItem['tx_lisztcommon_header'] = self::buildListingField($bibliographyItem, BibEntryConfig::getAuthorHeader());
if ($bibliographyItem['tx_lisztcommon_header'] == '') {
$bibliographyItem['tx_lisztcommon_header'] = self::buildListingField($bibliographyItem, BibEntryConfig::getEditorHeader());
}
$bibliographyItem['tx_lisztcommon_body'] = self::buildListingField($bibliographyItem, BibEntryConfig::getBody());
switch($bibliographyItem['itemType']) {
case 'book':
$bibliographyItem['tx_lisztcommon_footer'] = self::buildListingField($bibliographyItem, BibEntryConfig::getBookFooter());
break;
case 'bookSection':
$bibliographyItem['tx_lisztcommon_footer'] = self::buildListingField($bibliographyItem, BibEntryConfig::getBookSectionFooter());
break;
case 'journalArticle':
$bibliographyItem['tx_lisztcommon_footer'] = self::buildListingField($bibliographyItem, BibEntryConfig::getArticleFooter());
break;
case 'thesis':
$bibliographyItem['tx_lisztcommon_footer'] = 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);

Expand Down
Loading

0 comments on commit 1461895

Please sign in to comment.