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. 33
      ContentModel.inc
  3. 1
      MimeClass.inc
  4. 3
      ObjectHelper.inc
  5. 72
      api/fedora_item.inc
  6. 45
      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) {

33
ContentModel.inc

@ -1475,19 +1475,30 @@ 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);
$className = $method->getAttribute('class'); $file_extension = pathinfo($method->getAttribute('file'), PATHINFO_EXTENSION);
$methodName = ($method->getAttribute('method')); $file_path_without_extension = $method->getAttribute('file');
if (!class_exists($className)) { /* Only in PHP. This is meant to avoid file path
self::$errors[] = 'Execute Form Handler: class \'' . $className . '\' does not exist.'; * concatenation issues.*/
} $file_path_without_extension = substr($file_path_without_extension, 0, strlen($file_path_without_extension) - (strlen($file_extension) + 1));
else { /* Only try to execute if the module is present, this is
$class = new $className($pid); * necessarybecause we go outside of the expected
if (!method_exists($class, $methodName)) { * 'Drupal Way' and have dynamic dependencies.*/
self::$errors[] = 'Execute Form Handler: method \'' . $className . '->' . $methodName . '\' does not exist.'; 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');
$methodName = ($method->getAttribute('method'));
if (!class_exists($className)) {
self::$errors[] = 'Execute Form Handler: class \'' . $className . '\' does not exist.';
} }
else { else {
$output = $class->$methodName($page_number); $class = new $className($pid);
if (!method_exists($class, $methodName)) {
self::$errors[] = 'Execute Form Handler: method \'' . $className . '->' . $methodName . '\' does not exist.';
}
else {
$output = $class->$methodName($page_number);
}
} }
} }
} }

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();

72
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
* *
@ -1019,7 +1070,15 @@ RDF;
$content = file_get_contents($filename_or_content); $content = file_get_contents($filename_or_content);
} }
else { else {
$content = $filename_or_content; //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 {
$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;
} }

45
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)) {
$tabset['fedora_object_details']['tabset']['view'] = array( $dc_array = $dc_returned;
'#type' => 'tabpage', $dc_array['#weight'] = $i++;
'#title' => t('View'), }
'dc' => array( elseif (!empty($dc_returned)) {
'#type' => 'markup', $dc_array = array(
'#value' => $dc_html, //XXX: This could easily be done in Drupal, instead of using an XSL '#type' => 'markup',
'#weight' => $i++ '#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(
'#type' => 'tabpage',
'#title' => t('View'),
);
if (!empty($dc_array)) {
$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