diff --git a/CollectionClass.inc b/CollectionClass.inc index 35d9a0ca..08f669e0 100644 --- a/CollectionClass.inc +++ b/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); } @@ -78,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 $title + where ($object $title and $object $content and ($object or $object ) @@ -340,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; } } @@ -445,7 +450,7 @@ class CollectionClass { 'pidNamespace' => $pidNameSpace ); $object = $soapClient->__soapCall('getNextPID', array( - $params + $params )); } catch (exception $e) { drupal_set_message(t('Error getting Next PID: @e', array('@e' => check_plain($e->getMessage()))), 'error'); @@ -460,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); @@ -498,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'); } @@ -517,7 +521,7 @@ class CollectionClass { $show_batch_tab = FALSE; $policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); - if(!empty($policy)){ + if (!empty($policy)) { $content_models = $policy->getContentModels(); } if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") { diff --git a/ContentModel.inc b/ContentModel.inc index cbacd422..444f485c 100644 --- a/ContentModel.inc +++ b/ContentModel.inc @@ -429,12 +429,12 @@ class ContentModel extends XMLDatastream { */ public function getServices() { $query = 'select $object $title from <#ri> - where ($object $title - and $object $deploymentOf - and $object - and $object pid . '> - and $object ) - order by $title'; + where ($object $title + and $object $deploymentOf + and $object + and $object pid . '> + and $object ) + order by $title'; module_load_include('inc', 'fedora_repository', 'CollectionClass'); diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 313d2159..e8555635 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -383,8 +383,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 +729,7 @@ class ObjectHelper { */ function get_parent_objects($pid) { $query_string = 'select $object $title from <#ri> - where ($object $title + where ($object $title and $object and $object ) order by $title'; @@ -829,7 +829,7 @@ class ObjectHelper { // Get title and descriptions for $pid $query_string = 'select $title $desc from <#ri> - where $o $title + where $o $title and $o $desc and $o '; @@ -858,7 +858,7 @@ class ObjectHelper { $query_string = 'select $o $title from <#ri> ' . // $query_string = 'select $o $title $desc from <#ri> '. 'where $s $o ' . - 'and $o $title ' . + 'and $o $title ' . // 'and $o $desc '. 'and ( '; @@ -929,7 +929,7 @@ class ObjectHelper { } else { $query_string = 'select $parentObject $title $content from <#ri> - where ( $title + where ( $title and $parentObject $content and ( $parentObject or $parentObject @@ -963,7 +963,7 @@ class ObjectHelper { } else { - $breadcrumbs[] = l("Path Calculation Error", 'fedora/repository/' . $pid); + $breadcrumbs[] = l(t("Path Calculation Error"), 'fedora/repository/' . $pid); } } } diff --git a/SecurityClass.inc b/SecurityClass.inc index 55a6ebb4..970b108b 100644 --- a/SecurityClass.inc +++ b/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) { diff --git a/api/fedora_collection.inc b/api/fedora_collection.inc index a82bf39b..200fb324 100644 --- a/api/fedora_collection.inc +++ b/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 $title + where ($object $title and $object $content and ('; diff --git a/api/fedora_item.inc b/api/fedora_item.inc index a306bdab..1714c571 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -1,7 +1,7 @@ objectProfile)); @@ -82,7 +98,7 @@ class Fedora_Item { * @param type $datastream_mimetype * @param type $controlGroup * @param type $logMessage - * @return type + * @return type */ function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = NULL) { module_load_include('inc', 'fedora_repository', 'MimeClass'); @@ -117,7 +133,7 @@ class Fedora_Item { * @param type $datastream_mimetype * @param type $controlGroup * @param type $logMessage - * @return type + * @return type */ function add_datastream_from_url($datastream_url, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = NULL) { if (empty($datastream_label)) { @@ -152,7 +168,7 @@ class Fedora_Item { * @param type $datastream_mimetype * @param type $controlGroup * @param type $logMessage - * @return type + * @return type */ function add_datastream_from_string($str, $datastream_id, $datastream_label = NULL, $datastream_mimetype = 'text/xml', $controlGroup = 'M', $logMessage = NULL) { $dir = file_directory_temp(); @@ -166,7 +182,7 @@ class Fedora_Item { } /** - * Wrapper to add new or modify existing datastream + * Wrapper to add new or modify existing datastream * @global url $base_url * @param url $external_url * @param string $dsid @@ -175,7 +191,7 @@ class Fedora_Item { * @param string $controlGroup * @param boolean $force * @param string $logMessage - * @param boolean $quiet + * @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; @@ -193,7 +209,7 @@ class Fedora_Item { * does not support rels-int yet. * @param type $relationship * @param type $object - * @param type $namespaceURI + * @param type $namespaceURI */ function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI) { $ds_list = $this->get_datastreams_list_as_array(); @@ -301,7 +317,7 @@ class Fedora_Item { /** * Export as foxml - * @return type + * @return type */ function export_as_foxml() { $params = array( @@ -382,7 +398,7 @@ class Fedora_Item { * Get datastream dissemination * @param type $dsid * @param type $as_of_date_time - * @return string + * @return string */ function get_datastream_dissemination($dsid, $as_of_date_time = "") { $params = array( @@ -405,7 +421,7 @@ class Fedora_Item { * Get datastream * @param type $dsid * @param type $as_of_date_time - * @return type + * @return type */ function get_datastream($dsid, $as_of_date_time = "") { $params = array( @@ -421,7 +437,7 @@ class Fedora_Item { /** * Get datastream history * @param type $dsid - * @return type + * @return type */ function get_datastream_history($dsid) { $params = array( @@ -443,7 +459,7 @@ class Fedora_Item { * @param type $method_name * @param type $parameters * @param type $as_of_date_time - * @return string + * @return string */ function get_dissemination($service_definition_pid, $method_name, $parameters = array(), $as_of_date_time = NULL) { $params = array( @@ -692,19 +708,47 @@ 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 * @param type $force - * @return type + * @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); } @@ -715,7 +759,7 @@ class Fedora_Item { * @param type $end_date * @param type $log_message * @param type $force - * @return type + * @return type */ function purge_datastream($dsID, $start_date = NULL, $end_date = NULL, $log_message = 'Purged datastream using Islandora API', $force = FALSE) { $params = array( @@ -732,7 +776,7 @@ class Fedora_Item { /** * URL * @global type $base_url - * @return type + * @return type */ function url() { global $base_url; @@ -742,7 +786,7 @@ class Fedora_Item { /** * Get Next PID in Namespace * @param type $pid_namespace - * @return type + * @return type */ static function get_next_PID_in_namespace($pid_namespace = '') { @@ -770,7 +814,7 @@ class Fedora_Item { /** * ingest from FOXML * @param type $foxml - * @return Fedora_Item + * @return Fedora_Item */ static function ingest_from_FOXML($foxml) { $params = array('objectXML' => $foxml->saveXML(), 'format' => "info:fedora/fedora-system:FOXML-1.1", 'logMessage' => "Fedora Object Ingested"); @@ -781,7 +825,7 @@ class Fedora_Item { /** * ingest from FOXML file * @param type $foxml_file - * @return type + * @return type */ static function ingest_from_FOXML_file($foxml_file) { $foxml = new DOMDocument(); @@ -791,7 +835,7 @@ class Fedora_Item { /** * ingest from FOXML files in directory - * @param type $path + * @param type $path */ static function ingest_from_FOXML_files_in_directory($path) { // Open the directory @@ -819,7 +863,7 @@ class Fedora_Item { * @param type $ownerId * @param type $logMessage * @param type $quiet - * @return type + * @return type */ function modify_object($label = '', $state = NULL, $ownerId = NULL, $logMessage = 'Modified by Islandora API', $quiet=TRUE) { @@ -843,7 +887,7 @@ class Fedora_Item { * @param type $force * @param type $logMessage * @param type $quiet - * @return type + * @return type */ function modify_datastream_by_reference($external_url, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) { $params = array( @@ -871,7 +915,7 @@ class Fedora_Item { * @param type $force * @param type $logMessage * @param type $quiet - * @return type + * @return type */ function modify_datastream_by_value($content, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) { $params = array( @@ -904,74 +948,46 @@ 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')); - try { - 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 (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); - } - 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) { - - if (!$quiet) { - watchdog(t("FEDORA_REPOSITORY"), "Error trying to call SOAP function @fn: @e", array('@fn' => $function_name, '@e' => $e), NULL, WATCHDOG_ERROR); - } - return NULL; + $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 { + $soap_client = self::$connection_helper->getSoapClient($url); + if (isset($soap_client)) { + $result = $soap_client->__soapCall($function, array('parameters' => $parameters)); + } + else { + if (!$quiet) { + drupal_set_message(t('Error trying to get SOAP client connection')); } + watchdog('fedora_repository', 'Error trying to get SOAP client connection.'); + return NULL; + } + } catch (Exception $e) { + if (!$quiet) { + 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; } @@ -984,7 +1000,7 @@ class Fedora_Item { * @param string $state The initial state, A - Active, I - Inactive, D - Deleted * @param type $label * @param type $owner - * @return DOMDocument + * @return DOMDocument */ static function create_object_FOXML($pid = '', $state = 'A', $label = 'Untitled', $owner = '') { $foxml = new DOMDocument("1.0", "UTF-8"); @@ -1039,16 +1055,16 @@ class Fedora_Item { * @param type $state * @param type $label * @param type $owner - * @return type + * @return type */ static function ingest_new_item($pid = '', $state = 'A', $label = '', $owner = '') { return self::ingest_from_FOXML(self::create_object_FOXML($pid, $state, $label, $owner)); } /** - * fedora item exists + * fedora item exists * @param type $pid - * @return type + * @return type */ static function fedora_item_exists($pid) { $item = new Fedora_Item($pid); diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index c2665fc7..eb56bdcc 100644 --- a/api/fedora_utils.inc +++ b/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:'); $namespaces = explode(':', $allowed_string); $query = 'select $object $title from <#ri> - where ($object $title + where ($object $title and $object and $object ) order by $title'; @@ -288,7 +288,7 @@ function get_content_models_as_option_array() { } } $query = 'select $object $title from <#ri> - where ($object $title + where ($object $title and ($object or $object ) and $object ) diff --git a/fedora_repository.module b/fedora_repository.module index 00201ec9..eeee9851 100644 --- a/fedora_repository.module +++ b/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; } @@ -505,7 +508,7 @@ function fedora_repository_purge_object_form_validate($form, &$form_state) { foreach ($contentModels as $contentModel) { if ($contentModel->pid == 'islandora:collectionCModel') { $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.")); 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. $obj = new FedoraObjectDetailedContent($pid); $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->save(); $cmodel_collection->add_datastream_from_string('select $object $title from <#ri> - where ($object $title + where ($object $title and ($object or $object ) and $object ) @@ -2146,13 +2150,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 +2175,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 +2189,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); } diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index 1b395548..7743a0b7 100644 --- a/fedora_repository.solutionpacks.inc +++ b/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' => '

