From b3f04517dd6a5e73cc985941af129dfc2b271592 Mon Sep 17 00:00:00 2001 From: Frank Morgner <morgnerf@ub.uni-leipzig.de> Date: Wed, 4 Apr 2018 10:22:32 +0200 Subject: [PATCH] refs #12815 * adjust ViewHelper methods for finc collection-info.phtml and collection-record.phtml --- .../Root/RecordDataFormatterFactory.php | 131 ++++++++++++++++++ .../SolrDefault/collection-info.phtml | 6 +- .../SolrDefault/collection-record.phtml | 6 +- 3 files changed, 141 insertions(+), 2 deletions(-) diff --git a/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php b/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php index 430cca1e8b7..b256aae34cb 100644 --- a/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php +++ b/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php @@ -54,6 +54,12 @@ class RecordDataFormatterFactory { $helper = new RecordDataFormatter(); + $helper->setDefaults( + 'collection-info', [$this, 'getDefaultCollectionInfoSpecs'] + ); + $helper->setDefaults( + 'collection-record', [$this, 'getDefaultCollectionRecordSpecs'] + ); $helper->setDefaults('core', [$this, 'getDefaultCoreSpecs']); $helper->setDefaults( 'description', [$this, 'getDefaultDescriptionSpecs'] @@ -135,6 +141,131 @@ class RecordDataFormatterFactory return $spec->getArray(); } + /** + * Get default specifications for displaying data in collection-info metadata. + * + * @return array + */ + public function getDefaultCollectionInfoSpecs() + { + $spec = new RecordDataFormatter\SpecBuilder(); + $spec->setTemplateLine( + 'Authors/Corporations', + 'getDeduplicatedAuthors', + 'data-authors.phtml', + [ + 'useCache' => true, + 'context' => [ + 'requiredDataFields' => [ + ['name' => 'role', 'prefix' => 'CreatorRoles::'] + ] + ] + ] + ); + $spec->setTemplateLine( + 'Title', 'getTitleDetails', 'data-titleDetails.phtml' + ); + $spec->setTemplateLine( + 'Dates of publication', 'getDateSpan', 'data-escapeHtml.phtml' + ); + $spec->setTemplateLine( + 'Summary', 'getSummary', 'data-escapeHtml.phtml' + ); + $spec->setTemplateLine( + 'Published', 'getPublicationDetails', 'data-publicationDetails.phtml' + ); + $spec->setLine( + 'Edition', 'getEdition', null, + ['prefix' => '<span property="bookEdition">', 'suffix' => '</span>'] + ); + $spec->setTemplateLine( + 'Subjects', 'getAllSubjectHeadings', 'data-allSubjectHeadings.phtml' + ); + $spec->setTemplateLine( + 'Online Access', true, 'data-onlineAccess.phtml' + ); + $spec->setTemplateLine( + 'Item Description', 'getGeneralNotes', 'data-escapeHtml.phtml' + ); + $spec->setTemplateLine( + 'Production Credits', + 'getProductionCredits', + 'data-escapeHtml.phtml' + ); + $spec->setTemplateLine( + 'Set Multipart', + 'getHierarchyParentTitle', + 'data-hierarchyParentTitle.phtml' + ); + $spec->setTemplateLine( + 'ISBN', 'getISBNs', 'data-escapeHtml.phtml' + ); + $spec->setTemplateLine( + 'ISSN', 'getISSNs', 'data-escapeHtml.phtml' + ); + $spec->setTemplateLine( + 'Notes', + 'getAdditionalNotes', + 'data-escapeHtml.phtml', + [ + 'useCache' => true + ] + ); + $spec->setLine( + 'Format', 'getFormats', 'RecordHelper', + ['helperMethod' => 'getFormatList'] + ); + $spec->setTemplateLine( + 'Language', 'getLanguages', 'data-escapeHtml.phtml' + ); + $spec->setTemplateLine( + 'Additionals', + 'getAdditionals', + 'data-additionals.phtml', + [ + 'labelFunction' => function() { return null; } + ] + ); + return $spec->getArray(); + } + + /** + * Get default specifications for displaying data in collection-record metadata. + * + * @return array + */ + public function getDefaultCollectionRecordSpecs() + { + $spec = new RecordDataFormatter\SpecBuilder(); + $spec->setLine('Summary', 'getSummary'); + $spec->setTemplateLine( + 'Authors/Corporations', + 'getDeduplicatedAuthors', + 'data-authors.phtml', + [ + 'useCache' => true, + 'context' => [ + 'requiredDataFields' => [ + ['name' => 'role', 'prefix' => 'CreatorRoles::'] + ] + ] + ] + ); + $spec->setTemplateLine( + 'Language', 'getLanguages', 'data-escapeHtml.phtml' + ); + $spec->setLine( + 'Format', 'getFormats', 'RecordHelper', + ['helperMethod' => 'getFormatList'] + ); + $spec->setTemplateLine( + 'Access', 'getAccessRestrictions', 'data-escapeHtml.phtml' + ); + $spec->setTemplateLine( + 'Related Items', 'getRelationshipNotes', 'data-escapeHtml.phtml' + ); + return $spec->getArray(); + } /** * Get default specifications for displaying data in core metadata. diff --git a/themes/finc/templates/RecordDriver/SolrDefault/collection-info.phtml b/themes/finc/templates/RecordDriver/SolrDefault/collection-info.phtml index 2215d787c0e..185ff5dfeeb 100644 --- a/themes/finc/templates/RecordDriver/SolrDefault/collection-info.phtml +++ b/themes/finc/templates/RecordDriver/SolrDefault/collection-info.phtml @@ -51,7 +51,11 @@ <? /* Table summary not supported in html 5, finc-specific solution, CK */ ?> <caption class="sr-only"><?=$this->transEsc('Bibliographic Details')?></caption> <? foreach ($fields as $key => $current): ?> - <tr><th><?=$this->transEsc($key)?>:</th><td><?=$current['value']?></td></tr> + <? if ($key == null): ?> + <?=$current['value']?> + <? else: ?> + <tr><th><?=$this->transEsc($key)?>:</th><td><?=$current['value']?></td></tr> + <? endif; ?> <? endforeach; ?> </table> <? endif; ?> diff --git a/themes/finc/templates/RecordDriver/SolrDefault/collection-record.phtml b/themes/finc/templates/RecordDriver/SolrDefault/collection-record.phtml index 40a043a32bc..e15e4cd9179 100644 --- a/themes/finc/templates/RecordDriver/SolrDefault/collection-record.phtml +++ b/themes/finc/templates/RecordDriver/SolrDefault/collection-record.phtml @@ -13,7 +13,11 @@ $fields = $formatter->getData($driver, $formatter->getDefaults('collection-recor <? /* Table summary not supported in html 5, finc-specific solution, CK */ ?> <caption class="sr-only"><?=$this->transEsc('Bibliographic Details')?></caption> <? foreach ($fields as $key => $current): ?> - <tr><th><?=$this->transEsc($key)?>:</th><td><?=$current['value']?></td></tr> + <? if ($key == null): ?> + <?=$current['value']?> + <? else: ?> + <tr><th><?=$this->transEsc($key)?>:</th><td><?=$current['value']?></td></tr> + <? endif; ?> <? endforeach; ?> </table> <? endif; ?> -- GitLab