Browse Source

updated get_ref_relationships to accomodate new namespaces

pull/155/head
Alan Stanley 13 years ago
parent
commit
1bb2f4805f
  1. 51
      api/fedora_item.inc

51
api/fedora_item.inc

@ -158,7 +158,7 @@ class Fedora_Item {
// Fedora has some problems getting files from HTTPS connections sometimes, so if we are getting a file
// from the local drupal, we try to pass a HTTP url instead of a HTTPS one.
if(stripos($datastream_url, 'https://') !== FALSE && stripos($datastream_url, $base_url) !== FALSE) {
if (stripos($datastream_url, 'https://') !== FALSE && stripos($datastream_url, $base_url) !== FALSE) {
$datastream_url = str_ireplace('https://', 'http://', $datastream_url);
}
@ -348,10 +348,10 @@ RDF;
$rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship);
if (!empty($rels)) {
// iterate backwards so if we delete something our pointer doesn't get out of sync
for ($i = $rels->length; $i>0; $i--) {
$rel = $rels->item($i-1);
for ($i = $rels->length; $i > 0; $i--) {
$rel = $rels->item($i - 1);
// foreach ($rels as $rel) { // moving forward like this caused iteration errors when something was deleted
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.
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 == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) ||
(($literal_value == RELS_TYPE_PLAIN_LITERAL) && $rel->textContent == $object) ||
@ -752,8 +752,26 @@ RDF;
return $relationships;
}
function get_rdf_relationships() {
/**
* Retrieves RELS-EXT values from item
*
* @param array $namespaces
* @return array
*/
function get_rdf_relationships($namespaces = null) {
if ($namespaces == NULL) {
$namespaces = array(
RELS_EXT_URI,
FEDORA_MODEL_URI,
ISLANDORA_PAGE_URI,
ISLANDORA_RELS_EXT_URI,
ISLANDORA_RELS_INT_URI,
);
}
if (!is_array($namespaces)) {
$namespaces = array($namespaces);
}
$relationships = array();
try {
$relsext = $this->get_datastream_dissemination('RELS-EXT');
@ -767,13 +785,16 @@ RDF;
$relsextxml->loadXML($relsext);
$relsextxml->normalizeDocument();
$allTags = array();
$allTags[] = $relsextxml->getElementsByTagNameNS(RELS_EXT_URI, '*');
$allTags[] = $relsextxml->getElementsByTagNameNS(FEDORA_MODEL_URI, '*');
$allTags[] = $relsextxml->getElementsByTagNameNS(ISLANDORA_PAGE_URI, '*');
foreach ($namespaces as $namespace) {
$allTags[] = $relsextxml->getElementsByTagNameNS($namespace, '*');
}
foreach ($allTags as $tags) {
foreach ($tags as $child) {
$value = preg_replace('/info:fedora\//','',$child->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource'));
$value = preg_replace('/info:fedora\//', '', $child->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource'));
if (!$value) {
$value = $child->textContent;
}
$relationships[$child->tagName][] = $value;
}
}
@ -980,8 +1001,8 @@ RDF;
$params = array(
'pid' => $this->pid,
'ownerId' => (($ownerId !== NULL)? //Default to the current owner if none is provided.
$ownerId:
'ownerId' => (($ownerId !== NULL) ? //Default to the current owner if none is provided.
$ownerId :
$this->objectProfile->objOwnerId),
'state' => $state,
'label' => $label,
@ -1034,7 +1055,7 @@ RDF;
);
$result = drupal_http_request($fixed_url);
if ((int)($result->code / 100) === 2) {
if ((int) ($result->code / 100) === 2) {
$content = $result->data;
}
else {
@ -1148,7 +1169,7 @@ RDF;
// Fedora has some problems getting files from HTTPS connections sometimes, so if we are getting a file
// from the local drupal, we try to pass a HTTP url instead of a HTTPS one.
if(stripos($external_url, 'https://') !== FALSE && stripos($external_url, $base_url) !== FALSE) {
if (stripos($external_url, 'https://') !== FALSE && stripos($external_url, $base_url) !== FALSE) {
$external_url = str_ireplace('https://', 'http://', $external_url);
}
@ -1228,7 +1249,7 @@ RDF;
self::$connection_helper = new ConnectionHelper();
}
$url = (
in_array($function, self::$SoapManagedFunctions)?
in_array($function, self::$SoapManagedFunctions) ?
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')
);

Loading…
Cancel
Save