', @@ -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'])) { @@ -152,6 +153,12 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul '#type' => 'submit', '#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( @@ -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) { $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', @@ -185,7 +196,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))); } } @@ -200,7 +211,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@name", array("@cm" => $content_model, "@name"=>$form_name))); } } - diff --git a/formClass.inc b/formClass.inc index be5ef9d2..09bfce8b 100644 --- a/formClass.inc +++ b/formClass.inc @@ -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) { @@ -498,7 +510,7 @@ class formClass { '#title' => t('Content models available'), '#options' => $potential_models, '#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.
Additional information may be found here. '), + '#description' => t('Content models define datastream composition, relationships between this and other content models, and the mandatory behaviors associated with each digital object.
Additional information may be found here.'), ), ), 'collection_pid' => array( @@ -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 { diff --git a/plugins/FormBuilder.inc b/plugins/FormBuilder.inc index cd9dc4a9..715ca6af 100644 --- a/plugins/FormBuilder.inc +++ b/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) { diff --git a/plugins/PersonalCollectionClass.inc b/plugins/PersonalCollectionClass.inc index 29c76cfa..9ed6af07 100644 --- a/plugins/PersonalCollectionClass.inc +++ b/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; } diff --git a/plugins/Refworks.inc b/plugins/Refworks.inc index 5e39b3c2..2c86caa7 100644 --- a/plugins/Refworks.inc +++ b/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) { diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index a6e7eaad..9e20ca5a 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/plugins/ShowStreamsInFieldSets.inc @@ -109,7 +109,7 @@ class ShowStreamsInFieldSets { } $dc_html = $objectHelper->getFormattedDC($item); - $dl_link = l('

View Document
', 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE)); + $dl_link = l('

' . t('View Document') .'
', 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE)); $tabset['first_tab']['tabs']['view'] = array( '#type' => 'tabpage', diff --git a/xsl/sparql_to_html.xsl b/xsl/sparql_to_html.xsl index a4a4f934..99045659 100644 --- a/xsl/sparql_to_html.xsl +++ b/xsl/sparql_to_html.xsl @@ -173,7 +173,7 @@ - /fedora/repository//-/ + /fedora/repository/