Skip to content

Commit 716942c

Browse files
committed
Enhancement #68: Link via DAO xlink, if available
2 parents 3b738dd + 68d3e43 commit 716942c

File tree

6 files changed

+143
-15
lines changed

6 files changed

+143
-15
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ In `charlie`, we have three logical containers:
117117

118118
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.
119119

120+
### Q. How are links generated from the Finding Aid to digitized objects?
121+
122+
A. Links will be generated from the EAD rendering to digitized objects in one or more of two ways:
123+
124+
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".
125+
126+
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".
127+
120128
## Maintainers/Sponsors
121129
Current maintainers:
122130

includes/admin.form.inc

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,35 +53,64 @@ function islandora_manuscript_admin_settings_form(array $form, array &$form_stat
5353
),
5454
);
5555

56+
$form['islandora_manuscript_query_fieldset'] = array(
57+
'#type' => 'fieldset',
58+
'#title' => t('Link objects by query'),
59+
'islandora_manuscript_query_enable' => array(
60+
'#type' => 'checkbox',
61+
'#title' => t('Enable query link'),
62+
'#description' => t('Present links from containers within the Finding Aid by querying parent, box, and folder values within the children\'s metadata.'),
63+
'#default_value' => variable_get('islandora_manuscript_query_enable', TRUE),
64+
),
65+
);
66+
5667
// Solr field containing the parent book PID.
57-
$form['islandora_manuscript_parent_manuscript_solr_field'] = array(
68+
$form['islandora_manuscript_query_fieldset']['islandora_manuscript_parent_manuscript_solr_field'] = array(
5869
'#type' => 'textfield',
5970
'#title' => t('Parent Solr Field'),
6071
'#description' => t("Solr field containing the parent Manuscript's PID."),
6172
'#default_value' => variable_get('islandora_manuscript_parent_manuscript_solr_field', 'RELS_EXT_isMemberOf_uri_ms'),
6273
'#size' => 30,
6374
);
64-
$form['islandora_manuscript_box_identifier_solr_field'] = array(
75+
$form['islandora_manuscript_query_fieldset']['islandora_manuscript_box_identifier_solr_field'] = array(
6576
'#type' => 'textfield',
6677
'#title' => t('Manuscript Box Solr Field'),
6778
'#description' => t("Solr field containing the box identifier, on manuscript objects."),
6879
'#default_value' => variable_get('islandora_manuscript_box_identifier_solr_field', 'mods_relatedItem_host_part_detail_box_number_ms'),
6980
'#size' => 30,
7081
);
71-
$form['islandora_manuscript_folder_identifier_solr_field'] = array(
82+
$form['islandora_manuscript_query_fieldset']['islandora_manuscript_folder_identifier_solr_field'] = array(
7283
'#type' => 'textfield',
7384
'#title' => t('Manuscript Folder Solr Field'),
7485
'#description' => t("Solr field containing the folder identifier, on manuscript objects."),
7586
'#default_value' => variable_get('islandora_manuscript_folder_identifier_solr_field', 'mods_relatedItem_host_part_detail_folder_number_ms'),
7687
'#size' => 30,
7788
);
78-
$form['islandora_manuscript_component_identifier_solr_field'] = array(
89+
$form['islandora_manuscript_query_fieldset']['islandora_manuscript_component_identifier_solr_field'] = array(
7990
'#type' => 'textfield',
8091
'#title' => t('Component ID Solr Field'),
8192
'#description' => t("Solr field containing the identifier, on manuscript objects."),
8293
'#default_value' => variable_get('islandora_manuscript_component_identifier_solr_field', 'dereffed_ead_component_id_ms'),
8394
'#size' => 30,
8495
);
96+
$form['islandora_manuscript_direct_fieldset'] = array(
97+
'#type' => 'fieldset',
98+
'#title' => t('Link objects by DAO xlink'),
99+
'islandora_manuscript_direct_enable' => array(
100+
'#type' => 'checkbox',
101+
'#title' => t('Enable xlink'),
102+
'#description' => t('Present xlinks present on the DAO as links within the Finding Aid.'),
103+
'#default_value' => variable_get('islandora_manuscript_direct_enable', FALSE),
104+
),
105+
'islandora_manuscript_component_xlink_prefix' => array(
106+
'#type' => 'textfield',
107+
'#title' => t('Component xlink prefix'),
108+
'#description' => t("The URI prefix for xlink refrences on manuscript component DAOs"),
109+
'#default_value' => variable_get('islandora_manuscript_component_xlink_prefix', ''),
110+
'#size' => 30,
111+
),
112+
);
113+
85114

86115
module_load_include('inc', 'islandora', 'includes/solution_packs');
87116
$form += islandora_viewers_form('islandora_manuscript_viewers', NULL, 'islandora:manuscriptCModel');

includes/ead_html.inc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ function islandora_manuscript_preprocess_ead_display_variables(&$variables) {
2525
$variables['xslt_parameters'][''] = (isset($variables['xslt_parameters']['']) ? $variables['xslt_parameters'][''] : array()) + array(
2626
"container_string" => t('Containers'),
2727
);
28+
$variables['xslt_parameters']['']['call_query_link'] = variable_get('islandora_manuscript_query_enable', true) ? 'true' : 'false';
29+
$variables['xslt_parameters']['']['call_direct_link'] = variable_get('islandora_manuscript_direct_enable', false) ? 'true' : false;
30+
$variables['xslt_parameters']['']['direct_link_prefix'] = variable_get('islandora_manuscript_component_xlink_prefix', '');
2831
$variables['doc'] = $doc = new DOMDocument();
2932
$doc->loadXML($variables['object']['EAD']->content);
3033

@@ -287,3 +290,23 @@ function islandora_manuscript_build_flat_subfile_query(array $containers) {
287290
// Merge down to single array.
288291
return empty($parts) ? array() : call_user_func_array('array_merge', $parts);
289292
}
293+
294+
/**
295+
* Callback used in XSLT to build a direct URL.
296+
* N.b.: unused, but reserved for future use if logic becomes more complex than a simple prefix
297+
*
298+
* @param DOMAttribute[] $xlink
299+
* An array containing a single DOMAttribute (this is how XSLTProcessor
300+
* provides it) representing the xlink attribute for a DAO
301+
*
302+
* @return string
303+
* A string containing a URL to the given object.
304+
*/
305+
function islandora_manuscript_build_direct_url(array $xlink) {
306+
if ($xlink[0] && variable_get('islandora_manuscript_direct_enable', false)) {
307+
$path = variable_get('islandora_manuscript_component_xlink_prefix', '') . $xlink[0]->value;
308+
return url($path);
309+
}
310+
}
311+
312+

islandora_manuscript.module

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ function islandora_manuscript_theme() {
198198
'xslt_functions' => array(
199199
'islandora_manuscript_build_parented_query_url',
200200
'islandora_manuscript_build_flat_query_url',
201+
'islandora_manuscript_build_direct_url',
201202
),
202203
'doc' => NULL,
203204
'xslt_doc' => NULL,

theme/theme.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,3 @@ function template_process_islandora_manuscript_ead_display(&$variables) {
104104
islandora_manuscript_process_ead_display_variables($variables);
105105
}
106106

107-

transforms/ead_to_html.xslt

Lines changed: 78 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
>
1010
<xsl:param name="container_string">Containers</xsl:param>
1111

12+
<xsl:param name="call_query_link" />
13+
<xsl:param name="call_direct_link" />
14+
<xsl:param name="direct_link_prefix" />
15+
1216
<xsl:template match="/">
1317
<div class="ead">
1418
<xsl:apply-templates select="//ead:archdesc"/>
@@ -79,6 +83,16 @@
7983
<dl>
8084
<xsl:copy-of select="$contents"/>
8185
</dl>
86+
<xsl:if test="count(ead:dao[@xlink:href])">
87+
<xsl:variable name="xlinks">
88+
<xsl:call-template name="ead_dao_xlink" />
89+
</xsl:variable>
90+
<xsl:if test="normalize-space($xlinks)">
91+
<ul class="ead_daos">
92+
<xsl:copy-of select="$xlinks" />
93+
</ul>
94+
</xsl:if>
95+
</xsl:if>
8296
</xsl:if>
8397
</xsl:template>
8498

@@ -114,13 +128,25 @@
114128
</xsl:template>
115129

116130
<xsl:template name="flat_container">
131+
<xsl:variable name="query_url">
132+
<xsl:if test="$call_query_link = 'true'">
133+
<xsl:value-of select="php:function('islandora_manuscript_build_flat_query_url', ead:container)" />
134+
</xsl:if>
135+
</xsl:variable>
117136
<dd>
118-
<a>
119-
<xsl:attribute name="href">
120-
<xsl:copy-of select="php:function('islandora_manuscript_build_flat_query_url', ead:container)"/>
121-
</xsl:attribute>
137+
<xsl:choose>
138+
<xsl:when test="normalize-space($query_url)">
139+
<a>
140+
<xsl:attribute name="href">
141+
<xsl:value-of select="$query_url"/>
142+
</xsl:attribute>
143+
<xsl:apply-templates select="ead:container[1]" mode="flat_text"/>
144+
</a>
145+
</xsl:when>
146+
<xsl:otherwise>
122147
<xsl:apply-templates select="ead:container[1]" mode="flat_text"/>
123-
</a>
148+
</xsl:otherwise>
149+
</xsl:choose>
124150
</dd>
125151
</xsl:template>
126152
<xsl:template match="ead:container" mode="flat_text">
@@ -138,15 +164,28 @@
138164

139165
<xsl:template match="ead:container" mode="parent">
140166
<xsl:variable name="containers" select="//ead:container"/>
167+
<xsl:variable name="query_url">
168+
<xsl:if test="$call_query_link = 'true'">
169+
<xsl:value-of select="php:function('islandora_manuscript_build_parented_query_url', current(), $containers)" />
170+
</xsl:if>
171+
</xsl:variable>
141172
<dd>
142-
<a>
143-
<xsl:attribute name="href">
144-
<xsl:copy-of select="php:function('islandora_manuscript_build_parented_query_url', current(), $containers)"/>
145-
</xsl:attribute>
173+
<xsl:choose>
174+
<xsl:when test="normalize-space($query_url)">
175+
<a>
176+
<xsl:attribute name="href">
177+
<xsl:copy-of select="$query_url"/>
178+
</xsl:attribute>
179+
<xsl:apply-templates select="." mode="parent_text"/>
180+
</a>
181+
</xsl:when>
182+
<xsl:otherwise>
146183
<xsl:apply-templates select="." mode="parent_text"/>
147-
</a>
184+
</xsl:otherwise>
185+
</xsl:choose>
148186
</dd>
149187
</xsl:template>
188+
150189
<xsl:template match="ead:container" mode="parent_text">
151190
<xsl:variable name="parent" select="@parent"/>
152191
<xsl:variable name="parents">
@@ -161,6 +200,35 @@
161200
<xsl:apply-templates/>
162201
</xsl:template>
163202

203+
<xsl:template name="ead_dao_xlink">
204+
<xsl:for-each select="ead:dao[@xlink:href]">
205+
<xsl:variable name="direct_url">
206+
<xsl:if test="$call_direct_link = 'true'">
207+
<!--
208+
N.b.: unused but reserved for future use if logic becomes more complex than a simple prefix
209+
<xsl:value-of select="php:function('islandora_manuscript_build_direct_url', @xlink:href)" />
210+
-->
211+
<xsl:value-of select="$direct_link_prefix" /><xsl:value-of select="@xlink:href" />
212+
</xsl:if>
213+
</xsl:variable>
214+
<li>
215+
<xsl:choose>
216+
<xsl:when test="normalize-space($direct_url)">
217+
<a>
218+
<xsl:attribute name="href">
219+
<xsl:value-of select="$direct_url" />
220+
</xsl:attribute>
221+
<xsl:value-of select="ead:daodesc" />
222+
</a>
223+
</xsl:when>
224+
<xsl:otherwise>
225+
</xsl:otherwise>
226+
<xsl:value-of select="ead:daodesc" />
227+
</xsl:choose>
228+
</li>
229+
</xsl:for-each>
230+
</xsl:template>
231+
164232
<xsl:template match="text()" mode="did_list"/>
165233
<!-- end of did/definition list stuff -->
166234

0 commit comments

Comments
 (0)