Browse Source

Merge branch '6.x' of https://github.com/Islandora/islandora into 6.x

pull/147/head
Alan Stanley 13 years ago
parent
commit
06f4a0d335
  1. 10
      CollectionClass.inc
  2. 13
      ContentModel.inc
  3. 1
      MimeClass.inc
  4. 3
      ObjectHelper.inc
  5. 70
      api/fedora_item.inc
  6. 39
      plugins/FedoraObjectDetailedContent.inc

10
CollectionClass.inc

@ -34,12 +34,12 @@ class CollectionClass {
} }
public static function getCollectionQuery($pid) { public static function getCollectionQuery($pid) {
if ($query = self::getCollectionQueryFromStream($pid)) { $query = self::getCollectionQueryFromStream($pid);
return $query; if (!$query) {
} $query = self::getDefaultCollectionQuery($pid);
else {
return self::getDefaultCollectionQuery($pid);
} }
drupal_alter("islandora_collection_query", $query, $pid);
return $query;
} }
protected static function getCollectionQueryFromStream($pid) { protected static function getCollectionQueryFromStream($pid) {

13
ContentModel.inc

@ -1475,7 +1475,17 @@ class ContentModel extends XMLDatastream {
self::$errors[] = 'Execute Form Handler: file \'' . $path . '\' does not exist.'; self::$errors[] = 'Execute Form Handler: file \'' . $path . '\' does not exist.';
} }
else { else {
require_once($path);
$file_extension = pathinfo($method->getAttribute('file'), PATHINFO_EXTENSION);
$file_path_without_extension = $method->getAttribute('file');
/* Only in PHP. This is meant to avoid file path
* concatenation issues.*/
$file_path_without_extension = substr($file_path_without_extension, 0, strlen($file_path_without_extension) - (strlen($file_extension) + 1));
/* Only try to execute if the module is present, this is
* necessarybecause we go outside of the expected
* 'Drupal Way' and have dynamic dependencies.*/
if (module_exists(!empty($module) ? $module : 'fedora_repository')) {
module_load_include($file_extension, !empty($module) ? $module : 'fedora_repository', $file_path_without_extension);
$className = $method->getAttribute('class'); $className = $method->getAttribute('class');
$methodName = ($method->getAttribute('method')); $methodName = ($method->getAttribute('method'));
if (!class_exists($className)) { if (!class_exists($className)) {
@ -1496,6 +1506,7 @@ class ContentModel extends XMLDatastream {
} }
} }
} }
}
return $output; return $output;
} }

1
MimeClass.inc

