* Get an array of links to be passed to drupal_set_breadcrumb(). This is used for generating the bread-crumbs for the view object page.
* Get an array of links to be passed to drupal_set_breadcrumb(). This is used
* for generating the bread-crumbs for the view object page.
*
* Each link in the bread-crumbs represents a member of the given objects ancestry
* which is identified by any of the following RELS-EXT terms (isMemberOf,isMemberOfCollection,isPartOf).
* which is identified by any of the following RELS-EXT terms
* (isMemberOf,isMemberOfCollection,isPartOf).
*
* @param FedoraObject $object
* An object whose ancestry will be mapped to bread-crumbs.
@ -18,12 +20,15 @@
* @see drupal_set_breadcrumb()
*
* @return array
* Array of links, starting with most distant ancestor proceeding up to but not including the given object. For use in the function drupal_set_breadcrumb().
* Array of links, starting with most distant ancestor proceeding up to but
* not including the given object. For use in the function
* This file contains any functions meant to be part of the global space, ie. functions that and other modules will use without including a module file.
* This file contains any functions meant to be part of the global space, ie.
* functions that and other modules will use without including a module file.
*/
/**
* Just a wrapper around fetchings the IslandoraTuque object, with some very basic error logging.
* Just a wrapper around fetchings the IslandoraTuque object, with some very
* basic error logging.
*
* @return IslandoraTuque
* A IslandoraTuque instance
@ -25,13 +27,15 @@ function islandora_get_tuque_connection() {
}
/**
* Gets the given object if found, NULL if it is inaccessible and FALSE if it was not found.
* Gets the given object if found, NULL if it is inaccessible and FALSE if it
* was not found.
*
* @param string $object_id
* The identifier of the object to get.
*
* @return FedoraObject
* The object if found, NULL if it is inaccessible and FALSE if it was not found.
* The object if found, NULL if it is inaccessible and FALSE if it was not
* found.
*/
function islandora_get_object_by_id($object_id) {
$tuque = islandora_get_tuque_connection();
@ -52,7 +56,8 @@ function islandora_get_object_by_id($object_id) {
else {
IslandoraTuque::getError();
}
return NULL; // Assuming access denied in all other cases for now.
// Assuming access denied in all other cases for now.
return NULL;
}
/**
@ -110,13 +115,16 @@ function islandora_delete_object(FedoraObject &$object) {
foreach (islandora_build_hook_list(ISLANDORA_PRE_PURGE_DATASTREAM_HOOK, $datastream->parent->models) as $hook) {
$results = array_merge_recursive($results, module_invoke_all($hook, $datastream)); // @note Not sure this will work the greatest, probably an alter would be better...
// Not sure this will work the greatest, probably an alter would be better..
* #limit_validation_errors, is why when the previous button is pressed no values persisted in the form_state, but its also what allows us to go back when validation errors occur.
* To have a better solution going forward we can either limit validation only on required fields, or we can convert all required fields to use #element_validation functions, and
* Remove the need for #limit_validation_errors. Or maybe there is some other solution, regardless of what it is, it won't be standard.
*/
// #limit_validation_errors, is why when the previous button is pressed no
// values persisted in the form_state, but its also what allows us to go
// back when validation errors occur. To have a better solution going
// forward we can either limit validation only on required fields, or we can
// convert all required fields to use #element_validation functions, and
// Remove the need for #limit_validation_errors. Or maybe there is some
// other solution, regardless of what it is, it won't be standard.
'#limit_validation_errors' => array()
);
}
@ -151,10 +163,10 @@ function islandora_ingest_form_previous_button() {
function islandora_ingest_form_previous_submit(array $form, array &$form_state) {
watchdog('islandora', $e->getMessage(), NULL, WATCHDOG_ERROR); // If post hooks throws it may already exist at this point but may be invalid, so don't say failed :P
// If post hooks throws it may already exist at this point but may be invalid, so don't say failed :P
foreach (islandora_build_hook_list(ISLANDORA_VIEW_HOOK, $object->models) as $hook) {
$temp = module_invoke_all($hook, $object, $page_number, $page_size); // @todo Remove page number and size from this hook, implementers of the hook should use drupal page handling directly.
// @todo Remove page number and size from this hook, implementers of the
@ -435,24 +456,35 @@ function islandora_default_islandora_view_object($object) {
}
/**
* A helper function to get a connection and return an object for objects specified in the menu path as '%islandora_object'.
* A helper function to get a connection and return an object for objects
* specified in the menu path as '%islandora_object'.
*
* This should only be used by the Drupal menu wildcard system!
*
* When this function returns FALSE the Drupal menu system will issues a "page not found" error, when this function returns NULL,
* the access function is expected to check for the given object and return false generating a "accesss denied" error.
* When this function returns FALSE the Drupal menu system will issues a
* "page not found" error, when this function returns NULL, the access function
* is expected to check for the given object and return false generating a
* "accesss denied" error.
*
* This will currently display a message if the repository is inaccessable, ideally this would redirect to another page in such a case,
* as the access function will not be aware of this fact and will trigger the display of the "access denied" page.
* This will currently display a message if the repository is inaccessable,
* ideally this would redirect to another page in such a case,
* as the access function will not be aware of this fact and will trigger
* the display of the "access denied" page.
*
* @todo When the repository down this should return a 500 error or a site offline notice. Currently only displays a message.
* @todo When the repository down this should return a 500 error or a
* site offline notice. Currently only displays a message.
*
* @param string $object_id
* The pid of an object in the menu path identified by '%islandora_object'.
*
* @return FedoraObject
* If the given object id exists in the repository then this returns a FedoraObject, if no object was found it returns FALSE which triggers drupal_page_not_found(), if the
* object was inaccessible then NULL is returned, and the access callback is expected to catch that case, triggering drupal_access_denied().
* If the given object id exists in the repository then this returns a
* FedoraObject.
* If no object was found it returns FALSE which triggers
* drupal_page_not_found().
* If the object was inaccessible then NULL is returned, and the
* access callback is expected to catch that case, triggering
@ -471,46 +503,49 @@ function islandora_object_load($object_id) {
}
/**
* A helper function to get an datastream specified as '%islandora_datastream' for the object specified in the menu path as '%islandora_object'.
* A helper function to get an datastream specified as '%islandora_datastream'
* for the object specified in the menu path as '%islandora_object'.
*
* This should only be used by the Drupal menu wildcard system! As for non existing datastreams this will return page not found.
* This should only be used by the Drupal menu wildcard system!
*
* The following settings are required for any menu paths which intent to use this auto loader.
* The following settings are required for any menu paths which intent to use
* this auto loader.
*
* @code
* 'load arguments' => array('%map'),
* @endcode
*
* @see islandora_object_load() for solutions to access/not found problems.
*
* @todo For non accessible datastreams to the user this should return access denied.
* @todo Is there anything we can do to enhance caching?
* Its up to the access callbacks and menu callbacks to trigger
* drupal_access_denied() when appropriate.
*
* @param string $datastream_id
* The dsid of the datastream specified as '%islandora_datastream' to fetch from the given object in the menu path identified by '%islandora_object'.
* The dsid of the datastream specified as '%islandora_datastream' to fetch
* from the given object in the menu path identified by '%islandora_object'.
*
* @return FedoraDatastream
* If the given datastream id exists in the object then this returns a FedoraDatastream, in other cases this aborts.
* If the given datastream ID exists then this returns a FedoraDatastream
* object, otherwise it returns NULL which triggers drupal_page_not_found().
*/
function islandora_datastream_load($datastream_id, $map) {
static $datastream = NULL, $load_failed = FALSE; // @hack for bug in drupal_not_found() when used before the menu callback. Infinite recursion bug.
static $datastream = NULL, $load_failed = FALSE;
if ($load_failed || isset($datastream)) {
return $datastream;
}
foreach ($map as $element) {
$is_fedora_object = is_object($element) && strtolower(get_class($element)) == 'fedoraobject'; // @todo Probably a better way to check types by now.
if ($is_fedora_object && isset($element[$datastream_id])) { // @todo check for access denied to this datastream so we can show the access denied page instead.