commit
96e9bb5295
6 changed files with 188 additions and 0 deletions
@ -0,0 +1,5 @@
|
||||
name: Alter Mods Template (PWC) |
||||
description: "Alters the MODS template for OAI-PMH" |
||||
package: Custom |
||||
type: module |
||||
core_version_requirement: ^10.3 || ^11 |
||||
@ -0,0 +1,29 @@
|
||||
<?php |
||||
|
||||
function alter_mods_template_rest_oai_pmh_metadata_template_alter(array &$template) { |
||||
// Use my module's template file to render mods metadata. |
||||
if ($template['file'] == 'mods') { |
||||
// This would use the template path/to/mymodule/templates/mods.html.twig |
||||
// for mods metadata rendered in OAI-PMH. |
||||
$template['name'] = 'alter_mods_template'; |
||||
} |
||||
} |
||||
|
||||
function alter_mods_template_theme($existing, $type, $theme, $path) { |
||||
return [ |
||||
'paragraph__contributor__data' => [], |
||||
'field__field_contributor_name_and_role__data' => [], |
||||
'field__field_contributor_description__data' => [], |
||||
]; |
||||
} |
||||
|
||||
function alter_mods_template_theme_suggestions_field(array $variables) { |
||||
$suggestions = []; |
||||
$field = $variables['element']['#field_name']; |
||||
$view_mode = $variables['element']['#view_mode']; |
||||
$suggestions[] = 'field__' . $field . '__' . $view_mode; |
||||
if ($variables['element']['#view_mode'] == 'data') { |
||||
# dump($variables); |
||||
} |
||||
return $suggestions; |
||||
} |
||||
@ -0,0 +1 @@
|
||||
{{ element }} |
||||
@ -0,0 +1 @@
|
||||
{{ element[0]['#prefix'] | trim | lower }}{{ element[0]['#entity'].bundle }}:{{ element[0]['#plain_text'] }} |
||||
@ -0,0 +1,151 @@
|
||||
|
||||
|
||||
<titleInfo> |
||||
<title lang="eng">{{ elements.title }}</title> |
||||
{% if elements.subtitle is not empty%} <subTitle>{{ elements.subtitle }}</subTitle>{% endif %} |
||||
</titleInfo> |
||||
{% for name_info in elements.names | split ('|') %} |
||||
{% set name_info = name_info | split(':', 3) %} |
||||
{% set name__role = name_info[0] | trim | lower %} |
||||
{% set name__type = name_info[1] | replace({"corporate_body":"corporate"}) | raw %} |
||||
{% set name_info = name_info[2] | split("~", 2) %} |
||||
{% set name__name = name_info[0] | trim %} |
||||
{% set name__description = name_info[1] | trim %} |
||||
{% if name__name is not empty %} |
||||
<name type="{{ name__type }}"> |
||||
<namePart>{{ name__name }}</namePart> |
||||
<role> |
||||
<roleTerm authority="marcrelator" type="text">{{ name__role }}</roleTerm> |
||||
</role> |
||||
{% if name__description is not empty %} |
||||
<description>{{ name__description }}</description> |
||||
{% endif %} |
||||
</name> |
||||
{% endif %} |
||||
{% endfor %} |
||||
{% if elements.typeofresource is not empty %}<typeOfResource>{{ elements.typeofresource }}</typeOfResource> |
||||
{% endif %} |
||||
{% if elements.genre is not empty %}<genre>{{ elements.genre }}</genre> |
||||
{% endif %} |
||||
{% if elements.abstract is not empty %}<abstract>{{ elements.abstract }}</abstract> |
||||
{% endif %} |
||||
{% if elements.language_iso6392b is not empty %} |
||||
{% for language in elements.language_iso6392b | split ('|') %} |
||||
<language> |
||||
<languageTerm authority="iso639-2b" type="code">{{ language | trim }}</languageTerm> |
||||
</language> |
||||
{% endfor %} |
||||
{% endif %} |
||||
<originInfo> |
||||
{% if elements.publisher is not empty %} <publisher>{{ elements.publisher }}</publisher> |
||||
{% endif %} |
||||
{% if elements.published_place is not empty %} |
||||
<place> |
||||
<placeTerm type="text">{{ elements.published_place }}</placeTerm> |
||||
</place> |
||||
{% endif %}{% if elements.published_place_marccountry is not empty %} <place> |
||||
<placeTerm authority="marccountry">{{ elements.published_place_marccountry }}</placeTerm> |
||||
</place> |
||||
{% endif %} |
||||
{% if elements.dateissued_edtf is not empty %} <dateIssued encoding="edtf">{{ elements.dateissued_edtf }}</dateIssued> |
||||
{% endif %} |
||||
{% if elements.datecreated_edtf is not empty %} <dateCreated encoding="edtf">{{ elements.datecreated_edtf }}</dateCreated> |
||||
{% endif %} |
||||
{% if elements.datecopyright_edtf is not empty %} <copyrightDate>{{ elements.datecopyright_edtf}}</copyrightDate> |
||||
{% endif %}</originInfo> |
||||
<physicalDescription> |
||||
{% if elements.physicaldescription_form is not empty %} <form>{{ elements.physicaldescription_form }}</form> |
||||
{% endif %} |
||||
{% if elements.physicaldescription_extent is not empty %} <extent>{{ elements.physicaldescription_extent }}</extent> |
||||
{% endif %} |
||||
{% if elements.physicaldescription_note is not empty %} <note>{{ elements.physicaldescription_note }}</note> |
||||
{% endif %} |
||||
</physicalDescription> |
||||
{% for topic in elements.subject_topic |split ('|') %} |
||||
<subject> |
||||
<topic>{{ topic|trim }}</topic> |
||||
</subject> |
||||
{% endfor %} |
||||
{% for geographic in elements.subject_geographic |split ('|') %} |
||||
<subject> |
||||
<geographic>{{ geographic|trim }}</geographic> |
||||
</subject> |
||||
{% endfor %} |
||||
{% for temporal in elements.subject_temporal |split ('|') %} |
||||
<subject> |
||||
<temporal>{{ temporal|trim }}</temporal> |
||||
</subject> |
||||
{% endfor %} |
||||
{% if elements.subjects_name is not empty %} |
||||
{% set name_type_info = elements.subjects_name_vocabulary|split('|') %} |
||||
{% for subject_name_info in elements.subjects_name |split ('|') %} |
||||
{% set name_type_info_x = name_type_info[loop.index0] | replace({"Person":"person", "Corporate Body":"corporate", "Family":"family", "Conference":"conference"}) | raw %} |
||||
<subject> |
||||
<name type="{{ name_type_info_x }}"> |
||||
<namePart>{{ subject_name_info }}</namePart> |
||||
</name> |
||||
</subject> |
||||
{% endfor %} |
||||
{% endif %} |
||||
<subject> |
||||
<hierarchicalGeographic> |
||||
<continent>{{ elements.subject_hierarchicalgeographic_continent }}</continent> |
||||
<country>{{ elements.subject_hierarchicalgeographic_country }}</country> |
||||
<state>{{ elements.subject_hierarchicalgeographic_state }}</state> |
||||
<province>{{ elements.subject_hierarchicalgeographic_province }}</province> |
||||
<region>{{ elements.subject_hierarchicalgeographic_region }}</region> |
||||
<county>{{ elements.subject_hierarchicalgeographic_county }}</county> |
||||
<island>{{ elements.subject_hierarchicalgeographic_island }}</island> |
||||
<city>{{ elements.subject_hierarchicalgeographic_city }}</city> |
||||
<citySection>{{ elements.subject_hierarchicalgeographic_citysection }}</citySection> |
||||
</hierarchicalGeographic> |
||||
</subject> |
||||
<subject> |
||||
<cartographics> |
||||
<coordinates>{{ elements.subject_geographic_coordinates }}</coordinates> |
||||
</cartographics> |
||||
</subject> |
||||
{% if elements.relateditem_title is not empty %} |
||||
<relatedItem type="host"> |
||||
<titleInfo> |
||||
<title>{{ elements.relateditem_title }}</title> |
||||
</titleInfo> |
||||
</relatedItem> |
||||
{% endif %} |
||||
{% if elements.relateditem_collection_title is not empty %} |
||||
<relatedItem type="collection"> |
||||
<titleInfo> |
||||
<title>{{ elements.relateditem_collection_title }}</title> |
||||
</titleInfo> |
||||
</relatedItem> |
||||
{% endif %} |
||||
{% if elements.accesscondition_restrictiononaccess is not empty%} |
||||
<accessCondition type="restriction on access">{{ elements.accesscondition_restrictiononaccess }}</accessCondition> |
||||
{% endif %} |
||||
<accessCondition type="use and reproduction">{{ elements.accesscondition_useandreproduction }}</accessCondition> |
||||
<location> |
||||
<url usage="primary display">{{ elements.location_url }}</url> |
||||
{% if elements.location_physical is not empty %} |
||||
<physicalLocation>{{ elements.location_physical }}</physicalLocation> |
||||
{% endif %} |
||||
</location> |
||||
<identifier type="uri">{{ elements.identifier_uri}}</identifier> |
||||
<identifier type="local">{{ elements.identifier_local}}</identifier> |
||||
<identifier type="ark">{{ elements.identifier_ark}}</identifier> |
||||
<note>{{ elements.note }}</note> |
||||
<recordInfo> |
||||
{% if elements.recordinfo_note_coursecode is not empty %} |
||||
<recordInfoNote type="courseCode">{{ elements.recordinfo_note_coursecode }}</recordInfoNote> |
||||
{% endif %} |
||||
{% if elements.recordinfo_note_courseyear is not empty %} |
||||
<recordInfoNote type="courseYear">{{ elements.recordinfo_note_courseyear }}</recordInfoNote> |
||||
{% endif %} |
||||
{% if elements.recordinfo_note_courseterm is not empty %} |
||||
<recordInfoNote type="courseTerm">{{ elements.recordinfo_note_courseterm }}</recordInfoNote> |
||||
{% endif %} |
||||
<languageOfCataloging> |
||||
{% if elements.recordinfo_cataloguing_language_iso6392b is not empty %} |
||||
<languageTerm authority="iso639-2b" type="code">{{ elements.recordinfo_cataloguing_language_iso6392b }}</languageTerm> |
||||
{% endif %} |
||||
</languageOfCataloging> |
||||
</recordInfo> |
||||
Loading…
Reference in new issue