@ -133,6 +133,7 @@ class MimeClass {
'xht' => 'application/xhtml+xml', 'xht' => 'application/xhtml+xml',
'xhtml' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml',
'xsl' => 'text/xml', 'xsl' => 'text/xml',
'xslt' => 'text/xml',
'xml' => 'text/xml', 'xml' => 'text/xml',
'csv' => 'text/csv', 'csv' => 'text/csv',
'tsv' => 'text/tab-separated-values', 'tsv' => 'text/tab-separated-values',

3
ObjectHelper.inc

@ -137,9 +137,6 @@ class ObjectHelper {
$fedoraPass = $user->pass; $fedoraPass = $user->pass;
} }
$dataStreamInfo = $item->get_datastream_info($dsID);
$contentSize = $dataStreamInfo->datastream->size;
if (function_exists("curl_init")) { if (function_exists("curl_init")) {
$url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/objects/' . $pid . '/datastreams/' . $dsID . '/content'; $url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/objects/' . $pid . '/datastreams/' . $dsID . '/content';
$query_options = array(); $query_options = array();

70
api/fedora_item.inc

@ -347,7 +347,10 @@ RDF;
$modified = FALSE; $modified = FALSE;
$rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship); $rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship);
if (!empty($rels)) { if (!empty($rels)) {
foreach ($rels as $rel) { // 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);
// 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) || 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_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) ||
@ -986,6 +989,54 @@ RDF;
return self::soap_call('modifyObject', $params, $quiet); return self::soap_call('modifyObject', $params, $quiet);
} }
/**
* Work around function, due to file_create_url not URL encoding stuff.
*
* Parses and reassembles the URL, exploding, rawurlencoding and imploding
* the path components along the way.
*
* @param $url
* A string containing an HTTP(S) URL to attempt.
* @return string
* The results of the HTTP request if successful; boolean FALSE otherwise.
*/
protected static function try_http_get_content($url) {
//Can throw a warning prior to 5.3.3
$parsed_url = @parse_url($url);
$supported_schemes = array(
'http',
'https'
);
$content = FALSE;
if ($parsed_url && array_key_exists('scheme', $parsed_url) && in_array($parsed_url['scheme'], $supported_schemes)) {
$components = explode('/', $parsed_url['path']);
$components = array_map('rawurlencode', $components);
$result = drupal_http_request(
url(
t('!scheme://!user:!pass@!host:!port/!path', array(
'!scheme' => $parsed_url['scheme'],
'!user' => rawurlencode($parsed_url['user']),
'!pass' => rawurlencode($parsed_url['pass']),
'!host' => $parsed_url['host'],
'!path' => implode('/', $components),
)),
array(
'query' => $parsed_url['query'],
'fragment' => $parsed_url['fragment'],
)
)
);
if ((int)($result->code / 100) === 2) {
$content = $result->data;
}
}
return $content;
}
/** /**
* Wrap modify by value and reference * Wrap modify by value and reference
* *
@ -1018,9 +1069,17 @@ RDF;
if (is_file($filename_or_content) && is_readable($filename_or_content)) { if (is_file($filename_or_content) && is_readable($filename_or_content)) {
$content = file_get_contents($filename_or_content); $content = file_get_contents($filename_or_content);
} }
else {
//XXX: Get the contents to deal with fopen not being allowed for remote access
// in some OSs
$temp_content = self::try_http_get_content($filename_or_content);
if ($temp_content !== FALSE) {
$content = $temp_content;
}
else { else {
$content = $filename_or_content; $content = $filename_or_content;
} }
}
$toReturn = $this->modify_datastream_by_value($content, $dsid, $label, $mime_type, $force, $logMessage); $toReturn = $this->modify_datastream_by_value($content, $dsid, $label, $mime_type, $force, $logMessage);
} }
@ -1036,8 +1095,15 @@ RDF;
$created_temp = ($original_path != $file); $created_temp = ($original_path != $file);
} }
else { else {
//XXX: Get the contents to deal with fopen not being allowed for remote access
// in some OSs
$temp_content = self::try_http_get_content($filename_or_content);
if ($temp_content !== FALSE) {
$filename_or_content = $temp_content;
}
//Push contents to a web-accessible file //Push contents to a web-accessible file
$file = file_save_data($filename_or_content, file_directory_path()); $file = file_save_data($filename_or_content, file_create_filename($label, file_directory_path()));
$created_temp = TRUE; $created_temp = TRUE;
} }

39
plugins/FedoraObjectDetailedContent.inc

@ -55,14 +55,14 @@ class FedoraObjectDetailedContent {
if (!isset($profile)) { if (!isset($profile)) {
// default behaviour // default behaviour
watchdog('fedora_repository', "Error while reading the default object details display profile: @e", array("@e" => $e->getMessage()), WATCHDOG_WARNING); watchdog('fedora_repository', "Error while reading the default object details display profile: @e", array("@e" => $e->getMessage()), WATCHDOG_WARNING);
$dc_html = $objectHelper->getFormattedDC($this->item); $dc_returned = $objectHelper->getFormattedDC($this->item);
} }
else { else {
// invoke the requested display profile // invoke the requested display profile
require_once(drupal_get_path('module', $profile['module']) ."/". $profile['file']); require_once(drupal_get_path('module', $profile['module']) ."/". $profile['file']);
$details_function = $profile['function']; $details_function = $profile['function'];
if (function_exists($details_function)) { if (function_exists($details_function)) {
$dc_html = $details_function($this->item); $dc_returned = $details_function($this->item);
} }
else { else {
// problem - display profile not found // problem - display profile not found
@ -70,16 +70,31 @@ class FedoraObjectDetailedContent {
} }
} }
$dc_array = array();
$i = 0; $i = 0;
if (fedora_repository_access(OBJECTHELPER :: $VIEW_DETAILED_CONTENT_LIST, $this->pid, $user)) { if (is_array($dc_returned)) {
$dc_array = $dc_returned;
$dc_array['#weight'] = $i++;
}
elseif (!empty($dc_returned)) {
$dc_array = array(
'#type' => 'markup',
'#value' => $dc_returned, //XXX: This could easily be done in Drupal, instead of using an XSL
'#weight' => $i++
);
}
$tabset['fedora_object_details']['tabset']['view'] = array( $tabset['fedora_object_details']['tabset']['view'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('View'), '#title' => t('View'),
'dc' => array( );
'#type' => 'markup',
'#value' => $dc_html, //XXX: This could easily be done in Drupal, instead of using an XSL if (!empty($dc_array)) {
'#weight' => $i++ $tabset['fedora_object_details']['tabset']['view']['dc'] = $dc_array;
), }
if (fedora_repository_access(ObjectHelper :: $VIEW_DETAILED_CONTENT_LIST, $this->pid, $user)) {
$tabset['fedora_object_details']['tabset']['view'] += array(
'list' => array( 'list' => array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('Detailed List of Content'), '#title' => t('Detailed List of Content'),
@ -100,6 +115,11 @@ class FedoraObjectDetailedContent {
'#weight' => $i++, '#weight' => $i++,
), ),
), ),
);
}
if (fedora_repository_access(ObjectHelper :: $PURGE_FEDORA_OBJECTSANDSTREAMS, $this->pid, $user)) {
$tabset['fedora_object_details']['tabset']['view'] += array(
'purge' => array( 'purge' => array(
'#type' => 'markup', '#type' => 'markup',
'#value' => $purge_form, '#value' => $purge_form,
@ -119,7 +139,8 @@ class FedoraObjectDetailedContent {
} }
$ts = $tabset['fedora_object_details']['tabset']; $ts = $tabset['fedora_object_details']['tabset'];
if (array_key_exists('view', $ts) || array_key_exists('edit', $ts)) { if ((array_key_exists('view', $ts) && (count(element_children($ts['view'])) > 0)) ||
(array_key_exists('edit', $ts) && (count(element_children($ts['edit'])) > 0 || array_key_exists('#content', $ts['edit'])))) {
return $tabset; return $tabset;
} }
else { else {

Loading…
Cancel
Save