Browse Source

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

pull/347/head
Nelson Hart 12 years ago
parent
commit
4aa86bc3d8
  1. 6
      README.md
  2. 8
      includes/add_datastream.form.inc
  3. 2
      includes/breadcrumb.inc
  4. 79
      includes/content_model.autocomplete.inc
  5. 28
      includes/datastream.inc
  6. 6
      includes/delete_datastream.form.inc
  7. 4
      includes/delete_object.form.inc
  8. 10
      includes/ingest.form.inc
  9. 8
      includes/mime_detect.inc
  10. 4
      includes/object_properties.form.inc
  11. 10
      includes/solution_packs.inc
  12. 4
      includes/tuque_wrapper.inc
  13. 16
      includes/utilities.inc
  14. 70
      islandora.api.php
  15. 62
      islandora.module
  16. 6
      islandora.rules.inc
  17. 14
      tests/islandora_hooks_test.module
  18. 16
      tests/scripts/travis_setup.sh

6
README.md

@ -23,7 +23,11 @@ https://jira.duraspace.org/browse/ISLANDORA
REQUIREMENTS REQUIREMENTS
------------ ------------
The Tuque library must be installed to use Islandora. It can be found here:
http://github.com/Islandora/tuque
It is expected to be in one of two paths:
- sites/all/libraries/tuque (libraries directory may need to be created)
- islandora_folder/libraries/tuque
INSTALLATION INSTALLATION
------------ ------------

8
includes/add_datastream.form.inc

