Browse Source

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

pull/82/head
Alan Stanley 13 years ago
parent
commit
60228f5f80
  1. 28
      CollectionClass.inc
  2. 2
      ContentModel.inc
  3. 14
      ObjectHelper.inc
  4. 6
      SecurityClass.inc
  5. 2
      api/fedora_collection.inc
  6. 122
      api/fedora_item.inc
  7. 4
      api/fedora_utils.inc
  8. 23
      fedora_repository.module
  9. 20
      fedora_repository.solutionpacks.inc
  10. 18
      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

28
CollectionClass.inc

@ -45,11 +45,12 @@ class CollectionClass {
* @return type * @return type
*/ */
function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) { function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper();
if (!isset($itqlquery)) { if (!isset($itqlquery)) {
// $query_string = $objectHelper->getStream($pid, 'QUERY', 0); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$itqlquery = $objectHelper->getStream($pid, 'QUERY', 0); $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); return $this->getRelatedItems($pid, $itqlquery, $limit, $offset);
} }
@ -78,10 +79,14 @@ class CollectionClass {
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
$query_string = $itqlquery; $query_string = $itqlquery;
if (!isset($query_string)) { 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) { if ($query_string == NULL) {
$query_string = 'select $object $title $content from <#ri> $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-model:hasModel> $content
and ($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/' . $pid . '> and ($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/' . $pid . '>
or $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $pid . '>) or $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $pid . '>)
@ -340,7 +345,7 @@ class CollectionClass {
$thisClass = new $phpClass (); $thisClass = new $phpClass ();
$returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext); $returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext);
if (!$returnValue) { 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; return FALSE;
} }
} }
@ -460,7 +465,7 @@ class CollectionClass {
module_load_include('inc', 'fedora_repository', 'plugins/PersonalCollectionClass'); module_load_include('inc', 'fedora_repository', 'plugins/PersonalCollectionClass');
$personalCollectionClass = new PersonalCollectionClass(); $personalCollectionClass = new PersonalCollectionClass();
if (!$personalCollectionClass->createCollection($user, $pid, $soapClient)) { 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 return FALSE; //creation failed don't save the collection pid in drupal db
} }
user_save($user, $personal_collection_pid); user_save($user, $personal_collection_pid);
@ -498,11 +503,10 @@ class CollectionClass {
module_load_include('inc', 'fedora_repository', 'CollectionManagement'); module_load_include('inc', 'fedora_repository', 'CollectionManagement');
module_load_include('inc', 'fedora_repository', 'BatchIngest'); module_load_include('inc', 'fedora_repository', 'BatchIngest');
global $base_url; global $base_url;
$tabset = array();
global $user; global $user;
$objectHelper = new ObjectHelper(); $tabset = array();
$item = new Fedora_Item($this->pid);
$query = NULL; $query = NULL;
$item = new Fedora_Item($this->pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) { if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$query = $item->get_datastream_dissemination('QUERY'); $query = $item->get_datastream_dissemination('QUERY');
} }
@ -517,7 +521,7 @@ class CollectionClass {
$show_batch_tab = FALSE; $show_batch_tab = FALSE;
$policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); $policy = CollectionPolicy::loadFromCollection($this->pid, TRUE);
if(!empty($policy)){ if (!empty($policy)) {
$content_models = $policy->getContentModels(); $content_models = $policy->getContentModels();
} }
if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") { if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") {

2
ContentModel.inc

@ -429,7 +429,7 @@ class ContentModel extends XMLDatastream {
*/ */
public function getServices() { public function getServices() {
$query = 'select $object $title from <#ri> $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:isDeploymentOf> $deploymentOf
and $object <fedora-model:hasModel> <info:fedora/fedora-system:ServiceDeployment-3.0> and $object <fedora-model:hasModel> <info:fedora/fedora-system:ServiceDeployment-3.0>
and $object <fedora-model:isContractorOf> <info:fedora/' . $this->pid . '> and $object <fedora-model:isContractorOf> <info:fedora/' . $this->pid . '>

14
ObjectHelper.inc

@ -383,8 +383,8 @@ class ObjectHelper {
$xsl->load($path . '/xsl/convertQDC.xsl'); $xsl->load($path . '/xsl/convertQDC.xsl');
$input = new DomDocument(); $input = new DomDocument();
$input->loadXML(trim($xmlstr)); $input->loadXML(trim($xmlstr));
} catch (exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), "Problem loading XSL file: @e", array('@e' => $e), NULL, WATCHDOG_ERROR); watchdog('fedora_repository', "Problem loading XSL file: @e", array('@e' => $e->getMessage()), NULL, WATCHDOG_ERROR);
} }
$xsl = $proc->importStylesheet($xsl); $xsl = $proc->importStylesheet($xsl);
$newdom = $proc->transformToDoc($input); $newdom = $proc->transformToDoc($input);
@ -729,7 +729,7 @@ class ObjectHelper {
*/ */
function get_parent_objects($pid) { function get_parent_objects($pid) {
$query_string = 'select $object $title from <#ri> $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 <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $object
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title'; order by $title';
@ -829,7 +829,7 @@ class ObjectHelper {
// Get title and descriptions for $pid // Get title and descriptions for $pid
$query_string = 'select $title $desc from <#ri> $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 <dc:description> $desc
and $o <mulgara:is> <info:fedora/' . $pid . '>'; and $o <mulgara:is> <info:fedora/' . $pid . '>';
@ -858,7 +858,7 @@ class ObjectHelper {
$query_string = 'select $o $title from <#ri> ' . $query_string = 'select $o $title from <#ri> ' .
// $query_string = 'select $o $title $desc from <#ri> '. // $query_string = 'select $o $title $desc from <#ri> '.
'where $s <info:fedora/fedora-system:def/relations-external#hasMember> $o ' . '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 $o <dc:description> $desc '.
'and ( '; 'and ( ';
@ -929,7 +929,7 @@ class ObjectHelper {
} }
else { else {
$query_string = 'select $parentObject $title $content from <#ri> $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 $parentObject <fedora-model:hasModel> $content
and (<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject and (<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject
or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject
@ -963,7 +963,7 @@ class ObjectHelper {
} }
else { 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 { try {
$xml = new SimpleXMLElement($policyStream); $xml = new SimpleXMLElement($policyStream);
} catch (Exception $e) { } 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. //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; return NULL;
} }
$xml->registerXPathNamespace('default', 'urn:oasis:names:tc:xacml:1.0:policy'); $xml->registerXPathNamespace('default', 'urn:oasis:names:tc:xacml:1.0:policy');
@ -110,7 +110,7 @@ class SecurityClass {
try { try {
$doc->load(drupal_get_path('module', 'Fedora_Repository') . '/policies/noObjectEditPolicy.xml'); $doc->load(drupal_get_path('module', 'Fedora_Repository') . '/policies/noObjectEditPolicy.xml');
} catch (exception $e) { } 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'); $conditions = $doc->getElementsByTagName('Condition');
foreach ($conditions as $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> $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-model:hasModel> $content
and ('; and (';

122
api/fedora_item.inc

@ -19,6 +19,22 @@ class Fedora_Item {
public $datastreams = NULL; public $datastreams = NULL;
private static $connection_helper = NULL; private static $connection_helper = NULL;
private static $instantiated_pids = array(); 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. * Create an object to represent an item in the Fedora repository.
@ -692,6 +708,28 @@ class Fedora_Item {
return FALSE; 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. * Removes this object form the repository.
* @param type $log_message * @param type $log_message
@ -699,12 +737,18 @@ class Fedora_Item {
* @return type * @return type
*/ */
function purge($log_message = 'Purged using Islandora API.', $force = FALSE) { 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( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'logMessage' => $log_message, 'logMessage' => $log_message,
'force' => $force 'force' => $force
); );
// Delete the object
return $this->soap_call('purgeObject', $params); return $this->soap_call('purgeObject', $params);
} }
@ -904,75 +948,47 @@ class Fedora_Item {
} }
/** /**
* Soap call * Make a soap call to the fedora API.
* @param type $function_name *
* @param type $params_array * @param string $function
* @param type $quiet * The name of the soap function to call.
* @return type * @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) { if (!self::$connection_helper) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
self::$connection_helper = new ConnectionHelper(); self::$connection_helper = new ConnectionHelper();
} }
switch ($function_name) { $url = (array_search($function, self::$SoapManagedFunctions) !== FALSE) ?
case 'ingest': variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl') :
case 'addDataStream': variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
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'));
try { try {
if (!empty($soap_client)) { $soap_client = self::$connection_helper->getSoapClient($url);
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array)); if (isset($soap_client)) {
$result = $soap_client->__soapCall($function, array('parameters' => $parameters));
} }
else { else {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to get SOAP client connection.");
return NULL;
}
} catch (exception $e) {
if (!$quiet) { if (!$quiet) {
drupal_set_message(t('Error trying to get SOAP client connection'));
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);
} }
watchdog('fedora_repository', 'Error trying to get SOAP client connection.');
return NULL; return NULL;
} }
break; } catch (Exception $e) {
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) {
if (!$quiet) { 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 NULL;
} }
}
return $result; return $result;
} }

4
api/fedora_utils.inc

@ -239,7 +239,7 @@ function get_collections_as_option_array() {
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string); $namespaces = explode(':', $allowed_string);
$query = 'select $object $title from <#ri> $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 <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel>
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title'; order by $title';
@ -288,7 +288,7 @@ function get_content_models_as_option_array() {
} }
} }
$query = 'select $object $title from <#ri> $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> and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0>
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>) or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)

23
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) { 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 //only validate the form if the submit button was pressed (other buttons may be used for AHAH
if ($form_state['ahah_submission']) { if ($form_state['ahah_submission']) {
$form_state['submitted'] = false; $form_state['submitted'] = FALSE;
return; return;
} }
if ($form_state['storage']['xml']) { 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) { 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 //only validate the form if the submit button was pressed (other buttons may be used for AHAH
if ($form_state['ahah_submission']) { if ($form_state['ahah_submission']) {
$form_state['submitted'] = false; $form_state['submitted'] = FALSE;
return; return;
} }
if ($form_state['clicked_button']['#id'] == 'edit-submit' && $form_state['ahah_submission'] != 1) { 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 (!empty($file)) {
if (!in_array($dformat, $allowedMimeTypes)) { 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 ' . form_set_error('ingest-file-location',
implode(' ', $allowedMimeTypes))); t('The uploaded file\'s mimetype') .
' (' . $dformat . ') ' .
t('is not associated with this Content Model. The allowed types are') .
' ' . implode(' ', $allowedMimeTypes));
file_delete($file); file_delete($file);
return; return;
} }
@ -505,7 +508,7 @@ function fedora_repository_purge_object_form_validate($form, &$form_state) {
foreach ($contentModels as $contentModel) { foreach ($contentModels as $contentModel) {
if ($contentModel->pid == 'islandora:collectionCModel') { if ($contentModel->pid == 'islandora:collectionCModel') {
$member_pids = get_related_items_as_array($pid, 'isMemberOfCollection'); $member_pids = get_related_items_as_array($pid, 'isMemberOfCollection');
if (is_array($member_pids) && ! empty($member_pids)){ if (is_array($member_pids) && ! empty($member_pids)) {
form_set_error('new_collection_pid', t("Please purge all members of this collection before deleting the collection itself.")); form_set_error('new_collection_pid', t("Please purge all members of this collection before deleting the collection itself."));
return; return;
} }
@ -1008,6 +1011,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. // Add a 'manage object' tab for all objects, where detailed list of content is shown.
$obj = new FedoraObjectDetailedContent($pid); $obj = new FedoraObjectDetailedContent($pid);
$object_details = $obj->showFieldSets(); $object_details = $obj->showFieldSets();
@ -1592,7 +1596,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
$dc->set_element('dc:title', array('Installed Content Model')); $dc->set_element('dc:title', array('Installed Content Model'));
$dc->save(); $dc->save();
$cmodel_collection->add_datastream_from_string('select $object $title from <#ri> $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> and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0>
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>) or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
@ -2146,13 +2150,16 @@ function fedora_repository_display_schema($file) {
* @return type * @return type
*/ */
function fedora_repository_batch_reingest_object($object, &$context) { 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_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!empty($object) && is_array($object)) { if (!empty($object) && is_array($object)) {
$pid = $object['pid']; $pid = $object['pid'];
if (!valid_pid($pid)) { if (!valid_pid($pid)) {
return NULL; return NULL;
} }
// Does the object exist? If so, purge it. // Does the object exist? If so, purge it.
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
if ($item->exists()) { if ($item->exists()) {
@ -2168,6 +2175,7 @@ function fedora_repository_batch_reingest_object($object, &$context) {
$context['message'][] = "$new_item->pid installed."; $context['message'][] = "$new_item->pid installed.";
} }
} }
if (!empty($object['dsid']) && !empty($object['datastream_file'])) { if (!empty($object['dsid']) && !empty($object['datastream_file'])) {
$datastreams = array( $datastreams = array(
array( array(
@ -2181,10 +2189,13 @@ function fedora_repository_batch_reingest_object($object, &$context) {
} }
if (!empty($datastreams) && is_array($datastreams)) { if (!empty($datastreams) && is_array($datastreams)) {
$label = !empty($object['label']) ? $object['label'] : ''; $label = !empty($object['label']) ? $object['label'] : '';
if (empty($object['foxml_file']) && !isset($new_item)) { if (empty($object['foxml_file']) && !isset($new_item)) {
$new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label); $new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label);
} }
if (!empty($object['cmodel'])) { if (!empty($object['cmodel'])) {
$new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI); $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI);
} }

20
fedora_repository.solutionpacks.inc

@ -46,19 +46,21 @@ function fedora_repository_solution_packs_page() {
* @param array $solution_pack * @param array $solution_pack
*/ */
function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { 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. // Check each object to see if it is in the repository.
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
global $base_path; global $base_path;
$needs_update = FALSE; $needs_update = FALSE;
$needs_install = FALSE; $needs_install = FALSE;
$form = array(); $form = array();
$form['solution_pack_module'] = array( $form['solution_pack_module'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $solution_pack_module, '#value' => $solution_pack_module,
); );
if (!$form_state['submitted']) { if (!$form_state['submitted']) {
$form['soluction_pack_name'] = array( $form['solution_pack_name'] = array(
'#type' => 'markup', '#type' => 'markup',
'#value' => t($solution_pack_name), '#value' => t($solution_pack_name),
'#prefix' => '<h3>', '#prefix' => '<h3>',
@ -75,7 +77,6 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
$table_header = array('PID', 'Status'); $table_header = array('PID', 'Status');
$table_rows = array(); $table_rows = array();
foreach ($objects as $object) { foreach ($objects as $object) {
$datastreams = NULL; $datastreams = NULL;
if (isset($object['pid'])) { if (isset($object['pid'])) {
@ -152,6 +153,12 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
'#type' => 'submit', '#type' => 'submit',
'#name' => $solution_pack_module, '#name' => $solution_pack_module,
); );
$form['forcesubmit'] = array(
'#value' => t('Force Reinstall'),
//'#disabled' => !$needs_install && !$needs_update,
'#type' => 'submit',
'#name' => $solution_pack_module,
);
$form['#submit'] = array( $form['#submit'] = array(
@ -163,7 +170,11 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
function fedora_repository_solution_pack_form_submit($form, &$form_state) { function fedora_repository_solution_pack_form_submit($form, &$form_state) {
$what = $form_state; $what = $form_state;
$module_name = $form_state['values']['solution_pack_module']; $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 = call_user_func($module_name . '_required_fedora_objects');
//$solution_pack_info = module_invoke($module_name, 'required_fedora_objects');
$batch = array( $batch = array(
'title' => t('Installing / updating solution pack objects'), 'title' => t('Installing / updating solution pack objects'),
'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module', 'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module',
@ -185,7 +196,7 @@ function solution_pack_add_form($form_name, $form_xml) {
$object->name = $form_name; $object->name = $form_name;
$object->form = $form_xml; $object->form = $form_xml;
$result = drupal_write_record('xml_forms', $object); $result = drupal_write_record('xml_forms', $object);
drupal_set_message("Added $name"); drupal_set_message(t("Added @name", array("@name" => $form_name)));
} }
} }
@ -200,7 +211,6 @@ function solution_pack_add_form_association($content_model, $form_name) {
$object->title_field = "['titleInfo']['title']"; $object->title_field = "['titleInfo']['title']";
$object->transform = 'mods_to_dc.xsl'; $object->transform = 'mods_to_dc.xsl';
$result = drupal_write_record('islandora_content_model_forms', $object); $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@name", array("@cm" => $content_model, "@name"=>$form_name)));
} }
} }

18
formClass.inc

@ -48,7 +48,6 @@ class formClass {
'file' => 'fedora_repository.solutionpacks.inc', 'file' => 'fedora_repository.solutionpacks.inc',
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
); );
$items['islandoracm.xsd'] = array( $items['islandoracm.xsd'] = array(
'title' => t('Islandora Content Model XML Schema Definition'), 'title' => t('Islandora Content Model XML Schema Definition'),
'page callback' => 'fedora_repository_display_schema', 'page callback' => 'fedora_repository_display_schema',
@ -379,7 +378,13 @@ class formClass {
// DC elements // DC elements
$previousElement = NULL; // Used in case we have to nest elements for qualified dublin core. $previousElement = NULL; // Used in case we have to nest elements for qualified dublin core.
$label = null;
foreach ($form_values as $key => $value) { foreach ($form_values as $key => $value) {
//echo ($key);
if ($key == 'dc:title-0') {
$label = $value;
}
$index = strrpos($key, '-'); $index = strrpos($key, '-');
$key = substr($key, 0, $index); $key = substr($key, 0, $index);
$test = substr($key, 0, 2); $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); $dom->appendChild($oai);
if (!$client) { if (!$client) {
@ -498,7 +510,7 @@ class formClass {
'#title' => t('Content models available'), '#title' => t('Content models available'),
'#options' => $potential_models, '#options' => $potential_models,
'#default_value' => $selected_model, '#default_value' => $selected_model,
'#description' => t('Content models define datastream composition, relationships between this and other content models, and the mandatory behaviors associated with each digital object.<br /> Additional information may be found <a href="https://wiki.duraspace.org/display/FEDORACREATE/Content+Models+Overview">here.</a> '), '#description' => t('Content models define datastream composition, relationships between this and other content models, and the mandatory behaviors associated with each digital object.<br /> Additional information may be found <a href="https://wiki.duraspace.org/display/FEDORACREATE/Content+Models+Overview">here.</a>'),
), ),
), ),
'collection_pid' => array( 'collection_pid' => array(
@ -581,6 +593,8 @@ class formClass {
if (!$this->canShowIngestForm($collection_pid)) { if (!$this->canShowIngestForm($collection_pid)) {
return FALSE; return FALSE;
} }
drupal_set_title($collection_label);
if (module_exists('islandora_content_model_forms')) { if (module_exists('islandora_content_model_forms')) {
module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm');
try { try {

4
plugins/FormBuilder.inc

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

2
plugins/PersonalCollectionClass.inc

@ -75,7 +75,7 @@ class PersonalCollectionClass {
try { try {
$xml = new SimpleXMLElement($collectionTemplate); $xml = new SimpleXMLElement($collectionTemplate);
} catch (Exception $e) { } 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'); 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; return FALSE;
} }

4
plugins/Refworks.inc

@ -83,7 +83,7 @@ class Refworks {
//$dom = dom_import_simplexml($xml);//test to see if it behaves better //$dom = dom_import_simplexml($xml);//test to see if it behaves better
//$xml = new SimpleXMLElement(trim(file_get_contents($file))); //$xml = new SimpleXMLElement(trim(file_get_contents($file)));
} catch (Exception $e) { } 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; return FALSE;
} }
$this->referenceList = array(); $this->referenceList = array();
@ -296,7 +296,7 @@ class Refworks {
$object = $client->__soapCall('ingest', array( $object = $client->__soapCall('ingest', array(
$params $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 $deleteFiles = $form_values['delete_file']; //remove files from drupal file system
if ($deleteFiles > 0) { if ($deleteFiles > 0) {

2
plugins/ShowStreamsInFieldSets.inc

@ -109,7 +109,7 @@ class ShowStreamsInFieldSets {
} }
$dc_html = $objectHelper->getFormattedDC($item); $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( $tabset['first_tab']['tabs']['view'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',

2
xsl/sparql_to_html.xsl

@ -173,7 +173,7 @@
<xsl:otherwise> <xsl:otherwise>
<!--the below is an example of going straight to a datastream instead of the details page. <!--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"/>/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:otherwise>
</xsl:choose> </xsl:choose>
<xsl:value-of select="s:content"/> <xsl:value-of select="s:content"/>

Loading…
Cancel
Save