Skip to content

Commit

Permalink
#68: provide optional presentation of query and DAO links
Browse files Browse the repository at this point in the history
  • Loading branch information
ctgraham committed Sep 8, 2021
1 parent 9d7be92 commit f5eebbd
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 48 deletions.
41 changes: 31 additions & 10 deletions includes/admin.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,41 +53,62 @@ 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_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,
$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,
),
);


Expand Down
6 changes: 3 additions & 3 deletions theme/theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function template_process_islandora_manuscript_ead_display(&$variables) {
* A string containing a URL to the given object.
*/
function islandora_manuscript_build_direct_url(array $xlink) {
if ($xlink[0]) {
if ($xlink[0] && variable_get('islandora_manuscript_direct_enable', false)) {
$path = variable_get('islandora_manuscript_component_xlink_prefix', '') . $xlink[0]->value;
return url($path);
}
Expand All @@ -190,7 +190,7 @@ function islandora_manuscript_build_direct_url(array $xlink) {
*/
function islandora_manuscript_build_parented_query_url(array $container_array, array $all) {
$object = menu_get_object('islandora_object', 2);
if ($object && variable_get('islandora_manuscript_component_identifier_solr_field', false)) {
if ($object && variable_get('islandora_manuscript_query_enable', true)) {
$path = "islandora/object/{$object->id}/manuscript/manuscripts";
list($container) = $container_array;
return url($path, array(
Expand Down Expand Up @@ -353,7 +353,7 @@ function islandora_manuscript_findingaid_get_solr_field($raw_type) {
function islandora_manuscript_build_flat_query_url(array $containers) {
$object = menu_get_object('islandora_object', 2);
$parts = islandora_manuscript_build_flat_subfile_query($containers);
if ($object && !empty($parts)) {
if ($object && !empty($parts) && variable_get('islandora_manuscript_query_enable', true)) {
$path = "islandora/object/{$object->id}/manuscript/manuscripts";
return url($path, array(
'query' => array(
Expand Down
75 changes: 40 additions & 35 deletions transforms/ead_to_html.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,21 @@
</xsl:template>

<xsl:template name="flat_container">
<xsl:variable name="query_url" select="php:function('islandora_manuscript_build_flat_query_url', ead:container)" />
<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="$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 @@ -141,23 +149,6 @@
<xsl:variable name="query_url" select="php:function('islandora_manuscript_build_parented_query_url', current(), $containers)" />
<dd>
<xsl:choose>
<xsl:when test="../ead:dao[@xlink:href]">
<xsl:apply-templates select="." mode="parent_text"/>
<ul>
<xsl:for-each select="../ead:dao">
<li>
<xsl:choose>
<xsl:when test="@xlink:href">
<xsl:apply-templates select="." />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="ead:daodesc" />
</xsl:otherwise>
</xsl:choose>
</li>
</xsl:for-each>
</ul>
</xsl:when>
<xsl:when test="$query_url">
<a>
<xsl:attribute name="href">
Expand All @@ -170,6 +161,16 @@
<xsl:apply-templates select="." mode="parent_text"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="count(../ead:dao[@xlink:href])">
<xsl:variable name="contents">
<xsl:call-template name="ead_dao_xlink" />
</xsl:variable>
<xsl:if test="normalize-space($contents)">
<ul class="ead_daos">
<xsl:copy-of select="$contents" />
</ul>
</xsl:if>
</xsl:if>
</dd>
</xsl:template>

Expand All @@ -187,21 +188,25 @@
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="ead:dao[@xlink:href]">
<xsl:template name="ead_dao_xlink">
<xsl:for-each select="../ead:dao[@xlink:href]">
<xsl:variable name="direct_url" select="php:function('islandora_manuscript_build_direct_url', @xlink:href)" />
<xsl:choose>
<xsl:when test="$direct_url">
<a>
<xsl:attribute name="href">
<xsl:value-of select="php:function('islandora_manuscript_build_direct_url', @xlink:href)" />
</xsl:attribute>
<li>
<xsl:choose>
<xsl:when test="$direct_url">
<a>
<xsl:attribute name="href">
<xsl:value-of select="php:function('islandora_manuscript_build_direct_url', @xlink:href)" />
</xsl:attribute>
<xsl:value-of select="ead:daodesc" />
</a>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
<xsl:value-of select="ead:daodesc" />
</a>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
<xsl:value-of select="ead:daodesc" />
</xsl:choose>
</xsl:choose>
</li>
</xsl:for-each>
</xsl:template>

<xsl:template match="text()" mode="did_list"/>
Expand Down

0 comments on commit f5eebbd

Please sign in to comment.