Skip to content
Snippets Groups Projects
Commit d8390851 authored by Dorian Merz's avatar Dorian Merz Committed by Robert Lange
Browse files

refs #18292 [finc] refactor data-templates and RecordDataFormatterFactory in finc

* removes templates for simple escaped and translated data, this can be achieved via options in simple SpecLine
* add alterable separator to authors template
* replace data-dateSpan with RecordHelper SpecLine
parent 44567a59
Branches
Tags
No related merge requests found
...@@ -197,15 +197,13 @@ class RecordDataFormatterFactory ...@@ -197,15 +197,13 @@ class RecordDataFormatterFactory
'Title', 'Title',
'getTitleDetails' 'getTitleDetails'
); );
$spec->setTemplateLine( $spec->setLine(
'Dates of publication', 'Dates of publication',
'getDateSpan', 'getDateSpan'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Summary', 'Summary',
'getSummary', 'getSummary'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setTemplateLine(
'Published', 'Published',
...@@ -225,15 +223,13 @@ class RecordDataFormatterFactory ...@@ -225,15 +223,13 @@ class RecordDataFormatterFactory
); );
/* finc: remove 'Online Access' in record-details #13770 - VE */ /* finc: remove 'Online Access' in record-details #13770 - VE */
/* $spec->setTemplateLine('Online Access', true, 'data-onlineAccess.phtml'); */ /* $spec->setTemplateLine('Online Access', true, 'data-onlineAccess.phtml'); */
$spec->setTemplateLine( $spec->setLine(
'Item Description', 'Item Description',
'getGeneralNotes', 'getGeneralNotes'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Production Credits', 'Production Credits',
'getProductionCredits', 'getProductionCredits'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setTemplateLine(
'Set Multipart', 'Set Multipart',
...@@ -250,10 +246,10 @@ class RecordDataFormatterFactory ...@@ -250,10 +246,10 @@ class RecordDataFormatterFactory
'getISSNs', 'getISSNs',
'data-issn.phtml' 'data-issn.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Notes', 'Notes',
'getAdditionalNotes', 'getAdditionalNotes',
'data-escapeHtml.phtml', null,
[ [
'useCache' => true 'useCache' => true
] ]
...@@ -310,15 +306,13 @@ class RecordDataFormatterFactory ...@@ -310,15 +306,13 @@ class RecordDataFormatterFactory
'RecordHelper', 'RecordHelper',
['helperMethod' => 'getFormatList'] ['helperMethod' => 'getFormatList']
); );
$spec->setTemplateLine( $spec->setLine(
'Access', 'Access',
'getAccessRestrictions', 'getAccessRestrictions'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Related Items', 'Related Items',
'getRelationshipNotes', 'getRelationshipNotes'
'data-escapeHtml.phtml'
); );
return $spec->getArray(); return $spec->getArray();
} }
...@@ -383,7 +377,10 @@ class RecordDataFormatterFactory ...@@ -383,7 +377,10 @@ class RecordDataFormatterFactory
$spec->setLine( $spec->setLine(
'Dissertation Note', 'Dissertation Note',
'getDissertationNote', 'getDissertationNote',
'data-escapeHtmlCommaSep.phtml' null,
[
'separator' => ', '
]
); );
$spec->setLine( $spec->setLine(
'Format', 'Format',
...@@ -429,20 +426,19 @@ class RecordDataFormatterFactory ...@@ -429,20 +426,19 @@ class RecordDataFormatterFactory
'getAdditionals', 'getAdditionals',
[$this,'additionals'] [$this,'additionals']
); );
$spec->setTemplateLine( $spec->setLine(
'Source', 'Source',
'getMegaCollection', 'getMegaCollection'
'data-escapeHtml.phtml'
); );
$spec->setMultiLine( $spec->setMultiLine(
"Other Relationship Entry", "Other Relationship Entry",
'getOtherRelationshipEntry', 'getOtherRelationshipEntry',
[$this,'otherRelationshipEntry'] [$this,'otherRelationshipEntry']
); );
$spec->setTemplateLine( $spec->setLine(
'Notes', 'Notes',
'getAdditionalNotes', 'getAdditionalNotes',
'data-escapeHtml.phtml', null,
[ [
'useCache' => true 'useCache' => true
] ]
...@@ -459,60 +455,49 @@ class RecordDataFormatterFactory ...@@ -459,60 +455,49 @@ class RecordDataFormatterFactory
public function getDefaultDescriptionSpecs() public function getDefaultDescriptionSpecs()
{ {
$spec = new RecordDataFormatter\SpecBuilder(); $spec = new RecordDataFormatter\SpecBuilder();
$spec->setTemplateLine( $spec->setLine(
'Summary', 'Summary',
'getSummary', 'getSummary'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Dates of publication', 'Dates of publication',
'getDateSpan', 'getDateSpan'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Item Description', 'Item Description',
'getGeneralNotes', 'getGeneralNotes'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Physical Description', 'Physical Description',
'getPhysicalDescriptions', 'getPhysicalDescriptions'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Publication Frequency', 'Publication Frequency',
'getPublicationFrequency', 'getPublicationFrequency'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Playing Time', 'Playing Time',
'getPlayingTimes', 'getPlayingTimes'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Format', 'Format',
'getSystemDetails', 'getSystemDetails'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Audience', 'Audience',
'getTargetAudienceNotes', 'getTargetAudienceNotes'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Awards', 'Awards',
'getAwards', 'getAwards'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Production Credits', 'Production Credits',
'getProductionCredits', 'getProductionCredits'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Bibliography', 'Bibliography',
'getBibliographyNotes', 'getBibliographyNotes'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setTemplateLine(
'ISBN', 'ISBN',
...@@ -524,35 +509,29 @@ class RecordDataFormatterFactory ...@@ -524,35 +509,29 @@ class RecordDataFormatterFactory
'getISSNs', 'getISSNs',
'data-issn.phtml' 'data-issn.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'DOI', 'DOI',
'getCleanDOI', 'getCleanDOI'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'EISSN', 'EISSN',
'getEISSNs', 'getEISSNs'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Related Items', 'Related Items',
'getRelationshipNotes', 'getRelationshipNotes'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Access', 'Access',
'getAccessRestrictions', 'getAccessRestrictions'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Finding Aid', 'Finding Aid',
'getFindingAids', 'getFindingAids'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Publication_Place', 'Publication_Place',
'getHierarchicalPlaceNames', 'getHierarchicalPlaceNames'
'data-escapeHtml.phtml'
); );
$spec->setTemplateLine( $spec->setTemplateLine(
'Author Notes', 'Author Notes',
...@@ -564,10 +543,10 @@ class RecordDataFormatterFactory ...@@ -564,10 +543,10 @@ class RecordDataFormatterFactory
'getLocalSignature', 'getLocalSignature',
'data-localSignature.phtml' 'data-localSignature.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Notes', 'Notes',
'getAdditionalNotes', 'getAdditionalNotes',
'data-escapeHtml.phtml', null,
[ [
'useCache' => true 'useCache' => true
] ]
...@@ -636,86 +615,46 @@ class RecordDataFormatterFactory ...@@ -636,86 +615,46 @@ class RecordDataFormatterFactory
], ],
] ]
); );
$spec->setTemplateLine( $spec->setLine(
'Subject Detail', 'Subject Detail',
'getSubjectDetails', 'getSubjectDetails'
'data-escapeHtml.phtml',
[
'context' => ['class' => 'recordSubjects']
]
); );
$spec->setTemplateLine( $spec->setLine(
'Subject Place', 'Subject Place',
'getSubjectPlaces', 'getSubjectPlaces'
'data-escapeHtml.phtml',
[
'context' => ['class' => 'recordSubjects']
]
); );
$spec->setTemplateLine( $spec->setLine(
'Subject Date', 'Subject Date',
'getSubjectDates', 'getSubjectDates'
'data-escapeHtml.phtml',
[
'context' => ['class' => 'recordSubjects']
]
); );
$spec->setTemplateLine( $spec->setLine(
'Subject Actor', 'Subject Actor',
'getSubjectActors', 'getSubjectActors'
'data-escapeHtml.phtml',
[
'context' => ['class' => 'recordSubjects']
]
); );
$spec->setTemplateLine( $spec->setLine(
'Institution', 'Institution',
'getInstitutions', 'getInstitutions'
'data-institutions.phtml',
[
'context' => ['class' => 'recordInstitution']
]
); );
$spec->setTemplateLine( $spec->setLine(
'Inventory ID', 'Inventory ID',
'getIdentifier', 'getIdentifier'
'data-escapeHtml.phtml',
[
'context' => ['class' => 'recordIdentifier']
]
); );
$spec->setTemplateLine( $spec->setLine(
'Inventory ID', 'Inventory ID',
'getIdentifier', 'getIdentifier'
'data-escapeHtml.phtml',
[
'context' => ['class' => 'recordIdentifier']
]
); );
$spec->setTemplateLine( $spec->setLine(
'Measurements', 'Measurements',
'getMeasurements', 'getMeasurements'
'data-escapeHtml.phtml',
[
'context' => ['class' => 'recordMeasurements']
]
); );
$spec->setTemplateLine( $spec->setLine(
'Measurements', 'Measurements',
'getMeasurementsDescription', 'getMeasurementsDescription'
'data-escapeHtml.phtml',
[
'context' => ['class' => 'recordMeasurements']
]
); );
$spec->setTemplateLine( $spec->setLine(
'Collection', 'Collection',
'getCollections', 'getCollections'
'data-escapeHtml.phtml',
[
'context' => ['class' => 'recordCollection']
]
); );
$spec->setLine( $spec->setLine(
'Object type', 'Object type',
...@@ -723,21 +662,13 @@ class RecordDataFormatterFactory ...@@ -723,21 +662,13 @@ class RecordDataFormatterFactory
'RecordHelper', 'RecordHelper',
['helperMethod' => 'getFormatList'] ['helperMethod' => 'getFormatList']
); );
$spec->setTemplateLine( $spec->setLine(
'Other Classification', 'Other Classification',
'getFormatClassifications', 'getFormatClassifications'
'data-escapeHtml.phtml',
[
'context' => ['class' => 'recordClassifications']
]
); );
$spec->setTemplateLine( $spec->setLine(
'Other ID', 'Other ID',
'getLocalIdentifiers', 'getLocalIdentifiers'
'data-escapeHtml.phtml',
[
'context' => ['class' => 'recordIdentifiers']
]
); );
$spec->setMultiLine( $spec->setMultiLine(
'Events', 'Events',
...@@ -750,15 +681,18 @@ class RecordDataFormatterFactory ...@@ -750,15 +681,18 @@ class RecordDataFormatterFactory
'getLanguages', 'getLanguages',
'data-transEscCommaSepLang.phtml' 'data-transEscCommaSepLang.phtml'
); );
$spec->setTemplateLine( $spec->setLine(
'Time of origin', 'Time of origin',
'getDateSpan', 'getDateSpan',
'data-dateSpan.phtml' 'recordHelper',
[
'helperMethod' => 'mapDateListToRangeView'
]
); );
$spec->setTemplateLine( $spec->setLine(
'Edition', 'Edition',
'getEdition', 'getEdition',
'data-escapeHtml.phtml', null,
[ [
'prefix' => '<span property="bookEdition">', 'prefix' => '<span property="bookEdition">',
'suffix' => '</span>' 'suffix' => '</span>'
...@@ -787,10 +721,13 @@ class RecordDataFormatterFactory ...@@ -787,10 +721,13 @@ class RecordDataFormatterFactory
public function getLidoDescriptionSpecs() public function getLidoDescriptionSpecs()
{ {
$spec = new RecordDataFormatter\SpecBuilder(); $spec = new RecordDataFormatter\SpecBuilder();
$spec->setTemplateLine( $spec->setLine(
'Time of origin', 'Time of origin',
'getDateSpan', 'getDateSpan',
'data-dateSpan.phtml' 'recordHelper',
[
'helperMethod' => 'mapDateListToRangeView'
]
); );
$spec->setTemplateLine( $spec->setTemplateLine(
'Access', 'Access',
...@@ -858,7 +795,10 @@ class RecordDataFormatterFactory ...@@ -858,7 +795,10 @@ class RecordDataFormatterFactory
$spec->setLine( $spec->setLine(
'Dissertation Note', 'Dissertation Note',
'getDissertationNote', 'getDissertationNote',
'data-escapeHtmlCommaSep.phtml' null,
[
'separator' => ', '
]
); );
$spec->setLine( $spec->setLine(
'Format', 'Format',
...@@ -919,20 +859,19 @@ class RecordDataFormatterFactory ...@@ -919,20 +859,19 @@ class RecordDataFormatterFactory
} }
] ]
); );
$spec->setTemplateLine( $spec->setLine(
'Source', 'Source',
'getMegaCollection', 'getMegaCollection'
'data-escapeHtml.phtml'
); );
$spec->setMultiLine( $spec->setMultiLine(
"Other Relationship Entry", "Other Relationship Entry",
'getOtherRelationshipEntry', 'getOtherRelationshipEntry',
[$this,'otherRelationshipEntry'] [$this,'otherRelationshipEntry']
); );
$spec->setTemplateLine( $spec->setLine(
'Notes', 'Notes',
'getAdditionalNotes', 'getAdditionalNotes',
'data-escapeHtml.phtml', null,
[ [
'useCache' => true 'useCache' => true
] ]
......
...@@ -53,5 +53,5 @@ $types = [ ...@@ -53,5 +53,5 @@ $types = [
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
<?=implode(', ', $formattedAuthors)?> <?=implode($separator ?? ', ', $formattedAuthors)?>
<!-- finc: RecordDriver - DefaultRecord - data-authors - END --> <!-- finc: RecordDriver - DefaultRecord - data-authors - END -->
<?php // Don't add START and END comments ?>
<?php if (!empty($data)): ?>
<?php if (is_array($data)): ?>
<?=implode('<br/>', array_map(array($this, 'escapeHtml'), $data))?>
<?php else: ?>
<?=$this->escapeHtml($data)?>
<?php endif; ?>
<?php endif; ?>
\ No newline at end of file
<!-- finc: RecordDriver - DefaultRecord - data-escapeHtmlCommaSep -->
<?php if (!empty($data)): ?>
<?php if (is_array($data)): ?>
<?=implode(', ', array_map(array($this, 'escapeHtml'), $data));?>
<?php else: ?>
<?=$this->escapeHtml($data)?>
<?php endif; ?>
<?php endif; ?>
<!-- finc: RecordDriver - DefaultRecord - data-escapeHtmlCommaSep - END -->
\ No newline at end of file
<?php // Don't add START and END comments ?>
<?php if (!empty($data)): ?>
<?php if (is_array($data)): ?>
<?=implode('<br/>', array_map(array($this, 'transEsc'), $data))?>
<?php else: ?>
<?=$this->transEsc($data)?>
<?php endif; ?>
<?php endif; ?>
\ No newline at end of file
<?php if (!empty($data)): ?>
<?php if (is_array($data)): ?>
<?=implode(', ', array_map(array($this, 'transEsc'), $data));?>
<?php else: ?>
<?=$this->transEsc($data)?>
<?php endif; ?>
<?php endif; ?>
\ No newline at end of file
<?= $this->record($this->driver)->mapDateListToRangeView($data); ?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment