Jonathan Green
13 years ago
14 changed files with 1320 additions and 449 deletions
@ -0,0 +1,184 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
function fedora_repository_islandora_object_details_display() { |
||||||
|
$profiles = array( |
||||||
|
'hidden' => array( |
||||||
|
"name" => "Hidden", |
||||||
|
"module" => "fedora_repository", |
||||||
|
"file" => "ObjectDetails.inc", |
||||||
|
"function" => "fedora_repository_object_details_hidden", |
||||||
|
"description" => t("No object details page"), |
||||||
|
), |
||||||
|
'xslt' => array( |
||||||
|
"name" => "XSLT", |
||||||
|
"module" => "fedora_repository", |
||||||
|
"file" => "ObjectDetails.inc", |
||||||
|
"function" => "fedora_repository_object_details_xslt", |
||||||
|
"description" => t("Show a datastream with an XSLT"), |
||||||
|
"config" => "admin/settings/fedora_repository/object_details_xslt", |
||||||
|
), |
||||||
|
'table' => array( |
||||||
|
"name" => "Table", |
||||||
|
"module" => "fedora_repository", |
||||||
|
"file" => "ObjectDetails.inc", |
||||||
|
"function" => "fedora_repository_object_details_table", |
||||||
|
"description" => t("Show a datastream with a table"), |
||||||
|
"config" => "admin/settings/fedora_repository/object_details_table", |
||||||
|
) |
||||||
|
); |
||||||
|
return $profiles; |
||||||
|
} |
||||||
|
|
||||||
|
function fedora_repository_object_details_hidden($item) { |
||||||
|
// do nothing |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
function fedora_repository_object_details_XSLT($item) { |
||||||
|
global $base_url; |
||||||
|
$path = drupal_get_path('module', 'fedora_repository'); |
||||||
|
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); |
||||||
|
|
||||||
|
$dsid = variable_get('islandora_object_details_xslt_datastream', 'DC'); |
||||||
|
// special case for DC+QDC for backward compatibility |
||||||
|
if ($dsid == 'DC' || $dsid == 'QDC') { |
||||||
|
$dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC'; |
||||||
|
} |
||||||
|
$xmlstr = $item->get_datastream_dissemination($dsid); |
||||||
|
|
||||||
|
if (empty($xmlstr)) { |
||||||
|
return ''; |
||||||
|
} |
||||||
|
|
||||||
|
try { |
||||||
|
$proc = new XsltProcessor(); |
||||||
|
} catch (Exception $e) { |
||||||
|
drupal_set_message($e->getMessage(), 'error'); |
||||||
|
watchdog('fedora_repository', "Error while creating XSLT processor: @e", array('@e' => $e->getMessage()), WATCHDOG_ERROR); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
$proc->setParameter('', 'baseUrl', $base_url); |
||||||
|
$proc->setParameter('', 'path', $base_url . '/' . $path); |
||||||
|
$input = NULL; |
||||||
|
|
||||||
|
$xsl_file = './'. $path .'/'. variable_get('islandora_object_details_xslt_sheet', 'xsl/convertQDC.xsl'); |
||||||
|
if (is_readable($xsl_file)) { |
||||||
|
$xsl = new DOMDocument(); |
||||||
|
$xsl->load($xsl_file); |
||||||
|
$input = new DOMDocument(); |
||||||
|
$input->loadXML(trim($xmlstr)); |
||||||
|
$xsl = $proc->importStylesheet($xsl); |
||||||
|
$newdom = $proc->transformToDoc($input); |
||||||
|
$output = $newdom->saveHTML(); |
||||||
|
return $output; |
||||||
|
} |
||||||
|
else { |
||||||
|
watchdog('fedora_repository', 'The XSLT file @xslt_name is not readable.', array( |
||||||
|
'@xslt_name' => $xsl_file, |
||||||
|
)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function fedora_repository_object_details_table($item) { |
||||||
|
global $base_url; |
||||||
|
$path = drupal_get_path('module', 'fedora_repository'); |
||||||
|
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); |
||||||
|
|
||||||
|
$dsid = variable_get('islandora_object_details_table_datastream', 'DC'); |
||||||
|
// special case for DC+QDC for backward compatibility |
||||||
|
if ($dsid == 'DC' || $dsid == 'QDC') { |
||||||
|
$dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC'; |
||||||
|
} |
||||||
|
$xmlstr = $item->get_datastream_dissemination($dsid); |
||||||
|
|
||||||
|
if (empty($xmlstr)) { |
||||||
|
return ''; |
||||||
|
} |
||||||
|
|
||||||
|
$simplexml = new SimpleXMLElement($xmlstr); |
||||||
|
|
||||||
|
$headers = array( |
||||||
|
array( |
||||||
|
'data' => t('Metadata'), |
||||||
|
'colspan' => 2, |
||||||
|
), |
||||||
|
); |
||||||
|
$rows = array(); |
||||||
|
foreach ($simplexml->getNamespaces(TRUE) as $ns) { |
||||||
|
foreach ($simplexml->children($ns) as $child) { |
||||||
|
$rows[] = array( |
||||||
|
array( |
||||||
|
'data' => $child->getName(), |
||||||
|
'class' => 'dc-tag-name', |
||||||
|
), |
||||||
|
array( |
||||||
|
'data' => (string)$child, |
||||||
|
'class' => 'dc-content', |
||||||
|
), |
||||||
|
); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return theme('table', $headers, $rows, array('class' => 'dc-table')); |
||||||
|
} |
||||||
|
|
||||||
|
// configuration pages |
||||||
|
function fedora_repository_object_details_XSLT_config() { |
||||||
|
$form = array(); |
||||||
|
$form['config'] = array( |
||||||
|
'#type' => 'fieldset', |
||||||
|
'#title' => t("XSLT display options"), |
||||||
|
); |
||||||
|
|
||||||
|
$form['config']['xslt'] = array( |
||||||
|
'#type' => 'textfield', |
||||||
|
'#title' => t("XSL transform to use"), |
||||||
|
'#default_value' => variable_get('islandora_object_details_xslt_sheet', 'xsl/convertQDC.xsl'), |
||||||
|
'#required' => TRUE, |
||||||
|
); |
||||||
|
$form['config']['dsid'] = array( |
||||||
|
'#type' => 'textfield', |
||||||
|
'#title' => t("Datastream to transform"), |
||||||
|
'#default_value' => variable_get('islandora_object_details_xslt_datastream', 'DC'), |
||||||
|
'#required' => TRUE, |
||||||
|
); |
||||||
|
$form['submit'] = array( |
||||||
|
'#type' => 'submit', |
||||||
|
'#value' => t("Submit"), |
||||||
|
'#weight' => 1, |
||||||
|
); |
||||||
|
|
||||||
|
return $form; |
||||||
|
} |
||||||
|
|
||||||
|
function fedora_repository_object_details_table_config() { |
||||||
|
$form = array(); |
||||||
|
$form['config'] = array( |
||||||
|
'#type' => 'fieldset', |
||||||
|
'#title' => t("Table display options"), |
||||||
|
); |
||||||
|
|
||||||
|
$form['config']['dsid'] = array( |
||||||
|
'#type' => 'textfield', |
||||||
|
'#title' => t("Datastream to transform"), |
||||||
|
'#default_value' => variable_get('islandora_object_details_table_datastream', 'DC'), |
||||||
|
'#required' => TRUE, |
||||||
|
); |
||||||
|
$form['submit'] = array( |
||||||
|
'#type' => 'submit', |
||||||
|
'#value' => t("Submit"), |
||||||
|
'#weight' => 1, |
||||||
|
); |
||||||
|
|
||||||
|
return $form; |
||||||
|
} |
||||||
|
|
||||||
|
function fedora_repository_object_details_XSLT_config_submit($form, &$form_state) { |
||||||
|
variable_set('islandora_object_details_xslt_sheet', $form_state['values']['xslt']); |
||||||
|
variable_set('islandora_object_details_xslt_datastream', $form_state['values']['dsid']); |
||||||
|
} |
||||||
|
|
||||||
|
function fedora_repository_object_details_table_config_submit($form, &$form_state) { |
||||||
|
variable_set('islandora_object_details_table_datastream', $form_state['values']['dsid']); |
||||||
|
} |
@ -1,33 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
|
||||||
<xsl:variable name="BASEURL"> |
|
||||||
<xsl:value-of select="$baseUrl"/> |
|
||||||
</xsl:variable> |
|
||||||
<xsl:variable name="PATH"> |
|
||||||
<xsl:value-of select="$path"/> |
|
||||||
</xsl:variable> |
|
||||||
<xsl:template match="/"> |
|
||||||
|
|
||||||
<div><table cellspacing="3" cellpadding="3"><tbody> |
|
||||||
<tr><th colspan="3"><h3>MetaData</h3></th></tr> |
|
||||||
<xsl:for-each select="/*/*"> |
|
||||||
<xsl:variable name="FULLFIELD" select="name()"/> |
|
||||||
<xsl:variable name="FIELD" select="local-name()"/> |
|
||||||
<xsl:variable name="DATA" select="text()"/> |
|
||||||
<xsl:if test="$DATA != ' '"> |
|
||||||
<tr><td><strong><xsl:value-of select="local-name()"/></strong></td><td><xsl:value-of select="text()"/> |
|
||||||
<xsl:for-each select="*"> |
|
||||||
<div> |
|
||||||
<xsl:value-of select="local-name()"/> = <xsl:value-of select="text()"/> |
|
||||||
</div> |
|
||||||
</xsl:for-each> |
|
||||||
</td></tr> |
|
||||||
</xsl:if> |
|
||||||
</xsl:for-each> |
|
||||||
|
|
||||||
</tbody></table></div> |
|
||||||
|
|
||||||
</xsl:template> |
|
||||||
|
|
||||||
|
|
||||||
</xsl:stylesheet> |
|
@ -0,0 +1,34 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!-- This was how the metadata in the 'Fedora Object Details' tab was rendered. Can be renamed back to 'convertQDC.xsl' (without '.deprecated') to make it be used again. --> |
||||||
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
||||||
|
<!-- Old parameter names "$baseUrl" and "$path" are deprecated. Currently just used as defaults. --> |
||||||
|
<xsl:param name="BASEURL" select="$baseUrl"/> |
||||||
|
<xsl:param name="PATH" select="$path"/> |
||||||
|
|
||||||
|
<xsl:template match="/"> |
||||||
|
<div> |
||||||
|
<table cellspacing="3" cellpadding="3"> |
||||||
|
<tbody> |
||||||
|
<tr> |
||||||
|
<th colspan="3"><h3>MetaData</h3></th> |
||||||
|
</tr> |
||||||
|
<xsl:for-each select="/*/*"> |
||||||
|
<xsl:variable name="FULLFIELD" select="name()"/> |
||||||
|
<xsl:variable name="FIELD" select="local-name()"/> |
||||||
|
<xsl:variable name="DATA" select="normalize-space(text())"/> |
||||||
|
<xsl:if test="$DATA"> |
||||||
|
<tr> |
||||||
|
<td><strong><xsl:value-of select="local-name()"/></strong></td> |
||||||
|
<td><xsl:value-of select="$DATA"/> |
||||||
|
<xsl:for-each select="*"> |
||||||
|
<div><xsl:value-of select="concat(local-name(), ' = ', text())"/></div> |
||||||
|
</xsl:for-each> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
</xsl:if> |
||||||
|
</xsl:for-each> |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</xsl:template> |
||||||
|
</xsl:stylesheet> |
@ -0,0 +1,207 @@ |
|||||||
|
<xsl:stylesheet xmlns:mods="http://www.loc.gov/mods/v3" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="mods" version="1.0"> |
||||||
|
<xsl:output indent="yes" method="html"/> |
||||||
|
<xsl:variable name="dictionary" select="document('http://www.loc.gov/standards/mods/modsDictionary.xml')/dictionary"/> |
||||||
|
|
||||||
|
<xsl:template match="/"> |
||||||
|
<!--html> |
||||||
|
<head> |
||||||
|
<style type="text/css">TD {vertical-align:top}</style> |
||||||
|
</head> |
||||||
|
<body--> |
||||||
|
<xsl:choose> |
||||||
|
<xsl:when test="mods:modsCollection"> |
||||||
|
<xsl:apply-templates select="mods:modsCollection"/> |
||||||
|
</xsl:when> |
||||||
|
<xsl:when test="mods:mods"> |
||||||
|
<xsl:apply-templates select="mods:mods"/> |
||||||
|
</xsl:when> |
||||||
|
</xsl:choose> |
||||||
|
<!--/body> |
||||||
|
</html--> |
||||||
|
</xsl:template> |
||||||
|
|
||||||
|
<xsl:template match="mods:modsCollection"> |
||||||
|
<xsl:apply-templates select="mods:mods"/> |
||||||
|
</xsl:template> |
||||||
|
|
||||||
|
<xsl:template match="mods:mods"> |
||||||
|
<table class="modsContainer"> |
||||||
|
<xsl:apply-templates/> |
||||||
|
</table> |
||||||
|
<!--hr/--> |
||||||
|
</xsl:template> |
||||||
|
|
||||||
|
<xsl:template match="*"> |
||||||
|
<xsl:choose> |
||||||
|
<xsl:when test="child::*"> |
||||||
|
<tr><td colspan="2"> |
||||||
|
<span class="modsLabelTop"> |
||||||
|
<xsl:call-template name="longName"> |
||||||
|
<xsl:with-param name="name"> |
||||||
|
<xsl:value-of select="local-name()"/> |
||||||
|
</xsl:with-param> |
||||||
|
</xsl:call-template> |
||||||
|
<xsl:call-template name="attr"/> |
||||||
|
</span> |
||||||
|
</td></tr> |
||||||
|
<xsl:apply-templates mode="level2"/> |
||||||
|
</xsl:when> |
||||||
|
<xsl:otherwise> |
||||||
|
<tr><td> |
||||||
|
<span class="modsLabelTop"> |
||||||
|
<xsl:call-template name="longName"> |
||||||
|
<xsl:with-param name="name"> |
||||||
|
<xsl:value-of select="local-name()"/> |
||||||
|
</xsl:with-param> |
||||||
|
</xsl:call-template> |
||||||
|
<xsl:call-template name="attr"/> |
||||||
|
</span> |
||||||
|
</td><td> |
||||||
|
<span class="modsValueTop"> |
||||||
|
<xsl:call-template name="formatValue"/> |
||||||
|
</span> |
||||||
|
</td></tr> |
||||||
|
</xsl:otherwise> |
||||||
|
</xsl:choose> |
||||||
|
</xsl:template> |
||||||
|
|
||||||
|
<xsl:template name="formatValue"> |
||||||
|
<xsl:choose> |
||||||
|
<xsl:when test="@type='uri'"> |
||||||
|
<a href="{text()}" class="modsLink"> |
||||||
|
<xsl:value-of select="text()"/> |
||||||
|
</a> |
||||||
|
</xsl:when> |
||||||
|
<xsl:otherwise> |
||||||
|
<xsl:value-of select="text()"/> |
||||||
|
</xsl:otherwise> |
||||||
|
</xsl:choose> |
||||||
|
</xsl:template> |
||||||
|
|
||||||
|
<xsl:template match="*" mode="level2"> |
||||||
|
<xsl:choose> |
||||||
|
<xsl:when test="child::*"> |
||||||
|
<tr><td colspan="2"> |
||||||
|
<span class="modsLabelLevel2"> |
||||||
|
<xsl:call-template name="longName"> |
||||||
|
<xsl:with-param name="name"> |
||||||
|
<xsl:value-of select="local-name()"/> |
||||||
|
</xsl:with-param> |
||||||
|
</xsl:call-template> |
||||||
|
<xsl:call-template name="attr"/> |
||||||
|
</span> |
||||||
|
</td></tr> |
||||||
|
<xsl:apply-templates mode="level3"/> |
||||||
|
</xsl:when> |
||||||
|
<xsl:otherwise> |
||||||
|
<tr><td> |
||||||
|
<span class="modsLabelLevel2"> |
||||||
|
<xsl:call-template name="longName"> |
||||||
|
<xsl:with-param name="name"> |
||||||
|
<xsl:value-of select="local-name()"/> |
||||||
|
</xsl:with-param> |
||||||
|
</xsl:call-template> |
||||||
|
<xsl:call-template name="attr"/> |
||||||
|
</span> |
||||||
|
</td><td> |
||||||
|
<span class="modsValueLevel2"> |
||||||
|
<xsl:call-template name="formatValue"/> |
||||||
|
</span> |
||||||
|
</td></tr> |
||||||
|
</xsl:otherwise> |
||||||
|
</xsl:choose> |
||||||
|
</xsl:template> |
||||||
|
|
||||||
|
<xsl:template match="*" mode="level3"> |
||||||
|
<xsl:choose> |
||||||
|
<xsl:when test="child::*"> |
||||||
|
<tr><td colspan="2"> |
||||||
|
<span class="modsLabelLevel3"> |
||||||
|
<xsl:call-template name="longName"> |
||||||
|
<xsl:with-param name="name"> |
||||||
|
<xsl:value-of select="local-name()"/> |
||||||
|
</xsl:with-param> |
||||||
|
</xsl:call-template> |
||||||
|
<xsl:call-template name="attr"/> |
||||||
|
</span> |
||||||
|
</td></tr> |
||||||
|
<xsl:apply-templates mode="level4"/> |
||||||
|
</xsl:when> |
||||||
|
<xsl:otherwise> |
||||||
|
<tr><td> |
||||||
|
<span class="modsLabelLevel3"> |
||||||
|
<xsl:call-template name="longName"> |
||||||
|
<xsl:with-param name="name"> |
||||||
|
<xsl:value-of select="local-name()"/> |
||||||
|
</xsl:with-param> |
||||||
|
</xsl:call-template> |
||||||
|
<xsl:call-template name="attr"/> |
||||||
|
</span> |
||||||
|
</td><td> |
||||||
|
<span class="modsValueLevel3"> |
||||||
|
<xsl:call-template name="formatValue"/> |
||||||
|
</span> |
||||||
|
</td></tr> |
||||||
|
</xsl:otherwise> |
||||||
|
</xsl:choose> |
||||||
|
</xsl:template> |
||||||
|
|
||||||
|
<xsl:template match="*" mode="level4"> |
||||||
|
<tr><td> |
||||||
|
<span class="modsLabelLevel4"> |
||||||
|
<xsl:call-template name="longName"> |
||||||
|
<xsl:with-param name="name"> |
||||||
|
<xsl:value-of select="local-name()"/> |
||||||
|
</xsl:with-param> |
||||||
|
</xsl:call-template> |
||||||
|
<xsl:call-template name="attr"/> |
||||||
|
</span> |
||||||
|
</td><td> |
||||||
|
<span class="modsValueLevel4"> |
||||||
|
<xsl:value-of select="text()"/> |
||||||
|
</span> |
||||||
|
</td></tr> |
||||||
|
</xsl:template> |
||||||
|
|
||||||
|
<xsl:template name="longName"> |
||||||
|
<xsl:param name="name"/> |
||||||
|
<xsl:choose> |
||||||
|
<xsl:when test="$dictionary/entry[@key=$name]"> |
||||||
|
<xsl:value-of select="$dictionary/entry[@key=$name]"/> |
||||||
|
</xsl:when> |
||||||
|
<xsl:otherwise> |
||||||
|
<xsl:value-of select="$name"/> |
||||||
|
</xsl:otherwise> |
||||||
|
</xsl:choose> |
||||||
|
</xsl:template> |
||||||
|
|
||||||
|
<xsl:template name="attr"> |
||||||
|
<xsl:for-each select="@type|@point">: |
||||||
|
<xsl:call-template name="longName"> |
||||||
|
<xsl:with-param name="name"> |
||||||
|
<xsl:value-of select="."/> |
||||||
|
</xsl:with-param> |
||||||
|
</xsl:call-template> |
||||||
|
</xsl:for-each> |
||||||
|
<xsl:if test="@authority or @edition"> |
||||||
|
<xsl:for-each select="@authority">(<xsl:call-template name="longName"> |
||||||
|
<xsl:with-param name="name"> |
||||||
|
<xsl:value-of select="."/> |
||||||
|
</xsl:with-param> |
||||||
|
</xsl:call-template> |
||||||
|
</xsl:for-each> |
||||||
|
<xsl:if test="@edition"> |
||||||
|
Edition <xsl:value-of select="@edition"/> |
||||||
|
</xsl:if>) |
||||||
|
</xsl:if> |
||||||
|
<xsl:variable name="attrStr"> |
||||||
|
<xsl:for-each select="@*[local-name()!='edition' and local-name()!='type' and local-name()!='authority' and local-name()!='point']"> |
||||||
|
<xsl:value-of select="local-name()"/>="<xsl:value-of select="."/>", |
||||||
|
</xsl:for-each> |
||||||
|
</xsl:variable> |
||||||
|
<xsl:variable name="nattrStr" select="normalize-space($attrStr)"/> |
||||||
|
<xsl:if test="string-length($nattrStr)"> |
||||||
|
(<xsl:value-of select="substring($nattrStr,1,string-length($nattrStr)-1)"/>) |
||||||
|
</xsl:if> |
||||||
|
</xsl:template> |
||||||
|
</xsl:stylesheet> |
Loading…
Reference in new issue