From 1c7666842b1b517c0eb41c717e794961e45b7939 Mon Sep 17 00:00:00 2001
From: Jason MacWilliams
Date: Fri, 11 May 2012 16:26:51 -0300
Subject: [PATCH 1/9] invoke custom hooks to retrieve metadata display instead
of hard-coding it
---
plugins/FedoraObjectDetailedContent.inc | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/plugins/FedoraObjectDetailedContent.inc b/plugins/FedoraObjectDetailedContent.inc
index 30e222a6..a6656571 100644
--- a/plugins/FedoraObjectDetailedContent.inc
+++ b/plugins/FedoraObjectDetailedContent.inc
@@ -48,8 +48,29 @@ class FedoraObjectDetailedContent {
$tabset['fedora_object_details']['tabset'] = array(
'#type' => 'tabset',
);
-
- $dc_html = $objectHelper->getFormattedDC($this->item);
+
+ // ***** Jason: begin object details display profiles
+ module_load_include('inc', 'fedora_repository', 'ObjectDetails');
+ $object_details_profile = variable_get('islandora_object_details_display_table', 'xslt_dc');
+ $profiles = module_invoke_all("islandora_object_details_display");
+ $profile = $profiles[$object_details_profile];
+ if (!isset($profile)) {
+ // default behaviour
+ drupal_set_message(t("There was an error reading the default object details display profile"), "error");
+ $dc_html = $objectHelper->getFormattedDC($this->item);
+ }
+ else {
+ // invoke the requested display profile
+ require_once(drupal_get_path('module', $profile['module']) ."/". $profile['file']);
+ $details_function = $profile['function'];
+ if (function_exists($details_function)) {
+ $dc_html = $details_function($this->item);
+ }
+ else {
+ // problem
+ }
+ }
+ // ***** Jason: end object details display profiles
$i = 0;
if (fedora_repository_access(OBJECTHELPER :: $VIEW_DETAILED_CONTENT_LIST, $this->pid, $user)) {
From 6701587fd4df77ed7b946b30a4e93a4916b73ff5 Mon Sep 17 00:00:00 2001
From: Jason MacWilliams
Date: Fri, 11 May 2012 16:34:39 -0300
Subject: [PATCH 2/9] added menu path to load object profile configurations,
setup admin page to request all profiles and create a table for user
selection
---
formClass.inc | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/formClass.inc b/formClass.inc
index 713f1fcb..4d899ef1 100644
--- a/formClass.inc
+++ b/formClass.inc
@@ -179,6 +179,16 @@ class formClass {
'access arguments' => array('view fedora collection'),
);
+ // ***** Jason: begin menu path for xslt config page
+ $items['admin/settings/fedora_repository/object_details_xslt'] = array(
+ 'title' => "",
+ 'type' => MENU_CALLBACK,
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('fedora_repository_object_details_XSLT_config'),
+ 'file' => 'ObjectDetails.inc',
+ 'access arguments' => array('administer site configuration'),
+ );
+ // ***** Jason: end menu path for xslt config page
return $items;
}
@@ -233,7 +243,7 @@ class formClass {
theme('image', 'misc/watchdog-ok.png') . t('Successfully connected to Fedora server at @fedora_soap_url', array('@fedora_soap_url' => variable_get('fedora_soap_url', ''))) :
theme('image', 'misc/watchdog-error.png') . t('Unable to connect to Fedora server at @fedora_soap_url', array('@fedora_soap_url' => variable_get('fedora_soap_url', '')))) . '
',
);
-
+
$form['fedora_soap_manage_url'] = array(
'#type' => 'textfield',
'#title' => t('Fedora SOAP management URL'),
@@ -241,7 +251,7 @@ class formClass {
'#required' => TRUE,
'#weight' => -10
);
-
+
// will allow admin user to remove namepsace restrictions if not explicitly disallowed in settings.php
if (variable_get('allow_open_namespace', TRUE)) {
$form['fedora_namespace'] = array(
@@ -286,6 +296,7 @@ class formClass {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
+
//when checked show object details tab
$form['tabs']['fedora_repository_show_object_details_tab'] = array(
'#type' => 'checkbox',
@@ -293,7 +304,29 @@ class formClass {
'#default_value' => variable_get('fedora_repository_show_object_details_tab', TRUE),
'#description' => t("When enabled, the 'Object Details' tab will be visible to users with the correct permissions when viewing an object in the repository"),
);
-
+
+ // ***** Jason: begin object details display profiles
+ module_load_include('inc', 'fedora_repository', 'ObjectDetails');
+ $primary_display_mode = variable_get('islandora_object_details_display_table', 'convertQDC');
+ $profiles = module_invoke_all("islandora_object_details_display");
+
+ $display_options = array();
+ foreach ($profiles as $machine_name => $profile) {
+ $display_options[$machine_name] = $profile['name'];
+ $config_path = $profile['config'];
+ if (isset($config_path) && $config_path != ""){
+ $display_options[$machine_name] .= " (". l("config", $config_path, array()) .")";
+ }
+ }
+ $form['tabs']['islandora_object_details_display_table'] = array(
+ '#type' => 'radios',
+ '#title' => t('Show object details as'),
+ '#options' => $display_options,
+ '#default_value' => $primary_display_mode,
+// '#description' => t("Tells Islandora how to display the object details page for each object"),
+ );
+ // ***** Jason: end object details display profiles
+
$form['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced configuration options'),
From a88fee9fa9b1ae78cb371872b3e720e08a1ce4b9 Mon Sep 17 00:00:00 2001
From: Jason MacWilliams
Date: Fri, 11 May 2012 16:36:56 -0300
Subject: [PATCH 3/9] added core object details code
---
ObjectDetails.inc | 151 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 151 insertions(+)
create mode 100644 ObjectDetails.inc
diff --git a/ObjectDetails.inc b/ObjectDetails.inc
new file mode 100644
index 00000000..76b11590
--- /dev/null
+++ b/ObjectDetails.inc
@@ -0,0 +1,151 @@
+ 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"),
+ )
+ );
+ 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
+ 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');
+ return;
+ }
+
+ $proc->setParameter('', 'baseUrl', $base_url);
+ $proc->setParameter('', 'path', $base_url . '/' . $path);
+ $input = NULL;
+ $xsl = new DomDocument();
+ try {
+ $xsl->load('./'. $path .'/'. variable_get('islandora_object_details_xslt_sheet', 'xsl/convertQDC.xsl'));
+ $input = new DomDocument();
+ $input->loadXML(trim($xmlstr));
+ } catch (Exception $e) {
+ watchdog('fedora_repository', "Problem loading XSL file: @e", array('@e' => $e->getMessage()), NULL, WATCHDOG_ERROR);
+ }
+ $xsl = $proc->importStylesheet($xsl);
+ $newdom = $proc->transformToDoc($input);
+ $output = $newdom->saveHTML();
+ return $output;
+}
+
+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 = 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 Options"),
+ );
+
+ $form['config']['warning'] = array(
+ '#value' => 'Note: the elements here do not currently work',
+ '#weight' => 0,
+ );
+ $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_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']);
+}
From c05e3dab32dfd230c15099c8a5e148258c3d6530 Mon Sep 17 00:00:00 2001
From: Jason MacWilliams
Date: Fri, 11 May 2012 16:39:56 -0300
Subject: [PATCH 4/9] add the mod2html stylesheet for testing transforms
---
xsl/mods2html.xsl | 207 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 207 insertions(+)
create mode 100644 xsl/mods2html.xsl
diff --git a/xsl/mods2html.xsl b/xsl/mods2html.xsl
new file mode 100644
index 00000000..194fcec2
--- /dev/null
+++ b/xsl/mods2html.xsl
@@ -0,0 +1,207 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ (
+
+
+
+
+
+
+ Edition
+ )
+
+
+
+ ="",
+
+
+
+
+ ()
+
+
+
From 55a355ffcea99118702669e0a63d3760ea27fef9 Mon Sep 17 00:00:00 2001
From: Jason MacWilliams
Date: Mon, 14 May 2012 09:42:10 -0300
Subject: [PATCH 5/9] removed 'jason' code guards
---
formClass.inc | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/formClass.inc b/formClass.inc
index 4d899ef1..52cef748 100644
--- a/formClass.inc
+++ b/formClass.inc
@@ -179,7 +179,6 @@ class formClass {
'access arguments' => array('view fedora collection'),
);
- // ***** Jason: begin menu path for xslt config page
$items['admin/settings/fedora_repository/object_details_xslt'] = array(
'title' => "",
'type' => MENU_CALLBACK,
@@ -188,7 +187,7 @@ class formClass {
'file' => 'ObjectDetails.inc',
'access arguments' => array('administer site configuration'),
);
- // ***** Jason: end menu path for xslt config page
+
return $items;
}
@@ -305,7 +304,6 @@ class formClass {
'#description' => t("When enabled, the 'Object Details' tab will be visible to users with the correct permissions when viewing an object in the repository"),
);
- // ***** Jason: begin object details display profiles
module_load_include('inc', 'fedora_repository', 'ObjectDetails');
$primary_display_mode = variable_get('islandora_object_details_display_table', 'convertQDC');
$profiles = module_invoke_all("islandora_object_details_display");
@@ -325,7 +323,6 @@ class formClass {
'#default_value' => $primary_display_mode,
// '#description' => t("Tells Islandora how to display the object details page for each object"),
);
- // ***** Jason: end object details display profiles
$form['advanced'] = array(
'#type' => 'fieldset',
From a0891d6111491d6136af5e64d7ac176dd0964307 Mon Sep 17 00:00:00 2001
From: Jason MacWilliams
Date: Mon, 14 May 2012 09:42:59 -0300
Subject: [PATCH 6/9] remove 'jason' code guards
---
plugins/FedoraObjectDetailedContent.inc | 2 --
1 file changed, 2 deletions(-)
diff --git a/plugins/FedoraObjectDetailedContent.inc b/plugins/FedoraObjectDetailedContent.inc
index a6656571..1940d41f 100644
--- a/plugins/FedoraObjectDetailedContent.inc
+++ b/plugins/FedoraObjectDetailedContent.inc
@@ -49,7 +49,6 @@ class FedoraObjectDetailedContent {
'#type' => 'tabset',
);
- // ***** Jason: begin object details display profiles
module_load_include('inc', 'fedora_repository', 'ObjectDetails');
$object_details_profile = variable_get('islandora_object_details_display_table', 'xslt_dc');
$profiles = module_invoke_all("islandora_object_details_display");
@@ -70,7 +69,6 @@ class FedoraObjectDetailedContent {
// problem
}
}
- // ***** Jason: end object details display profiles
$i = 0;
if (fedora_repository_access(OBJECTHELPER :: $VIEW_DETAILED_CONTENT_LIST, $this->pid, $user)) {
From 672179a133ff7ae765d526bea6ee3683b62cdc34 Mon Sep 17 00:00:00 2001
From: Jason MacWilliams
Date: Mon, 14 May 2012 12:32:38 -0300
Subject: [PATCH 7/9] remove an erroneous text widget (from development) and
completed the table display mode (with configuration)
---
ObjectDetails.inc | 42 +++++++++++++++++++++++++++++++++++-------
1 file changed, 35 insertions(+), 7 deletions(-)
diff --git a/ObjectDetails.inc b/ObjectDetails.inc
index 76b11590..5da6a063 100644
--- a/ObjectDetails.inc
+++ b/ObjectDetails.inc
@@ -23,6 +23,7 @@ function fedora_repository_islandora_object_details_display() {
"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;
@@ -39,7 +40,7 @@ function fedora_repository_object_details_XSLT($item) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
$dsid = variable_get('islandora_object_details_xslt_datastream', 'DC');
- // special case for DC+QDC
+ // 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';
}
@@ -53,6 +54,7 @@ function fedora_repository_object_details_XSLT($item) {
$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;
}
@@ -78,7 +80,11 @@ function fedora_repository_object_details_table($item) {
$path = drupal_get_path('module', 'fedora_repository');
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
- $dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC';
+ $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)) {
@@ -117,13 +123,9 @@ function fedora_repository_object_details_XSLT_config() {
$form = array();
$form['config'] = array(
'#type' => 'fieldset',
- '#title' => t("XSLT Options"),
+ '#title' => t("XSLT display options"),
);
- $form['config']['warning'] = array(
- '#value' => 'Note: the elements here do not currently work',
- '#weight' => 0,
- );
$form['config']['xslt'] = array(
'#type' => 'textfield',
'#title' => t("XSL transform to use"),
@@ -145,7 +147,33 @@ function fedora_repository_object_details_XSLT_config() {
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']);
+}
From 2e427bb4d10ad6cd83a292f69f73cc4cc75c13d9 Mon Sep 17 00:00:00 2001
From: Jason MacWilliams
Date: Mon, 14 May 2012 12:33:11 -0300
Subject: [PATCH 8/9] moved alert message to watchdog and fixed an incorrect
default value
---
plugins/FedoraObjectDetailedContent.inc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/FedoraObjectDetailedContent.inc b/plugins/FedoraObjectDetailedContent.inc
index 1940d41f..4eeef78b 100644
--- a/plugins/FedoraObjectDetailedContent.inc
+++ b/plugins/FedoraObjectDetailedContent.inc
@@ -50,12 +50,12 @@ class FedoraObjectDetailedContent {
);
module_load_include('inc', 'fedora_repository', 'ObjectDetails');
- $object_details_profile = variable_get('islandora_object_details_display_table', 'xslt_dc');
+ $object_details_profile = variable_get('islandora_object_details_display_table', 'xslt');
$profiles = module_invoke_all("islandora_object_details_display");
$profile = $profiles[$object_details_profile];
if (!isset($profile)) {
// default behaviour
- drupal_set_message(t("There was an error reading the default object details display profile"), "error");
+ watchdog('fedora_repository', "Error while reading the default object details display profile: @e", array("@e" => $e->getMessage()), WATCHDOG_WARNING);
$dc_html = $objectHelper->getFormattedDC($this->item);
}
else {
From 1fcdfbd83682047edbb1123c88362c72479254d0 Mon Sep 17 00:00:00 2001
From: Jason MacWilliams
Date: Mon, 14 May 2012 12:34:00 -0300
Subject: [PATCH 9/9] added menu hook so table config works, fixed an incorrect
default value, added description to radiogroup
---
formClass.inc | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/formClass.inc b/formClass.inc
index 52cef748..97f46c43 100644
--- a/formClass.inc
+++ b/formClass.inc
@@ -187,6 +187,14 @@ class formClass {
'file' => 'ObjectDetails.inc',
'access arguments' => array('administer site configuration'),
);
+ $items['admin/settings/fedora_repository/object_details_table'] = array(
+ 'title' => "",
+ 'type' => MENU_CALLBACK,
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('fedora_repository_object_details_table_config'),
+ 'file' => 'ObjectDetails.inc',
+ 'access arguments' => array('administer site configuration'),
+ );
return $items;
}
@@ -291,7 +299,7 @@ class formClass {
$form['tabs'] = array(
'#type' => 'fieldset',
'#title' => t('Tabs Configuration'),
- '#description' => t('Configure the tabs avaialble when viewing Fedora objects.'),
+ '#description' => t('Configure the tabs available when viewing Fedora objects.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
@@ -305,7 +313,7 @@ class formClass {
);
module_load_include('inc', 'fedora_repository', 'ObjectDetails');
- $primary_display_mode = variable_get('islandora_object_details_display_table', 'convertQDC');
+ $primary_display_mode = variable_get('islandora_object_details_display_table', 'xslt');
$profiles = module_invoke_all("islandora_object_details_display");
$display_options = array();
@@ -321,7 +329,7 @@ class formClass {
'#title' => t('Show object details as'),
'#options' => $display_options,
'#default_value' => $primary_display_mode,
-// '#description' => t("Tells Islandora how to display the object details page for each object"),
+ '#description' => t("Tells Islandora how to display the object details page for each object"),
);
$form['advanced'] = array(