Skip to content

Commit

Permalink
discoverygarden#68: Link via DAO xlink, if available
Browse files Browse the repository at this point in the history
  • Loading branch information
ctgraham committed Nov 5, 2021
1 parent 3b738dd commit 6438729
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 15 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ In `charlie`, we have three logical containers:

Do note that the code tries not to make any assumptions about the numbering of boxes or folders. Folders could either be numbered sequentially across boxes (in which case specifying a range of folders could make sense when specifying a range of boxes) or specific to a box. Additionally, pluralization of types is largely ignored.

### Q. How are links generated from the Finding Aid to digitized objects?

A. Links will be generated from the EAD rendering to digitized objects in one or more of two ways:

1) If the child objects have Solr metadata which points to the EAD object, box identifier, folder identifier, and component id, search queries will be formulated from the Finding Aid to the matching digital objects. This is configured in the settings form, under the heading "Link Objects by Query".

2) If the DAOs in the EAD have links in the xlink namespace which point to paths identifying the digital objects, these URIs can be embedded (with an optional prefix) within the Finding Aid display. Examples could be where the DAO's href might point to a link resolver, a DOI, relative or absolute URI, or a Fedora PID. This is configured in the settings form, under the heading "Link Objects by DAO xlink".

## Maintainers/Sponsors
Current maintainers:

Expand Down
37 changes: 33 additions & 4 deletions includes/admin.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,64 @@ function islandora_manuscript_admin_settings_form(array $form, array &$form_stat
),
);

$form['islandora_manuscript_query_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Link objects by query'),
'islandora_manuscript_query_enable' => array(
'#type' => 'checkbox',
'#title' => t('Enable query link'),
'#description' => t('Present links from containers within the Finding Aid by querying parent, box, and folder values within the children\'s metadata.'),
'#default_value' => variable_get('islandora_manuscript_query_enable', TRUE),
),
);

