Browse Source

Merge remote-tracking branch 'adam/6.x' into 6.x

pull/97/merge
jonathangreen 13 years ago
parent
commit
603b3db014
  1. 66
      CollectionClass.inc
  2. 6
      CollectionPolicy.inc
  3. 7
      ConnectionHelper.inc
  4. 33
      ObjectHelper.inc
  5. 240
      api/fedora_item.inc
  6. 81
      fedora_repository.module
  7. 7
      fedora_repository.solutionpacks.inc
  8. 17
      formClass.inc
  9. 27
      plugins/FedoraObjectDetailedContent.inc

66
CollectionClass.inc

@ -6,6 +6,11 @@
* Collection Class Class * Collection Class Class
*/ */
if (!defined('PHP_VERSION_ID')) { //XXX: This should go elsewhere
$version = explode('.', PHP_VERSION);
define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
}
/** /**
* This CLASS caches the streams so once you call a getstream once it will always return * This CLASS caches the streams so once you call a getstream once it will always return
* the same stream as long as you are using the instance of this class. Cached to * the same stream as long as you are using the instance of this class. Cached to
@ -500,10 +505,11 @@ class CollectionClass {
*/ */
function showFieldSets($page_number) { function showFieldSets($page_number) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'CollectionManagement'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
module_load_include('inc', 'fedora_repository', 'BatchIngest'); //module_load_include('inc', 'fedora_repository', 'BatchIngest'); //Legacy code?
global $base_url; global $base_url;
global $user; global $user;
$tabset = array(); $tabset = array();
$query = NULL; $query = NULL;
$item = new Fedora_Item($this->pid); $item = new Fedora_Item($this->pid);
@ -513,10 +519,7 @@ class CollectionClass {
$results = $this->getRelatedItems($this->pid, $query); $results = $this->getRelatedItems($this->pid, $query);
$collection_items = $this->renderCollection($results, $this->pid, NULL, NULL, $page_number); $collection_items = $this->renderCollection($results, $this->pid, NULL, NULL, $page_number);
$collection_item = new Fedora_Item($this->pid); //$collection_item = new Fedora_Item($this->pid); //XXX: This didn't seem to be used...
// 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();
$show_batch_tab = FALSE; $show_batch_tab = FALSE;
$policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); $policy = CollectionPolicy::loadFromCollection($this->pid, TRUE);
@ -527,39 +530,42 @@ class CollectionClass {
if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") { if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") {
$show_batch_tab = FALSE; $show_batch_tab = FALSE;
} }
if (!$show_ingest_tab) {
$view_selected = TRUE;
}
if (!$collection_items) {
$view_selected = FALSE;
$add_selected = TRUE;
}
$view_selected = !$show_ingest_tab;
// Check the form post to see if we are in the middle of an ingest operation.
$add_selected = ((!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_ingest_form') || !$collection_items);
$view_selected = !$add_selected;
$tabset['view_tab'] = array( $tabset['view_tab'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => 'View', '#title' => t('View'),
'#selected' => $view_selected, '#selected' => $view_selected,
'#content' => $collection_items, '#content' => $collection_items,
'#tab_name' => 'view-tab',
); );
$add_to_collection = $this->getIngestInterface();
if (!empty($add_to_collection)) {
$tabset['add_tab'] = array( $tabset['add_tab'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('Add'), '#title' => t('Add'),
'#selected' => $add_selected, '#selected' => $add_selected,
// This will be the content of the tab. // This will be the content of the tab.
'#content' => $add_to_collection, '#content' => $add_to_collection,
'#tab_name' => 'add-tab',
); );
}
if ($show_batch_tab && user_access('create batch process')) { if ($show_batch_tab && user_access('create batch process')) { //XXX: Is this not put in by the batch module?
$tabset['batch_ingest_tab'] = array( $tabset['batch_ingest_tab'] = array(
// #type and #title are the minimum requirements. // #type and #title are the minimum requirements.
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('Batch Ingest'), '#title' => t('Batch Ingest'),
// This will be the content of the tab. // This will be the content of the tab.
'#content' => drupal_get_form('batch_creation_form', $this->pid, $content_models), '#content' => drupal_get_form('batch_creation_form', $this->pid, $content_models),
'#tab_name' => 'batch-ingest-tab',
); );
} }
return $tabset; return $tabset;
} }
@ -622,7 +628,7 @@ class CollectionClass {
$pageNumber = 1; $pageNumber = 1;
} }
if (!isset($collectionName)) { if (empty($collectionName)) {
$collectionName = variable_get('fedora_repository_name', 'Collection'); $collectionName = variable_get('fedora_repository_name', 'Collection');
} }
$xslContent = $this->getXslContent($pid, $path); $xslContent = $this->getXslContent($pid, $path);
@ -636,11 +642,23 @@ class CollectionClass {
if ($results->length > 0) { if ($results->length > 0) {
try { try {
$proc = new XsltProcessor(); $proc = new XsltProcessor();
$proc->setParameter('', 'collectionPid', $collection_pid); $options = array( //Could make this the return of a hook?
$proc->setParameter('', 'collectionTitle', $collectionName); 'collectionPid' => $collection_pid,
$proc->setParameter('', 'baseUrl', $base_url); 'collectionTitle' => $collectionName,
$proc->setParameter('', 'path', $base_url . '/' . $path); 'baseUrl' => $base_url,
$proc->setParameter('', 'hitPage', $pageNumber); 'path' => "$base_url/$path",
'hitPage' => $pageNumber,
);
if (defined('PHP_VERSION_ID') && PHP_VERSION_ID >= 50100) {
$proc->setParameter('', $options);
}
else {
foreach ($options as $name => $value) {
$proc->setParameter('', $name, $value);
}
}
$proc->registerPHPFunctions(); $proc->registerPHPFunctions();
$xsl = new DomDocument(); $xsl = new DomDocument();
$xsl->loadXML($xslContent); $xsl->loadXML($xslContent);
@ -657,13 +675,13 @@ class CollectionClass {
throw new Exception("Invalid XML."); throw new Exception("Invalid XML.");
} }
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); drupal_set_message(check_plain($e->getMessage()), 'error');
return ''; return '';
} }
} }
} }
else { else {
drupal_set_message(t("No Objects in this collection or bad query.")); drupal_set_message(t("No objects in this collection (or bad query)."));
} }
return $objectList; return $objectList;
} }

