Skip to content
Snippets Groups Projects
Commit 4f7cb4d1 authored by Mario Trojan's avatar Mario Trojan Committed by Robert Lange
Browse files

schema.org optimizations (#1555)

- add new itemPrefix/itemSuffix options.
- use schema.org property "datePublished" instead of invalid "publicationDate".
- schema.org changes for isbn, issn, identifier, language.
- use itemPrefix/itemSuffix for DOI + Edition.
parent 79ea7604
No related merge requests found
......@@ -357,7 +357,9 @@ class RecordDataFormatter extends AbstractHelper
$remaining = count($array);
foreach ($array as $line) {
$remaining--;
$text = $escaper($transDomain . $line);
$text = $options['itemPrefix'] ?? '';
$text .= $escaper($transDomain . $line);
$text .= $options['itemSuffix'] ?? '';
$retVal .= ($link = $this->getLink($line, $options))
? '<a href="' . $link . '">' . $text . '</a>' : $text;
if ($remaining > 0) {
......
......@@ -141,13 +141,19 @@ class RecordDataFormatterFactory implements FactoryInterface
'Format', 'getFormats', 'RecordHelper',
['helperMethod' => 'getFormatList']
);
$spec->setLine('Language', 'getLanguages');
$spec->setLine(
'Language', 'getLanguages', null,
['itemPrefix' => '<span property="availableLanguage" typeof="Language">'
. '<span property="name">',
'itemSuffix' => '</span></span>']
);
$spec->setTemplateLine(
'Published', 'getPublicationDetails', 'data-publicationDetails.phtml'
);
$spec->setLine(
'Edition', 'getEdition', null,
['prefix' => '<span property="bookEdition">', 'suffix' => '</span>']
['itemPrefix' => '<span property="bookEdition">',
'itemSuffix' => '</span>']
);
$spec->setTemplateLine('Series', 'getSeries', 'data-series.phtml');
$spec->setTemplateLine(
......@@ -159,8 +165,14 @@ class RecordDataFormatterFactory implements FactoryInterface
);
$spec->setLine('Notes', 'getGeneralNotes');
$spec->setLine('Production Credits', 'getProductionCredits');
$spec->setLine('ISBN', 'getISBNs');
$spec->setLine('ISSN', 'getISSNs');
$spec->setLine(
'ISBN', 'getISBNs', null,
['itemPrefix' => '<span property="isbn">', 'itemSuffix' => '</span>']
);
$spec->setLine(
'ISSN', 'getISSNs', null,
['itemPrefix' => '<span property="issn">', 'itemSuffix' => '</span>']
);
return $spec->getArray();
}
......@@ -176,7 +188,12 @@ class RecordDataFormatterFactory implements FactoryInterface
$spec->setMultiLine(
'Authors', 'getDeduplicatedAuthors', $this->getAuthorFunction()
);
$spec->setLine('Language', 'getLanguages');
$spec->setLine(
'Language', 'getLanguages', null,
['itemPrefix' => '<span property="availableLanguage" typeof="Language">'
. '<span property="name">',
'itemSuffix' => '</span></span>']
);
$spec->setLine(
'Format', 'getFormats', 'RecordHelper',
['helperMethod' => 'getFormatList']
......@@ -210,13 +227,19 @@ class RecordDataFormatterFactory implements FactoryInterface
'Format', 'getFormats', 'RecordHelper',
['helperMethod' => 'getFormatList']
);
$spec->setLine('Language', 'getLanguages');
$spec->setLine(
'Language', 'getLanguages', null,
['itemPrefix' => '<span property="availableLanguage" typeof="Language">'
. '<span property="name">',
'itemSuffix' => '</span></span>']
);
$spec->setTemplateLine(
'Published', 'getPublicationDetails', 'data-publicationDetails.phtml'
);
$spec->setLine(
'Edition', 'getEdition', null,
['prefix' => '<span property="bookEdition">', 'suffix' => '</span>']
['itemPrefix' => '<span property="bookEdition">',
'itemSuffix' => '</span>']
);
$spec->setTemplateLine('Series', 'getSeries', 'data-series.phtml');
$spec->setTemplateLine(
......@@ -253,9 +276,19 @@ class RecordDataFormatterFactory implements FactoryInterface
$spec->setLine('Awards', 'getAwards');
$spec->setLine('Production Credits', 'getProductionCredits');
$spec->setLine('Bibliography', 'getBibliographyNotes');
$spec->setLine('ISBN', 'getISBNs');
$spec->setLine('ISSN', 'getISSNs');
$spec->setLine('DOI', 'getCleanDOI');
$spec->setLine(
'ISBN', 'getISBNs', null,
['itemPrefix' => '<span property="isbn">', 'itemSuffix' => '</span>']
);
$spec->setLine(
'ISSN', 'getISSNs', null,
['itemPrefix' => '<span property="issn">', 'itemSuffix' => '</span>']
);
$spec->setLine(
'DOI', 'getCleanDOI', null,
['itemPrefix' => '<span property="identifier">',
'itemSuffix' => '</span>']
);
$spec->setLine('Related Items', 'getRelationshipNotes');
$spec->setLine('Access', 'getAccessRestrictions');
$spec->setLine('Finding Aid', 'getFindingAids');
......
......@@ -344,7 +344,7 @@ class RecordDataFormatterTest extends \VuFindTest\Unit\ViewHelperTestCase
// Check for exact markup in representative example:
$this->assertEquals(
'Italian<br />Latin', $this->findResult('Language', $results)['value']
'<span property="availableLanguage" typeof="Language"><span property="name">Italian</span></span><br /><span property="availableLanguage" typeof="Language"><span property="name">Latin</span></span>', $this->findResult('Language', $results)['value']
);
// Check for context in Building:
......
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