Browse Source

Simplify logic in get datastream list and allow multiple pids to be obtained.

pull/126/head
Adam Vessey 13 years ago
parent
commit
48c63fad76
  1. 21
      api/fedora_item.inc

21
api/fedora_item.inc

@ -637,8 +637,12 @@ RDF;
// 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) > 1) { $xml_list = $this->datastreams_list->datastreamDef;
foreach ($this->datastreams_list->datastreamDef as $ds) { if (!is_array($this->datastreams_list->datastreamDef)) {
$xml_list = array($xml_list);
}
foreach ($xml_list as $ds) {
if (!is_object($ds)) { if (!is_object($ds)) {
print_r($ds); print_r($ds);
} }
@ -647,13 +651,6 @@ RDF;
$ds_list[$ds->ID]['URL'] = $this->url() . '/' . $ds->ID . '/' . drupal_urlencode($ds->label); $ds_list[$ds->ID]['URL'] = $this->url() . '/' . $ds->ID . '/' . drupal_urlencode($ds->label);
} }
} }
else {
$ds = $this->datastreams_list->datastreamDef;
$ds_list[$ds->ID]['label'] = $ds->label;
$ds_list[$ds->ID]['MIMEType'] = $ds->MIMEType;
$ds_list[$ds->ID]['URL'] = $this->url() . '/' . $ds->ID . '/' . drupal_urlencode($ds->label);
}
}
return $ds_list; return $ds_list;
} }
@ -852,7 +849,7 @@ RDF;
* @param $pid_namespace string * @param $pid_namespace string
* @return string * @return string
*/ */
static function get_next_PID_in_namespace($pid_namespace = '') { static function get_next_PID_in_namespace($pid_namespace = '', $number_of_pids = 1) {
if (empty($pid_namespace)) { if (empty($pid_namespace)) {
// Just get the first one in the config settings. // Just get the first one in the config settings.
$allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
@ -866,11 +863,12 @@ RDF;
} }
$params = array( $params = array(
'numPIDs' => '', 'numPIDs' => $number_of_pids,
'pidNamespace' => $pid_namespace, 'pidNamespace' => $pid_namespace,
); );
$result = self::soap_call('getNextPID', $params); $result = self::soap_call('getNextPID', $params);
return $result->pid; return $result->pid;
} }
@ -1147,6 +1145,7 @@ RDF;
$pid = self::get_next_PID_in_namespace(); $pid = self::get_next_PID_in_namespace();
} }
if (empty($owner)) { if (empty($owner)) {
global $user;
if (!empty($user->uid)) { // Default to current Drupal user. if (!empty($user->uid)) { // Default to current Drupal user.
$owner = $user->uid; $owner = $user->uid;
} }

Loading…
Cancel
Save