From da5fb410a4c0316341272d585fc6c39c45a588ae Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Fri, 21 Jan 2011 11:47:33 -0400 Subject: [PATCH] Added datastream list and DC to collection tab view. --- CollectionClass.inc | 10 ++-- ObjectHelper.inc | 108 ++++++++++++++++++++++---------------------- 2 files changed, 61 insertions(+), 57 deletions(-) diff --git a/CollectionClass.inc b/CollectionClass.inc index fc82cfd8..49bde84e 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -412,7 +412,7 @@ class CollectionClass { $results = $this->getRelatedItems($this->pid, NULL); $collection_items = $objectHelper->renderCollection($results, $this->pid, NULL, NULL, $page_number ); - + $collection_item = new Fedora_Item($this->pid); // Check the form post to see if we are in the middle of an ingest operation. $show_ingest_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_ingest_form'); $add_to_collection = $this->getIngestInterface(); @@ -438,12 +438,16 @@ class CollectionClass { $tabset['my_tabset']['third_tab']['tabset'] = array( '#type' => 'tabset', ); + $dc_html = $objectHelper->getQDC($this->pid); + + $ds_list = $objectHelper->getFormattedDatastreamList($this->pid, NULL, $collection_item); $tabset['my_tabset']['third_tab']['tabset']['view'] = array( '#type' => 'tabpage', - '#title' => t('Darwin Core'), - '#content' => "METADATA", + '#title' => t('View'), + '#content' => $dc_html . $ds_list, ); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); /* $obj = new ObjectHelper(); if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 73498578..75e1d0dd 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -392,6 +392,59 @@ class ObjectHelper { return $output; } + function getFormattedDatastreamList($object_pid, $contentModels, &$fedoraItem) { + $availableDataStreamsText = 'Detailed List of Content'; + //$metaDataText='Description'; + $mainStreamLabel = NULL; + $object = $fedoraItem->get_datastreams_list_as_SimpleXML(); + if (!isset($object)) { + drupal_set_message(t("No datastreams available")); + return ' '; + } + $hasOBJStream = NULL; + $hasTNStream = FALSE; + $dataStreamBody = "
\n"; + + $cmDatastreams = array(); + if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE && ($cm = ContentModel::loadFromObject($object_pid)) !== FALSE) { + $cmDatastreams = $cm->listDatastreams(); + } + + $dataStreamBody .= $this->get_parent_objects_asHTML($object_pid); + $dataStreamBody .= ''; + foreach ($object as $datastream) { + foreach ($datastream as $datastreamValue) { + + if (variable_get('fedora_object_restrict_datastreams', FALSE) == FALSE || ((isset($user) && in_array('administrator',$user->roles)) || in_array($datastreamValue->ID,$cmDatastreams))) { + if ($datastreamValue->ID == 'OBJ') { + $hasOBJStream = '1'; + $mainStreamLabel = $datastreamValue->label; + $mainStreamLabel = str_replace("_", " ", $mainStreamLabel); + } + if ($datastreamValue->ID == 'TN') { + $hasTNStream = TRUE; + } + //create the links to each datastream + $dataStreamBody .= $this->create_link_for_ds($object_pid, $datastreamValue); //"\n"; + } + } + } + $dataStreamBody .= "

' . t("!text", array('!text' => $availableDataStreamsText)) . '

$key :$value
\n"; + //if they have access let them add a datastream + if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) { + $allow=TRUE; + if (module_exists('fedora_fesl')) { + $allow= fedora_fesl_check_roles($object_pid,'write'); + } + if ($allow) { + $dataStreamBody .= drupal_get_form('add_stream_form', $object_pid); + } + } + + $dataStreamBody = '
' . $dataStreamBody . '
'; + return $dataStreamBody; + } + /** * Gets a list of datastreams from an object using its pid * @@ -417,60 +470,7 @@ class ObjectHelper { $fedoraItem = new Fedora_Item($object_pid); if (user_access(ObjectHelper :: $VIEW_DETAILED_CONTENT_LIST)) { - $availableDataStreamsText = 'Detailed List of Content'; - //$metaDataText='Description'; - $mainStreamLabel = NULL; - $object = $fedoraItem->get_datastreams_list_as_SimpleXML(); - if (!isset($object)) { - drupal_set_message(t("No datastreams available")); - return ' '; - } - $hasOBJStream = NULL; - $hasTNStream = FALSE; - $dataStreamBody = "
\n"; - - $cmDatastreams = array(); - if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE && ($cm = ContentModel::loadFromObject($object_pid)) !== FALSE) { - $cmDatastreams = $cm->listDatastreams(); - } - - $dataStreamBody .= $this->get_parent_objects_asHTML($object_pid); - $dataStreamBody .= ''; - foreach ($object as $datastream) { - foreach ($datastream as $datastreamValue) { - - if (variable_get('fedora_object_restrict_datastreams', FALSE) == FALSE || ((isset($user) && in_array('administrator',$user->roles)) || in_array($datastreamValue->ID,$cmDatastreams))) { - if ($datastreamValue->ID == 'OBJ') { - $hasOBJStream = '1'; - $mainStreamLabel = $datastreamValue->label; - $mainStreamLabel = str_replace("_", " ", $mainStreamLabel); - } - if ($datastreamValue->ID == 'TN') { - $hasTNStream = TRUE; - } - //create the links to each datastream - $dataStreamBody .= $this->create_link_for_ds($object_pid, $datastreamValue); //"\n"; - } - } - } - $dataStreamBody .= "

' . t("!text", array('!text' => $availableDataStreamsText)) . '

$key :$value
\n"; - //if they have access let them add a datastream - if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) { - $allow=TRUE; - if (module_exists('fedora_fesl')) { - $allow= fedora_fesl_check_roles($object_pid,'write'); - } - if ($allow) { - $dataStreamBody .= drupal_get_form('add_stream_form', $object_pid); - } - } - $fieldset = array( - '#title' => t("!text", array('!text' => $availableDataStreamsText)), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#value' => $dataStreamBody - ); - $dataStreamBody = '
' . theme('fieldset', $fieldset) . '
'; + $dataStreamBody = $this->getFormattedDatastreamList($object_pid, $contentModels, $fedoraItem); } $content = '';