// Solr field containing the parent book PID.
$form['islandora_manuscript_parent_manuscript_solr_field'] = array(
$form['islandora_manuscript_query_fieldset']['islandora_manuscript_parent_manuscript_solr_field'] = array(
'#type' => 'textfield',
'#title' => t('Parent Solr Field'),
'#description' => t("Solr field containing the parent Manuscript's PID."),
'#default_value' => variable_get('islandora_manuscript_parent_manuscript_solr_field', 'RELS_EXT_isMemberOf_uri_ms'),
'#size' => 30,
);
$form['islandora_manuscript_box_identifier_solr_field'] = array(
$form['islandora_manuscript_query_fieldset']['islandora_manuscript_box_identifier_solr_field'] = array(
'#type' => 'textfield',
'#title' => t('Manuscript Box Solr Field'),
'#description' => t("Solr field containing the box identifier, on manuscript objects."),
'#default_value' => variable_get('islandora_manuscript_box_identifier_solr_field', 'mods_relatedItem_host_part_detail_box_number_ms'),
'#size' => 30,
);
$form['islandora_manuscript_folder_identifier_solr_field'] = array(
$form['islandora_manuscript_query_fieldset']['islandora_manuscript_folder_identifier_solr_field'] = array(
'#type' => 'textfield',
'#title' => t('Manuscript Folder Solr Field'),
'#description' => t("Solr field containing the folder identifier, on manuscript objects."),
'#default_value' => variable_get('islandora_manuscript_folder_identifier_solr_field', 'mods_relatedItem_host_part_detail_folder_number_ms'),
'#size' => 30,
);
$form['islandora_manuscript_component_identifier_solr_field'] = array(
$form['islandora_manuscript_query_fieldset']['islandora_manuscript_component_identifier_solr_field'] = array(
'#type' => 'textfield',
'#title' => t('Component ID Solr Field'),
'#description' => t("Solr field containing the identifier, on manuscript objects."),
'#default_value' => variable_get('islandora_manuscript_component_identifier_solr_field', 'dereffed_ead_component_id_ms'),
'#size' => 30,
);
$form['islandora_manuscript_direct_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Link objects by DAO xlink'),
'islandora_manuscript_direct_enable' => array(
'#type' => 'checkbox',
'#title' => t('Enable xlink'),
'#description' => t('Present xlinks present on the DAO as links within the Finding Aid.'),
'#default_value' => variable_get('islandora_manuscript_direct_enable', FALSE),
),
'islandora_manuscript_component_xlink_prefix' => array(
'#type' => 'textfield',
'#title' => t('Component xlink prefix'),
'#description' => t("The URI prefix for xlink refrences on manuscript component DAOs"),
'#default_value' => variable_get('islandora_manuscript_component_xlink_prefix', ''),
'#size' => 30,
),
);


module_load_include('inc', 'islandora', 'includes/solution_packs');
$form += islandora_viewers_form('islandora_manuscript_viewers', NULL, 'islandora:manuscriptCModel');
Expand Down
23 changes: 23 additions & 0 deletions includes/ead_html.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ function islandora_manuscript_preprocess_ead_display_variables(&$variables) {
$variables['xslt_parameters'][''] = (isset($variables['xslt_parameters']['']) ? $variables['xslt_parameters'][''] : array()) + array(
"container_string" => t('Containers'),
);
$variables['xslt_parameters']['']['call_query_link'] = variable_get('islandora_manuscript_query_enable', true) ? 'true' : 'false';
$variables['xslt_parameters']['']['call_direct_link'] = variable_get('islandora_manuscript_direct_enable', false) ? 'true' : false;
$variables['xslt_parameters']['']['direct_link_prefix'] = variable_get('islandora_manuscript_component_xlink_prefix', '');
$variables['doc'] = $doc = new DOMDocument();
$doc->loadXML($variables['object']['EAD']->content);

Expand Down Expand Up @@ -287,3 +290,23 @@ function islandora_manuscript_build_flat_subfile_query(array $containers) {
// Merge down to single array.
return empty($parts) ? array() : call_user_func_array('array_merge', $parts);
}

/**
* Callback used in XSLT to build a direct URL.
* N.b.: unused, but reserved for future use if logic becomes more complex than a simple prefix
*
* @param DOMAttribute[] $xlink
* An array containing a single DOMAttribute (this is how XSLTProcessor
* provides it) representing the xlink attribute for a DAO
*
* @return string
* A string containing a URL to the given object.
*/
function islandora_manuscript_build_direct_url(array $xlink) {
if ($xlink[0] && variable_get('islandora_manuscript_direct_enable', false)) {
$path = variable_get('islandora_manuscript_component_xlink_prefix', '') . $xlink[0]->value;
return url($path);
}
}


1 change: 1 addition & 0 deletions islandora_manuscript.module
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ function islandora_manuscript_theme() {
'xslt_functions' => array(
'islandora_manuscript_build_parented_query_url',
'islandora_manuscript_build_flat_query_url',
'islandora_manuscript_build_direct_url',
),
'doc' => NULL,
'xslt_doc' => NULL,
Expand Down
1 change: 0 additions & 1 deletion theme/theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,3 @@ function template_process_islandora_manuscript_ead_display(&$variables) {
islandora_manuscript_process_ead_display_variables($variables);
}


88 changes: 78 additions & 10 deletions transforms/ead_to_html.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
>
<xsl:param name="container_string">Containers</xsl:param>

<xsl:param name="call_query_link" />
<xsl:param name="call_direct_link" />
<xsl:param name="direct_link_prefix" />

<xsl:template match="/">
<div class="ead">
<xsl:apply-templates select="//ead:archdesc"/>
Expand Down Expand Up @@ -79,6 +83,16 @@
<dl>
<xsl:copy-of select="$contents"/>
</dl>
<xsl:if test="count(ead:dao[@xlink:href])">
<xsl:variable name="xlinks">
<xsl:call-template name="ead_dao_xlink" />
</xsl:variable>
<xsl:if test="normalize-space($xlinks)">
<ul class="ead_daos">
<xsl:copy-of select="$xlinks" />
</ul>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:template>

Expand Down Expand Up @@ -114,13 +128,25 @@
</xsl:template>

<xsl:template name="flat_container">
<xsl:variable name="query_url">
<xsl:if test="$call_query_link = 'true'">
<xsl:value-of select="php:function('islandora_manuscript_build_flat_query_url', ead:container)" />
</xsl:if>
</xsl:variable>
<dd>
<a>
<xsl:attribute name="href">
<xsl:copy-of select="php:function('islandora_manuscript_build_flat_query_url', ead:container)"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="normalize-space($query_url)">
<a>
<xsl:attribute name="href">
<xsl:value-of select="$query_url"/>
</xsl:attribute>
<xsl:apply-templates select="ead:container[1]" mode="flat_text"/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="ead:container[1]" mode="flat_text"/>
</a>
</xsl:otherwise>
</xsl:choose>
</dd>
</xsl:template>
<xsl:template match="ead:container" mode="flat_text">
Expand All @@ -138,15 +164,28 @@

<xsl:template match="ead:container" mode="parent">
<xsl:variable name="containers" select="//ead:container"/>
<xsl:variable name="query_url">
<xsl:if test="$call_query_link = 'true'">
<xsl:value-of select="php:function('islandora_manuscript_build_parented_query_url', current(), $containers)" />
</xsl:if>
</xsl:variable>
<dd>
<a>
<xsl:attribute name="href">
<xsl:copy-of select="php:function('islandora_manuscript_build_parented_query_url', current(), $containers)"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="normalize-space($query_url)">
<a>
<xsl:attribute name="href">
<xsl:copy-of select="$query_url"/>
</xsl:attribute>
<xsl:apply-templates select="." mode="parent_text"/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="parent_text"/>
</a>
</xsl:otherwise>
</xsl:choose>
</dd>
</xsl:template>

<xsl:template match="ead:container" mode="parent_text">
<xsl:variable name="parent" select="@parent"/>
<xsl:variable name="parents">
Expand All @@ -161,6 +200,35 @@
<xsl:apply-templates/>
</xsl:template>

<xsl:template name="ead_dao_xlink">
<xsl:for-each select="ead:dao[@xlink:href]">
<xsl:variable name="direct_url">
<xsl:if test="$call_direct_link = 'true'">
<!--
N.b.: unused but reserved for future use if logic becomes more complex than a simple prefix
<xsl:value-of select="php:function('islandora_manuscript_build_direct_url', @xlink:href)" />
-->
<xsl:value-of select="$direct_link_prefix" /><xsl:value-of select="@xlink:href" />
</xsl:if>
</xsl:variable>
<li>
<xsl:choose>
<xsl:when test="normalize-space($direct_url)">
<a>
<xsl:attribute name="href">
<xsl:value-of select="$direct_url" />
</xsl:attribute>
<xsl:value-of select="ead:daodesc" />
</a>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
<xsl:value-of select="ead:daodesc" />
</xsl:choose>
</li>
</xsl:for-each>
</xsl:template>

<xsl:template match="text()" mode="did_list"/>
<!-- end of did/definition list stuff -->

Expand Down

0 comments on commit 6438729

Please sign in to comment.