6
CollectionPolicy.inc

@ -44,8 +44,13 @@ class CollectionPolicy extends XMLDatastream {
if ($preFetch) { if ($preFetch) {
$fedoraItem = new Fedora_Item($pid); $fedoraItem = new Fedora_Item($pid);
if (array_key_exists($dsid, $fedoraItem->get_datastreams_list_as_array())) {
$ds = $fedoraItem->get_datastream_dissemination($dsid); $ds = $fedoraItem->get_datastream_dissemination($dsid);
} }
else { //No collection policy stream (of the default name, anyway)
return FALSE;
}
}
else { else {
$ds = NULL; $ds = NULL;
} }
@ -55,7 +60,6 @@ class CollectionPolicy extends XMLDatastream {
$ret = new CollectionPolicy($ds, $pid, $dsid); $ret = new CollectionPolicy($ds, $pid, $dsid);
} }
} catch (SOAPException $e) { } catch (SOAPException $e) {
$ret = FALSE; $ret = FALSE;
} }
return $ret; return $ret;

7
ConnectionHelper.inc

@ -63,10 +63,11 @@ class ConnectionHelper {
//anonymous user. We will need an entry in the fedora users.xml file //anonymous user. We will need an entry in the fedora users.xml file
//with the appropriate entry for a username of anonymous password of anonymous //with the appropriate entry for a username of anonymous password of anonymous
try { try {
$client = new SoapClient($this->_fixURL($url, 'anonymous', 'anonymous'), array( $client = new SoapClient($url, array(
'login' => 'anonymous', 'login' => 'anonymous',
'password' => 'anonymous', 'password' => 'anonymous',
'exceptions' => $exceptions, 'exceptions' => $exceptions,
'authentication' => SOAP_AUTHENTICATION_BASIC
)); ));
} catch (SoapFault $e) { } catch (SoapFault $e) {
drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage())))); drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))));
@ -75,10 +76,12 @@ class ConnectionHelper {
} }
else { else {
try { try {
$client = new SoapClient($this->_fixURL($url, $user->name, $user->pass), array( $client = new SoapClient($url, array(
'login' => $user->name, 'login' => $user->name,
'password' => $user->pass, 'password' => $user->pass,
'exceptions' => TRUE, 'exceptions' => TRUE,
'authentication' => SOAP_AUTHENTICATION_BASIC,
'cache_wsdl' => WSDL_CACHE_MEMORY
)); ));
} catch (SoapFault $e) { } catch (SoapFault $e) {
drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage())))); drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))));

33
ObjectHelper.inc

