Browse Source

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

pull/92/head
ppound 13 years ago
parent
commit
d5d2a36e4f
  1. 29
      CollectionClass.inc
  2. 3
      ContentModel.inc
  3. 23
      ObjectHelper.inc
  4. 6
      SecurityClass.inc
  5. 2
      api/fedora_collection.inc
  6. 206
      api/fedora_item.inc
  7. 15
      api/fedora_utils.inc
  8. 36
      fedora_repository.module
  9. 21
      fedora_repository.solutionpacks.inc
  10. 20
      formClass.inc
  11. 4
      plugins/FormBuilder.inc
  12. 2
      plugins/PersonalCollectionClass.inc
  13. 4
      plugins/Refworks.inc
  14. 2
      plugins/ShowStreamsInFieldSets.inc
  15. 2
      xsl/sparql_to_html.xsl

29
CollectionClass.inc

@ -45,11 +45,12 @@ class CollectionClass {
* @return type
*/
function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper();
if (!isset($itqlquery)) {
// $query_string = $objectHelper->getStream($pid, 'QUERY', 0);
$itqlquery = $objectHelper->getStream($pid, 'QUERY', 0);
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new Fedora_Item($pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$itqlquery = $item->get_datastream_dissemination('QUERY');
}
}
return $this->getRelatedItems($pid, $itqlquery, $limit, $offset);
}
@ -67,9 +68,6 @@ class CollectionClass {
function getRelatedItems($pid, $itqlquery = NULL, $limit = NULL, $offset = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!isset($limit)) {
$limit = 1000;
}
if (!isset($offset)) {
$offset = 0;
}
@ -81,10 +79,14 @@ class CollectionClass {
$objectHelper = new ObjectHelper();
$query_string = $itqlquery;
if (!isset($query_string)) {
$query_string = $objectHelper->getStream($pid, 'QUERY', 0);
$query_string = NULL;
$item = new Fedora_Item($pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$query_string = $item->get_datastream_dissemination('QUERY');
}
if ($query_string == NULL) {
$query_string = 'select $object $title $content from <#ri>
where ($object <dc:title> $title
where ($object <fedora-model:label> $title
and $object <fedora-model:hasModel> $content
and ($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/' . $pid . '>
or $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $pid . '>)
@ -343,7 +345,7 @@ class CollectionClass {
$thisClass = new $phpClass ();
$returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext);
if (!$returnValue) {
drupal_set_message('Error! Failed running content model method !m !rv', array('!m' => $phpMethod, '!rv' => $returnValue));
drupal_set_message(t('Error! Failed running content model method !m !rv', array('!m' => $phpMethod, '!rv' => $returnValue)));
return FALSE;
}
}
@ -463,7 +465,7 @@ class CollectionClass {
module_load_include('inc', 'fedora_repository', 'plugins/PersonalCollectionClass');
$personalCollectionClass = new PersonalCollectionClass();
if (!$personalCollectionClass->createCollection($user, $pid, $soapClient)) {
drupal_set_message("Did not create a personal collection object for !u", array('!u' => $user->name));
drupal_set_message(t("Did not create a personal collection object for !u", array('!u' => $user->name)));
return FALSE; //creation failed don't save the collection pid in drupal db
}
user_save($user, $personal_collection_pid);
@ -501,11 +503,10 @@ class CollectionClass {
module_load_include('inc', 'fedora_repository', 'CollectionManagement');
module_load_include('inc', 'fedora_repository', 'BatchIngest');
global $base_url;
$tabset = array();
global $user;
$objectHelper = new ObjectHelper();
$item = new Fedora_Item($this->pid);
$tabset = array();
$query = NULL;
$item = new Fedora_Item($this->pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$query = $item->get_datastream_dissemination('QUERY');
}

3
ContentModel.inc

@ -429,7 +429,7 @@ class ContentModel extends XMLDatastream {
*/
public function getServices() {
$query = 'select $object $title from <#ri>
where ($object <dc:title> $title
where ($object <fedora-model:label> $title
and $object <fedora-model:isDeploymentOf> $deploymentOf
and $object <fedora-model:hasModel> <info:fedora/fedora-system:ServiceDeployment-3.0>
and $object <fedora-model:isContractorOf> <info:fedora/' . $this->pid . '>
@ -1374,6 +1374,7 @@ class ContentModel extends XMLDatastream {
else {
$status = $class->$methodName($param_array, $method->getAttribute('dsid'), $file, $method->getAttribute('modified_files_ext'));
if ($status !== TRUE) {
self::$errors[] = 'Execute Ingest Rules: method \'' . $className . '->' . $methodName . '\' failed.';
$ret = FALSE;
}
}

23
ObjectHelper.inc

@ -122,8 +122,7 @@ class ObjectHelper {
$dsID = variable_get('fedora_default_display_dsid', 'TN');
$mimeType = 'image/jpeg';
}
$url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/get/' . $pid . '/' . $dsID;
$url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/objects/' . $pid . '/datastreams/' . $dsID . '/content';
if ($version) {
$url .= '/' . $version; //drupal_urlencode($version);
}
@ -383,8 +382,8 @@ class ObjectHelper {
$xsl->load($path . '/xsl/convertQDC.xsl');
$input = new DomDocument();
$input->loadXML(trim($xmlstr));
} catch (exception $e) {
watchdog(t("Fedora_Repository"), "Problem loading XSL file: @e", array('@e' => $e), NULL, WATCHDOG_ERROR);
} catch (Exception $e) {
watchdog('fedora_repository', "Problem loading XSL file: @e", array('@e' => $e->getMessage()), NULL, WATCHDOG_ERROR);
}
$xsl = $proc->importStylesheet($xsl);
$newdom = $proc->transformToDoc($input);
@ -729,7 +728,7 @@ class ObjectHelper {
*/
function get_parent_objects($pid) {
$query_string = 'select $object $title from <#ri>
where ($object <dc:title> $title
where ($object <fedora-model:label> $title
and <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $object
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title';
@ -829,7 +828,7 @@ class ObjectHelper {
// Get title and descriptions for $pid
$query_string = 'select $title $desc from <#ri>
where $o <dc:title> $title
where $o <fedora-model:label> $title
and $o <dc:description> $desc
and $o <mulgara:is> <info:fedora/' . $pid . '>';
@ -858,7 +857,7 @@ class ObjectHelper {
$query_string = 'select $o $title from <#ri> ' .
// $query_string = 'select $o $title $desc from <#ri> '.
'where $s <info:fedora/fedora-system:def/relations-external#hasMember> $o ' .
'and $o <dc:title> $title ' .
'and $o <fedora-model:label> $title ' .
// 'and $o <dc:description> $desc '.
'and ( ';
@ -924,12 +923,13 @@ class ObjectHelper {
// Before executing the query, we hve a base case of accessing the top-level collection
global $base_url;
if ($pid == variable_get('fedora_repository_pid', 'islandora:root')) {
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
//$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(variable_get('fedora_repository_title', 'Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), $base_url);
}
else {
$query_string = 'select $parentObject $title $content from <#ri>
where (<info:fedora/' . $pid . '> <dc:title> $title
where (<info:fedora/' . $pid . '> <fedora-model:label> $title
and $parentObject <fedora-model:hasModel> $content
and (<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject
or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject
@ -954,7 +954,8 @@ class ObjectHelper {
$breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid);
if ($parent == variable_get('fedora_repository_pid', 'islandora:root')) {
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
//$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(variable_get('fedora_repository_title', 'Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), $base_url);
}
elseif ($level > 0) {
@ -963,7 +964,7 @@ class ObjectHelper {
}
else {
$breadcrumbs[] = l("Path Calculation Error", 'fedora/repository/' . $pid);
$breadcrumbs[] = l(t("Path Calculation Error"), 'fedora/repository/' . $pid);
}
}
}

6
SecurityClass.inc

@ -71,9 +71,9 @@ class SecurityClass {
try {
$xml = new SimpleXMLElement($policyStream);
} catch (Exception $e) {
watchdog(t("Fedora_Repository"), t("No roles found in security policy, could not parse policy stream."), NULL, WATCHDOG_ERROR);
watchdog(t("Fedora_Repository"), "No roles found in security policy, could not parse policy stream.", NULL, WATCHDOG_ERROR);
//we may not want to send this to the screen.
drupal_set_message(t('No roles found in security policy, could not parse policy stream: !message', array('!message' => $e->getMessage())), 'error');
drupal_set_message(t('No roles found in security policy, could not parse policy stream: !message', array('!message' => check_plain($e->getMessage()))), 'error');
return NULL;
}
$xml->registerXPathNamespace('default', 'urn:oasis:names:tc:xacml:1.0:policy');
@ -110,7 +110,7 @@ class SecurityClass {
try {
$doc->load(drupal_get_path('module', 'Fedora_Repository') . '/policies/noObjectEditPolicy.xml');
} catch (exception $e) {
watchdog(t("Fedora_Repository"), t("Problem loading policy file."), NULL, WATCHDOG_ERROR);
watchdog(t("Fedora_Repository"), "Problem loading policy file.", NULL, WATCHDOG_ERROR);
}
$conditions = $doc->getElementsByTagName('Condition');
foreach ($conditions as $condition) {

2
api/fedora_collection.inc

@ -77,7 +77,7 @@ function get_related_items_as_xml($collection_pid, $relationship = array('isMemb
}
$query_string = 'select $object $title $content from <#ri>
where ($object <dc:title> $title
where ($object <fedora-model:label> $title
and $object <fedora-model:hasModel> $content
and (';

206
api/fedora_item.inc

@ -6,6 +6,7 @@
*/
define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#');
define("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#');
define("ISLANDORA_PAGE_URI", 'info:islandora/islandora-system:def/pageinfo#');
/**
* Fedora Item Class
@ -18,6 +19,22 @@ class Fedora_Item {
public $datastreams = NULL;
private static $connection_helper = NULL;
private static $instantiated_pids = array();
private static $SoapManagedFunctions = array(
'ingest',
'addDataStream',
'addRelationship',
'export',
'getDatastream',
'getDatastreamHistory',
'getNextPID',
'getRelationships',
'modifyDatastreamByValue',
'modifyDatastreamByReference',
'purgeDatastream',
'purgeObject',
'modifyObject',
'setDatastreamState'
);
/**
* Create an object to represent an item in the Fedora repository.
@ -42,7 +59,7 @@ class Fedora_Item {
self::$connection_helper = new ConnectionHelper();
}
$raw_objprofile = $this->soap_call('getObjectProfile', array('pid' => $this->pid, 'asOfDateTime' => ""));
$raw_objprofile = $this->soap_call('getObjectProfile', array('pid' => $this->pid, 'asOfDateTime' => ""), TRUE);
if (!empty($raw_objprofile)) {
$this->objectProfile = $raw_objprofile->objectProfile;
@ -56,6 +73,15 @@ class Fedora_Item {
}
}
/**
* Forget this Object, do manually when memory constraints apply.
*
* Removes this object from the static list of $instantiated_pids
*/
function forget() {
unset(Fedora_Item::$instantiated_pids[$this->pid]);
}
/**
* Exists
* @return type
@ -110,10 +136,18 @@ class Fedora_Item {
* @return type
*/
function add_datastream_from_url($datastream_url, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = NULL) {
global $base_url;
if (empty($datastream_label)) {
$datastream_label = $datastream_id;
}
// 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) {
$datastream_url = str_ireplace('https://', 'http://', $datastream_url);
}
$params = array(
'pid' => $this->pid,
'dsID' => $datastream_id,
@ -155,6 +189,29 @@ class Fedora_Item {
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.
* does not support rels-int yet.
@ -237,6 +294,10 @@ class Fedora_Item {
$relationship = "hasModel";
$namespaceURI = FEDORA_MODEL_URI;
break;
case "isPageNumber":
$relationship = "isPageNumber";
$namespaceURI = ISLANDORA_PAGE_URI;
break;
}
if (substr($object, 0, 12) != 'info:fedora/') {
@ -345,15 +406,18 @@ class Fedora_Item {
* Get datastream dissemination
* @param type $dsid
* @param type $as_of_date_time
* @return string
* @param type $quiet
* @return null
*/
function get_datastream_dissemination($dsid, $as_of_date_time = "") {
function get_datastream_dissemination($dsid, $as_of_date_time = "", $quiet=TRUE) {
$params = array(
'pid' => $this->pid,
'dsID' => $dsid,
'asOfDateTime' => $as_of_date_time,
);
$object = self::soap_call('getDataStreamDissemination', $params);
// Make soap call with quite
$object = self::soap_call('getDataStreamDissemination', $params, $quiet);
if (!empty($object)) {
$content = $object->dissemination->stream;
$content = trim($content);
@ -574,6 +638,34 @@ class Fedora_Item {
return $relationships;
}
function get_rdf_relationships() {
$relationships = array();
try {
$relsext = $this->get_datastream_dissemination('RELS-EXT');
} catch (exception $e) {
drupal_set_message(t("Error retrieving RELS-EXT of object $pid"), 'error');
return $relationships;
}
// Parse the RELS-EXT into an associative array.
$relsextxml = new DOMDocument();
$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 ($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'));
$relationships[$child->tagName][] = $value;
}
}
return $relationships;
}
function get_models() {
$relationships = array();
@ -627,6 +719,28 @@ class Fedora_Item {
return FALSE;
}
/**
* Set the object to a deleted state
*/
function move_to_trash($log_message = 'Flagged deleted using Islandora API.') {
// Loop through the datastreams and mark them deleted
foreach ($this->get_datastreams_list_as_array() as $dsid) {
$this->set_datastream_state($dsid, 'D');
}
// Create a message to mark the object deleted
$params = array(
'pid' => $this->pid,
'state' => 'D',
'logMessage' => $logMessage,
'label' => $this->objectProfile->objLabel,
'ownerId' => null,
);
// Send message to mark the object deleted
return self::soap_call('modifyObject', $params, $quiet);
}
/**
* Removes this object form the repository.
* @param type $log_message
@ -634,12 +748,18 @@ class Fedora_Item {
* @return type
*/
function purge($log_message = 'Purged using Islandora API.', $force = FALSE) {
// Flag the object to be deleted first
$this->move_to_trash($log_message);
// Create the delete message
$params = array(
'pid' => $this->pid,
'logMessage' => $log_message,
'force' => $force
);
// Delete the object
return $this->soap_call('purgeObject', $params);
}
@ -839,75 +959,47 @@ class Fedora_Item {
}
/**
* Soap call
* @param type $function_name
* @param type $params_array
* @param type $quiet
* @return type
* Make a soap call to the fedora API.
*
* @param string $function
* The name of the soap function to call.
* @param array $parameters
* Paramters to pass onto the soap call
* @param boolean $quiet
* If TRUE suppress drupal messages.
*
* @return mixed
* The return value from the soap function if successful, NULL otherwise.
*/
static function soap_call($function_name, $params_array, $quiet = FALSE) {
static function soap_call($function, $parameters, $quiet = FALSE) {
if (!self::$connection_helper) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
self::$connection_helper = new ConnectionHelper();
}
switch ($function_name) {
case 'ingest':
case 'addDataStream':
case 'addRelationship':
case 'export':
case 'getDatastream':
case 'getDatastreamHistory':
case 'getNextPID':
case 'getRelationships':
case 'modifyDatastreamByValue':
case 'modifyDatastreamByReference':
case 'purgeDatastream':
case 'purgeObject':
case 'modifyObject':
case 'setDatastreamState':
$soap_client = self::$connection_helper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$url = (array_search($function, self::$SoapManagedFunctions) !== FALSE) ?
variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl') :
variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
try {
if (!empty($soap_client)) {
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array));
$soap_client = self::$connection_helper->getSoapClient($url);
if (isset($soap_client)) {
$result = $soap_client->__soapCall($function, array('parameters' => $parameters));
}
else {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to get SOAP client connection.");
return NULL;
}
} catch (exception $e) {
if (!$quiet) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to call SOAP function !fn.', array('!fn' => $function_name)), 'error');
}
else {
drupal_set_message(t("Error trying to call SOAP function $function_name. Check watchdog logs for more information."), 'error');
}
watchdog(t("FEDORA_REPOSITORY"), "Error Trying to call SOAP function @fn: @e", array('@fn' => $function_name, '@e' => $e), NULL, WATCHDOG_ERROR);
drupal_set_message(t('Error trying to get SOAP client connection'));
}
watchdog('fedora_repository', 'Error trying to get SOAP client connection.');
return NULL;
}
break;
default:
try {
$soap_client = self::$connection_helper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
if (!empty($soap_client)) {
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array));
}
else {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to get SOAP client connection.");
return NULL;
}
} catch (exception $e) {
} catch (Exception $e) {
if (!$quiet) {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to call SOAP function @fn: @e", array('@fn' => $function_name, '@e' => $e), NULL, WATCHDOG_ERROR);
preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage()) ?
drupal_set_message(t('Insufficient permissions to call SOAP function "%func".', array('%func' => $function)), 'error') :
drupal_set_message(t('Error trying to call SOAP function "%func". Check watchdog logs for more information.', array('%func' => $function)), 'error');
}
watchdog('fedora_repository', 'Error Trying to call SOAP function "%func". Exception: @e in @f(@l)\n@t', array('%func' => $function, '@e' => $e->getMessage(), '@f' => $e->getFile(), '@l' => $e->getLine(), '@t' => $e->getTraceAsString()), NULL, WATCHDOG_ERROR);
return NULL;
}
}
return $result;
}

15
api/fedora_utils.inc

@ -236,8 +236,10 @@ function fix_dsid($dsid) {
function get_collections_as_option_array() {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string);
$query = 'select $object $title from <#ri>
where ($object <dc:title> $title
where ($object <fedora-model:label> $title
and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel>
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title';
@ -247,13 +249,22 @@ function get_collections_as_option_array() {
$list = explode("\n", $content);
array_shift($list);
$list = preg_replace('/info:fedora\//', '', $list);
foreach ($namespaces as $namespace) {
$trimmed_names[] = trim($namespace);
}
$options = array();
foreach ($list as $item) { //removes blanks
if ($item) {
$parts = explode(',', $item);
$namespace = explode(':', $parts[0]);
$namespace = trim($namespace[0]);
$bool = in_array($namespace, $trimmed_names);
if (!$restricted || in_array($namespace, $trimmed_names)) {
$options[$parts[0]] = $parts[1];
}
}
}
unset($options['islandora:ContentModelCollection']);
return $options;
}
@ -277,7 +288,7 @@ function get_content_models_as_option_array() {
}
}
$query = 'select $object $title from <#ri>
where ($object <dc:title> $title
where ($object <fedora-model:label> $title
and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0>
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)

36
fedora_repository.module

@ -143,7 +143,7 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
//only validate the form if the submit button was pressed (other buttons may be used for AHAH
if ($form_state['ahah_submission']) {
$form_state['submitted'] = false;
$form_state['submitted'] = FALSE;
return;
}
if ($form_state['storage']['xml']) {
@ -202,7 +202,7 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
function fedora_repository_ingest_form_validate($form, &$form_state) {
//only validate the form if the submit button was pressed (other buttons may be used for AHAH
if ($form_state['ahah_submission']) {
$form_state['submitted'] = false;
$form_state['submitted'] = FALSE;
return;
}
if ($form_state['clicked_button']['#id'] == 'edit-submit' && $form_state['ahah_submission'] != 1) {
@ -246,8 +246,11 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
if (!empty($file)) {
if (!in_array($dformat, $allowedMimeTypes)) {
form_set_error('ingest-file-location', t('The uploaded file\'s mimetype (' . $dformat . ') is not associated with this Content Model. The allowed types are ' .
implode(' ', $allowedMimeTypes)));
form_set_error('ingest-file-location',
t('The uploaded file\'s mimetype') .
' (' . $dformat . ') ' .
t('is not associated with this Content Model. The allowed types are') .
' ' . implode(' ', $allowedMimeTypes));
file_delete($file);
return;
}
@ -614,7 +617,7 @@ function fedora_repository_purge_stream_form_submit($form, &$form_state) {
* @param type $collectionName
* @return type
*/
function fedora_repository_replace_stream($pid, $dsId, $dsLabel, $collectionName = NULL) {
function fedora_repository_replace_stream($pid, $dsId, $dsLabel = '', $collectionName = NULL) {
if ($pid == NULL || $dsId == NULL) {
drupal_set_message(t('You must specify an pid and dsId to replace.'), 'error');
return '';
@ -704,8 +707,20 @@ function fedora_repository_replace_stream_form_submit($form, &$form_state) {
$dformat = $mimetype->getType($file->filepath);
$item = new Fedora_Item($pid);
$info = $item->get_datastream_info($dsid);
if($info->datastream->controlGroup == 'M') {
$item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat);
} elseif ($info->datastream->controlGroup == 'X') {
if($dformat == 'text/xml') {
$item->modify_datastream_by_value(file_get_contents($file->filepath), $dsid, $dsLabel, $dformat);
}
else {
drupal_set_message('File must be of mimetype text/xml in order to replace inline XML datastream.', 'error');
}
} else {
drupal_set_message('Cannot replace Redirect or Managed Datastream.', 'error');
}
$form_state['redirect'] = 'fedora/repository/' . $pid;
}
@ -879,6 +894,7 @@ function fedora_repository_access($op, $node, $account) {
* @param $dsID String
*/
function makeObject($pid, $dsID) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!valid_pid($pid)) {
drupal_set_message(t("Invalid PID!"), 'error');
@ -1008,6 +1024,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
);
}
}
// Add a 'manage object' tab for all objects, where detailed list of content is shown.
$obj = new FedoraObjectDetailedContent($pid);
$object_details = $obj->showFieldSets();
@ -1592,7 +1609,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
$dc->set_element('dc:title', array('Installed Content Model'));
$dc->save();
$cmodel_collection->add_datastream_from_string('select $object $title from <#ri>
where ($object <dc:title> $title
where ($object <fedora-model:label> $title
and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0>
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
@ -2146,13 +2163,16 @@ function fedora_repository_display_schema($file) {
* @return type
*/
function fedora_repository_batch_reingest_object($object, &$context) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!empty($object) && is_array($object)) {
$pid = $object['pid'];
if (!valid_pid($pid)) {
return NULL;
}
// Does the object exist? If so, purge it.
$item = new Fedora_Item($pid);
if ($item->exists()) {
@ -2168,6 +2188,7 @@ function fedora_repository_batch_reingest_object($object, &$context) {
$context['message'][] = "$new_item->pid installed.";
}
}
if (!empty($object['dsid']) && !empty($object['datastream_file'])) {
$datastreams = array(
array(
@ -2181,10 +2202,13 @@ function fedora_repository_batch_reingest_object($object, &$context) {
}
if (!empty($datastreams) && is_array($datastreams)) {
$label = !empty($object['label']) ? $object['label'] : '';
if (empty($object['foxml_file']) && !isset($new_item)) {
$new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label);
}
if (!empty($object['cmodel'])) {
$new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI);
}

21
fedora_repository.solutionpacks.inc

@ -46,19 +46,21 @@ function fedora_repository_solution_packs_page() {
* @param array $solution_pack
*/
function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) {
// Check each object to see if it is in the repository.
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
global $base_path;
$needs_update = FALSE;
$needs_install = FALSE;
$form = array();
$form['solution_pack_module'] = array(
'#type' => 'hidden',
'#value' => $solution_pack_module,
);
if (!$form_state['submitted']) {
$form['soluction_pack_name'] = array(
$form['solution_pack_name'] = array(
'#type' => 'markup',
'#value' => t($solution_pack_name),
'#prefix' => '<h3>',
@ -75,7 +77,6 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
$table_header = array('PID', 'Status');
$table_rows = array();
foreach ($objects as $object) {
$datastreams = NULL;
if (isset($object['pid'])) {
@ -139,13 +140,16 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
);
if (!$needs_install && !$needs_update) {
$form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.');
$submit_button_text = t("Force Reinstallation of Fedora Objects");
}
else {
$form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.');
$submit_button_text = t("Install Fedora Objects");
}
$form['submit'] = array(
'#value' => t('Install'),
'#disabled' => !$needs_install && !$needs_update,
'#value' => $submit_button_text,
'#type' => 'submit',
'#name' => $solution_pack_module,
);
@ -159,7 +163,11 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
function fedora_repository_solution_pack_form_submit($form, &$form_state) {
$what = $form_state;
$module_name = $form_state['values']['solution_pack_module'];
// This should be replaced with module_invoke
$solution_pack_info = call_user_func($module_name . '_required_fedora_objects');
//$solution_pack_info = module_invoke($module_name, 'required_fedora_objects');
$batch = array(
'title' => t('Installing / updating solution pack objects'),
'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module',
@ -181,7 +189,7 @@ function solution_pack_add_form($form_name, $form_xml) {
$object->name = $form_name;
$object->form = $form_xml;
$result = drupal_write_record('xml_forms', $object);
drupal_set_message("Added $name");
drupal_set_message(t("Added @name", array("@name" => $form_name)));
}
}
@ -196,7 +204,6 @@ function solution_pack_add_form_association($content_model, $form_name) {
$object->title_field = "['titleInfo']['title']";
$object->transform = 'mods_to_dc.xsl';
$result = drupal_write_record('islandora_content_model_forms', $object);
drupal_set_message("Added association between $content_model$name");
drupal_set_message(t("Added association between @cm and @name", array("@cm" => $content_model, "@name"=>$form_name)));
}
}

20
formClass.inc

@ -25,8 +25,8 @@ class formClass {
$items = array();
$items['admin/settings/fedora_repository'] = array(
'title' => t('Islandora Configure'),
'description' => t('Enter the Islandora Collection information here'),
'title' => t('Islandora Configuration'),
'description' => t("Configure Islandora's interaction with Fedora"),
'page callback' => 'drupal_get_form',
'page arguments' => array('fedora_repository_admin'),
'access arguments' => array('administer site configuration'),
@ -48,7 +48,6 @@ class formClass {
'file' => 'fedora_repository.solutionpacks.inc',
'type' => MENU_LOCAL_TASK,
);
$items['islandoracm.xsd'] = array(
'title' => t('Islandora Content Model XML Schema Definition'),
'page callback' => 'fedora_repository_display_schema',
@ -379,7 +378,13 @@ class formClass {
// DC elements
$previousElement = NULL; // Used in case we have to nest elements for qualified dublin core.
$label = null;
foreach ($form_values as $key => $value) {
//echo ($key);
if ($key == 'dc:title-0') {
$label = $value;
}
$index = strrpos($key, '-');
$key = substr($key, 0, $index);
$test = substr($key, 0, 2);
@ -400,6 +405,13 @@ class formClass {
}
}
// Save the title
if ( $label != null )
{
$object = new Fedora_Item($form_values['pid']);
$object->modify_object($label);
}
$dom->appendChild($oai);
if (!$client) {
@ -581,6 +593,8 @@ class formClass {
if (!$this->canShowIngestForm($collection_pid)) {
return FALSE;
}
drupal_set_title($collection_label);
if (module_exists('islandora_content_model_forms')) {
module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm');
try {

4
plugins/FormBuilder.inc

@ -95,7 +95,7 @@ class FormBuilder {
try {
$xml = new SimpleXMLElement($policyStreamDoc);
} catch (Exception $e) {
watchdog(t("Fedora_Repository"), t("Problem getting security policy."), NULL, WATCHDOG_ERROR);
watchdog(t("Fedora_Repository"), "Problem getting security policy.", NULL, WATCHDOG_ERROR);
drupal_set_message(t('Problem getting security policy: @e', array('@e' => check_plain($e->getMessage()))), 'error');
return FALSE;
}
@ -173,7 +173,7 @@ class FormBuilder {
$object = Fedora_Item::ingest_from_FOXML($dom);
if (!empty($object->pid)) {
// drupal_set_message("Item ". l($object->pid, 'fedora/repository/'. $object->pid) . " created successfully.", "status");
drupal_set_message(t("Item !pid created successfully.", array('!pid' => l($object->pid, 'fedora/repository/' . $object->pid))), "status");
drupal_set_message(t("Item !pid created successfully.", array('!pid' => l(check_plain($object->pid), 'fedora/repository/' . check_plain($object->pid)))), "status");
}
if (!empty($_SESSION['fedora_ingest_files'])) {
foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) {

2
plugins/PersonalCollectionClass.inc

@ -75,7 +75,7 @@ class PersonalCollectionClass {
try {
$xml = new SimpleXMLElement($collectionTemplate);
} catch (Exception $e) {
watchdog(t("Fedora_Repository"), t("Problem creating personal collection policy, could not parse collection policy stream."), NULL, WATCHDOG_ERROR);
watchdog(t("Fedora_Repository"), "Problem creating personal collection policy, could not parse collection policy stream.", NULL, WATCHDOG_ERROR);
drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: @e', array('@e' => check_plain($e->getMessage()))), 'error');
return FALSE;
}

4
plugins/Refworks.inc

@ -83,7 +83,7 @@ class Refworks {
//$dom = dom_import_simplexml($xml);//test to see if it behaves better
//$xml = new SimpleXMLElement(trim(file_get_contents($file)));
} catch (Exception $e) {
drupal_set_message(t('Error processing Refworks file:') . " " . $e->getMessage());
drupal_set_message(t('Error processing Refworks file: @message', array('@message' => $e->getMessage())));
return FALSE;
}
$this->referenceList = array();
@ -296,7 +296,7 @@ class Refworks {
$object = $client->__soapCall('ingest', array(
$params
));
watchdog(t("FEDORA_REPOSITORY"), t("Successfully added repository item !pid - !it", array('!pid' => $pid, '!it' => $item_title)), NULL, WATCHDOG_INFO);
watchdog(t("FEDORA_REPOSITORY"), "Successfully added repository item " . $pid . " - ". $item_title, NULL, WATCHDOG_INFO);
$deleteFiles = $form_values['delete_file']; //remove files from drupal file system
if ($deleteFiles > 0) {

2
plugins/ShowStreamsInFieldSets.inc

@ -109,7 +109,7 @@ class ShowStreamsInFieldSets {
}
$dc_html = $objectHelper->getFormattedDC($item);
$dl_link = l('<div style="float:left; padding: 10px"><img src="' . $tn_url . '"><br />View Document</div>', 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE));
$dl_link = l('<div style="float:left; padding: 10px"><img src="' . $tn_url . '"><br />' . t('View Document') .'</div>', 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE));
$tabset['first_tab']['tabs']['view'] = array(
'#type' => 'tabpage',

2
xsl/sparql_to_html.xsl

@ -173,7 +173,7 @@
<xsl:otherwise>
<!--the below is an example of going straight to a datastream instead of the details page.
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>-->
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/>
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="s:content"/>

Loading…
Cancel
Save