diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 9341a6c6..80d354df 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -34,11 +34,12 @@ class ObjectHelper { /** * Grabs a stream from fedora sets the mimetype and returns it. $dsID is the - * datastream id. + * datastream id. If $forceSoap is set, the function will always buffer the datastream from fedora. Otherwise, it will + * try and use a redirect if possible. * @param $pid String * @param $dsID String */ - function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL) { + function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL, $forceSoap = FALSE) { global $user; module_load_include('inc','fedora_repository','ContentModel'); if ($pid == NULL || $dsID == NULL) { @@ -163,7 +164,12 @@ class ObjectHelper { header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"'); } - curl_exec($ch); + + if ( (isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { + curl_exec($ch); + } else { + header('Location: '.$url); + } } curl_close($ch); } else { @@ -986,7 +992,8 @@ class ObjectHelper { where ( $title and $parentObject $content and ( $parentObject - or $parentObject) + or $parentObject + or $parentObject) and $parentObject ) minus $content order by $title'; diff --git a/fedora_repository.module b/fedora_repository.module index 3df97f91..093bdb2d 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -91,6 +91,7 @@ function fedora_repository_collection_view($pid = NULL, $collection = NULL, $pag function fedora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) { module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); if (!user_access('ingest new fedora objects')) { drupal_set_message(t('You do not have permission to ingest.'), 'error'); return ''; @@ -112,6 +113,11 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label } $output = drupal_get_form('fedora_repository_ingest_form', $collection_pid, $collection_label, $content_model); + $breadcrumbs = array(); + $objectHelper = new ObjectHelper(); + $objectHelper->getBreadcrumbs($collection_pid, $breadcrumbs); + drupal_set_breadcrumb(array_reverse($breadcrumbs)); + return $output; } @@ -586,6 +592,11 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) { $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); // Check if there is a custom edit metadata function defined in the content model. + $breadcrumbs = array(); + $objectHelper = new ObjectHelper(); + $objectHelper->getBreadcrumbs($pid, $breadcrumbs); + drupal_set_breadcrumb(array_reverse($breadcrumbs)); + $output = ''; if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) { diff --git a/form_elements/js/filechooser.js b/form_elements/js/filechooser.js index ac81ec47..7a9625ef 100644 --- a/form_elements/js/filechooser.js +++ b/form_elements/js/filechooser.js @@ -63,7 +63,6 @@ $(document).ready(function () { mouseWheel: true, circular: false, speed: 750, - easing: "bounceout", visible: visibleFiles, scroll: visibleFiles, initial: selectedIndex diff --git a/ilives/book.inc b/ilives/book.inc index f3de4f00..c7ec2eec 100644 --- a/ilives/book.inc +++ b/ilives/book.inc @@ -36,16 +36,17 @@ class IslandoraBook { '#title' => 'Catalogue item URL', ); $form['unapi_url_submit'] = array( - '#type' => 'submit', - '#value' => t('Retrieve MODS record'), - '#submit' => array('fedora_ilives_retrieve_unapi_submit'), - '#ahah' => array( - 'path' => 'fedora/ilives/retrieve_unapi/js', // path we defined in hook_menu - 'wrapper' => 'mods-wrapper', // the HTML that wraps the element that needs to be replaced - 'method' => 'replace', // the method we're going to use: a replace operation - 'effect' => 'fade', // the effect used when replacing the element (try fade!) - ) - ); + '#type' => 'submit', + '#value' => t('Retrieve MODS record'), + '#submit' => array('fedora_ilives_retrieve_unapi_submit'), + '#ahah' => array( + 'path' => 'fedora/ilives/retrieve_unapi/js', // path we defined in hook_menu + 'wrapper' => 'mods-wrapper', // the HTML that wraps the element that needs to be replaced + 'method' => 'replace', // the method we're going to use: a replace operation + //'effect' => 'fade', // the effect used when replacing the element (try fade!) + ), + '#suffix' => '
', + ); drupal_add_js('', 'inline'); // We define a
wrapper. Everything in it will be replaced. $form['mods'] = array( @@ -56,6 +57,7 @@ class IslandoraBook { $form['mods']['mods_record'] = array( '#type' => 'textarea', '#title' => 'MODS Record to Import', + '#rows' => 20, '#value' => (!empty($mods_save) ? $mods_save['mods']['mods_record'] : ''), ); return $form; @@ -133,7 +135,13 @@ class IslandoraBook { $dc = transform_mods_to_dc($form_values['mods']['mods_record']); if ($dc) { - $new_item->modify_datastream_by_value($dc, 'DC', 'Dublin Core XML Metadata', 'text/xml'); + // Add the PID to a dc:identifier field. + $dc_doc = simplexml_load_string($dc); + $dc_item = $dc_doc->xpath('/srw_dc:dcCollection/srw_dc:dc[1]'); + foreach($dc_item as $node) { + $node->addChild('identifier', $new_item->pid, 'http://purl.org/dc/elements/1.1/'); + } + $new_item->modify_datastream_by_value($dc_doc->saveXML(), 'DC', 'Dublin Core XML Metadata', 'text/xml'); } $new_item->add_relationship('hasModel', $form_values['content_model_pid'], FEDORA_MODEL_URI); $new_item->add_relationship(!empty($form_values['relationship']) ? $form_values['relationship'] : 'isMemberOfCollection', $form_values['collection_pid']); diff --git a/ilives/fedora_ilives.module b/ilives/fedora_ilives.module index 84a4b4a5..ddab8d77 100644 --- a/ilives/fedora_ilives.module +++ b/ilives/fedora_ilives.module @@ -430,7 +430,7 @@ function retrieve_unapi_MODS_record($url) { $bib_response = drupal_http_request($url); $bib_html = $bib_response->data; $bib_doc = new DOMDocument; - $bib_doc->loadHTML($bib_html); + @$bib_doc->loadHTML($bib_html); $links = $bib_doc->getElementsByTagName('link'); foreach ($links as $link) { if ($link->getAttribute('rel') == 'unapi-server') { diff --git a/plugins/Exiftool.inc b/plugins/Exiftool.inc index 7d27bc02..d4feac7a 100644 --- a/plugins/Exiftool.inc +++ b/plugins/Exiftool.inc @@ -8,7 +8,15 @@ */ class Exiftool { - function Exiftool() { + + private $pid = NULL; + private $item = NULL; + + function __construct($pid) { + //drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); + $this->pid = $pid; + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + $this->item = new Fedora_Item($this->pid); } function extractMetadata($parameterArray, $dsid, $file, $file_ext) { @@ -21,4 +29,36 @@ class Exiftool { $_SESSION['fedora_ingest_files']["$dsid"] = $file . $file_suffix; return TRUE; } + + function displayMetadata() { + $output=''; + $exifDom = DOMDocument::loadXML($this->item->get_datastream_dissemination('EXIF')); + if ($exifDom != NULL) { + $description = $exifDom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#','Description'); + if ($description->length > 0) { + $description=$description->item(0); + $output .= ''; + + $fieldset = array( + '#title' => t("!text", array('!text' => 'Technical Metadata')), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#value' => $output + ); + $output = theme('fieldset', $fieldset); + } + } + return $output; + } + } diff --git a/plugins/ModsFormBuilder.inc b/plugins/ModsFormBuilder.inc index 597dea14..47dab34c 100644 --- a/plugins/ModsFormBuilder.inc +++ b/plugins/ModsFormBuilder.inc @@ -5,9 +5,9 @@ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); class ModsFormBuilder extends FormBuilder { static $MODS_NS = 'http://www.loc.gov/mods/v3'; - private $cm; - private $item; - private $pid; + protected $cm; + protected $item; + protected $pid; function __construct($pid=null) { @@ -43,7 +43,7 @@ class ModsFormBuilder extends FormBuilder { '#type' => 'fieldset', '#title' => t('Edit metadata'), ); - + if ($this->cm !== FALSE && $this->item != NULL) { $form['pid'] = array('#type'=>'hidden','#value'=>$this->pid); @@ -85,9 +85,12 @@ class ModsFormBuilder extends FormBuilder { $includeEl=FALSE; break; + case '#edit_metadata_xpath': $nodeList = $xpath->evaluate($val); -// echo $val. ' '.$nodeList->length.' '. $nodeList. '
'; +// echo $val. ' '.$nodeList->length.' '; +// echo $nodeList->item(0)->nodeValue.' '; +// echo '
'; if (is_string($nodeList)) { @@ -101,7 +104,15 @@ class ModsFormBuilder extends FormBuilder { } } else if ($nodeList->length > 0) { - $el['#default_value'] = $nodeList->item(0)->nodeValue; + if ($el['#type'] == 'list') { + $values=array(); + for ($i=0;$i<$nodeList->length;$i++) { + $values[]=$nodeList->item($i)->nodeValue; + } + $el['#default_value']=join('; ',$values); + } else { + $el['#default_value'] = $nodeList->item(0)->nodeValue; + } } break; } @@ -385,6 +396,25 @@ class ModsFormBuilder extends FormBuilder { $mods->appendChild($titleinfo); } + if (isset($form_values['mods_alternative_titles']) && trim($form_values['mods_alternative_titles']) != '') { + $titles=preg_split('/\s+\;\s+/',trim($form_values['mods_alternative_titles'])); + foreach ($titles as $t) { + $titleinfo = $dom->createElement('mods:titleInfo'); + $titleinfo->setAttribute('type','alternative') ; + $title = $dom->createElement('mods:title',$t); + $titleinfo->appendChild($title); + $mods->appendChild($titleinfo); + } + } + + if (isset($form_values['mods_alternative_title']) && trim($form_values['mods_alternative_title']) != '') { + $titleinfo = $dom->createElement('mods:titleInfo'); + $titleinfo->setAttribute('type','alternative') ; + $title = $dom->createElement('mods:title',trim($form_values['mods_alternative_title'])); + $titleinfo->appendChild($title); + $mods->appendChild($titleinfo); + } + if (isset($form_values['mods_description']) && trim($form_values['mods_description']) != '') { $abstract = $dom->createElement('mods:abstract', htmlspecialchars(trim($form_values['mods_description']))); $mods->appendChild($abstract); @@ -443,7 +473,8 @@ class ModsFormBuilder extends FormBuilder { $originInfo->appendChild($edition); $addOriginInfo = TRUE; } - + + if (isset($form_values['mods_pubinfo_date']) && trim($form_values['mods_pubinfo_date']) != '' && isset($form_values['mods_pubinfo_dateType']) && trim($form_values['mods_pubinfo_dateType']) != '') { if (in_array($form_values['mods_pubinfo_dateType'], array('issued', 'created', 'copyright', 'captured'))) { @@ -456,18 +487,45 @@ class ModsFormBuilder extends FormBuilder { } $originInfo->appendChild($date); $addOriginInfo = TRUE; + } else { + if (isset($form_values['mods_createdDate'])) { + $date = $dom->createElement('mods:createdDate',htmlspecialchars(trim($form_values['mods_createdDate']))); + $originInfo->appendChild($date); + $addOriginInfo = TRUE; + } + + if (isset($form_values['mods_issuedDate'])) { + $date = $dom->createElement('mods:issuedDate',htmlspecialchars(trim($form_values['mods_issuedDate']))); + $originInfo->appendChild($date); + $addOriginInfo = TRUE; + } + + if (isset($form_values['mods_copyrightDate'])) { + $date = $dom->createElement('mods:copyrightDate',htmlspecialchars(trim($form_values['mods_copyrightDate']))); + $originInfo->appendChild($date); + $addOriginInfo = TRUE; + } + + if (isset($form_values['mods_capturedDate'])) { + $date = $dom->createElement('mods:capturedDate',htmlspecialchars(trim($form_values['mods_capturedDate']))); + $originInfo->appendChild($date); + $addOriginInfo = TRUE; + } + } if (isset($form_values['mods_pubinfo_journalFreq']) && trim($form_values['mods_pubinfo_journalFreq']) != '') { $frequency = $dom->createElement('mods:frequency', htmlspecialchars(trim($form_values['mods_pubinfo_journalFreq']))); $originInfo->appendChild($frequency); $issuance= $dom->createElement('mods:issuance', 'journal'); + $originInfo->appendChild($issuance); $addOriginInfo = TRUE; } - else { + elseif (isset($form_values['mods_pubinfo_journalFreq'])) { $issuance= $dom->createElement('mods:issuance', 'monographic'); + $originInfo->appendChild($issuance); } - $originInfo->appendChild($issuance); + if ($addOriginInfo) { $mods->appendChild($originInfo); @@ -477,6 +535,12 @@ class ModsFormBuilder extends FormBuilder { $note = $dom->createElement('mods:note', htmlspecialchars(trim($form_values['mods_note']))); $mods->appendChild($note); } + + if (isset($form_values['mods_caption']) && trim($form_values['mods_caption']) != '') { + $note = $dom->createElement('mods:note', htmlspecialchars(trim($form_values['mods_caption']))); + $note->setAttribute('type','caption'); + $mods->appendChild($note); + } if (isset($form_values['mods_format']) && trim($form_values['mods_format']) != '') { $typeOfResource = $dom->createElement('mods:typeOfResource', htmlspecialchars($form_values['mods_format'])); @@ -524,6 +588,13 @@ class ModsFormBuilder extends FormBuilder { $city = $dom->createElement('mods:city', htmlspecialchars($form_values['mods_city'])); $geographic->appendChild($city); } + + if (isset($form_values['mods_area']) && trim($form_values['mods_area']) != '') { + $state = $dom->createElement('mods:area', htmlspecialchars($form_values['mods_area'])); + $geographic->appendChild($state); + } + + $subject->appendChild($geographic); } diff --git a/workflow_client/islandora_workflow_client.module b/workflow_client/islandora_workflow_client.module index 5ab2be70..7c2d8946 100644 --- a/workflow_client/islandora_workflow_client.module +++ b/workflow_client/islandora_workflow_client.module @@ -16,44 +16,66 @@ function islandora_workflow_client_menu() function islandora_workflow_client_search_submit($form,&$form_state) { - if (trim($form['collection_pid']['#value']) !== '') - { - drupal_goto('admin/settings/workflow_client/'.$form['process_name']['#value'].'/'.$form['collection_pid']['#value']); - } else - { - drupal_goto('admin/settings/workflow_client/'.$form['process_name']['#value']); + $url ='admin/settings/workflow_client/'.$form['process_name']['#value']; + if (trim($form['process_id']['#value']) !== '') { + $url.='/'.$form['process_id']['#value']; + } else { + $url .= '/-/'; } + + if (trim($form['collection_pid']['#value']) !== '') { + $url.='/'.$form['collection_pid']['#value']; + } else { + $url .= '/-/'; + } + + drupal_goto($url); + } -function islandora_workflow_client_search() +function islandora_workflow_client_search(&$form_state,$terms=null,$process_id=null,$collection=null) { module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $form = array(); $form['process_name'] = array( '#type' => 'textfield', + '#required'=> TRUE, '#title' => t('Search by Process Name'), + '#default_value' => ($terms!=null?$terms:''), '#description' => t('Returns a list of objects that match the process name(s) entered. Separate multiple names by spaces.'), ); + $form['process_id'] = array( + '#type' => 'textfield', + '#title' => t('Search by Process ID'), + '#default_value' => ($process_id!=null?$process_id:''), + '#description' => t('Returns only objects that match the also match the process id entered. '), + ); + + $form['collection_pid'] = array( '#type' => 'textfield', '#title' => t('Search by Collection PID'), + '#default_value' => ($collection!=null?$collection:''), '#description' => t('Returns only objects that match the also match the collection pid(s) entered. Separate multiple PIDs by spaces.'), ); + $form['submit'] = array('#type' => 'submit', '#value' => t('Search')); return $form; } -function islandora_workflow_client_manage($terms = null, $collection = null, $queue= null, $queueProcess = null) +function islandora_workflow_client_manage($terms = null, $process_id= null, $collection = null, $queue= null, $queueProcess = null) { - if ($collection == 'none') - { + if ($collection == 'none' || $collection == '-') { $collection = null; } + if ($process_id == 'none' || $process_id == '-') { + $process_id = null; + } $output = ''; if (trim($terms) != '') @@ -143,49 +165,57 @@ function islandora_workflow_client_manage($terms = null, $collection = null, $qu $errCount = 0; $waitCount =0; $completeCount = 0; + $display = false; foreach ($pids as $pid) { if ( isset($workflows[$pid]) && $workflows[$pid] !== false ) { + $display = true; $procs = $workflows[$pid]->getProcesses(); $updated = FALSE; foreach ($procs as $id=>$n) { - - if ($name == $n) - { - $proc=$workflows[$pid]->getProcess($id); - if (($queue == 'queue'|| ($queue =='errorQueue' && $proc['state'] == 'error')) && $queueProcess == $n) - { - $workflows[$pid]->setState($id,'waiting'); - $updated=TRUE; - } - - - switch ($proc['state']) - { - case 'completed': - $completeCount++; - break; - case 'waiting': - $waitCount++; - break; - case 'error': - $errCount++; - $errors[]=$proc; - break; + if ($process_id == null || $id == $process_id) + { + if ($name == $n) + { + $proc=$workflows[$pid]->getProcess($id); + if (($queue == 'queue'|| ($queue =='errorQueue' && $proc['state'] == 'error')) && $queueProcess == $n) + { + $workflows[$pid]->setState($id,'waiting'); + $updated=TRUE; + } + + + switch ($proc['state']) + { + case 'completed': + $completeCount++; + break; + case 'waiting': + $waitCount++; + break; + case 'error': + $errCount++; + $errors[]=$proc; + break; + } } } - } - if ($updated) - { - $workflows[$pid]->saveToFedora(); + if ($updated) + { + $workflows[$pid]->saveToFedora(); + } } } } - $rows[]= array($name, $waitCount,$completeCount,$errCount,l('Add All to Queue','admin/settings/workflow_client/'.$terms.'/'.(trim($collection)==''?'none':$collection).'/queue/'.$name).'
'.l('Add Errors to Queue','admin/settings/workflow_client/'.$terms.'/'.(trim($collection)==''?'none':$collection).'/errorQueue/'.$name)); + if ($display) { + $rows[]= array($name, $waitCount,$completeCount,$errCount, + l('Add All to Queue','admin/settings/workflow_client/'.$terms.'/'.(trim($process_id)==''?'none':$process_id).'/'.(trim($collection)==''?'none':$collection).'/queue/'.$name).'
'. + l('Add Errors to Queue','admin/settings/workflow_client/'.$terms.'/'.(trim($process_id)==''?'none':$process_id).'/'.(trim($collection)==''?'none':$collection).'/errorQueue/'.$name)); + } } if ($queue == 'queue' || $queue == 'errorQueue') @@ -193,7 +223,7 @@ function islandora_workflow_client_manage($terms = null, $collection = null, $qu drupal_goto('admin/settings/workflow_client/'.$terms.(trim($collection)==''?'/'.$collection:'')); } - $output.='

Search for "'.$terms.'" '.(trim($collection)!=''?'in collection(s) "'.$collection.'" ':'').'returned Processes:

'; + $output.='

Search for '.($process_id!=null?'process id '.$process_id.' with terms ':'').' "'.$terms.'" '.(trim($collection)!=''?'in collection(s) "'.$collection.'" ':'').'returned Processes:

'; $output.=theme('table',$headers,$rows); if (count ($errors) > 0) @@ -223,7 +253,7 @@ function islandora_workflow_client_manage($terms = null, $collection = null, $qu } } - $output .= drupal_get_form('islandora_workflow_client_search'); + $output .= drupal_get_form('islandora_workflow_client_search',$form,NULL, $terms, $process_id, $collection); return $output; } @@ -239,7 +269,7 @@ function islandora_workflow_client_cron() $queue='/queue/fedora.apim.update'; $con->subscribe($queue); $messagesToSend=array(); - for ($i=0;$i<50;$i++) { + for ($i=0;$i<100;$i++) { $msg = $con->readFrame(); if ($msg != null) { diff --git a/workflow_client/plugins/exif.inc b/workflow_client/plugins/exif.inc new file mode 100644 index 00000000..5a1ba414 --- /dev/null +++ b/workflow_client/plugins/exif.inc @@ -0,0 +1,72 @@ + 0) { + $this->setMessage(t('Missing parameter(s) "%params" for exif process on "%pid"', array('%params' => join(',', $missing_params), '%pid' => $pid))); + return FALSE; + } + + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + + $item = new fedora_item($pid); + $dslist = $item->get_datastreams_list_as_array(); + if (!isset($dslist[$parameters['dsid']])) { + $this->setMessage(t('Datastream "%dsid" could not be found for exif process on "%pid"', array('%dsid' => $parameters['dsid'], '%pid' => $pid))); + return FALSE; + } + + $ds = $dslist[$parameters['dsid']]; + $file = '/tmp/'. $ds['label']; + $dest_ds = isset($parameters['dest_ds']) ? $parameters['dest_ds'] : 'EXIF'; + + $objectHelper = new ObjectHelper(); + $objectHelper->makeObject($pid, $parameters['dsid'], FALSE, NULL, $file); + + if (!file_exists($file)) { + $this->setMessage('couldnt get datastream '. $parameters['dsid'] .' as '. $file); + return FALSE; + } + + $system = getenv('System'); + $returnValue=TRUE; + $output=array(); + + $command = '/usr/local/exif/exiftool -X '. $file; + exec($command, $output, $returnValue); + + if (!file_exists($file . $file_suffix)) { + $this->setMessage('command failed: '. htmlentities($command ."\n" . join("\n", $output) ."\n return value: $returnValue")); + @unlink($file); + return FALSE; + } + + if ($returnValue == '0') { + if (isset($dslist[$dest_ds])) { + $item->purge_datastream($dest_ds); + } + + $ret = $item->add_datastream_from_string(join("\n",$output), $dest_ds, $ds['label'] . $file_suffix, 'text/xml', 'X','Added by workflow process EXIF.'); + @unlink($file); + @unlink($file . $file_suffix); + + if (!$ret) { + $this->setMessage(t('Unable to add datastream "%dsid" to "%pid".', array('%dsid' => $dest_ds, '%pid' => $pid))); + return FALSE; + } + + return TRUE; + + } + } +} diff --git a/workflow_client/plugins/mods_extend.inc b/workflow_client/plugins/mods_extend.inc index caf13aff..575974e0 100644 --- a/workflow_client/plugins/mods_extend.inc +++ b/workflow_client/plugins/mods_extend.inc @@ -65,35 +65,39 @@ class mods_extend extends Process { break; } } - - $collections= $relsExtDom->getElementsByTagName('isMemberOfCollection'); - for ($i=0; $i < $collections->length; $i++) { - $collection = $collections->item($i); - list(, $ident) = explode('/', $collection->getAttribute('rdf:resource')); + + $relationships = array('isMemberOfCollection','isMemberOf','isPartOf'); + foreach ($relationships as $relationship) + { + $collections= $relsExtDom->getElementsByTagName($relationship); + for ($i=0; $i < $collections->length; $i++) { + $collection = $collections->item($i); + list(, $ident) = explode('/', $collection->getAttribute('rdf:resource')); - $collection = new fedora_item($ident); - $dc = new SimpleXMLElement($collection->get_datastream_dissemination('DC'), NULL, FALSE, 'http://purl.org/dc/elements/1.1/'); + $collection = new fedora_item($ident); + $dc = new SimpleXMLElement($collection->get_datastream_dissemination('DC'), NULL, FALSE, 'http://purl.org/dc/elements/1.1/'); - $relatedItem = $modsDom->createElement('mods:relatedItem'); - $relatedItem->setAttribute('type', 'host'); - $titleInfo = $modsDom->createElement('mods:titleInfo'); - $title = $modsDom->createElement('mods:title', $dc->title); - $titleInfo->appendChild($title); - $relatedItem->appendChild($titleInfo); + $relatedItem = $modsDom->createElement('mods:relatedItem'); + $relatedItem->setAttribute('type', 'host'); + $titleInfo = $modsDom->createElement('mods:titleInfo'); + $title = $modsDom->createElement('mods:title', $dc->title); + $titleInfo->appendChild($title); + $relatedItem->appendChild($titleInfo); - $identifier = $modsDom->createElement('mods:identifier', $ident); - $identifier->setAttribute('type', 'pid'); - $relatedItem->appendChild($identifier); + $identifier = $modsDom->createElement('mods:identifier', $ident); + $identifier->setAttribute('type', 'pid'); + $relatedItem->appendChild($identifier); - $ident = preg_replace('/^.*\:/', '10719/', $ident); + $ident = preg_replace('/^.*\:/', '10719/', $ident); - $identifier = $modsDom->createElement('mods:identifier', $ident); - $identifier->setAttribute('type', 'hdl'); - $relatedItem->appendChild($identifier); + $identifier = $modsDom->createElement('mods:identifier', $ident); + $identifier->setAttribute('type', 'hdl'); + $relatedItem->appendChild($identifier); - $modsRoot->appendChild($relatedItem); + $modsRoot->appendChild($relatedItem); + } } - + $identifier = $modsDom->createElement('mods:identifier', $pid); $identifier->setAttribute('type', 'pid'); $modsRoot->appendChild($identifier);