Browse Source

Merge pull request #76 from ajstanley/6.x

added convenience method to wrap datastream writing
pull/77/merge
Ben Woodhead 13 years ago
parent
commit
d53b25e0bd
  1. 31
      api/fedora_item.inc

31
api/fedora_item.inc

@ -43,7 +43,7 @@ class Fedora_Item {
} }
$raw_objprofile = $this->soap_call('getObjectProfile', array('pid' => $this->pid, 'asOfDateTime' => "")); $raw_objprofile = $this->soap_call('getObjectProfile', array('pid' => $this->pid, 'asOfDateTime' => ""));
if (!empty($raw_objprofile)) { if (!empty($raw_objprofile)) {
$this->objectProfile = $raw_objprofile->objectProfile; $this->objectProfile = $raw_objprofile->objectProfile;
$this->datastreams = $this->get_datastreams_list_as_array(); $this->datastreams = $this->get_datastreams_list_as_array();
@ -55,7 +55,7 @@ class Fedora_Item {
Fedora_Item::$instantiated_pids[$pid] = &$this; Fedora_Item::$instantiated_pids[$pid] = &$this;
} }
} }
/** /**
* Forget this Object, do manually when memory constraints apply. * Forget this Object, do manually when memory constraints apply.
* *
@ -164,6 +164,30 @@ class Fedora_Item {
return $returnvalue; return $returnvalue;
} }
/**
* Wrapper to add new or modify existing datastream
* @global url $base_url
* @param url $external_url
* @param string $dsid
* @param string $label
* @param string $mime_type
* @param string $controlGroup
* @param boolean $force
* @param string $logMessage
* @param boolean $quiet
*/
function add_or_modify_by_reference($external_url, $dsid, $label, $mime_type, $controlGroup = 'M', $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) {
global $base_url;
if (array_key_exists($dsid, $this->datastreams)) {
$this->modify_datastream_by_reference($external_url, $dsid, $label, $mime_type, $force, $logMessage, $quiet);
}
else {
$file_location = str_replace("$base_url/", '', $external_url);
$this->add_datastream_from_file($file_location, $dsid, $label, $mime_type, $controlGroup = 'M', $logMessage = NULL);
}
}
/** /**
* 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.
@ -583,8 +607,7 @@ class Fedora_Item {
return $relationships; return $relationships;
} }
function get_models() {
function get_models() {
$relationships = array(); $relationships = array();
try { try {
$relsext = $this->get_datastream_dissemination('RELS-EXT'); $relsext = $this->get_datastream_dissemination('RELS-EXT');

Loading…
Cancel
Save