@ -12,13 +12,13 @@
* The Drupal form. * The Drupal form.
* @param array $form_state * @param array $form_state
* The Drupal form state. * The Drupal form state.
* @param FedoraObject $object * @param AbstractObject $object
* The object to be deleted. * The object to be deleted.
* *
* @return array * @return array
* The drupal form definition. * The drupal form definition.
*/ */
function islandora_add_datastream_form(array $form, array &$form_state, FedoraObject $object) { function islandora_add_datastream_form(array $form, array &$form_state, AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/content_model'); module_load_include('inc', 'islandora', 'includes/content_model');
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
form_load_include($form_state, 'inc', 'islandora', 'includes/add_datastream.form'); form_load_include($form_state, 'inc', 'islandora', 'includes/add_datastream.form');
@ -206,13 +206,13 @@ function islandora_add_datastream_form_submit(array $form, array &$form_state) {
* *
* It lists the missing required (may be optional) datastreams. * It lists the missing required (may be optional) datastreams.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object used to check for missing required datastreams used to populate * The object used to check for missing required datastreams used to populate
* the options in this callback. * the options in this callback.
* @param string $query * @param string $query
* vThe user query to match against the missing required datastreams. * vThe user query to match against the missing required datastreams.
*/ */
function islandora_add_datastream_form_autocomplete_callback(FedoraObject $object, $query = '') { function islandora_add_datastream_form_autocomplete_callback(AbstractObject $object, $query = '') {
module_load_include('inc', 'islandora', 'includes/content_model'); module_load_include('inc', 'islandora', 'includes/content_model');
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$dsids = array_keys(islandora_get_missing_datastreams_requirements($object)); $dsids = array_keys(islandora_get_missing_datastreams_requirements($object));

2
includes/breadcrumb.inc

@ -14,7 +14,7 @@
* ancestry which is identified by any of the following RELS-EXT terms * ancestry which is identified by any of the following RELS-EXT terms
* (isMemberOf,isMemberOfCollection,isPartOf). * (isMemberOf,isMemberOfCollection,isPartOf).
* *
* @param FedoraObject $object * @param AbstractObject $object
* An object whose ancestry will be mapped to bread-crumbs. * An object whose ancestry will be mapped to bread-crumbs.
* *
* @see drupal_set_breadcrumb() * @see drupal_set_breadcrumb()

79
includes/content_model.autocomplete.inc

@ -0,0 +1,79 @@
<?php
/**
* @file
* Autocomplete functionality for content models in Islandora.
*/
/**
* Autocomplete the content model name.
*
* @param string $string
* A search string.
*
* @return string
* The rendered JSON results.
*/
function islandora_content_model_autocomplete($string) {
$content_models = islandora_get_content_model_names();
$output = array();
foreach ($content_models as $model => $label) {
if (preg_match("/{$string}/i", $label) !== 0) {
$output[$model] = $label;
}
}
return drupal_json_output($output);
}
/**
* Gets a map of form names suitable for use as select #options.
*/
function islandora_get_content_model_names() {
$results = islandora_query_content_models();
$ret = array();
foreach ($results as $result) {
$ret[$result['model']['value']] = "{$result['label']['value']} ({$result['model']['value']})";
}
return $ret;
}
/**
* Perform a resource index query to determine get a list of content models.
*
* Only returns content models with at least one subscribing object.
*
* @return array
* An array of RI results, as given by the Tuque RI query interface.
*/
function islandora_query_content_models() {
$connection = islandora_get_tuque_connection();
if ($connection) {
$query = 'select $model $label from <#ri> where
$model <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0> and $model <fedora-model:label> $label
minus $model <mulgara:is><info:fedora/fedora-system:FedoraObject-3.0>
minus $model <mulgara:is><info:fedora/fedora-system:ContentModel-3.0>
minus $model <mulgara:is><info:fedora/fedora-system:ServiceDefinition-3.0>
minus $model <mulgara:is><info:fedora/fedora-system:ServiceDeployment-3.0>';
$results = $connection->repository->ri->itqlQuery($query);
return $results;
}
return array();
}
/**
* Minor array transformation.
*
* @param array $content
* The array of results as returned from Tuque's RI query interface.
*
* @return array
* An array of results in a more usable format.
*/
function islandora_parse_query($content) {
$content_models = array();
foreach ($content as $model) {
$content_models[] = $model['object']['value'];
}
$content_models = array_unique($content_models);
$content_models = array_values($content_models);
return $content_models;
}

28
includes/datastream.inc

@ -8,10 +8,10 @@
/** /**
* Callback to download the given datastream to the users computer. * Callback to download the given datastream to the users computer.
* *
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream to download. * The datastream to download.
*/ */
function islandora_download_datastream(FedoraDatastream $datastream) { function islandora_download_datastream(AbstractDatastream $datastream) {
islandora_view_datastream($datastream, TRUE); islandora_view_datastream($datastream, TRUE);
} }
@ -21,13 +21,13 @@ function islandora_download_datastream(FedoraDatastream $datastream) {
* @note * @note
* This function calls exit(). * This function calls exit().
* *
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream to view/download. * The datastream to view/download.
* @param bool $download * @param bool $download
* If TRUE the file is download to the user computer for viewing otherwise it * If TRUE the file is download to the user computer for viewing otherwise it
* will attempt to display in the browser natively. * will attempt to display in the browser natively.
*/ */
function islandora_view_datastream(FedoraDatastream $datastream, $download = FALSE) { function islandora_view_datastream(AbstractDatastream $datastream, $download = FALSE) {
header_remove('Cache-Control'); header_remove('Cache-Control');
header_remove('Expires'); header_remove('Expires');
header('Content-type: ' . $datastream->mimetype); header('Content-type: ' . $datastream->mimetype);
@ -51,14 +51,14 @@ function islandora_view_datastream(FedoraDatastream $datastream, $download = FAL
/** /**
* Get the human readable size of the given datastream. * Get the human readable size of the given datastream.
* *
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream to check. * The datastream to check.
* *
* @return string * @return string
* A human readable size of the given datastream, or '-' if the size could not * A human readable size of the given datastream, or '-' if the size could not
* be determined. * be determined.
*/ */
function islandora_datastream_get_human_readable_size(FedoraDatastream $datastream) { function islandora_datastream_get_human_readable_size(AbstractDatastream $datastream) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$size_is_calculatable = $datastream->controlGroup == 'M' || $datastream->controlGroup == 'X'; $size_is_calculatable = $datastream->controlGroup == 'M' || $datastream->controlGroup == 'X';
return $size_is_calculatable ? islandora_convert_bytes_to_human_readable($datastream->size) : '-'; return $size_is_calculatable ? islandora_convert_bytes_to_human_readable($datastream->size) : '-';
@ -67,23 +67,23 @@ function islandora_datastream_get_human_readable_size(FedoraDatastream $datastre
/** /**
* Get either the 'view' or 'download' url for the given datastream if possible. * Get either the 'view' or 'download' url for the given datastream if possible.
* *
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream to generated the url to. * The datastream to generated the url to.
* *
* @return string * @return string
* either the 'view' or 'download' url for the given datastream. * either the 'view' or 'download' url for the given datastream.
*/ */
function islandora_datastream_get_url(FedoraDatastream $datastream, $type = 'download') { function islandora_datastream_get_url(AbstractDatastream $datastream, $type = 'download') {
return $datastream->controlGroup == 'R' ? $datastream->url : "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/$type"; return $datastream->controlGroup == 'R' ? $datastream->url : "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/$type";
} }
/** /**
* Gets the delete link. * Gets the delete link.
* *
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream to generated the url to. * The datastream to generated the url to.
*/ */
function islandora_datastream_get_delete_link(FedoraDatastream $datastream) { function islandora_datastream_get_delete_link(AbstractDatastream $datastream) {
$datastreams = module_invoke_all('islandora_undeletable_datastreams', $datastream->parent->models); $datastreams = module_invoke_all('islandora_undeletable_datastreams', $datastream->parent->models);
$can_delete = !in_array($datastream->id, $datastreams); $can_delete = !in_array($datastream->id, $datastreams);
return $can_delete ? l(t('delete'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/delete") : ''; return $can_delete ? l(t('delete'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/delete") : '';
@ -92,10 +92,10 @@ function islandora_datastream_get_delete_link(FedoraDatastream $datastream) {
/** /**
* Gets the edit link. * Gets the edit link.
* *
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream to generated the url to. * The datastream to generated the url to.
*/ */
function islandora_datastream_edit_get_link(FedoraDatastream $datastream) { function islandora_datastream_edit_get_link(AbstractDatastream $datastream) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream); $edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream);
$can_edit = count($edit_registry) > 0 && user_access(FEDORA_METADATA_EDIT); $can_edit = count($edit_registry) > 0 && user_access(FEDORA_METADATA_EDIT);
return $can_edit ? l(t('edit'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/edit") : ''; return $can_edit ? l(t('edit'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/edit") : '';
@ -104,10 +104,10 @@ function islandora_datastream_edit_get_link(FedoraDatastream $datastream) {
/** /**
* Display the edit datastream page. * Display the edit datastream page.
* *
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream to edit. * The datastream to edit.
*/ */
function islandora_edit_datastream(FedoraDatastream $datastream) { function islandora_edit_datastream(AbstractDatastream $datastream) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream); $edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream);
$edit_count = count($edit_registry); $edit_count = count($edit_registry);
switch ($edit_count) { switch ($edit_count) {

6
includes/delete_datastream.form.inc

@ -12,13 +12,13 @@
* The Drupal form. * The Drupal form.
* @param array $form_state * @param array $form_state
* The Drupal form state. * The Drupal form state.
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream to be deleted. * The datastream to be deleted.
* *
* @return array * @return array
* The drupal form definition. * The drupal form definition.
*/ */
function islandora_delete_datastream_form(array $form, array &$form_state, FedoraDatastream $datastream) { function islandora_delete_datastream_form(array $form, array &$form_state, AbstractDatastream $datastream) {
$form_state['datastream'] = $datastream; $form_state['datastream'] = $datastream;
return confirm_form($form, return confirm_form($form,
t('Are you sure you want to delete the %dsid datastream?', array('%dsid' => $datastream->id)), t('Are you sure you want to delete the %dsid datastream?', array('%dsid' => $datastream->id)),
@ -32,7 +32,7 @@ function islandora_delete_datastream_form(array $form, array &$form_state, Fedor
/** /**
* Submit handler for the delete datastream form. * Submit handler for the delete datastream form.
* *
* Purges/Delete's the given FedoraDatastream if possible. * Purges/Delete's the given AbstractDatastream if possible.
* *
* The ISLANDORA_PRE_PURGE_DATASTREAM_HOOK will query other modules as to * The ISLANDORA_PRE_PURGE_DATASTREAM_HOOK will query other modules as to
* whether the given FedoraDatastream * whether the given FedoraDatastream

4
includes/delete_object.form.inc

@ -12,13 +12,13 @@
* The Drupal form. * The Drupal form.
* @param array $form_state * @param array $form_state
* The Drupal form state. * The Drupal form state.
* @param FedoraObject $object * @param AbstractObject $object
* The object to be deleted. * The object to be deleted.
* *
* @return array * @return array
* The drupal form definition. * The drupal form definition.
*/ */
function islandora_delete_object_form(array $form, array &$form_state, FedoraObject $object) { function islandora_delete_object_form(array $form, array &$form_state, AbstractObject $object) {
$form_state['object'] = $object; $form_state['object'] = $object;
return confirm_form($form, return confirm_form($form,
t('Are you sure you want to delete %title?', array('%title' => $object->label)), t('Are you sure you want to delete %title?', array('%title' => $object->label)),

10
includes/ingest.form.inc

@ -78,6 +78,12 @@ function islandora_ingest_form_init_form_state_storage(array &$form_state, array
if (empty($objects)) { if (empty($objects)) {
$objects[] = islandora_ingest_form_prepare_new_object($configuration); $objects[] = islandora_ingest_form_prepare_new_object($configuration);
} }
// Make sure the models actually exist.
foreach ($configuration['models'] as $key => $model) {
if (!islandora_object_load($model)) {
unset($configuration['models'][$key]);
}
}
// No need to persist the 'objects' within the configuration. // No need to persist the 'objects' within the configuration.
unset($configuration['objects']); unset($configuration['objects']);
// Required for step hooks. // Required for step hooks.
@ -534,7 +540,7 @@ function islandora_ingest_form_previous_button(array &$form_state) {
$prev_form_step = islandora_ingest_form_get_previous_form_step($form_state); $prev_form_step = islandora_ingest_form_get_previous_form_step($form_state);
$form_id = $prev_form_step['form_id']; $form_id = $prev_form_step['form_id'];
$submit_callback = $form_id . '_undo_submit'; $submit_callback = $form_id . '_undo_submit';
$submit = function_exists($submit_callback) ? array($submit_callback, 'islandora_ingest_form_previous_submit') : array('islandora_ingest_form_previous_submit'); $submit = function_exists($submit_callback) ? array('islandora_ingest_form_previous_submit', $submit_callback) : array('islandora_ingest_form_previous_submit');
return array( return array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Previous'), '#value' => t('Previous'),
@ -731,7 +737,7 @@ function &islandora_ingest_form_get_objects(array &$form_state) {
*/ */
function islandora_ingest_form_get_object(array &$form_state) { function islandora_ingest_form_get_object(array &$form_state) {
$objects = &islandora_ingest_form_get_objects($form_state); $objects = &islandora_ingest_form_get_objects($form_state);
return current($objects); return reset($objects);
} }
/** /**

8
includes/mime_detect.inc

@ -148,7 +148,7 @@ class MimeDetect {
"jp2" => "image/jp2", "jp2" => "image/jp2",
"png" => "image/png", "png" => "image/png",
"tiff" => "image/tiff", "tiff" => "image/tiff",
"tif" => "image/tif", "tif" => "image/tiff",
"djvu" => "image/vnd.djvu", "djvu" => "image/vnd.djvu",
"djv" => "image/vnd.djvu", "djv" => "image/vnd.djvu",
"wbmp" => "image/vnd.wap.wbmp", "wbmp" => "image/vnd.wap.wbmp",
@ -194,6 +194,11 @@ class MimeDetect {
'bin' => 'application/octet-stream', 'bin' => 'application/octet-stream',
); );
protected $protectedFileExtensions; protected $protectedFileExtensions;
protected $extensionExceptions = array(
// XXX: Deprecated... Only here due to old 'tif' => 'image/tif' mapping...
// The correct MIMEtype is 'image/tiff'.
'image/tif' => 'tif',
);
protected $systemTypes; protected $systemTypes;
protected $systemExts; protected $systemExts;
protected $etcMimeTypes = '/etc/mime.types'; protected $etcMimeTypes = '/etc/mime.types';
@ -205,6 +210,7 @@ class MimeDetect {
// Populate the reverse shortlist: // Populate the reverse shortlist:
$this->protectedFileExtensions = array_flip($this->protectedMimeTypes); $this->protectedFileExtensions = array_flip($this->protectedMimeTypes);
$this->protectedFileExtensions += $this->extensionExceptions;
// Pick up a local mime.types file if it is available. // Pick up a local mime.types file if it is available.
if (is_readable('mime.types')) { if (is_readable('mime.types')) {

4
includes/object_properties.form.inc

@ -12,13 +12,13 @@
* The Drupal form. * The Drupal form.
* @param array $form_state * @param array $form_state
* The Drupal form state. * The Drupal form state.
* @param FedoraObject $object * @param AbstractObject $object
* The object whose properties this form will modify. * The object whose properties this form will modify.
* *
* @return array * @return array
* The drupal form definition. * The drupal form definition.
*/ */
function islandora_object_properties_form(array $form, array &$form_state, FedoraObject $object) { function islandora_object_properties_form(array $form, array &$form_state, AbstractObject $object) {
drupal_set_title($object->label); drupal_set_title($object->label);
$form_state['object'] = $object; $form_state['object'] = $object;
return array( return array(

10
includes/solution_packs.inc

@ -180,12 +180,12 @@ function islandora_solution_pack_form_submit(array $form, array &$form_state) {
/** /**
* Batch operation to ingest/reingest required object(s). * Batch operation to ingest/reingest required object(s).
* *
* @param NewFedoraObject $object * @param AbstractObject $object
* The object to ingest/reingest. * The object to ingest/reingest.
* @param array $context * @param array $context
* The context of this batch operation. * The context of this batch operation.
*/ */
function islandora_solution_pack_batch_operation_reingest_object(NewFedoraObject $object, array &$context) { function islandora_solution_pack_batch_operation_reingest_object(AbstractObject $object, array &$context) {
$existing_object = islandora_object_load($object->id); $existing_object = islandora_object_load($object->id);
$deleted = FALSE; $deleted = FALSE;
if ($existing_object) { if ($existing_object) {
@ -367,7 +367,7 @@ function islandora_uninstall_solution_pack($module) {
/** /**
* Function to check the status of an object against an object model array. * Function to check the status of an object against an object model array.
* *
* @param NewFedoraObject $object_definition * @param AbstractObject $object_definition
* A new fedora object that defines what the object should contain. * A new fedora object that defines what the object should contain.
* *
* @return string * @return string
@ -378,7 +378,7 @@ function islandora_uninstall_solution_pack($module) {
* @see islandora_solution_pack_form() * @see islandora_solution_pack_form()
* @see islandora_install_solution_pack() * @see islandora_install_solution_pack()
*/ */
function islandora_check_object_status(NewFedoraObject $object_definition) { function islandora_check_object_status(AbstractObject $object_definition) {
$existing_object = islandora_object_load($object_definition->id); $existing_object = islandora_object_load($object_definition->id);
if (!$existing_object) { if (!$existing_object) {
return array('status' => 'missing', 'status_friendly' => t('Missing')); return array('status' => 'missing', 'status_friendly' => t('Missing'));
@ -627,7 +627,7 @@ function theme_islandora_viewers_table($variables) {
* Array or string with data the module needs in order to render a full viewer * Array or string with data the module needs in order to render a full viewer
* @param string $variable_id * @param string $variable_id
* The id of the Drupal variable the viewer settings are saved in * The id of the Drupal variable the viewer settings are saved in
* @param FedoraObject $fedora_object * @param AbstractObject $fedora_object
* The tuque object representing the fedora object being displayed * The tuque object representing the fedora object being displayed
* *
* @return string * @return string

4
includes/tuque_wrapper.inc

@ -34,7 +34,7 @@ $islandora_module_path = drupal_get_path('module', 'islandora');
/** /**
* Allow modules to alter an object before a mutable event occurs. * Allow modules to alter an object before a mutable event occurs.
*/ */
function islandora_alter_object(AbstractFedoraObject $object, array &$context) { function islandora_alter_object(AbstractObject $object, array &$context) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
drupal_alter(islandora_build_hook_list('islandora_object', $object->models), $object, $context); drupal_alter(islandora_build_hook_list('islandora_object', $object->models), $object, $context);
} }
@ -42,7 +42,7 @@ function islandora_alter_object(AbstractFedoraObject $object, array &$context) {
/** /**
* Allow modules to alter a datastream before a mutable event occurs. * Allow modules to alter a datastream before a mutable event occurs.
*/ */
function islandora_alter_datastream(AbstractFedoraObject $object, AbstractDatastream $datastream, array &$context) { function islandora_alter_datastream(AbstractObject $object, AbstractDatastream $datastream, array &$context) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$types = array(); $types = array();
foreach ($object->models as $model) { foreach ($object->models as $model) {

16
includes/utilities.inc

@ -271,14 +271,14 @@ function islandora_namespace_accessible($id) {
* This function gets its info from the RELS-EXT directly rather than through an * This function gets its info from the RELS-EXT directly rather than through an
* risearch. * risearch.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object whose parents will be returned. * The object whose parents will be returned.
* *
* @return array * @return array
* An array of FedoraObject's that the given object has a * An array of FedoraObject's that the given object has a
* (isMemberOf, isMemberOfCollection) relationship with. * (isMemberOf, isMemberOfCollection) relationship with.
*/ */
function islandora_get_parents_from_rels_ext(FedoraObject $object) { function islandora_get_parents_from_rels_ext(AbstractObject $object) {
try { try {
$collections = array_merge( $collections = array_merge(
$object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOfCollection'), $object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOfCollection'),
@ -298,7 +298,7 @@ function islandora_get_parents_from_rels_ext(FedoraObject $object) {
/** /**
* Gets the datastreams requirments that are missing. * Gets the datastreams requirments that are missing.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object which models will be used to determine what datastreams it * The object which models will be used to determine what datastreams it
* should have. * should have.
* *
@ -306,7 +306,7 @@ function islandora_get_parents_from_rels_ext(FedoraObject $object) {
* The DS-COMPOSITE-MODEL defined datastreams that are required for the given * The DS-COMPOSITE-MODEL defined datastreams that are required for the given
* object, but not already present. * object, but not already present.
*/ */
function islandora_get_missing_datastreams_requirements(FedoraObject $object) { function islandora_get_missing_datastreams_requirements(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$datastreams = islandora_get_datastreams_requirements($object); $datastreams = islandora_get_datastreams_requirements($object);
foreach ($datastreams as $dsid => $requirements) { foreach ($datastreams as $dsid => $requirements) {
@ -331,7 +331,7 @@ function islandora_get_missing_datastreams_requirements(FedoraObject $object) {
* *
* @see islandora_get_required_datastreams_from_content_model() * @see islandora_get_required_datastreams_from_content_model()
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object which models will be used to determine what datastreams it * The object which models will be used to determine what datastreams it
* should have. * should have.
* *
@ -339,7 +339,7 @@ function islandora_get_missing_datastreams_requirements(FedoraObject $object) {
* The DS-COMPOSITE-MODEL defined datastreams that are required for the given * The DS-COMPOSITE-MODEL defined datastreams that are required for the given
* object. * object.
*/ */
function islandora_get_datastreams_requirements(FedoraObject $object) { function islandora_get_datastreams_requirements(AbstractObject $object) {
return islandora_get_datastreams_requirements_from_models($object->models); return islandora_get_datastreams_requirements_from_models($object->models);
} }
@ -375,7 +375,7 @@ function islandora_get_datastreams_requirements_from_models(array $models) {
* *
* @todo Add support for fetching the schema information. * @todo Add support for fetching the schema information.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The content model whose DS-COMPOSITE-MODEL datastream will be used to * The content model whose DS-COMPOSITE-MODEL datastream will be used to
* determine what datastreams are required. * determine what datastreams are required.
* *
@ -388,7 +388,7 @@ function islandora_get_datastreams_requirements_from_models(array $models) {
* - "mime": A array containing MIME-types the stream may have. * - "mime": A array containing MIME-types the stream may have.
* - "optional": A boolean indicating if the given stream is optional. * - "optional": A boolean indicating if the given stream is optional.
*/ */
function islandora_get_datastreams_requirements_from_content_model(FedoraObject $object) { function islandora_get_datastreams_requirements_from_content_model(AbstractObject $object) {
if (empty($object[DS_COMP_STREAM])) { if (empty($object[DS_COMP_STREAM])) {
return array(); return array();
} }

70
islandora.api.php

@ -8,7 +8,7 @@
/** /**
* Generate a repository objects view. * Generate a repository objects view.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object to display * The object to display
* @param object $user * @param object $user
* The user accessing the object. * The user accessing the object.
@ -29,7 +29,7 @@ function hook_islandora_view_object($object, $user, $page_number, $page_size) {
* Content models PIDs have colons and hyphens changed to underscores, to * Content models PIDs have colons and hyphens changed to underscores, to
* create the hook name. * create the hook name.
* *
* @param FedoraObject $object * @param AbstractObject $object
* A Tuque FedoraObject * A Tuque FedoraObject
* *
* @return array * @return array
@ -42,8 +42,8 @@ function hook_CMODEL_PID_islandora_view_object($object) {
/** /**
* Alter display output after it has been generated. * Alter display output after it has been generated.
* *
* @param FedoraObject $object * @param AbstractObject $object
* A Tuque FedoraObject being operated on. * A Tuque AbstractObject being operated on.
* @param array $rendered * @param array $rendered
* The array of rendered views. * The array of rendered views.
*/ */
@ -55,8 +55,8 @@ function hook_islandora_view_object_alter(&$object, &$rendered) {
* *
* @see hook_islandora_view_object_alter() * @see hook_islandora_view_object_alter()
* *
* @param FedoraObject $object * @param AbstractObject $object
* A Tuque FedoraObject being operated on. * A Tuque AbstractObject being operated on.
* @param array $rendered * @param array $rendered
* The array of rendered views. * The array of rendered views.
*/ */
@ -66,7 +66,7 @@ function hook_CMODEL_PID_islandora_view_object_alter(&$object, &$rendered) {
/** /**
* Generate an object's management display. * Generate an object's management display.
* *
* @param FedoraObject $object * @param AbstractObject $object
* A Tuque FedoraObject * A Tuque FedoraObject
* *
* @return array * @return array
@ -81,7 +81,7 @@ function hook_islandora_edit_object($object) {
* Content models PIDs have colons and hyphens changed to underscores, to * Content models PIDs have colons and hyphens changed to underscores, to
* create the hook name. * create the hook name.
* *
* @param FedoraObject $object * @param AbstractObject $object
* A Tuque FedoraObject * A Tuque FedoraObject
* *
* @return array * @return array
@ -93,7 +93,7 @@ function hook_CMODEL_PID_islandora_edit_object($object) {
/** /**
* Allow management display output to be altered. * Allow management display output to be altered.
* *
* @param FedoraObject $object * @param AbstractObject $object
* A Tuque FedoraObject * A Tuque FedoraObject
* @param array $rendered * @param array $rendered
* an arr of rendered views * an arr of rendered views
@ -110,7 +110,7 @@ function hook_islandora_edit_object_alter(&$object, &$rendered) {
* Changing object properties such as "label", or "state", are considered * Changing object properties such as "label", or "state", are considered
* modifications, where as manipulating an object's datstreams are not. * modifications, where as manipulating an object's datstreams are not.
* *
* @param AbstractFedoraObject $object * @param AbstractObject $object
* The object to alter. * The object to alter.
* @param array $context * @param array $context
* An associative array containing: * An associative array containing:
@ -130,7 +130,7 @@ function hook_islandora_edit_object_alter(&$object, &$rendered) {
* *
* @see FedoraApiM::modifyObject() * @see FedoraApiM::modifyObject()
*/ */
function hook_islandora_object_alter(AbstractFedoraObject $object, array &$context) { function hook_islandora_object_alter(AbstractObject $object, array &$context) {
} }
/** /**
@ -138,7 +138,7 @@ function hook_islandora_object_alter(AbstractFedoraObject $object, array &$conte
* *
* @see hook_islandora_object_alter() * @see hook_islandora_object_alter()
*/ */
function hook_CMODEL_PID_islandora_object_alter(AbstractFedoraObject $object, array &$context) { function hook_CMODEL_PID_islandora_object_alter(AbstractObject $object, array &$context) {
} }
/** /**
@ -151,15 +151,15 @@ function hook_CMODEL_PID_islandora_object_alter(AbstractFedoraObject $object, ar
* immediately, instead it will be triggered for all datastreams at the time * immediately, instead it will be triggered for all datastreams at the time
* of the NewFedoraObject's ingest. * of the NewFedoraObject's ingest.
* *
* Purging datastreams from a NewFedoraObject will not trigger this alter hook * Purging datastreams from a AbstractObject will not trigger this alter hook
* at all. * at all.
* *
* Changing datastream's properties such as "label", or "state", are considered * Changing datastream's properties such as "label", or "state", are considered
* modifications, as well as changing the datastreams content. * modifications, as well as changing the datastreams content.
* *
* @param AbstractFedoraObject $object * @param AbstractObject $object
* The object to the datastream belong to. * The object to the datastream belong to.
* @param AbstractFedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream to alter. * The datastream to alter.
* @param array $context * @param array $context
* An associative array containing: * An associative array containing:
@ -179,7 +179,7 @@ function hook_CMODEL_PID_islandora_object_alter(AbstractFedoraObject $object, ar
* *
* @see FedoraApiM::modifyDatastream() * @see FedoraApiM::modifyDatastream()
*/ */
function hook_islandora_datastream_alter(AbstractFedoraObject $object, AbstractFedoraDatastream $datastream, array &$context) { function hook_islandora_datastream_alter(AbstractObject $object, AbstractDatastream $datastream, array &$context) {
} }
/** /**
@ -187,7 +187,7 @@ function hook_islandora_datastream_alter(AbstractFedoraObject $object, AbstractF
* *
* @see hook_islandora_datastream_alter() * @see hook_islandora_datastream_alter()
*/ */
function hook_CMODEL_PID_DSID_islandora_datastream_alter(AbstractFedoraObject $object, AbstractFedoraDatastream $datastream, array &$context) { function hook_CMODEL_PID_DSID_islandora_datastream_alter(AbstractObject $object, AbstractDatastream $datastream, array &$context) {
} }
/** /**
@ -200,10 +200,10 @@ function hook_CMODEL_PID_DSID_islandora_datastream_alter(AbstractFedoraObject $o
* If ingested directly via the FedoraApiM object this will not be called as we * If ingested directly via the FedoraApiM object this will not be called as we
* don't have access to the ingested object at that time. * don't have access to the ingested object at that time.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object that was ingested. * The object that was ingested.
*/ */
function hook_islandora_object_ingested(FedoraObject $object) { function hook_islandora_object_ingested(AbstractObject $object) {
} }
/** /**
@ -211,7 +211,7 @@ function hook_islandora_object_ingested(FedoraObject $object) {
* *
* @see hook_islandora_object_ingested() * @see hook_islandora_object_ingested()
*/ */
function hook_CMODEL_PID_islandora_object_ingested(FedoraObject $object) { function hook_CMODEL_PID_islandora_object_ingested(AbstractObject $object) {
} }
/** /**
@ -222,13 +222,13 @@ function hook_CMODEL_PID_islandora_object_ingested(FedoraObject $object) {
* Changing object properties such as "label", or "state", are considered * Changing object properties such as "label", or "state", are considered
* modifications, where as manipulating an object's datstreams are not. * modifications, where as manipulating an object's datstreams are not.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object that was ingested. * The object that was ingested.
* *
* @todo We should also include what changes were made in a additional * @todo We should also include what changes were made in a additional
* parameter. * parameter.
*/ */
function hook_islandora_object_modified(FedoraObject $object) { function hook_islandora_object_modified(AbstractObject $object) {
} }
/** /**
@ -236,7 +236,7 @@ function hook_islandora_object_modified(FedoraObject $object) {
* *
* @see hook_islandora_object_modified() * @see hook_islandora_object_modified()
*/ */
function hook_CMODEL_PID_islandora_object_modified(FedoraObject $object) { function hook_CMODEL_PID_islandora_object_modified(AbstractObject $object) {
} }
/** /**
@ -268,12 +268,12 @@ function hook_CMODEL_PID_islandora_object_purged($pid) {
* If ingested directly via the FedoraApiM object this will not be called as we * If ingested directly via the FedoraApiM object this will not be called as we
* don't have access to the ingested datastream at that time. * don't have access to the ingested datastream at that time.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object the datastream belongs to. * The object the datastream belongs to.
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The ingested datastream. * The ingested datastream.
*/ */
function hook_islandora_datastream_ingested(FedoraObject $object, FedoraDatastream $datastream) { function hook_islandora_datastream_ingested(AbstractObject $object, AbstractDatastream $datastream) {
} }
/** /**
@ -281,7 +281,7 @@ function hook_islandora_datastream_ingested(FedoraObject $object, FedoraDatastre
* *
* @see hook_islandora_object_ingested() * @see hook_islandora_object_ingested()
*/ */
function hook_CMODEL_PID_DSID_islandora_datastream_ingested(FedoraObject $object, FedoraDatastream $datastream) { function hook_CMODEL_PID_DSID_islandora_datastream_ingested(AbstractObject $object, AbstractDatastream $datastream) {
} }
/** /**
@ -292,15 +292,15 @@ function hook_CMODEL_PID_DSID_islandora_datastream_ingested(FedoraObject $object
* Changing datastream properties such as "label", or "state", are considered * Changing datastream properties such as "label", or "state", are considered
* modifications, as well as the datastreams content. * modifications, as well as the datastreams content.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object the datastream belongs to. * The object the datastream belongs to.
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream that was ingested. * The datastream that was ingested.
* *
* @todo We should also include what changes were made in a additional * @todo We should also include what changes were made in a additional
* parameter. * parameter.
*/ */
function hook_islandora_datastream_modified(FedoraObject $object, FedoraDatastream $datastream) { function hook_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream) {
} }
/** /**
@ -308,7 +308,7 @@ function hook_islandora_datastream_modified(FedoraObject $object, FedoraDatastre
* *
* @see hook_islandora_datastream_modified() * @see hook_islandora_datastream_modified()
*/ */
function hook_CMODEL_PID_islandora_datastream_modified(FedoraObject $object, FedoraDatastream $datastream) { function hook_CMODEL_PID_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream) {
} }
/** /**
@ -317,12 +317,12 @@ function hook_CMODEL_PID_islandora_datastream_modified(FedoraObject $object, Fed
* This hook is called after an datastream has been successfully purged, or * This hook is called after an datastream has been successfully purged, or
* when its state has been changed to "Deleted". * when its state has been changed to "Deleted".
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object the datastream belonged to. * The object the datastream belonged to.
* @param string $dsid * @param string $dsid
* The ID of the datastream that was purged/deleted. * The ID of the datastream that was purged/deleted.
*/ */
function hook_islandora_datastream_purged(FedoraObject $object, $dsid) { function hook_islandora_datastream_purged(AbstractObject $object, $dsid) {
} }
/** /**
@ -330,13 +330,13 @@ function hook_islandora_datastream_purged(FedoraObject $object, $dsid) {
* *
* @see hook_islandora_datastream_purged() * @see hook_islandora_datastream_purged()
*/ */
function hook_CMODEL_PID_islandora_datastream_purged(FedoraObject $object, $dsid) { function hook_CMODEL_PID_islandora_datastream_purged(AbstractObject $object, $dsid) {
} }
/** /**
* Register a datastream edit route/form. * Register a datastream edit route/form.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object to check. * The object to check.
* @param string $dsid * @param string $dsid
* todo * todo

62
islandora.module

@ -52,6 +52,9 @@ define('ISLANDORA_DATASTREAM_MODIFIED_HOOK', 'islandora_datastream_modified');
define('ISLANDORA_DATASTREAM_PURGED_HOOK', 'islandora_datastream_purged'); define('ISLANDORA_DATASTREAM_PURGED_HOOK', 'islandora_datastream_purged');
define('ISLANDORA_INGEST_STEP_HOOK', 'islandora_ingest_steps'); define('ISLANDORA_INGEST_STEP_HOOK', 'islandora_ingest_steps');
// Autocomplete paths.
define('ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE', 'islandora/autocomplete/content-models');
/** /**
* Implements hook_menu(). * Implements hook_menu().
* *
@ -246,6 +249,15 @@ function islandora_menu() {
'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), 'access arguments' => array(FEDORA_VIEW_OBJECTS, 2),
'load arguments' => array(2), 'load arguments' => array(2),
); );
$items[ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE] = array(
'title' => 'Autocomplete callback',
'description' => 'Autocomplete a Fedora content model PID.',
'file' => 'includes/content_model.autocomplete.inc',
'page callback' => 'islandora_content_model_autocomplete',
'page arguments' => array(3),
'access arguments' => array('administer site configuration'),
'type' => MENU_CALLBACK,
);
return $items; return $items;
} }
@ -370,7 +382,7 @@ function islandora_forms($form_id) {
* @global $user * @global $user
* *
* @param mixed $object * @param mixed $object
* The FedoraObject or FedoraDatastream to test for accessibility, if NULL * The AbstractObject or AbstractDatastream to test for accessibility, if NULL
* is given the object is assumed to not exist or be inaccessible. * is given the object is assumed to not exist or be inaccessible.
* @param array $permissions * @param array $permissions
* The required user permissions. * The required user permissions.
@ -448,7 +460,7 @@ function islandora_user_access($object, array $permissions, $content_models = ar
* *
* @param string $perm * @param string $perm
* User permission to test for. * User permission to test for.
* @param FedoraObject $object * @param AbstractObject $object
* The object to test, if NULL given the object doesn't exist or is * The object to test, if NULL given the object doesn't exist or is
* inaccessible. * inaccessible.
* *
@ -474,10 +486,10 @@ function islandora_object_access_callback($perm, $object = NULL) {
* *
* @param string $perm * @param string $perm
* The user permission to test for. * The user permission to test for.
* @param FedoraObject $object * @param AbstractObject $object
* The object to test, if NULL given the object doesn't exist or is * The object to test, if NULL given the object doesn't exist or is
* inaccessible. * inaccessible.
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream to test, if NULL given the datastream doesn't exist * The datastream to test, if NULL given the datastream doesn't exist
* or is inaccessible. * or is inaccessible.
* @param StdObject $account * @param StdObject $account
@ -525,7 +537,7 @@ function islandora_object_datastream_tokened_access_callback($perm, $object = NU
* *
* @param array $perms * @param array $perms
* Array of user permission to test for. * Array of user permission to test for.
* @param FedoraObject $object * @param AbstractObject $object
* The object to test, if NULL given the object doesn't exist or is * The object to test, if NULL given the object doesn't exist or is
* inaccessible. * inaccessible.
* *
@ -551,13 +563,13 @@ function islandora_object_manage_access_callback($perms, $object = NULL) {
/** /**
* Renders the given objects manage overview page. * Renders the given objects manage overview page.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object to manage. * The object to manage.
* *
* @return string * @return string
* The HTML repersentation of the manage object page. * The HTML repersentation of the manage object page.
*/ */
function islandora_manage_overview_object(FedoraObject $object) { function islandora_manage_overview_object(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$output = array(); $output = array();
foreach (islandora_build_hook_list(ISLANDORA_OVERVIEW_HOOK, $object->models) as $hook) { foreach (islandora_build_hook_list(ISLANDORA_OVERVIEW_HOOK, $object->models) as $hook) {
@ -578,14 +590,14 @@ function islandora_manage_overview_object(FedoraObject $object) {
/** /**
* Renders the default manage object page for the given object. * Renders the default manage object page for the given object.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object used to render the manage object page. * The object used to render the manage object page.
* *
* @return array * @return array
* The default rendering of the object manage page, indexed at * The default rendering of the object manage page, indexed at
* 'Default Edit output'. * 'Default Edit output'.
*/ */
function islandora_default_islandora_manage_overview_object(FedoraObject $object) { function islandora_default_islandora_manage_overview_object(AbstractObject $object) {
$output = theme('islandora_default_overview', array('islandora_object' => $object)); $output = theme('islandora_default_overview', array('islandora_object' => $object));
return array('Default overview output' => $output); return array('Default overview output' => $output);
} }
@ -599,13 +611,13 @@ function islandora_default_islandora_manage_overview_object(FedoraObject $object
* If no modules implement 'ISLANDORA_EDIT_HOOK' then this function returns the * If no modules implement 'ISLANDORA_EDIT_HOOK' then this function returns the
* default manage view. * default manage view.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object to manage. * The object to manage.
* *
* @return string * @return string
* The HTML repersentation of the manage object page. * The HTML repersentation of the manage object page.
*/ */
function islandora_edit_object(FedoraObject $object) { function islandora_edit_object(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/breadcrumb'); module_load_include('inc', 'islandora', 'includes/breadcrumb');
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
drupal_set_title($object->label); drupal_set_title($object->label);
@ -629,14 +641,14 @@ function islandora_edit_object(FedoraObject $object) {
/** /**
* Renders the default manage object page for the given object. * Renders the default manage object page for the given object.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object used to render the manage object page. * The object used to render the manage object page.
* *
* @return array * @return array
* The default rendering of the object manage page, indexed at * The default rendering of the object manage page, indexed at
* 'Default Edit output'. * 'Default Edit output'.
*/ */
function islandora_default_islandora_edit_object(FedoraObject $object) { function islandora_default_islandora_edit_object(AbstractObject $object) {
$output = theme('islandora_default_edit', array('islandora_object' => $object)); $output = theme('islandora_default_edit', array('islandora_object' => $object));
return array('Default Edit output' => $output); return array('Default Edit output' => $output);
} }
@ -661,13 +673,13 @@ function islandora_view_default_object() {
* If no modules implement the hook then the default view object page * If no modules implement the hook then the default view object page
* will be rendered. * will be rendered.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object to view. * The object to view.
* *
* @return string * @return string
* The html repersentation of this object. * The html repersentation of this object.
*/ */
function islandora_view_object(FedoraObject $object) { function islandora_view_object(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/breadcrumb'); module_load_include('inc', 'islandora', 'includes/breadcrumb');
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
drupal_set_title($object->label); drupal_set_title($object->label);
@ -697,7 +709,7 @@ function islandora_view_object(FedoraObject $object) {
/** /**
* Renders the default view object page for the given object. * Renders the default view object page for the given object.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object used to render the view object page. * The object used to render the view object page.
* *
* @return array * @return array
@ -849,7 +861,7 @@ function islandora_tokened_datastream_load($datastream_id, $map) {
* *
* @param mixed $object_id * @param mixed $object_id
* The object to load the datastream from. This can be a Fedora PID or * The object to load the datastream from. This can be a Fedora PID or
* an instantiated IslandoraFedoraObject as it implements __toString() * an instantiated IslandoraAbstractObject as it implements __toString()
* returning the PID. * returning the PID.
* *
* @return FedoraDatastream * @return FedoraDatastream
@ -872,7 +884,7 @@ function islandora_datastream_load($datastream_id, $object_id) {
* attribute, as in: * attribute, as in:
* <content_model name="Collection" version="2" ... * <content_model name="Collection" version="2" ...
* *
* @param FedoraObject $object * @param AbstractObject $object
* The Object the datastream belongs to. * The Object the datastream belongs to.
* @param string $dsid * @param string $dsid
* The ID of the datastream. * The ID of the datastream.
@ -941,26 +953,26 @@ function islandora_islandora_undeletable_datastreams(array $models) {
/** /**
* Ingest the given object. * Ingest the given object.
* *
* @param NewFedoraObject $object * @param AbstractObject $object
* An ingestable FedoraObject. * An ingestable FedoraObject.
* *
* @return FedoraObject * @return FedoraObject
* The ingested FedoraObject. * The ingested FedoraObject.
*/ */
function islandora_add_object(NewFedoraObject &$object) { function islandora_add_object(AbstractObject &$object) {
return $object->repository->ingestObject($object); return $object->repository->ingestObject($object);
} }
/** /**
* Delete's or purges the given object. * Delete's or purges the given object.
* *
* @param FedoraObject $object * @param AbstractObject $object
* An object to delete. * An object to delete.
* *
* @return bool * @return bool
* TRUE if successful, FALSE otherwise. * TRUE if successful, FALSE otherwise.
*/ */
function islandora_delete_object(FedoraObject &$object) { function islandora_delete_object(AbstractObject &$object) {
try { try {
$object->repository->purgeObject($object->id); $object->repository->purgeObject($object->id);
$object = NULL; $object = NULL;
@ -979,13 +991,13 @@ function islandora_delete_object(FedoraObject &$object) {
* Which types are undefined, but more than likely because of the hooks * Which types are undefined, but more than likely because of the hooks
* there will be several kinds. * there will be several kinds.
* *
* @param FedoraDatastream $datastream * @param AbstractDatastream $datastream
* The datastream to delete. * The datastream to delete.
* *
* @return bool * @return bool
* TRUE if successful, FALSE otherwise. * TRUE if successful, FALSE otherwise.
*/ */
function islandora_delete_datastream(FedoraDatastream &$datastream) { function islandora_delete_datastream(AbstractDatastream &$datastream) {
$object = $datastream->parent; $object = $datastream->parent;
return $object->purgeDatastream($datastream->id); return $object->purgeDatastream($datastream->id);
} }
@ -1065,7 +1077,7 @@ function islandora_entity_property_info() {
* Modules can either implement preprocess functions to append content onto the * Modules can either implement preprocess functions to append content onto the
* 'content' variable, or override the display by providing a theme suggestion. * 'content' variable, or override the display by providing a theme suggestion.
* *
* @param FedoraObject $object * @param AbstractObject $object
* The object. * The object.
* *
* @return array * @return array

6
islandora.rules.inc

@ -80,7 +80,7 @@ function islandora_rules_action_info() {
/** /**
* Checks that there is a relationship match on the given object. * Checks that there is a relationship match on the given object.
* *
* Takes a subject (either a FedoraObject or a FedoraDatastream), as well as * Takes a subject (either a AbstractObject or a FedoraDatastream), as well as
* the parameters for FedoraRelsExt::get() or FedoraRelsInt::get(), to try to * the parameters for FedoraRelsExt::get() or FedoraRelsInt::get(), to try to
* find a match. * find a match.
* *
@ -94,7 +94,7 @@ function islandora_object_has_relationship($sub, $pred_uri, $pred, $object, $typ
/** /**
* Remove a relationship from the given object. * Remove a relationship from the given object.
* *
* Takes a subject (either a FedoraObject or a FedoraDatastream), as well as * Takes a subject (either a AbstractObject or a FedoraDatastream), as well as
* the parameters for FedoraRelsExt::remove() or FedoraRelsInt::remove(), to * the parameters for FedoraRelsExt::remove() or FedoraRelsInt::remove(), to
* try to find a match. * try to find a match.
* *
@ -107,7 +107,7 @@ function islandora_object_remove_relationship($sub, $pred_uri, $pred, $object, $
/** /**
* Add a relationship to the given object. * Add a relationship to the given object.
* *
* Takes a subject (either a FedoraObject or a FedoraDatastream), as well as * Takes a subject (either a AbstractObject or a FedoraDatastream), as well as
* the parameters for FedoraRelsExt::add() or FedoraRelsInt::add(), and adds * the parameters for FedoraRelsExt::add() or FedoraRelsInt::add(), and adds
* the represented relationship. * the represented relationship.
* *

14
tests/islandora_hooks_test.module

@ -8,7 +8,7 @@
/** /**
* Implements hook_islandora_object_alter(). * Implements hook_islandora_object_alter().
*/ */
function islandora_hooks_test_islandora_object_alter(AbstractFedoraObject $object, array &$context) { function islandora_hooks_test_islandora_object_alter(AbstractObject $object, array &$context) {
switch ($context['action']) { switch ($context['action']) {
case 'ingest': case 'ingest':
if ($object->id == 'test:testIngestedObjectHook') { if ($object->id == 'test:testIngestedObjectHook') {
@ -54,7 +54,7 @@ function islandora_hooks_test_islandora_object_alter(AbstractFedoraObject $objec
/** /**
* Implements hook_islandora_object_alter(). * Implements hook_islandora_object_alter().
*/ */
function islandora_hooks_test_islandora_datastream_alter(AbstractFedoraObject $object, AbstractFedoraDatastream $datastream, array &$context) { function islandora_hooks_test_islandora_datastream_alter(AbstractObject $object, AbstractDatastream $datastream, array &$context) {
switch ($context['action']) { switch ($context['action']) {
case 'ingest': case 'ingest':
if ($object->id == 'test:testIngestedDatastreamHook') { if ($object->id == 'test:testIngestedDatastreamHook') {
@ -100,7 +100,7 @@ function islandora_hooks_test_islandora_datastream_alter(AbstractFedoraObject $o
/** /**
* Implements hook_islandora_object_ingested(). * Implements hook_islandora_object_ingested().
*/ */
function islandora_hooks_test_islandora_object_ingested(FedoraObject $object) { function islandora_hooks_test_islandora_object_ingested(AbstractObject $object) {
if ($object->id == 'test:testIngestedObjectHook') { if ($object->id == 'test:testIngestedObjectHook') {
$_SESSION['islandora_hooks']['hook'][ISLANDORA_OBJECT_INGESTED_HOOK] = TRUE; $_SESSION['islandora_hooks']['hook'][ISLANDORA_OBJECT_INGESTED_HOOK] = TRUE;
} }
@ -109,7 +109,7 @@ function islandora_hooks_test_islandora_object_ingested(FedoraObject $object) {
/** /**
* Implements hook_islandora_object_modified(). * Implements hook_islandora_object_modified().
*/ */
function islandora_hooks_test_islandora_object_modified(FedoraObject $object) { function islandora_hooks_test_islandora_object_modified(AbstractObject $object) {
if ($object->id == 'test:testModifiedObjectHook') { if ($object->id == 'test:testModifiedObjectHook') {
$_SESSION['islandora_hooks']['hook'][ISLANDORA_OBJECT_MODIFIED_HOOK] = TRUE; $_SESSION['islandora_hooks']['hook'][ISLANDORA_OBJECT_MODIFIED_HOOK] = TRUE;
} }
@ -127,7 +127,7 @@ function islandora_hooks_test_islandora_object_purged($pid) {
/** /**
* Implements hook_islandora_datastream_ingested(). * Implements hook_islandora_datastream_ingested().
*/ */
function islandora_hooks_test_islandora_datastream_ingested(FedoraObject $object, FedoraDatastream $datastream) { function islandora_hooks_test_islandora_datastream_ingested(AbstractObject $object, AbstractDatastream $datastream) {
if ($object->id == 'test:testIngestedDatastreamHook' && $datastream->id == "TEST") { if ($object->id == 'test:testIngestedDatastreamHook' && $datastream->id == "TEST") {
$_SESSION['islandora_hooks']['hook'][ISLANDORA_DATASTREAM_INGESTED_HOOK] = TRUE; $_SESSION['islandora_hooks']['hook'][ISLANDORA_DATASTREAM_INGESTED_HOOK] = TRUE;
} }
@ -136,7 +136,7 @@ function islandora_hooks_test_islandora_datastream_ingested(FedoraObject $object
/** /**
* Implements hook_islandora_datastream_modified(). * Implements hook_islandora_datastream_modified().
*/ */
function islandora_hooks_test_islandora_datastream_modified(FedoraObject $object, FedoraDatastream $datastream) { function islandora_hooks_test_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream) {
if ($object->id == 'test:testModifiedDatastreamHook' && $datastream->id == "TEST") { if ($object->id == 'test:testModifiedDatastreamHook' && $datastream->id == "TEST") {
$_SESSION['islandora_hooks']['hook'][ISLANDORA_DATASTREAM_MODIFIED_HOOK] = TRUE; $_SESSION['islandora_hooks']['hook'][ISLANDORA_DATASTREAM_MODIFIED_HOOK] = TRUE;
} }
@ -145,7 +145,7 @@ function islandora_hooks_test_islandora_datastream_modified(FedoraObject $object
/** /**
* Implements hook_islandora_datastream_purged(). * Implements hook_islandora_datastream_purged().
*/ */
function islandora_hooks_test_islandora_datastream_purged(FedoraObject $object, $dsid) { function islandora_hooks_test_islandora_datastream_purged(AbstractObject $object, $dsid) {
if ($object->id == 'test:testPurgedDatastreamHook' && $dsid == "TEST") { if ($object->id == 'test:testPurgedDatastreamHook' && $dsid == "TEST") {
$_SESSION['islandora_hooks']['hook'][ISLANDORA_DATASTREAM_PURGED_HOOK] = TRUE; $_SESSION['islandora_hooks']['hook'][ISLANDORA_DATASTREAM_PURGED_HOOK] = TRUE;
} }

16
tests/scripts/travis_setup.sh

@ -11,12 +11,16 @@ cd islandora_tomcat
export CATALINA_HOME='.' export CATALINA_HOME='.'
./bin/startup.sh ./bin/startup.sh
cd $HOME cd $HOME
pyrus channel-discover pear.drush.org pear upgrade –force Console_Getopt
pyrus channel-discover pear.phpqatools.org pear upgrade –force pear
pyrus channel-discover pear.netpirates.net pear upgrade-all
pyrus install drush/drush pear channel-discover pear.drush.org
pyrus install pear/PHP_CodeSniffer pear channel-discover pear.drush.org
pyrus install pear.phpunit.de/phpcpd pear channel-discover pear.phpqatools.org
pear channel-discover pear.netpirates.net
pear install pear/PHP_CodeSniffer
pear install pear.phpunit.de/phpcpd
pear install drush/drush
phpenv rehash phpenv rehash
drush dl --yes drupal drush dl --yes drupal
cd drupal-* cd drupal-*

Loading…
Cancel
Save