@ -138,7 +138,7 @@ class ObjectHelper {
curl_setopt($ch, CURLOPT_USERPWD, "$fedoraUser:$fedoraPass"); curl_setopt($ch, CURLOPT_USERPWD, "$fedoraUser:$fedoraPass");
// There seems to be a bug in Fedora 3.1's REST authentication, removing this line fixes the authorization denied error. // There seems to be a bug in Fedora 3.1's REST authentication, removing this line fixes the authorization denied error.
// curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); // return into a variable curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // return into a variable
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
@ -150,7 +150,6 @@ class ObjectHelper {
fclose($fp); fclose($fp);
} }
else { else {
header("Content-type: $mimeType"); header("Content-type: $mimeType");
if ($contentSize > 0) { if ($contentSize > 0) {
header("Content-length: $contentSize"); header("Content-length: $contentSize");
@ -181,13 +180,39 @@ class ObjectHelper {
header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"'); header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"');
} }
if ((isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { curl_setopt($ch, CURLOPT_NOBODY, TRUE);
curl_exec($ch); $curl_out = curl_exec($ch);
if ($curl_out !== FALSE) {
$info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
//dd($info, 'effective URL');
if ($url !== $info) { //Handle redirect streams (the final URL is not the same as the Fedora URL)
//Add the parameters passed to Drupal, leaving out the 'q'
$query = array();
parse_str($_SERVER['QUERY_STRING'], $query);
if (isset($query['q'])) {
unset($query['q']);
}
header('HTTP/1.1 307 Moved Temporarily');
header('Location: ' . $info . '?' . http_build_query($query)); //Fedora seems to discard the query portion.
}
elseif ((isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { //If not anonymous, soap is force or we're using HTTPS
//Have the webserver mediate the transfer (download and restream)
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE); //CURLOPT_NOBODY sets it to 'HEAD'
$toReturn = curl_exec($ch);
echo $toReturn;
} }
else { else {
header('Location: ' . $url); header('Location: ' . $url);
} }
} }
else {
//Curl error...
}
}
curl_close($ch); curl_close($ch);
} }
else { else {

240
api/fedora_item.inc

@ -103,9 +103,14 @@ class Fedora_Item {
function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = NULL) { function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = NULL) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
if (!is_file($datastream_file)) { if (!is_file($datastream_file)) {
drupal_set_message("$datastream_file not found<br />", 'warning'); drupal_set_message(t('The datastream file %datastream_file could not found! (or is not a regular file...)', array('%datastream_file' => $datastream_file)), 'warning');
return; return;
} }
elseif (!is_readable($datastream_file)) {
drupal_set_message(t('The datastream file %datastream_file could not be read! (likely due to permissions...)', array('%datastream_file' => $datastream_file)), 'warning');
return;
}
if (empty($datastream_mimetype)) { if (empty($datastream_mimetype)) {
// Get mime type from the file extension. // Get mime type from the file extension.
$mimetype_helper = new MimeClass(); $mimetype_helper = new MimeClass();
@ -214,43 +219,64 @@ class Fedora_Item {
/** /**
* Add a relationship string to this object's RELS-EXT. * Add a relationship string to this object's RELS-EXT.
*
* does not support rels-int yet. * does not support rels-int yet.
* @param type $relationship *
* @param type $object * @param string $relationship
* @param type $namespaceURI * The predicate/relationship tag to add
* @param string $object
* The object to be related to.
* @param string $namespaceURI
* The predicate namespace.
* @param boolean $literal_value
* Whether or not the object should be added as a URI (FALSE) or a literal (TRUE).
*/ */
function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI) { function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = FALSE) {
//dd($this, 'The Fedora_Item');
$ds_list = $this->get_datastreams_list_as_array(); $ds_list = $this->get_datastreams_list_as_array();
$f_prefix = 'info:fedora/';
if (empty($ds_list['RELS-EXT'])) { if (!array_key_exists('RELS-EXT', $ds_list)) {
$this->add_datastream_from_string(' <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> $rdf_string = <<<RDF
<rdf:Description rdf:about="info:fedora/' . $this->pid . '"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="$f_prefix{$this->pid}">
</rdf:Description> </rdf:Description>
</rdf:RDF>', 'RELS-EXT', 'Fedora object-to-object relationship metadata', 'text/xml', 'X'); </rdf:RDF>
RDF;
$this->add_datastream_from_string($rdf_string, 'RELS-EXT', 'Fedora object-to-object relationship metadata', 'application/rdf+xml', 'X');
} }
$relsext = $this->get_datastream_dissemination('RELS-EXT'); $relsext = $this->get_datastream_dissemination('RELS-EXT');
if (substr($object, 0, 12) != 'info:fedora/') { if (!$literal_value && strpos($object, $f_prefix) !== 0) {
$object = "info:fedora/$object"; $object = $f_prefix . $object;
} }
$relsextxml = new DomDocument(); $relsextxml = new DOMDocument();
$relsextxml->loadXML($relsext); $relsextxml->loadXML($relsext);
$description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description'); $description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description');
if ($description->length == 0) { if ($description->length == 0) {
//XXX: This really shouldn't be done; lower case d doesn't fit the schema. Warn users to fix the data and generators, pending deprecation.
$description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'description'); $description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'description');
if ($description->length > 0) {
drupal_set_message(t('RDF with lower case "d" in "description" encountered. Should be uppercase! PID: %pid', array('%pid' => $this->pid)), 'warning');
}
} }
$description = $description->item(0); $description = $description->item(0);
// Create the new relationship node. // Create the new relationship node.
$newrel = $relsextxml->createElementNS($namespaceURI, $relationship); $newrel = $relsextxml->createElementNS($namespaceURI, $relationship);
if ($literal_value) {
$newrel->appendChild($relsextxml->createTextNode($object));
}
else {
$newrel->setAttribute('rdf:resource', $object); $newrel->setAttribute('rdf:resource', $object);
}
$description->appendChild($newrel); $description->appendChild($newrel);
$this->modify_datastream_by_value($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml');
$this->modify_datastream($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'application/rdf+xml');
//print ($description->dump_node()); //print ($description->dump_node());
/* /*
$params = array( 'pid' => $this->pid, $params = array( 'pid' => $this->pid,
@ -264,8 +290,55 @@ class Fedora_Item {
*/ */
} }
/**
* Purge/delete relationships string from this object's RELS-EXT.
*
* does not support rels-int yet.
*
* @param string $relationship
* The predicate/relationship tag to delete
* @param string $object
* The object to be related to. (NULL/value for which empty() evaluates to true will remove all relations of the given type, ignoring $literal_value)
* @param string $namespaceURI
* The predicate namespace.
* @param boolean $literal_value
* Whether or not the object should be looked for as a URI (FALSE) or a literal (TRUE).
* @return boolean
* Whether or not this operation has produced any changes in the RELS-EXT
*/
function purge_relationships($relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = FALSE) {
$relsext = $this->get_datastream_dissemination('RELS-EXT');
$relsextxml = new DomDocument();
$relsextxml->loadXML($relsext);
$modified = FALSE;
$rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship);
if (!empty($rels)) {
foreach ($rels as $rel) {
if ( //If either no object is specified, or the object matches (in either the literal or URI case), remove this node from it's parent, and mark as changed.
empty($object) ||
(!$literal_value && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) ||
($literal_value && $rel->textContent == $object)) {
$rel->parentNode->removeChild($rel);
$modified = TRUE;
}
}
}
//Save changes.
if ($modified) {
$this->modify_datastream($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml');
}
//Return whether or not we've introduced any changes.
return $modified;
}
/** /**
* Removes the given relationship from the item's RELS-EXT and re-saves it. * Removes the given relationship from the item's RELS-EXT and re-saves it.
*
* @deprecated
* Dropped in favour of purge_relationships, which follows the same paradigm as add_relationship. This function tries to figure out the predicate URI based on the prefix/predicate given, which requires specific naming...
* @param string $relationship * @param string $relationship
* @param string $object * @param string $object
*/ */
@ -300,7 +373,7 @@ class Fedora_Item {
break; break;
} }
if (substr($object, 0, 12) != 'info:fedora/') { if (!empty($object) && substr($object, 0, 12) != 'info:fedora/') {
$object = "info:fedora/$object"; $object = "info:fedora/$object";
} }
@ -310,17 +383,16 @@ class Fedora_Item {
$rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship); $rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship);
if (!empty($rels)) { if (!empty($rels)) {
foreach ($rels as $rel) { foreach ($rels as $rel) {
if ($rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) { if (empty($object) || $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) {
$rel->parentNode->removeChild($rel); $rel->parentNode->removeChild($rel);
$modified = TRUE; $modified = TRUE;
} }
} }
} }
if ($modified) { if ($modified) {
$this->modify_datastream_by_value($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml'); $this->modify_datastream($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml');
} }
return $modified; return $modified;
//print ($description->dump_node());
} }
/** /**
@ -434,7 +506,7 @@ class Fedora_Item {
* @param type $as_of_date_time * @param type $as_of_date_time
* @return type * @return type
*/ */
function get_datastream($dsid, $as_of_date_time = "") { function get_datastream($dsid, $as_of_date_time = '') {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid, 'dsID' => $dsid,
@ -530,7 +602,7 @@ class Fedora_Item {
* @return datastream object * @return datastream object
* get the mimetype size etc. in one shot. instead of iterating throught the datastream list for what we need * get the mimetype size etc. in one shot. instead of iterating throught the datastream list for what we need
*/ */
function get_datastream_info($dsid, $as_of_date_time = "") { function get_datastream_info($dsid, $as_of_date_time = '') {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid, 'dsID' => $dsid,
@ -563,7 +635,7 @@ class Fedora_Item {
// datastream, instead of returning it as an array, only // datastream, instead of returning it as an array, only
// the single item will be returned directly. We have to // the single item will be returned directly. We have to
// check for this. // check for this.
if (count($this->datastreams_list->datastreamDef) >= 2) { if (count($this->datastreams_list->datastreamDef) > 1) {
foreach ($this->datastreams_list->datastreamDef as $ds) { foreach ($this->datastreams_list->datastreamDef as $ds) {
if (!is_object($ds)) { if (!is_object($ds)) {
print_r($ds); print_r($ds);
@ -644,7 +716,7 @@ class Fedora_Item {
try { try {
$relsext = $this->get_datastream_dissemination('RELS-EXT'); $relsext = $this->get_datastream_dissemination('RELS-EXT');
} catch (exception $e) { } catch (exception $e) {
drupal_set_message(t("Error retrieving RELS-EXT of object $pid"), 'error'); drupal_set_message(t('Error retrieving RELS-EXT of object %pid.', array('%pid' => $pid)), 'error');
return $relationships; return $relationships;
} }
@ -668,30 +740,8 @@ class Fedora_Item {
} }
function get_models() { function get_models() {
$relationships = array(); //This is/was formerly just a copy/paste jobbie, without the parameter being passable...
try { return $this->get_relationships();
$relsext = $this->get_datastream_dissemination('RELS-EXT');
} catch (exception $e) {
drupal_set_message(t("Error retrieving RELS-EXT of object $pid"), 'error');
return $relationships;
}
// Parse the RELS-EXT into an associative array.
$relsextxml = new DOMDocument();
$relsextxml->loadXML($relsext);
$relsextxml->normalizeDocument();
$mods = $relsextxml->getElementsByTagNameNS(FEDORA_MODEL_URI, '*');
foreach ($mods as $child) {
if (empty($relationship) || preg_match("/$relationship/", $child->tagName)) {
$relationships[] = array(
'subject' => $this->pid,
'predicate' => $child->tagName,
'object' => substr($child->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource'), 12),
);
}
}
return $relationships;
} }
/** /**
@ -790,8 +840,9 @@ class Fedora_Item {
* @return type * @return type
*/ */
function url() { function url() {
global $base_url; return url('fedora/repository/' . $this->pid . (!empty($this->objectProfile) ? '/-/' . drupal_urlencode($this->objectProfile->objLabel) : ''), array(
return $base_url . '/fedora/repository/' . $this->pid . (!empty($this->objectProfile) ? '/-/' . drupal_urlencode($this->objectProfile->objLabel) : ''); 'absolute' => TRUE
));
} }
/** /**
@ -827,9 +878,14 @@ class Fedora_Item {
* @param type $foxml * @param type $foxml
* @return Fedora_Item * @return Fedora_Item
*/ */
static function ingest_from_FOXML($foxml) { static function ingest_from_FOXML(DOMDocument $foxml) {
$params = array('objectXML' => $foxml->saveXML(), 'format' => "info:fedora/fedora-system:FOXML-1.1", 'logMessage' => "Fedora Object Ingested"); $params = array(
'objectXML' => $foxml->saveXML(),
'format' => 'info:fedora/fedora-system:FOXML-1.1',
'logMessage' => 'Fedora Object Ingested'
);
$object = self::soap_call('ingest', $params); $object = self::soap_call('ingest', $params);
//dd($object, 'Soap return');
return new Fedora_Item($object->objectPID); return new Fedora_Item($object->objectPID);
} }
@ -889,6 +945,69 @@ class Fedora_Item {
return self::soap_call('modifyObject', $params, $quiet); return self::soap_call('modifyObject', $params, $quiet);
} }
/**
* Wrap modify by value and reference
*
* Wrap modify by value and reference, so that the proper one gets called in the correct instance. (value if inline XML, reference otherwise)
*
* First tries to treat the passed in value as a filename, tries using as contents second.
* Coerces the data into what is required, and passes it on to the relevant function.
*
* @param string $filename_or_content
* Either a filename to add, or an string of content.
* @param string $dsid
* The DSID to update
* @param string $label
* A label to withwhich to update the datastream
* @param string $mime_type
* Mimetype for the data being pushed into the datastream
* @param boolean $force
* Dunno, refer to underlying functions/SOAP interface. We just pass it like a chump.
* @param string $logMessage
* A message for the audit log.
* @param boolean $quiet
* Error suppression? Refer to soap_call for usage (just passed along here).
*/
function modify_datastream($filename_or_content, $dsid, $label, $mime_type, $force = FALSE, $logMessage='Modified by Islandora API', $quiet=FALSE) {
//Determine if it's inline xml; if it is, modify by value
if ($this->get_datastream($dsid)->controlGroup === 'X') {
$content = '<null/>';
if (is_file($filename_or_content) && is_readable($filename_or_content)) {
$content = file_get_contents($filename_or_content);
}
else {
$content = $filename_or_content;
}
$this->modify_datastream_by_value($content, $dsid, $label, $mime_type, $force, $logMessage);
}
//Otherwise, write to web-accessible temp file and modify by reference.
else {
$file = '';
$created_temp = FALSE;
if (is_file($filename_or_content) && is_readable($filename_or_content)) {
$file = $filename_or_content;
$original_path = $file;
// Temporarily move file to a web-accessible location.
file_copy($file, file_directory_path());
$created_temp = ($original_path != $file);
}
else {
//Push contents to a web-accessible file
$file = file_save_data($filename_or_content, file_directory_path());
$created_temp = TRUE;
}
$file_url = file_create_url($file);
$this->modify_datastream_by_reference($file_url, $dsid, $label, $mime_type, $force, $logMessage);
if ($created_temp && is_file($file) && is_writable($file)) {
file_delete($file);
}
}
}
/** /**
* Modify datastream by reference * Modify datastream by reference
* @param type $external_url * @param type $external_url
@ -976,9 +1095,11 @@ class Fedora_Item {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
self::$connection_helper = new ConnectionHelper(); self::$connection_helper = new ConnectionHelper();
} }
$url = (array_search($function, self::$SoapManagedFunctions) !== FALSE) ? $url = (
in_array($function, self::$SoapManagedFunctions)?
variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/wsdl?api=API-M') : variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/wsdl?api=API-M') :
variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'); variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')
);
try { try {
$soap_client = self::$connection_helper->getSoapClient($url); $soap_client = self::$connection_helper->getSoapClient($url);
if (isset($soap_client)) { if (isset($soap_client)) {
@ -1029,25 +1150,23 @@ class Fedora_Item {
} }
} }
$root_element = $foxml->createElement("foxml:digitalObject"); $root_element = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:digitalObject");
$root_element->setAttribute("VERSION", "1.1"); $root_element->setAttribute("VERSION", "1.1");
$root_element->setAttribute("PID", $pid); $root_element->setAttribute("PID", $pid);
$root_element->setAttribute("xmlns:foxml", "info:fedora/fedora-system:def/foxml#"); $root_element->setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation", "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd");
$root_element->setAttribute("xmlns:xsl", "http://www.w3.org/2001/XMLSchema-instance");
$root_element->setAttribute("xsl:schemaLocation", "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd");
$foxml->appendChild($root_element); $foxml->appendChild($root_element);
// FOXML object properties section // FOXML object properties section
$object_properties = $foxml->createElement("foxml:objectProperties"); $object_properties = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:objectProperties");
$state_property = $foxml->createElement("foxml:property"); $state_property = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:property");
$state_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#state"); $state_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#state");
$state_property->setAttribute("VALUE", $state); $state_property->setAttribute("VALUE", $state);
$label_property = $foxml->createElement("foxml:property"); $label_property = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:property");
$label_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#label"); $label_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#label");
$label_property->setAttribute("VALUE", $label); $label_property->setAttribute("VALUE", $label);
$owner_property = $foxml->createElement("foxml:property"); $owner_property = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:property");
$owner_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#ownerId"); $owner_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#ownerId");
$owner_property->setAttribute("VALUE", $owner); $owner_property->setAttribute("VALUE", $owner);
@ -1056,7 +1175,6 @@ class Fedora_Item {
$object_properties->appendChild($owner_property); $object_properties->appendChild($owner_property);
$root_element->appendChild($object_properties); $root_element->appendChild($object_properties);
$foxml->appendChild($root_element); $foxml->appendChild($root_element);
return $foxml; return $foxml;
} }

81
fedora_repository.module

@ -146,14 +146,13 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
$form_state['submitted'] = FALSE; $form_state['submitted'] = FALSE;
return; return;
} }
if ($form_state['storage']['xml']) { //ddebug_backtrace();
if (module_exists('islandora_content_model_forms')) { if ($form_state['storage']['xml'] && module_exists('islandora_content_model_forms')) {
module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm');
$xml_form = new IngestObjectMetadataForm(); $xml_form = new IngestObjectMetadataForm();
$xml_form->submit($form, $form_state); $xml_form->submit($form, $form_state);
} }
} elseif (strpos($form_state['clicked_button']['#id'], 'edit-submit') === 0) {
elseif ($form_state['clicked_button']['#id'] == 'edit-submit') {
global $base_url; global $base_url;
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
@ -188,7 +187,7 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
} }
if ($redirect) { if ($redirect) {
$form_state['redirect'] = ($err) ? ' ' : $base_url . "/fedora/repository/{$form_state['values']['collection_pid']}"; $form_state['redirect'] = ($err) ? ' ' : url("fedora/repository/{$form_state['values']['collection_pid']}");
} }
} }
} }
@ -205,7 +204,7 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
$form_state['submitted'] = FALSE; $form_state['submitted'] = FALSE;
return; return;
} }
if ($form_state['clicked_button']['#id'] == 'edit-submit' && $form_state['ahah_submission'] != 1) { if (strpos($form_state['clicked_button']['#id'], 'edit-submit') === 0 && $form_state['ahah_submission'] != 1) {
switch ($form_state['storage']['step']) { switch ($form_state['storage']['step']) {
case 1: case 1:
$form_state['storage']['step']++; $form_state['storage']['step']++;
@ -286,7 +285,8 @@ function fedora_repository_ingest_form(&$form_state, $collection_pid, $collectio
$ingestForm = new formClass(); $ingestForm = new formClass();
$form_state['storage']['content_model'] = $content_model; $form_state['storage']['content_model'] = $content_model;
$form_state['storage']['collection_pid'] = $collection_pid; $form_state['storage']['collection_pid'] = $collection_pid;
return $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state); $form = $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state);
return $form;
} }
/** /**
@ -771,13 +771,6 @@ 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')); $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. // 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 = ''; $output = '';
if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) { if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) {
$output = $cm->buildEditMetadataForm($pid, $dsId); $output = $cm->buildEditMetadataForm($pid, $dsId);
@ -821,7 +814,7 @@ function fedora_repository_edit_qdc_form_validate($form, &$form_state) {
function fedora_repository_edit_qdc_form_submit($form, &$form_state) { function fedora_repository_edit_qdc_form_submit($form, &$form_state) {
if ($form_state['storage']['xml']) { if ($form_state['storage']['xml']) {
module_load_include('inc', 'islandora_content_model_forms', 'EditObjectMetadataForm'); module_load_include('inc', 'islandora_content_model_forms', 'EditObjectMetadataForm');
$xml_form = new EditObjectMetadataForm($form_state); $xml_form = new EditObjectMetadataForm();
$xml_form->submit($form, $form_state); $xml_form->submit($form, $form_state);
} }
else { else {
@ -1047,6 +1040,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
/** /**
* fedora repository urlencode string * fedora repository urlencode string
* FIXME: URL-encoding is not the same as HTML/XML encoding...
* @param type $str * @param type $str
* @return type * @return type
*/ */
@ -1722,7 +1716,7 @@ function fedora_repository_required_fedora_objects() {
'pid' => 'islandora:collectionCModel', 'pid' => 'islandora:collectionCModel',
'label' => 'Islandora Collection Content Model', 'label' => 'Islandora Collection Content Model',
'dsid' => 'ISLANDORACM', 'dsid' => 'ISLANDORACM',
'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml", 'datastream_file' => "./$module_path/content_models/COLLECTIONCM.xml",
'dsversion' => 2, 'dsversion' => 2,
'cmodel' => 'fedora-system:ContentModel-3.0', 'cmodel' => 'fedora-system:ContentModel-3.0',
), ),
@ -1733,11 +1727,11 @@ function fedora_repository_required_fedora_objects() {
'datastreams' => array( 'datastreams' => array(
array( array(
'dsid' => 'COLLECTION_POLICY', 'dsid' => 'COLLECTION_POLICY',
'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml", 'datastream_file' => "./$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml",
), ),
array( array(
'dsid' => 'TN', 'dsid' => 'TN',
'datastream_file' => "$module_path/images/Gnome-emblem-photos.png", 'datastream_file' => "./$module_path/images/Gnome-emblem-photos.png",
'mimetype' => 'image/png', 'mimetype' => 'image/png',
), ),
), ),
@ -2176,49 +2170,61 @@ function fedora_repository_batch_reingest_object($object, &$context) {
return NULL; return NULL;
} }
// Does the object exist? If so, purge it. // Does the object exist? If so, purge it.
//dd("About to test existence of PID: $pid");
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
if ($item->exists()) { if ($item->exists()) {
//dd(' Found');
$item->purge(t('Remove during re-install batch job')); $item->purge(t('Remove during re-install batch job'));
//dd(' Purged');
} }
$new_item = NULL; //Need to have this a couple places... (After trying from FOXML and later for individual DSs)
$datastreams = array(); //Seems like this might be getting messed up due to scope?
// Ingest the object from the source file. // Ingest the object from the source file.
if (!empty($object['foxml_file'])) { if (!empty($object['foxml_file'])) {
$foxml_file = $object['foxml_file']; $foxml_file = $object['foxml_file'];
$new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file); $new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file);
if ($new_item->exists()) { if ($new_item->exists()) {
// Batch operation was successful. // Batch operation was successful; can still add additional DSs, though
$context['message'][] = "$new_item->pid installed."; $context['message'][] = t('%pid installed.', array('%pid' => $new_item->pid));
} }
} }
if (!empty($object['dsid']) && !empty($object['datastream_file'])) { if (!empty($object['dsid']) && !empty($object['datastream_file'])) {
$datastreams = array( $datastreams[] = array(
array(
'dsid' => $object['dsid'], 'dsid' => $object['dsid'],
'datastream_file' => $object['datastream_file'], 'datastream_file' => $object['datastream_file'],
)
); );
} }
elseif (!empty($object['datastreams'])) { elseif (!empty($object['datastreams'])) {
$datastreams = $object['datastreams']; $datastreams = $object['datastreams'];
} }
if (!empty($datastreams) && is_array($datastreams)) {
$label = !empty($object['label']) ? $object['label'] : ''; $label = !empty($object['label']) ? $object['label'] : '';
if (!isset($new_item)) {
if (empty($object['foxml_file']) && !isset($new_item)) { //dd(' Not found, creating');
$new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label); $new_item = Fedora_Item::ingest_new_item($pid, 'A', $label);
//dd(' Created');
}
elseif (!empty($label)) {
$new_item->modify_object($label);
} }
if (isset($new_item)) {
if (!empty($object['cmodel'])) { if (!empty($object['cmodel'])) {
//dd(' relating to cmodel');
$new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI); $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI);
//dd(' related to cmodel');
} }
if (!empty($object['parent'])) { if (!empty($object['parent'])) {
//dd(' adding parent');
$new_item->add_relationship('isMemberOfCollection', $object['parent']); $new_item->add_relationship('isMemberOfCollection', $object['parent']);
//dd(' parent added');
} }
foreach ($datastreams as $ds) { foreach ((array)$datastreams as $ds) {
//dd("trying to add ds: {$ds['dsid']}");
if ($ds['dsid'] == 'DC') { if ($ds['dsid'] == 'DC') {
$new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml'); $new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml');
} }
@ -2242,22 +2248,17 @@ function fedora_repository_batch_reingest_object($object, &$context) {
*/ */
function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) { function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) {
$return = NULL; $return = NULL;
if (isset($item)) { if (!empty($item) && !empty($dsid)) {
$doc = simplexml_load_string($item->get_datastream_dissemination($dsid)); $doc = simplexml_load_string($item->get_datastream_dissemination($dsid));
} }
elseif (isset($datastream_file)) { elseif (!empty($datastream_file)) {
$doc = simplexml_load_file($datastream_file); $doc = simplexml_load_file($datastream_file);
} }
if (!empty($doc)) { if (!empty($doc) && $version = (int)$doc->attributes()->version) {
$attrs = $doc->attributes(); $return = $version;
foreach ($attrs as $name => $value) {
if ($name == 'version') {
$return = (int) $value;
break;
}
}
} }
return $return; return $return;
} }

7
fedora_repository.solutionpacks.inc

@ -110,10 +110,11 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
$object_status = 'Missing datastream'; $object_status = 'Missing datastream';
break; break;
} }
if (isset($ds['dsversion'])) { elseif (isset($ds['dsversion'])) {
// Check if the datastream is versioned and needs updating. // Check if the datastream is versioned and needs updating.
$installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']); $installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']);
$available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); $available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']);
if ($available_version > $installed_version) { if ($available_version > $installed_version) {
$needs_update = TRUE; $needs_update = TRUE;
$object_status = 'Out of date'; $object_status = 'Out of date';
@ -165,8 +166,8 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) {
$module_name = $form_state['values']['solution_pack_module']; $module_name = $form_state['values']['solution_pack_module'];
// This should be replaced with module_invoke // This should be replaced with module_invoke
$solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); //$solution_pack_info = call_user_func($module_name . '_required_fedora_objects');
//$solution_pack_info = module_invoke($module_name, 'required_fedora_objects'); $solution_pack_info = module_invoke($module_name, 'required_fedora_objects');
$batch = array( $batch = array(
'title' => t('Installing / updating solution pack objects'), 'title' => t('Installing / updating solution pack objects'),

17
formClass.inc

@ -69,19 +69,13 @@ class formClass {
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('view fedora collection'), 'access arguments' => array('view fedora collection'),
); );
$repository_title = variable_get('fedora_repository_title', 'Digital repository');
if (trim($repository_title) != '') {
$respository_title = t($repository_title);
}
else {
$repository_title = NULL;
}
$items['fedora/repository'] = array( $items['fedora/repository'] = array(
'title' => $repository_title, 'title' => '',
'title callback' => 'variable_get',
'title arguments' => array('fedora_repository_name', 'Digital Repository'),
'page callback' => 'repository_page', 'page callback' => 'repository_page',
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
'access arguments' => array('view fedora collection'), 'access arguments' => array('view fedora collection'),
// 'access' => TRUE
); );
$items['fedora/repository/service'] = array( $items['fedora/repository/service'] = array(
@ -100,8 +94,6 @@ class formClass {
$items['fedora/repository/editmetadata'] = array( $items['fedora/repository/editmetadata'] = array(
'title' => t('Edit metadata'), 'title' => t('Edit metadata'),
'page callback' => 'fedora_repository_edit_qdc_page', 'page callback' => 'fedora_repository_edit_qdc_page',
// 'page arguments' => array(1),
//'type' => MENU_LOCAL_TASK,
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('edit fedora meta data') 'access arguments' => array('edit fedora meta data')
); );
@ -123,7 +115,6 @@ class formClass {
$items['fedora/repository/purgeObject'] = array( $items['fedora/repository/purgeObject'] = array(
'title' => t('Purge object'), 'title' => t('Purge object'),
'page callback' => 'fedora_repository_purge_object', 'page callback' => 'fedora_repository_purge_object',
// 'type' => MENU_LOCAL_TASK,
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('purge objects and datastreams') 'access arguments' => array('purge objects and datastreams')
); );
@ -131,7 +122,6 @@ class formClass {
$items['fedora/repository/addStream'] = array( $items['fedora/repository/addStream'] = array(
'title' => t('Add stream'), 'title' => t('Add stream'),
'page callback' => 'add_stream', 'page callback' => 'add_stream',
// 'type' => MENU_LOCAL_TASK,
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('add fedora datastreams') 'access arguments' => array('add fedora datastreams')
); );
@ -617,6 +607,7 @@ class formClass {
$form = new IngestObjectMetadataForm(); $form = new IngestObjectMetadataForm();
return $form->create($collection_pid, $collection_label, $form_state); return $form->create($collection_pid, $collection_label, $form_state);
} catch (Exception $e) { } catch (Exception $e) {
//dd('An error occured; reverting to QDC form...');
$form_state['storage']['xml'] = FALSE; // An error occured revert back to the QDC Form. $form_state['storage']['xml'] = FALSE; // An error occured revert back to the QDC Form.
} }
} }

27
plugins/FedoraObjectDetailedContent.inc

@ -43,6 +43,7 @@ class FedoraObjectDetailedContent {
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('Object Details'), '#title' => t('Object Details'),
'#selected' => $details_selected, '#selected' => $details_selected,
'#weight' => 100, //XXX: Make the weight configurable?
); );
$tabset['fedora_object_details']['tabset'] = array( $tabset['fedora_object_details']['tabset'] = array(
'#type' => 'tabset', '#type' => 'tabset',
@ -51,12 +52,28 @@ class FedoraObjectDetailedContent {
$ds_list = $objectHelper->get_formatted_datastream_list($this->pid, NULL, $this->item); $ds_list = $objectHelper->get_formatted_datastream_list($this->pid, NULL, $this->item);
$i = 0;
if (fedora_repository_access(OBJECTHELPER :: $VIEW_DETAILED_CONTENT_LIST, $this->pid, $user)) {
$tabset['fedora_object_details']['tabset']['view'] = array( $tabset['fedora_object_details']['tabset']['view'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('View'), '#title' => t('View'),
'#content' => $dc_html . $ds_list . $purge_form, 'dc' => array(
'#type' => 'markup',
'#value' => $dc_html, //XXX: This could easily be done in Drupal, instead of using an XSL
'#weight' => $i++
),
'list' => array(
'#type' => 'markup',
'#value' => $ds_list, //XXX: The function called here could be cleaned up a fair bit as well...
'#weight' => $i++
),
'purge' => array(
'#type' => 'markup',
'#value' => $purge_form,
'#weight' => $i++
)
); );
}
if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) {
$editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC'); $editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC');
@ -68,7 +85,13 @@ class FedoraObjectDetailedContent {
); );
} }
$ts = $tabset['fedora_object_details']['tabset'];
if (array_key_exists('view', $ts) || array_key_exists('edit', $ts)) {
return $tabset; return $tabset;
} }
else {
return array();
}
}
} }

Loading…
Cancel
Save