Browse Source

Update coding standards.

pull/695/head
Jonathan Green 7 years ago
parent
commit
ec23bc9dce
No known key found for this signature in database
GPG Key ID: E96938FA4DF26243
  1. 9
      css/islandora.admin.css
  2. 8
      css/islandora.base.css
  3. 20
      css/islandora.print.css
  4. 2
      includes/add_datastream.form.inc
  5. 13
      includes/admin.form.inc
  6. 10
      includes/authtokens.inc
  7. 3
      includes/content_model.autocomplete.inc
  8. 30
      includes/datastream.inc
  9. 31
      includes/datastream.version.inc
  10. 17
      includes/delete_datastream.form.inc
  11. 7
      includes/derivatives.inc
  12. 7
      includes/dublin_core.inc
  13. 26
      includes/ingest.form.inc
  14. 23
      includes/manage_deleted_objects.inc
  15. 7
      includes/metadata.inc
  16. 116
      includes/mime_detect.inc
  17. 1
      includes/mime_type.autocomplete.inc
  18. 2
      includes/mimetype.utils.inc
  19. 6
      includes/object.entity_controller.inc
  20. 13
      includes/object_properties.form.inc
  21. 10
      includes/regenerate_derivatives.form.inc
  22. 73
      includes/solution_packs.inc
  23. 10
      includes/tuque.inc
  24. 99
      includes/tuque_wrapper.inc
  25. 22
      includes/utilities.inc
  26. 86
      islandora.api.php
  27. 58
      islandora.module
  28. 11
      islandora.rules.inc
  29. 10
      tests/authtokens.test
  30. 5
      tests/datastream_cache.test
  31. 5
      tests/datastream_validator_tests.test
  32. 5
      tests/datastream_versions.test
  33. 17
      tests/derivatives.test
  34. 3
      tests/hooked_access.test
  35. 3
      tests/hooks.test
  36. 50
      tests/includes/datastream_validators.inc
  37. 7
      tests/includes/islandora_unit_test_case.inc
  38. 29
      tests/includes/islandora_web_test_case.inc
  39. 2
      tests/includes/test_utility_abstraction.inc
  40. 9
      tests/includes/utilities.inc
  41. 2
      tests/ingest.test
  42. 6
      tests/islandora_derivatives_test.module
  43. 2
      tests/islandora_hooked_access_test.module
  44. 2
      tests/islandora_hooks_test.module
  45. 2
      tests/islandora_ingest_test.module
  46. 3
      tests/islandora_manage_permissions.test
  47. 3
      tests/islandora_manage_temp_file.test
  48. 1
      theme/islandora-dublin-core-description.tpl.php
  49. 27
      theme/islandora-dublin-core-display.tpl.php
  50. 4
      theme/islandora-object-edit.tpl.php
  51. 1
      theme/islandora-object-print.tpl.php
  52. 30
      theme/islandora-object.tpl.php
  53. 6
      theme/islandora-objects.tpl.php
  54. 8
      theme/theme.inc

9
css/islandora.admin.css

@ -5,19 +5,16 @@
/* Solution pack admin page */ /* Solution pack admin page */
.islandora-solution-pack-fieldset .islandora-solution-pack-fieldset {
{
padding-top: 0.5em; padding-top: 0.5em;
} }
.islandora-solution-pack-fieldset table th, .islandora-solution-pack-fieldset table th,
.islandora-solution-pack-fieldset table td .islandora-solution-pack-fieldset table td {
{
width: 30%; width: 30%;
} }
.islandora-solution-pack-fieldset table th:first-child, .islandora-solution-pack-fieldset table th:first-child,
.islandora-solution-pack-fieldset table td:first-child .islandora-solution-pack-fieldset table td:first-child {
{
width: 10%; width: 10%;
} }

8
css/islandora.base.css

@ -26,7 +26,7 @@
dl.islandora-inline-metadata { dl.islandora-inline-metadata {
margin: 0 auto; margin: 0 auto;
letter-spacing: -0.31em; letter-spacing: -0.31em;
*letter-spacing:normal; *letter-spacing: normal;
word-spacing: -0.43em; word-spacing: -0.43em;
} }
@ -44,17 +44,17 @@ dl.islandora-inline-metadata {
} }
dl.islandora-metadata-fields { dl.islandora-metadata-fields {
width:100%; width: 100%;
} }
.islandora-metadata dt, .islandora-metadata dt,
.islandora-metadata dd { .islandora-metadata dd {
border-top:1px solid #e5e5e5; border-top: 1px solid #e5e5e5;
} }
.islandora-metadata dt.first, .islandora-metadata dt.first,
.islandora-metadata dd.first { .islandora-metadata dd.first {
border-top:0; border-top: 0;
} }
/* /*
* In this rule, we reset the white-space (see hack above) * In this rule, we reset the white-space (see hack above)

20
css/islandora.print.css

@ -5,21 +5,11 @@
* We provide some sane print styling for Drupal, hiding most visuals. * We provide some sane print styling for Drupal, hiding most visuals.
*/ */
#content a[href^="javascript:"]:after,
#content a[href^="#"]:after { /* Only display useful links. */
/* content: ""; */
}
#content abbr[title]:after { /* Add visible title after abbreviations. */
/* content: " (" attr(title) ")"; */
}
#content { #content {
left: 0 !important; left: 0 !important;
width: 100% !important; width: 100% !important;
} }
uncomment when ready to test printing uncomment when ready to test printing #header {
#header {
display: none !important; display: none !important;
} }
@ -40,8 +30,8 @@ body,
} }
body.sidebar-first { body.sidebar-first {
left: 0 !important; left: 0 !important;
width: 100% !important; width: 100% !important;
} }
#skip-link, #skip-link,
#toolbar, #toolbar,

2
includes/add_datastream.form.inc

@ -227,7 +227,7 @@ function islandora_add_datastream_form_autocomplete_callback(AbstractObject $obj
$dsids = array_combine($dsids, $dsids); $dsids = array_combine($dsids, $dsids);
$query = trim($query); $query = trim($query);
if (!empty($query)) { if (!empty($query)) {
$filter = function($id) use($query) { $filter = function ($id) use ($query) {
return stripos($id, $query) !== FALSE; return stripos($id, $query) !== FALSE;
}; };
$dsids = array_filter($dsids, $filter); $dsids = array_filter($dsids, $filter);

13
includes/admin.form.inc

@ -48,7 +48,8 @@ function islandora_repository_admin(array $form, array &$form_state) {
'#title' => t('Fedora base URL'), '#title' => t('Fedora base URL'),
'#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'), '#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'),
'#description' => t('The URL to use for REST connections <br/> !confirmation_message', array( '#description' => t('The URL to use for REST connections <br/> !confirmation_message', array(
'!confirmation_message' => $confirmation_message)), '!confirmation_message' => $confirmation_message,
)),
'#required' => TRUE, '#required' => TRUE,
'#ajax' => array( '#ajax' => array(
'callback' => 'islandora_update_url_div', 'callback' => 'islandora_update_url_div',
@ -225,17 +226,21 @@ function islandora_admin_settings_form_repository_access_message($url) {
if ($info && $dc) { if ($info && $dc) {
$confirmation_message = theme_image(array('path' => 'misc/watchdog-ok.png', 'attributes' => array())); $confirmation_message = theme_image(array('path' => 'misc/watchdog-ok.png', 'attributes' => array()));
$confirmation_message .= t('Successfully connected to Fedora Server (Version !version).', array( $confirmation_message .= t('Successfully connected to Fedora Server (Version !version).', array(
'!version' => $info['repositoryVersion'])); '!version' => $info['repositoryVersion'],
));
} }
elseif ($info) { elseif ($info) {
$confirmation_message = theme_image(array('path' => 'misc/watchdog-warning.png', 'attributes' => array())); $confirmation_message = theme_image(array('path' => 'misc/watchdog-warning.png', 'attributes' => array()));
$confirmation_message .= t('Unable to authenticate when connecting to to Fedora Server (Version !version). Please configure the !filter.', array( $confirmation_message .= t('Unable to authenticate when connecting to to Fedora Server (Version !version). Please configure the !filter.', array(
'!version' => $info['repositoryVersion'], '!filter' => 'Drupal Filter')); '!version' => $info['repositoryVersion'],
'!filter' => 'Drupal Filter',
));
} }
else { else {
$confirmation_message = theme_image(array('path' => 'misc/watchdog-error.png', 'attributes' => array())); $confirmation_message = theme_image(array('path' => 'misc/watchdog-error.png', 'attributes' => array()));
$confirmation_message .= t('Unable to connect to Fedora server at !islandora_url', array( $confirmation_message .= t('Unable to connect to Fedora server at !islandora_url', array(
'!islandora_url' => $url)); '!islandora_url' => $url,
));
} }
return $confirmation_message; return $confirmation_message;
} }

10
includes/authtokens.inc

@ -104,11 +104,11 @@ function islandora_validate_object_token($pid, $dsid, $token) {
// Decrement authentication token uses. // Decrement authentication token uses.
else { else {
db_update("islandora_authtokens") db_update("islandora_authtokens")
->fields(array('remaining_uses' => $remaining_uses)) ->fields(array('remaining_uses' => $remaining_uses))
->condition('token', $token, '=') ->condition('token', $token, '=')
->condition('pid', $pid, '=') ->condition('pid', $pid, '=')
->condition('dsid', $dsid, '=') ->condition('dsid', $dsid, '=')
->execute(); ->execute();
} }
unset($result[0]->remaining_uses); unset($result[0]->remaining_uses);
$accounts[$pid][$dsid][$token] = $result[0]; $accounts[$pid][$dsid][$token] = $result[0];

3
includes/content_model.autocomplete.inc

@ -1,4 +1,5 @@
<?php <?php
/** /**
* @file * @file
* Autocomplete functionality for content models in Islandora. * Autocomplete functionality for content models in Islandora.
@ -46,7 +47,7 @@ function islandora_get_content_model_names() {
* @return array * @return array
* An array of results in a more usable format. * An array of results in a more usable format.
*/ */
function islandora_parse_query($content) { function islandora_parse_query(array $content) {
$content_models = array(); $content_models = array();
foreach ($content as $model) { foreach ($content as $model) {
$content_models[] = $model['object']['value']; $content_models[] = $model['object']['value'];

30
includes/datastream.inc

@ -18,16 +18,16 @@ function islandora_download_datastream(AbstractDatastream $datastream) {
/** /**
* Callback function to view or download a datastream. * Callback function to view or download a datastream.
* *
* @note
* This function calls exit().
*
* @param AbstractDatastream $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.
* @param int $version * @param int $version
* The version of the datastream to display * The version of the datastream to display.
*
* @note
* This function calls exit().
*/ */
function islandora_view_datastream(AbstractDatastream $datastream, $download = FALSE, $version = NULL) { function islandora_view_datastream(AbstractDatastream $datastream, $download = FALSE, $version = NULL) {
module_load_include('inc', 'islandora', 'includes/mimetype.utils'); module_load_include('inc', 'islandora', 'includes/mimetype.utils');
@ -120,14 +120,14 @@ function islandora_view_datastream(AbstractDatastream $datastream, $download = F
* - fdsa * - fdsa
* - 2132 * - 2132
* *
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26
*
* @param string $header_value * @param string $header_value
* The value from the headers. * The value from the headers.
* *
* @return array * @return array
* An array containing all the etags present. * An array containing all the etags present.
*
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26
*/ */
function islandora_parse_http_match_headers($header_value) { function islandora_parse_http_match_headers($header_value) {
$matches = array(); $matches = array();
@ -268,7 +268,7 @@ function islandora_datastream_get_human_readable_size(AbstractDatastream $datast
* @param string $type * @param string $type
* One of: * One of:
* - download * - download
* - view * - view.
* @param int $version * @param int $version
* (Optional) The version of the datastream to get a URL for. * (Optional) The version of the datastream to get a URL for.
* *
@ -380,7 +380,7 @@ function islandora_view_datastream_set_chunk_headers(AbstractDatastream $datastr
$c_start = $size - substr($range, 1); $c_start = $size - substr($range, 1);
} }
else { else {
$range = explode('-', $range); $range = explode('-', $range);
$c_start = $range[0]; $c_start = $range[0];
$c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
} }
@ -395,8 +395,8 @@ function islandora_view_datastream_set_chunk_headers(AbstractDatastream $datastr
header("Content-Range: bytes $start-$end/$size"); header("Content-Range: bytes $start-$end/$size");
exit; exit;
} }
$start = $c_start; $start = $c_start;
$end = $c_end; $end = $c_end;
// Calculate new content length. // Calculate new content length.
$length = $end - $start + 1; $length = $end - $start + 1;
header('HTTP/1.1 206 Partial Content'); header('HTTP/1.1 206 Partial Content');
@ -418,7 +418,7 @@ function islandora_view_datastream_set_chunk_headers(AbstractDatastream $datastr
* @param array $params * @param array $params
* An associate array containing the start and ending chunk bytes. * An associate array containing the start and ending chunk bytes.
*/ */
function islandora_view_datastream_deliver_chunks(AbstractDatastream $datastream, $params) { function islandora_view_datastream_deliver_chunks(AbstractDatastream $datastream, array $params) {
$file_uri = islandora_view_datastream_retrieve_file_uri($datastream); $file_uri = islandora_view_datastream_retrieve_file_uri($datastream);
// The meat of this has been taken from: // The meat of this has been taken from:
// http://mobiforge.com/design-development/content-delivery-mobile-devices. // http://mobiforge.com/design-development/content-delivery-mobile-devices.
@ -445,14 +445,14 @@ function islandora_view_datastream_deliver_chunks(AbstractDatastream $datastream
* File locks are used to ensure the datastream is completely downloaded before * File locks are used to ensure the datastream is completely downloaded before
* attempting to serve up chunks from the file. * attempting to serve up chunks from the file.
* *
* @throws RepositoryException|Exception
* Exceptions may be thrown if the file was unable to be reliably acquired.
*
* @param AbstractDatastream $datastream * @param AbstractDatastream $datastream
* An AbstractDatastream representing a datastream on a Fedora object. * An AbstractDatastream representing a datastream on a Fedora object.
* *
* @return string * @return string
* The URI of the file. * The URI of the file.
*
* @throws RepositoryException|Exception
* Exceptions may be thrown if the file was unable to be reliably acquired.
*/ */
function islandora_view_datastream_retrieve_file_uri(AbstractDatastream $datastream) { function islandora_view_datastream_retrieve_file_uri(AbstractDatastream $datastream) {
module_load_include('inc', 'islandora', 'includes/mimetype.utils'); module_load_include('inc', 'islandora', 'includes/mimetype.utils');

31
includes/datastream.version.inc

@ -142,15 +142,17 @@ function islandora_delete_datastream_version_form_submit(array $form, array &$fo
} }
catch (Exception $e) { catch (Exception $e) {
drupal_set_message(t('Error deleting version %v of %s datastream from object %o %e', array( drupal_set_message(t('Error deleting version %v of %s datastream from object %o %e', array(
'%v' => $version, '%v' => $version,
'%s' => $datastream_id, '%s' => $datastream_id,
'%o' => $object->label, '%o' => $object->label,
'%e' => $e->getMessage())), 'error'); '%e' => $e->getMessage(),
)), 'error');
} }
drupal_set_message(t('%d datastream version successfully deleted from Islandora object %o', array( drupal_set_message(t('%d datastream version successfully deleted from Islandora object %o', array(
'%d' => $datastream_id, '%d' => $datastream_id,
'%o' => $object->label))); '%o' => $object->label,
)));
$form_state['redirect'] = "islandora/object/{$object->id}/datastream/{$datastream->id}/version"; $form_state['redirect'] = "islandora/object/{$object->id}/datastream/{$datastream->id}/version";
} }
@ -224,9 +226,10 @@ function islandora_revert_datastream_version_form_submit(array $form, array &$fo
} }
drupal_set_message(t('%d datastream successfully reverted to version %v for Islandora object %o', array( drupal_set_message(t('%d datastream successfully reverted to version %v for Islandora object %o', array(
'%d' => $datastream_to_revert->id, '%d' => $datastream_to_revert->id,
'%v' => $version, '%v' => $version,
'%o' => $islandora_object->label))); '%o' => $islandora_object->label,
)));
$form_state['redirect'] = "islandora/object/{$islandora_object->id}/datastream/{$datastream_to_revert->id}/version"; $form_state['redirect'] = "islandora/object/{$islandora_object->id}/datastream/{$datastream_to_revert->id}/version";
} }
@ -235,9 +238,9 @@ function islandora_revert_datastream_version_form_submit(array $form, array &$fo
* Process available dsids, mime and extensions for a given object. * Process available dsids, mime and extensions for a given object.
* *
* @param AbstractObject $object * @param AbstractObject $object
* The FedoraObject to process available extensions * The FedoraObject to process available extensions.
* *
* @return array() * @return array
* An associative array, merged from calls to * An associative array, merged from calls to
* islandora_get_datastreams_requirements_from_content_models() * islandora_get_datastreams_requirements_from_content_models()
* and an objects dsid's. * and an objects dsid's.
@ -272,7 +275,7 @@ function islandora_get_object_extensions(AbstractObject $object) {
* @return array * @return array
* The drupal form definition. * The drupal form definition.
*/ */
function islandora_datastream_version_replace_form($form, &$form_state, AbstractDatastream $datastream) { function islandora_datastream_version_replace_form(array $form, array &$form_state, AbstractDatastream $datastream) {
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');
module_load_include('inc', 'islandora', 'includes/mimetype.utils'); module_load_include('inc', 'islandora', 'includes/mimetype.utils');
@ -330,7 +333,7 @@ function islandora_datastream_version_replace_form($form, &$form_state, Abstract
* @param array $form_state * @param array $form_state
* The Drupal form state. * The Drupal form state.
*/ */
function islandora_datastream_version_replace_form_submit($form, &$form_state) { function islandora_datastream_version_replace_form_submit(array $form, array &$form_state) {
$object = islandora_object_load($form_state['object_id']); $object = islandora_object_load($form_state['object_id']);
$form_state['redirect'] = "islandora/object/{$object->id}"; $form_state['redirect'] = "islandora/object/{$object->id}";
$file = file_load($form_state['values']['file']); $file = file_load($form_state['values']['file']);
@ -363,7 +366,7 @@ function islandora_datastream_version_replace_form_submit($form, &$form_state) {
* Gets Audit datastream values from foxml. * Gets Audit datastream values from foxml.
* *
* @param string $pid * @param string $pid
* PID of parent object * PID of parent object.
* *
* @return array * @return array
* Array of audit values * Array of audit values

17
includes/delete_datastream.form.inc

@ -127,19 +127,22 @@ function islandora_delete_datastream_form_submit(array $form, array &$form_state
} }
catch (Exception $e) { catch (Exception $e) {
drupal_set_message(t('Error deleting %s datastream from object %o %e', array( drupal_set_message(t('Error deleting %s datastream from object %o %e', array(
'%s' => $datastream_id, '%s' => $datastream_id,
'%o' => $object->label, '%o' => $object->label,
'%e' => $e->getMessage())), 'error'); '%e' => $e->getMessage(),
)), 'error');
} }
if ($deleted) { if ($deleted) {
drupal_set_message(t('%d datastream sucessfully deleted from Islandora object %o', array( drupal_set_message(t('%d datastream sucessfully deleted from Islandora object %o', array(
'%d' => $datastream_id, '%d' => $datastream_id,
'%o' => $object->label))); '%o' => $object->label,
)));
} }
else { else {
drupal_set_message(t('Error deleting %s datastream from object %o', array( drupal_set_message(t('Error deleting %s datastream from object %o', array(
'%s' => $datastream_id, '%s' => $datastream_id,
'%o' => $object->label)), 'error'); '%o' => $object->label,
)), 'error');
} }
$form_state['redirect'] = "islandora/object/{$object->id}"; $form_state['redirect'] = "islandora/object/{$object->id}";
} }

7
includes/derivatives.inc

@ -1,4 +1,5 @@
<?php <?php
/** /**
* @file * @file
* Defines functions used when constructing derivatives. * Defines functions used when constructing derivatives.
@ -209,7 +210,7 @@ function islandora_do_batch_derivatives(AbstractObject $object, array $options)
* @return array * @return array
* Returns the filtered array of hooks to be ran. * Returns the filtered array of hooks to be ran.
*/ */
function islandora_filter_derivatives($hooks, $options, AbstractObject $object) { function islandora_filter_derivatives(array $hooks, array $options, AbstractObject $object) {
if (array_key_exists('source_dsid', $options)) { if (array_key_exists('source_dsid', $options)) {
$hooks = array_filter($hooks, function ($filter_hook) use ($options) { $hooks = array_filter($hooks, function ($filter_hook) use ($options) {
return array_key_exists('source_dsid', $filter_hook) && return array_key_exists('source_dsid', $filter_hook) &&
@ -284,10 +285,10 @@ function islandora_remove_defer_derivatives_flag(AbstractObject $object) {
* *
* @param AbstractObject $object * @param AbstractObject $object
* The object to find derivatives for. * The object to find derivatives for.
* @param &array $options * @param array $options
* Options for derivatives, will be updated to default force to FALSE. * Options for derivatives, will be updated to default force to FALSE.
*/ */
function islandora_get_derivative_list(AbstractObject $object, &$options) { function islandora_get_derivative_list(AbstractObject $object, array &$options) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$ds_modified_params = isset($options['ds_modified_params']) ? $options['ds_modified_params'] : array(); $ds_modified_params = isset($options['ds_modified_params']) ? $options['ds_modified_params'] : array();

7
includes/dublin_core.inc

@ -9,7 +9,7 @@
*/ */
/** /**
* Dublin Core Class * Dublin Core Class.
*/ */
class DublinCore { class DublinCore {
@ -81,7 +81,7 @@ class DublinCore {
* @return string * @return string
* The serialized XML. * The serialized XML.
*/ */
public function asXML() { public function asXml() {
$dc_xml = new DomDocument(); $dc_xml = new DomDocument();
$oai_dc = $dc_xml->createElementNS('http://www.openarchives.org/OAI/2.0/oai_dc/', 'oai_dc:dc'); $oai_dc = $dc_xml->createElementNS('http://www.openarchives.org/OAI/2.0/oai_dc/', 'oai_dc:dc');
$oai_dc->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $oai_dc->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
@ -152,7 +152,8 @@ class DublinCore {
* @return DublinCore * @return DublinCore
* The instantiated object. * The instantiated object.
*/ */
public static function importFromXMLString($dc_xml) { // @codingStandardsIgnoreLine
public static function importFromXmlString($dc_xml) {
$dc_doc = new DomDocument(); $dc_doc = new DomDocument();
if (!empty($dc_xml) && $dc_doc->loadXML($dc_xml)) { if (!empty($dc_xml) && $dc_doc->loadXML($dc_xml)) {
$oai_dc = $dc_doc->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/', '*'); $oai_dc = $dc_doc->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/', '*');

26
includes/ingest.form.inc

@ -65,7 +65,9 @@ function islandora_ingest_form(array $form, array &$form_state, array $configura
); );
drupal_set_message($e->getMessage(), 'error'); drupal_set_message($e->getMessage(), 'error');
return array(array( return array(array(
'#markup' => l(t('Back'), 'javascript:window.history.back();', array('external' => TRUE)))); '#markup' => l(t('Back'), 'javascript:window.history.back();', array('external' => TRUE)),
),
);
} }
} }
@ -285,7 +287,7 @@ function islandora_ingest_form_increment_step(array &$form_state) {
* The Drupal form state. * The Drupal form state.
*/ */
function islandora_ingest_form_decrement_step(array &$form_state) { function islandora_ingest_form_decrement_step(array &$form_state) {
$previous_step_id = islandora_ingest_form_get_previous_step_id($form_state); $previous_step_id = islandora_ingest_form_get_previous_step_id($form_state);
// Don't decrement passed the first step. // Don't decrement passed the first step.
if (isset($previous_step_id)) { if (isset($previous_step_id)) {
islandora_ingest_form_stash_info($form_state); islandora_ingest_form_stash_info($form_state);
@ -496,7 +498,7 @@ function islandora_ingest_form_stepify(array $form, array &$form_state, array $s
*/ */
function islandora_ingest_form_add_step_context(array &$form, array $form_state) { function islandora_ingest_form_add_step_context(array &$form, array $form_state) {
$items = array(); $items = array();
$get_label = function(AbstractObject $collection = NULL, AbstractObject $fedora_cmodel) { $get_label = function (AbstractObject $collection = NULL, AbstractObject $fedora_cmodel) {
if (isset($collection['COLLECTION_POLICY'])) { if (isset($collection['COLLECTION_POLICY'])) {
$policy = new CollectionPolicy($collection['COLLECTION_POLICY']->content); $policy = new CollectionPolicy($collection['COLLECTION_POLICY']->content);
$policy_content_models = $policy->getContentModels(); $policy_content_models = $policy->getContentModels();
@ -876,18 +878,18 @@ function &islandora_ingest_form_get_objects(array &$form_state) {
/** /**
* Gets a single object from the stored NewFedoraObject's. * Gets a single object from the stored NewFedoraObject's.
* *
* @note In our current use case we are only dealing with a single object
* ingest, this makes it convenient to access it. Ideally the steps
* implementations will be abstracted to be indifferent to what object it's
* currently working on. This will act as a placeholder for such
* functionality.
*
* @param array $form_state * @param array $form_state
* The Drupal form state. * The Drupal form state.
* *
* @return NewFedoraObject * @return NewFedoraObject
* Returns the 'current' object in the array of NewFedoraObjects, generally * Returns the 'current' object in the array of NewFedoraObjects, generally
* this is only used when there is one object in the list of objects. * this is only used when there is one object in the list of objects.
*
* @note In our current use case we are only dealing with a single object
* ingest, this makes it convenient to access it. Ideally the steps
* implementations will be abstracted to be indifferent to what object it's
* currently working on. This will act as a placeholder for such
* functionality.
*/ */
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);
@ -899,7 +901,7 @@ function islandora_ingest_form_get_object(array &$form_state) {
* *
* @param array $form_state * @param array $form_state
* The Drupal form state. * The Drupal form state.
* @param array $step_id * @param string $step_id
* The ID of the step. * The ID of the step.
* *
* @return array * @return array
@ -1004,7 +1006,7 @@ function islandora_ingest_form_get_steps(array &$form_state) {
*/ */
function islandora_ingest_form_get_form_steps(array &$form_state) { function islandora_ingest_form_get_form_steps(array &$form_state) {
$steps = islandora_ingest_form_get_steps($form_state); $steps = islandora_ingest_form_get_steps($form_state);
$form_step_filter = function($o) { $form_step_filter = function ($o) {
return $o['type'] == 'form'; return $o['type'] == 'form';
}; };
return array_filter($steps, $form_step_filter); return array_filter($steps, $form_step_filter);
@ -1022,7 +1024,7 @@ function islandora_ingest_form_get_form_steps(array &$form_state) {
*/ */
function islandora_ingest_form_get_callback_steps(array &$form_state) { function islandora_ingest_form_get_callback_steps(array &$form_state) {
$steps = islandora_ingest_form_get_steps($form_state); $steps = islandora_ingest_form_get_steps($form_state);
$callback_step_filter = function($o) { $callback_step_filter = function ($o) {
return $o['type'] == 'callback'; return $o['type'] == 'callback';
}; };
return array_filter($steps, $callback_step_filter); return array_filter($steps, $callback_step_filter);

23
includes/manage_deleted_objects.inc

@ -16,7 +16,7 @@
* @return array * @return array
* The Drupal form definition. * The Drupal form definition.
*/ */
function islandora_deleted_objects_prep_form($form, $form_state, $serialized_chosen = NULL) { function islandora_deleted_objects_prep_form(array $form, array $form_state, $serialized_chosen = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$chosen_contentmodels = array(); $chosen_contentmodels = array();
if ($serialized_chosen) { if ($serialized_chosen) {
@ -67,9 +67,9 @@ function islandora_deleted_objects_prep_form($form, $form_state, $serialized_cho
* @param array $form_state * @param array $form_state
* The form state. * The form state.
*/ */
function islandora_deleted_objects_prep_form_submit($form, $form_state) { function islandora_deleted_objects_prep_form_submit(array $form, array $form_state) {
$content_models = $form_state['values']['contentmodels']; $content_models = $form_state['values']['contentmodels'];
$chosen = function($element) { $chosen = function ($element) {
return $element; return $element;
}; };
$serialized_contentmodels = serialize(array_filter($content_models, $chosen)); $serialized_contentmodels = serialize(array_filter($content_models, $chosen));
@ -87,7 +87,7 @@ function islandora_deleted_objects_prep_form_submit($form, $form_state) {
* @return array * @return array
* The Drupal form definition. * The Drupal form definition.
*/ */
function islandora_deleted_objects_manage_form($form, $form_state, $serialized_chosen = NULL) { function islandora_deleted_objects_manage_form(array $form, array $form_state, $serialized_chosen = NULL) {
$form['previous'] = array( $form['previous'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Previous'), '#value' => t('Previous'),
@ -186,7 +186,7 @@ function islandora_deleted_objects_manage_form($form, $form_state, $serialized_c
* @param array $form_state * @param array $form_state
* The form state. * The form state.
*/ */
function islandora_deleted_objects_manage_form_submit($form, $form_state) { function islandora_deleted_objects_manage_form_submit(array $form, array $form_state) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$serialized_chosen = isset($form_state['values']['serialized_chosen']) ? $form_state['values']['serialized_chosen'] : NULL; $serialized_chosen = isset($form_state['values']['serialized_chosen']) ? $form_state['values']['serialized_chosen'] : NULL;
@ -246,7 +246,8 @@ function islandora_get_deleted_objects($content_models, $limit, $offset) {
$cm_pid = $object['object']['value']; $cm_pid = $object['object']['value'];
$title = $object['label']['value']; $title = $object['label']['value'];
$deleted_objects[$pid] = array( $deleted_objects[$pid] = array(
'title' => $title, 'pid' => $pid, 'title' => $title,
'pid' => $pid,
'content_model' => $content_models[$cm_pid], 'content_model' => $content_models[$cm_pid],
); );
} }
@ -288,7 +289,7 @@ function islandora_get_contentmodels_with_deleted_members() {
* Restores deleted object. * Restores deleted object.
* *
* @param string $pid * @param string $pid
* PID of object to be restored * PID of object to be restored.
*/ */
function islandora_restore_object_by_pid($pid) { function islandora_restore_object_by_pid($pid) {
$fedora_object = islandora_object_load($pid); $fedora_object = islandora_object_load($pid);
@ -299,7 +300,7 @@ function islandora_restore_object_by_pid($pid) {
* Purges deleted object. * Purges deleted object.
* *
* @param string $pid * @param string $pid
* PID of object to be restored * PID of object to be restored.
*/ */
function islandora_purge_object_by_pid($pid) { function islandora_purge_object_by_pid($pid) {
$fedora_object = islandora_object_load($pid); $fedora_object = islandora_object_load($pid);
@ -310,14 +311,14 @@ function islandora_purge_object_by_pid($pid) {
* Get query to find all deleted objects by content type. * Get query to find all deleted objects by content type.
* *
* @param array $content_models * @param array $content_models
* Content models to restrict search * Content models to restrict search.
* @param int $offset * @param int $offset
* offset to be added to search * Offset to be added to search.
* *
* @return string * @return string
* Sparql query * Sparql query
*/ */
function islandora_get_deleted_query($content_models, $offset = 0) { function islandora_get_deleted_query(array $content_models, $offset = 0) {
$candidates = array_keys($content_models); $candidates = array_keys($content_models);
$first_contentmodel = array_shift($candidates); $first_contentmodel = array_shift($candidates);
$prefix = "PREFIX fm: <" . FEDORA_MODEL_URI . "> "; $prefix = "PREFIX fm: <" . FEDORA_MODEL_URI . "> ";

7
includes/metadata.inc

@ -1,4 +1,5 @@
<?php <?php
/** /**
* @file * @file
* Defines functions used when viewing metadata displays on Islandora objects. * Defines functions used when viewing metadata displays on Islandora objects.
@ -70,7 +71,7 @@ function islandora_retrieve_description_markup(AbstractObject $object) {
* @return array * @return array
* An array representing the metadata display viewer form. * An array representing the metadata display viewer form.
*/ */
function islandora_metadata_display_form($form, $form_state) { function islandora_metadata_display_form(array $form, array $form_state) {
module_load_include('inc', 'islandora', 'includes/solution_packs.inc'); module_load_include('inc', 'islandora', 'includes/solution_packs.inc');
$form = array(); $form = array();
$defined_displays = module_invoke_all('islandora_metadata_display_info'); $defined_displays = module_invoke_all('islandora_metadata_display_info');
@ -106,7 +107,7 @@ function islandora_metadata_display_form($form, $form_state) {
); );
$form['viewers']['configuration'][$name] = array( $form['viewers']['configuration'][$name] = array(
'#type' => 'item', '#type' => 'item',
'#markup' => (isset($profile['configuration']) AND $profile['configuration'] != '') ? l(t('configure'), $profile['configuration']) : '', '#markup' => (isset($profile['configuration']) and $profile['configuration'] != '') ? l(t('configure'), $profile['configuration']) : '',
); );
} }
$form['viewers']['default'] = array( $form['viewers']['default'] = array(
@ -135,7 +136,7 @@ function islandora_metadata_display_form($form, $form_state) {
* @param array $form_state * @param array $form_state
* An array containing the Drupal form state. * An array containing the Drupal form state.
*/ */
function islandora_metadata_display_form_submit($form, $form_state) { function islandora_metadata_display_form_submit(array $form, array $form_state) {
variable_set('islandora_metadata_display', $form_state['values']['viewers']['default']); variable_set('islandora_metadata_display', $form_state['values']['viewers']['default']);
drupal_set_message(t('The configuration options have been saved.')); drupal_set_message(t('The configuration options have been saved.'));
} }

116
includes/mime_detect.inc

@ -21,50 +21,85 @@
* http://api.drupal.org/api/function/file_default_mimetype_mapping/7 * http://api.drupal.org/api/function/file_default_mimetype_mapping/7
*/ */
/**
* Class for doing mapping to mimetypes.
*/
class MimeDetect { class MimeDetect {
/**
* This is a shortlist of mimetypes.
*
* It should catch most mimetype<-->extension lookups in the context of
* Islandora collections.
*
* It has been cut from a much longer list.
*
* Two types of mimetypes should be put in this list:
* 1) Special emerging formats which may not yet be expressed in the system
* mime.types file.
* 2) Heavily used mimetypes of particular importance to the Islandora
* project, as lookups against this list will be quicker and less
* resource intensive than other methods.
*
* Lookups are first checked against this short list. If no results are
* found, then the lookup function may move on to check other sources,
* namely the system's mime.types file.
*
* In most cases though, this short list should suffice.
*
* If modifying this list, please note that for promiscuous mimetypes
* (those which map to multiple extensions, such as text/plain)
* The function get_extension will always return the *LAST* extension in
* this list, so you should put your preferred extension *LAST*.
*
* e.g...
* "jpeg" => "image/jpeg",
* "jpe" => "image/jpeg",
* "jpg" => "image/jpeg",
*
* $this->get_extension('image/jpeg') will always return 'jpg'.
*
* @var array
*/
protected $protectedMimeTypes;
protected $protectedMimeTypes = array( /**
/* * This is a shortlist of file extensions.
* This is a shortlist of mimetypes which should catch most *
* mimetype<-->extension lookups in the context of Islandora collections. * @var array
* */
* It has been cut from a much longer list.
*
* Two types of mimetypes should be put in this list:
* 1) Special emerging formats which may not yet be expressed in the system
* mime.types file.
* 2) Heavily used mimetypes of particular importance to the Islandora
* project, as lookups against this list will be quicker and less
* resource intensive than other methods.
*
* Lookups are first checked against this short list. If no results are
* found, then the lookup function may move on to check other sources,
* namely the system's mime.types file.
*
* In most cases though, this short list should suffice.
*
* If modifying this list, please note that for promiscuous mimetypes
* (those which map to multiple extensions, such as text/plain)
* The function get_extension will always return the *LAST* extension in
* this list, so you should put your preferred extension *LAST*.
*
* e.g...
* "jpeg" => "image/jpeg",
* "jpe" => "image/jpeg",
* "jpg" => "image/jpeg",
*
* $this->get_extension('image/jpeg') will always return 'jpg'.
*
*/
);
protected $protectedFileExtensions; protected $protectedFileExtensions;
/**
* Extension exceptions.
*
* XXX: Deprecated... Only here due to old 'tif' => 'image/tif' mapping...
* The correct MIMEtype is 'image/tiff'.
*
* @var array
*/
protected $extensionExceptions = array( protected $extensionExceptions = array(
// XXX: Deprecated... Only here due to old 'tif' => 'image/tif' mapping...
// The correct MIMEtype is 'image/tiff'.
'image/tif' => 'tif', 'image/tif' => 'tif',
); );
/**
* Stores the system list of mimetypes.
*
* @var array
*/
protected $systemTypes; protected $systemTypes;
/**
* Stores the system list of extensions.
*
* @var array
*/
protected $systemExts; protected $systemExts;
/**
* System mime.types file location.
*
* @var string
*/
protected $etcMimeTypes = '/etc/mime.types'; protected $etcMimeTypes = '/etc/mime.types';
/** /**
@ -87,7 +122,7 @@ class MimeDetect {
* Gets MIME type associated with the give file's extension. * Gets MIME type associated with the give file's extension.
* *
* @param string $filename * @param string $filename
* The filename * The filename.
* @param bool $debug * @param bool $debug
* Returns a debug array. * Returns a debug array.
* *
@ -171,7 +206,8 @@ class MimeDetect {
/** /**
* Gets an associative array of MIME type and extension associations. * Gets an associative array of MIME type and extension associations.
* *
* Users the system mime.types file, or a local mime.types if one is found * Users the system mime.types file, or a local mime.types if one is found.
*
* @see MIMEDetect::__constuctor() * @see MIMEDetect::__constuctor()
* *
* @return array * @return array
@ -206,7 +242,8 @@ class MimeDetect {
/** /**
* Gets a associative array of extensions and MIME types. * Gets a associative array of extensions and MIME types.
* *
* Users the system mime.types file, or a local mime.types if one is found * Users the system mime.types file, or a local mime.types if one is found.
*
* @see MIMEDetect::__constuctor() * @see MIMEDetect::__constuctor()
* *
* @return array * @return array
@ -262,4 +299,5 @@ class MimeDetect {
}; };
return array_keys(array_filter($this->protectedMimeTypes, $filter)); return array_keys(array_filter($this->protectedMimeTypes, $filter));
} }
} }

1
includes/mime_type.autocomplete.inc

@ -1,4 +1,5 @@
<?php <?php
/** /**
* @file * @file
* Autocomplete functionality for MIME types in Islandora. * Autocomplete functionality for MIME types in Islandora.

2
includes/mimetype.utils.inc

@ -268,7 +268,7 @@ function islandora_mime_mapping() {
// Web Archives: // Web Archives:
"warc" => "application/warc", "warc" => "application/warc",
"json" => "application/json", "json" => "application/json",
// JSON-LD // JSON-LD.
"jsonld" => "application/ld+json", "jsonld" => "application/ld+json",
); );
} }

6
includes/object.entity_controller.inc

@ -5,6 +5,9 @@
* Very basic entity controller. * Very basic entity controller.
*/ */
/**
* Very basic entity controller for Islandora.
*/
class IslandoraObjectEntityController implements DrupalEntityControllerInterface { class IslandoraObjectEntityController implements DrupalEntityControllerInterface {
/** /**
@ -28,7 +31,7 @@ class IslandoraObjectEntityController implements DrupalEntityControllerInterface
* @return array * @return array
* An array of loaded objects. * An array of loaded objects.
*/ */
public function load($ids = array(), $conditions = array()) { public function load(array $ids = array(), array $conditions = array()) {
if (!empty($conditions)) { if (!empty($conditions)) {
// TODO: Allow loading by specifying IDs in the condition. // TODO: Allow loading by specifying IDs in the condition.
throw new Exception('Conditions not implemented.'); throw new Exception('Conditions not implemented.');
@ -54,4 +57,5 @@ class IslandoraObjectEntityController implements DrupalEntityControllerInterface
public function resetCache(array $ids = NULL) { public function resetCache(array $ids = NULL) {
// no-op. // no-op.
} }
} }

13
includes/object_properties.form.inc

@ -90,7 +90,8 @@ function islandora_object_properties_form(array $form, array &$form_state, Abstr
'#type' => 'submit', '#type' => 'submit',
'#access' => islandora_object_access(ISLANDORA_PURGE, $object), '#access' => islandora_object_access(ISLANDORA_PURGE, $object),
'#value' => t("Permanently remove '@label' from repository", array( '#value' => t("Permanently remove '@label' from repository", array(
'@label' => truncate_utf8($object->label, 32, TRUE, TRUE)) '@label' => truncate_utf8($object->label, 32, TRUE, TRUE),
)
), ),
'#submit' => array('islandora_object_properties_form_delete'), '#submit' => array('islandora_object_properties_form_delete'),
'#limit_validation_errors' => array(array('pid')), '#limit_validation_errors' => array(array('pid')),
@ -200,15 +201,15 @@ function islandora_object_properties_form_delete(array $form, array &$form_state
* Updates object state. * Updates object state.
* *
* @param string $pid * @param string $pid
* PID of object to be updated * PID of object to be updated.
* @param bool $update_states * @param bool $update_states
* If TRUE, update object state * If TRUE, update object state.
* @param string $state * @param string $state
* Desired object state * Desired object state.
* @param bool $update_owners * @param bool $update_owners
* If TRUE, update Owner * If TRUE, update Owner.
* @param string $owner * @param string $owner
* New Owner * New Owner.
*/ */
function islandora_update_object_properties($pid, $update_states, $state, $update_owners, $owner) { function islandora_update_object_properties($pid, $update_states, $state, $update_owners, $owner) {
$fedora_object = islandora_object_load($pid); $fedora_object = islandora_object_load($pid);

10
includes/regenerate_derivatives.form.inc

@ -122,8 +122,8 @@ function islandora_regenerate_datastream_derivative_batch(AbstractDatastream $da
return array( return array(
'title' => t('Regenerating derivatives for the @dsid datastream', array('@dsid' => $datastream->id)), 'title' => t('Regenerating derivatives for the @dsid datastream', array('@dsid' => $datastream->id)),
'operations' => islandora_do_batch_derivatives($datastream->parent, array( 'operations' => islandora_do_batch_derivatives($datastream->parent, array(
'force' => TRUE, 'force' => TRUE,
'destination_dsid' => $datastream->id, 'destination_dsid' => $datastream->id,
)), )),
'init_message' => t('Preparing to regenerate derivatives...'), 'init_message' => t('Preparing to regenerate derivatives...'),
'progress_message' => t('Time elapsed: @elapsed <br/>Estimated time remaining @estimate.'), 'progress_message' => t('Time elapsed: @elapsed <br/>Estimated time remaining @estimate.'),
@ -139,7 +139,7 @@ function islandora_regenerate_datastream_derivative_batch(AbstractDatastream $da
* @param string $function * @param string $function
* The name of the function we are calling for derivatives. * The name of the function we are calling for derivatives.
* @param bool|string $file * @param bool|string $file
* FALSE if there is no file to load, the path to require otherwise * FALSE if there is no file to load, the path to require otherwise.
* @param string $pid * @param string $pid
* The pid of the object we are performing. * The pid of the object we are performing.
* @param bool $force * @param bool $force
@ -149,7 +149,7 @@ function islandora_regenerate_datastream_derivative_batch(AbstractDatastream $da
* @param array $context * @param array $context
* The context of the current batch operation. * The context of the current batch operation.
*/ */
function islandora_derivative_perform_batch_operation($function, $file, $pid, $force, $hook, &$context) { function islandora_derivative_perform_batch_operation($function, $file, $pid, $force, array $hook, array &$context) {
if ($file) { if ($file) {
require_once $file; require_once $file;
} }
@ -174,7 +174,7 @@ function islandora_derivative_perform_batch_operation($function, $file, $pid, $f
* @param array $operations * @param array $operations
* An array of operations passed from the batch. * An array of operations passed from the batch.
*/ */
function islandora_regenerate_derivative_batch_finished($success, $results, $operations) { function islandora_regenerate_derivative_batch_finished(array $success, array $results, array $operations) {
module_load_include('inc', 'islandora', 'includes/derivatives'); module_load_include('inc', 'islandora', 'includes/derivatives');
if (!empty($results['logging'])) { if (!empty($results['logging'])) {
islandora_derivative_logging($results['logging']); islandora_derivative_logging($results['logging']);

73
includes/solution_packs.inc

@ -105,7 +105,7 @@ function islandora_solution_packs_admin() {
* @return array * @return array
* The Drupal form definition. * The Drupal form definition.
*/ */
function islandora_solution_pack_form(array $form, array &$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { function islandora_solution_pack_form(array $form, array &$form_state, $solution_pack_module, $solution_pack_name, array $objects = array()) {
// The order is important in terms of severity of the status, where higher // The order is important in terms of severity of the status, where higher
// index indicates the status is more serious, this will be used to determine // index indicates the status is more serious, this will be used to determine
// what messages get displayed to the user. // what messages get displayed to the user.
@ -145,7 +145,8 @@ function islandora_solution_pack_form(array $form, array &$form_state, $solution
$header = array( $header = array(
'label' => t('Label'), 'label' => t('Label'),
'pid' => t('PID'), 'pid' => t('PID'),
'status' => t('Status')); 'status' => t('Status'),
);
$object_info = array(); $object_info = array();
foreach ($objects as $object) { foreach ($objects as $object) {
@ -161,7 +162,8 @@ function islandora_solution_pack_form(array $form, array &$form_state, $solution
$object_info[] = array( $object_info[] = array(
'label' => $label, 'label' => $label,
'pid' => $object->id, 'pid' => $object->id,
'status' => $status_msg); 'status' => $status_msg,
);
} }
$solution_pack_status = $status_severities[$solution_pack_status_severity]; $solution_pack_status = $status_severities[$solution_pack_status_severity];
$solution_pack_status_info = $status_info[$solution_pack_status]; $solution_pack_status_info = $status_info[$solution_pack_status];
@ -260,7 +262,7 @@ function islandora_solution_pack_form_submit(array $form, array &$form_state) {
* @return array * @return array
* An array defining a batch which can be passed on to batch_set(). * An array defining a batch which can be passed on to batch_set().
*/ */
function islandora_solution_pack_get_batch($module, $not_checked = array()) { function islandora_solution_pack_get_batch($module, array $not_checked = array()) {
$batch = array( $batch = array(
'title' => t('Installing / Updating solution pack objects'), 'title' => t('Installing / Updating solution pack objects'),
'file' => drupal_get_path('module', 'islandora') . '/includes/solution_packs.inc', 'file' => drupal_get_path('module', 'islandora') . '/includes/solution_packs.inc',
@ -299,8 +301,8 @@ function islandora_solution_pack_batch_operation_reingest_object(AbstractObject
if (!$deleted) { if (!$deleted) {
$object_link = l($existing_object->label, "islandora/object/{$existing_object->id}"); $object_link = l($existing_object->label, "islandora/object/{$existing_object->id}");
drupal_set_message(filter_xss(t('Failed to purge existing object !object_link.', array( drupal_set_message(filter_xss(t('Failed to purge existing object !object_link.', array(
'!object_link' => $object_link, '!object_link' => $object_link,
))), 'error'); ))), 'error');
// Failed to purge don't attempt to ingest. // Failed to purge don't attempt to ingest.
return; return;
} }
@ -405,8 +407,8 @@ function islandora_install_solution_pack($module, $op = 'install', $force = FALS
$object_status = islandora_check_object_status($object); $object_status = islandora_check_object_status($object);
$here_params = array( $here_params = array(
'!summary' => $t("@module: Did not install !object_link.", array( '!summary' => $t("@module: Did not install !object_link.", array(
'!object_link' => $object_link, '!object_link' => $object_link,
) + $t_params), ) + $t_params),
'!description' => $status_messages[$object_status['status']], '!description' => $status_messages[$object_status['status']],
); );
drupal_set_message(filter_xss(format_string('!summary !description', $here_params)), 'warning'); drupal_set_message(filter_xss(format_string('!summary !description', $here_params)), 'warning');
@ -422,25 +424,25 @@ function islandora_install_solution_pack($module, $op = 'install', $force = FALS
if ($object) { if ($object) {
if ($deleted) { if ($deleted) {
drupal_set_message(filter_xss($t('@module: Successfully reinstalled. !object_link.', array( drupal_set_message(filter_xss($t('@module: Successfully reinstalled. !object_link.', array(
'!object_link' => $object_link, '!object_link' => $object_link,
) + $t_params)), 'status'); ) + $t_params)), 'status');
} }
else { else {
drupal_set_message(filter_xss($t('@module: Successfully installed. !object_link.', array( drupal_set_message(filter_xss($t('@module: Successfully installed. !object_link.', array(
'!object_link' => $object_link, '!object_link' => $object_link,
) + $t_params)), 'status'); ) + $t_params)), 'status');
} }
} }
else { else {
drupal_set_message($t('@module: Failed to install. @label.', array( drupal_set_message($t('@module: Failed to install. @label.', array(
'@label' => $label, '@label' => $label,
) + $t_params), 'warning'); ) + $t_params), 'warning');
} }
} }
else { else {
drupal_set_message($t('@module: "@label" already exists and failed to be deleted.', array( drupal_set_message($t('@module: "@label" already exists and failed to be deleted.', array(
'@label' => $label, '@label' => $label,
) + $t_params), 'warning'); ) + $t_params), 'warning');
} }
} }
} }
@ -535,7 +537,7 @@ function islandora_check_object_status(AbstractObject $object_definition) {
); );
} }
$is_xml_datastream = function($ds) { $is_xml_datastream = function ($ds) {
return $ds->mimetype == 'text/xml'; return $ds->mimetype == 'text/xml';
}; };
$xml_datastreams = array_filter(iterator_to_array($object_definition), $is_xml_datastream); $xml_datastreams = array_filter(iterator_to_array($object_definition), $is_xml_datastream);
@ -627,11 +629,11 @@ function islandora_check_object_status(AbstractObject $object_definition) {
* that supports either the give $mimetype or $model will be listed. * that supports either the give $mimetype or $model will be listed.
* *
* @param string $variable_id * @param string $variable_id
* The ID of the Drupal variable to save the viewer settings in * The ID of the Drupal variable to save the viewer settings in.
* @param string $mimetype * @param string $mimetype
* The table will be populated with viewers supporting this mimetype * The table will be populated with viewers supporting this mimetype.
* @param string $model * @param string $model
* The table will be populated with viewers supporting this content model * The table will be populated with viewers supporting this content model.
* *
* @return array * @return array
* A form api array which defines a themed table to select a viewer. * A form api array which defines a themed table to select a viewer.
@ -680,7 +682,7 @@ function islandora_viewers_form($variable_id = NULL, $mimetype = NULL, $model =
); );
$form['viewers'][$variable_id]['configuration'][$name] = array( $form['viewers'][$variable_id]['configuration'][$name] = array(
'#type' => 'item', '#type' => 'item',
'#markup' => (isset($profile['configuration']) AND $profile['configuration'] != '') ? l(t('configure'), $profile['configuration']) : '', '#markup' => (isset($profile['configuration']) and $profile['configuration'] != '') ? l(t('configure'), $profile['configuration']) : '',
); );
} }
$form['viewers'][$variable_id]['default'] = array( $form['viewers'][$variable_id]['default'] = array(
@ -717,7 +719,7 @@ function islandora_viewers_form($variable_id = NULL, $mimetype = NULL, $model =
* @return array * @return array
* Viewer definitions, or FALSE if none are found. * Viewer definitions, or FALSE if none are found.
*/ */
function islandora_get_viewers($mimetype = array(), $content_model = NULL) { function islandora_get_viewers(array $mimetype = array(), $content_model = NULL) {
$viewers = array(); $viewers = array();
$defined_viewers = module_invoke_all('islandora_viewer_info'); $defined_viewers = module_invoke_all('islandora_viewer_info');
@ -729,7 +731,7 @@ function islandora_get_viewers($mimetype = array(), $content_model = NULL) {
foreach ($defined_viewers as $key => $value) { foreach ($defined_viewers as $key => $value) {
$value['mimetype'] = isset($value['mimetype']) ? $value['mimetype'] : array(); $value['mimetype'] = isset($value['mimetype']) ? $value['mimetype'] : array();
$value['model'] = isset($value['model']) ? $value['model'] : array(); $value['model'] = isset($value['model']) ? $value['model'] : array();
if (array_intersect($mimetype, $value['mimetype']) OR in_array($content_model, $value['model'])) { if (array_intersect($mimetype, $value['mimetype']) or in_array($content_model, $value['model'])) {
$viewers[$key] = $value; $viewers[$key] = $value;
} }
} }
@ -763,10 +765,10 @@ function theme_islandora_viewers_table($variables) {
$output = ''; $output = '';
$output .= theme('table', array( $output .= theme('table', array(
'header' => $header, 'header' => $header,
'rows' => $rows, 'rows' => $rows,
'attributes' => array('id' => 'islandora-viewers-table'), 'attributes' => array('id' => 'islandora-viewers-table'),
)); ));
$output .= drupal_render_children($form); $output .= drupal_render_children($form);
return $output; return $output;
} }
@ -774,22 +776,22 @@ function theme_islandora_viewers_table($variables) {
/** /**
* Gather information and return a rendered viewer. * Gather information and return a rendered viewer.
* *
* @param array/string $params * @param array|string $params
* Array or string with data the module needs in order to render a full viewer * Array or string with data the module needs 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 AbstractObject $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
* The callback to the viewer module. Returns a rendered viewer. Returns FALSE * The callback to the viewer module. Returns a rendered viewer. Returns FALSE
* if no viewer is set. * if no viewer is set.
*/ */
function islandora_get_viewer($params = NULL, $variable_id = NULL, $fedora_object = NULL) { function islandora_get_viewer($params = NULL, $variable_id = NULL, AbstractObject $fedora_object = NULL) {
$settings = variable_get($variable_id, array()); $settings = variable_get($variable_id, array());
if (!empty($settings) AND $settings['default'] !== 'none') { if (!empty($settings) and $settings['default'] !== 'none') {
$viewer_id = islandora_get_viewer_id($variable_id); $viewer_id = islandora_get_viewer_id($variable_id);
if ($viewer_id AND $params !== NULL) { if ($viewer_id and $params !== NULL) {
$callback = islandora_get_viewer_callback($viewer_id); $callback = islandora_get_viewer_callback($viewer_id);
if (function_exists($callback)) { if (function_exists($callback)) {
return $callback($params, $fedora_object); return $callback($params, $fedora_object);
@ -803,7 +805,7 @@ function islandora_get_viewer($params = NULL, $variable_id = NULL, $fedora_objec
* Get id of the enabled viewer. * Get id of the enabled 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.
* *
* @return string * @return string
* The enabled viewer id. Returns FALSE if no viewer config is set. * The enabled viewer id. Returns FALSE if no viewer config is set.
@ -834,6 +836,7 @@ function islandora_get_viewer_callback($viewer_id = NULL) {
} }
return FALSE; return FALSE;
} }
/** /**
* @} End of "defgroup viewer-functions". * @} End of "defgroup viewer-functions".
*/ */

10
includes/tuque.inc

@ -28,17 +28,20 @@ $islandora_module_path = drupal_get_path('module', 'islandora');
@include_once "$islandora_module_path/libraries/tuque/Repository.php"; @include_once "$islandora_module_path/libraries/tuque/Repository.php";
@include_once "$islandora_module_path/libraries/tuque/FedoraRelationships.php"; @include_once "$islandora_module_path/libraries/tuque/FedoraRelationships.php";
/**
* Class for setting up tuque in Islandora.
*/
class IslandoraTuque { class IslandoraTuque {
/** /**
* Connection to the repository * Connection to the repository.
* *
* @var RepositoryConnection * @var RepositoryConnection
*/ */
public $connection = NULL; public $connection = NULL;
/** /**
* The Fedora API we are using * The Fedora API we are using.
* *
* @var FedoraAPI * @var FedoraAPI
*/ */
@ -61,7 +64,7 @@ class IslandoraTuque {
/** /**
* Constructor. * Constructor.
* *
* @param array $user * @param object $user
* A Drupal user. * A Drupal user.
* @param string $url * @param string $url
* The url to the fedora instance. * The url to the fedora instance.
@ -113,4 +116,5 @@ class IslandoraTuque {
$message = t('Islandora requires the !tuque_url. Please install in /sites/all/libraries/tuque before continuing. See the !islandora_url.', array('!tuque_url' => $tuque_link, '!islandora_url' => $islandora_doc_link)); $message = t('Islandora requires the !tuque_url. Please install in /sites/all/libraries/tuque before continuing. See the !islandora_url.', array('!tuque_url' => $tuque_link, '!islandora_url' => $islandora_doc_link));
drupal_set_message(filter_xss($message), 'error', FALSE); drupal_set_message(filter_xss($message), 'error', FALSE);
} }
} }

99
includes/tuque_wrapper.inc

@ -2,8 +2,9 @@
/** /**
* @file * @file
* Wrapper around the tuque library, allows for autoloading of Islandora Tuque * Wrapper around the tuque library.
* Objects. *
* Allows for autoloading of Islandora Tuque Objects.
* *
* @todo Overload functions and apply pre/post hooks. * @todo Overload functions and apply pre/post hooks.
*/ */
@ -75,6 +76,9 @@ function islandora_invoke_datastream_hooks($hook, array $models, $dsid) {
return islandora_invoke_hook_list($hook, $refinements, array_slice(func_get_args(), 3)); return islandora_invoke_hook_list($hook, $refinements, array_slice(func_get_args(), 3));
} }
/**
* Wraps the Tuque FedoraRepository class.
*/
class IslandoraFedoraRepository extends FedoraRepository { class IslandoraFedoraRepository extends FedoraRepository {
protected $queryClass = 'IslandoraRepositoryQuery'; protected $queryClass = 'IslandoraRepositoryQuery';
protected $newObjectClass = 'IslandoraNewFedoraObject'; protected $newObjectClass = 'IslandoraNewFedoraObject';
@ -119,9 +123,10 @@ class IslandoraFedoraRepository extends FedoraRepository {
} }
catch (Exception $e) { catch (Exception $e) {
watchdog('islandora', 'Failed to ingest object: @pid</br>code: @code<br/>message: @msg', array( watchdog('islandora', 'Failed to ingest object: @pid</br>code: @code<br/>message: @msg', array(
'@pid' => $object->id, '@pid' => $object->id,
'@code' => $e->getCode(), '@code' => $e->getCode(),
'@msg' => $e->getMessage()), WATCHDOG_ERROR); '@msg' => $e->getMessage(),
), WATCHDOG_ERROR);
throw $e; throw $e;
} }
} }
@ -151,7 +156,7 @@ class IslandoraFedoraRepository extends FedoraRepository {
/** /**
* Helper for three-valued logic with UUIDs. * Helper for three-valued logic with UUIDs.
* *
* @param bool|NULL $to_create * @param bool|null $to_create
* The variable to test. * The variable to test.
* *
* @return bool * @return bool
@ -159,21 +164,32 @@ class IslandoraFedoraRepository extends FedoraRepository {
* 'islandora_basic_collection_generate_uuid' Drupal variable; otherwise, * 'islandora_basic_collection_generate_uuid' Drupal variable; otherwise,
* the value of $to_create itself. * the value of $to_create itself.
*/ */
protected static function useUUIDs($to_create) { protected static function useUuids($to_create) {
return is_null($to_create) ? return is_null($to_create) ?
variable_get('islandora_basic_collection_generate_uuid', FALSE) : variable_get('islandora_basic_collection_generate_uuid', FALSE) :
$to_create; $to_create;
} }
} }
/**
* Wraps tuques RepositoryQuery.
*/
class IslandoraRepositoryQuery extends RepositoryQuery {} class IslandoraRepositoryQuery extends RepositoryQuery {}
/**
* Wraps tuques NewFedoraObject.
*/
class IslandoraNewFedoraObject extends NewFedoraObject { class IslandoraNewFedoraObject extends NewFedoraObject {
protected $newFedoraDatastreamClass = 'IslandoraNewFedoraDatastream'; protected $newFedoraDatastreamClass = 'IslandoraNewFedoraDatastream';
protected $fedoraDatastreamClass = 'IslandoraFedoraDatastream'; protected $fedoraDatastreamClass = 'IslandoraFedoraDatastream';
protected $fedoraRelsExtClass = 'IslandoraFedoraRelsExt'; protected $fedoraRelsExtClass = 'IslandoraFedoraRelsExt';
} }
/**
* Wraps Tuques FedoraObject.
*/
class IslandoraFedoraObject extends FedoraObject { class IslandoraFedoraObject extends FedoraObject {
protected $newFedoraDatastreamClass = 'IslandoraNewFedoraDatastream'; protected $newFedoraDatastreamClass = 'IslandoraNewFedoraDatastream';
protected $fedoraDatastreamClass = 'IslandoraFedoraDatastream'; protected $fedoraDatastreamClass = 'IslandoraFedoraDatastream';
@ -275,9 +291,10 @@ class IslandoraFedoraObject extends FedoraObject {
} }
catch (Exception $e) { catch (Exception $e) {
watchdog('islandora', 'Failed to modify object: @pid</br>code: @code<br/>message: @msg', array( watchdog('islandora', 'Failed to modify object: @pid</br>code: @code<br/>message: @msg', array(
'@pid' => $this->id, '@pid' => $this->id,
'@code' => $e->getCode(), '@code' => $e->getCode(),
'@msg' => $e->getMessage()), WATCHDOG_ERROR); '@msg' => $e->getMessage(),
), WATCHDOG_ERROR);
throw $e; throw $e;
} }
} }
@ -322,16 +339,22 @@ class IslandoraFedoraObject extends FedoraObject {
} }
catch (Exception $e) { catch (Exception $e) {
watchdog('islandora', 'Failed to purge datastream @dsid from @pid</br>code: @code<br/>message: @msg', array( watchdog('islandora', 'Failed to purge datastream @dsid from @pid</br>code: @code<br/>message: @msg', array(
'@pid' => $this->id, '@pid' => $this->id,
'@dsid' => $id, '@dsid' => $id,
'@code' => $e->getCode(), '@code' => $e->getCode(),
'@msg' => $e->getMessage()), WATCHDOG_ERROR); '@msg' => $e->getMessage(),
), WATCHDOG_ERROR);
throw $e; throw $e;
} }
} }
} }
/**
* Wraps tuques RepositoryConnection.
*/
class IslandoraRepositoryConnection extends RepositoryConnection { class IslandoraRepositoryConnection extends RepositoryConnection {
/** /**
* Constructor. * Constructor.
* *
@ -345,8 +368,12 @@ class IslandoraRepositoryConnection extends RepositoryConnection {
parent::__construct($url, $username, $password); parent::__construct($url, $username, $password);
drupal_alter('islandora_repository_connection_construction', $this); drupal_alter('islandora_repository_connection_construction', $this);
} }
} }
/**
* Wraps Tuques FedoraApi.
*/
class IslandoraFedoraApi extends FedoraApi { class IslandoraFedoraApi extends FedoraApi {
/** /**
@ -362,8 +389,12 @@ class IslandoraFedoraApi extends FedoraApi {
$this->m = new IslandoraFedoraApiM($connection, $serializer); $this->m = new IslandoraFedoraApiM($connection, $serializer);
$this->connection = $connection; $this->connection = $connection;
} }
} }
/**
* Wraps Tuques FedoraApiM.
*/
class IslandoraFedoraApiM extends FedoraApiM { class IslandoraFedoraApiM extends FedoraApiM {
/** /**
@ -452,9 +483,10 @@ class IslandoraFedoraApiM extends FedoraApiM {
} }
catch (Exception $e) { catch (Exception $e) {
watchdog('islandora', 'Failed to purge object @pid</br>code: @code<br/>message: @msg', array( watchdog('islandora', 'Failed to purge object @pid</br>code: @code<br/>message: @msg', array(
'@pid' => $pid, '@pid' => $pid,
'@code' => $e->getCode(), '@code' => $e->getCode(),
'@msg' => $e->getMessage()), WATCHDOG_ERROR); '@msg' => $e->getMessage(),
), WATCHDOG_ERROR);
throw $e; throw $e;
} }
} }
@ -505,7 +537,7 @@ class IslandoraFedoraApiM extends FedoraApiM {
* *
* All extra arguments are passed along to the callback. * All extra arguments are passed along to the callback.
* *
* @param callable $callback * @param string $callback
* The method we are wrapping. * The method we are wrapping.
* @param string $pid * @param string $pid
* The PID to create a semaphore for. * The PID to create a semaphore for.
@ -540,15 +572,26 @@ class IslandoraFedoraApiM extends FedoraApiM {
return call_user_func_array(array($this, "parent::$callback"), $args); return call_user_func_array(array($this, "parent::$callback"), $args);
} }
} }
} }
/**
* Wraps Tuques SimpleCache.
*/
class IslandoraSimpleCache extends SimpleCache {} class IslandoraSimpleCache extends SimpleCache {}
/**
* Wraps Tuques NewFedoraDatastream.
*/
class IslandoraNewFedoraDatastream extends NewFedoraDatastream { class IslandoraNewFedoraDatastream extends NewFedoraDatastream {
protected $fedoraRelsIntClass = 'IslandoraFedoraRelsInt'; protected $fedoraRelsIntClass = 'IslandoraFedoraRelsInt';
protected $fedoraDatastreamVersionClass = 'IslandoraFedoraDatastreamVersion'; protected $fedoraDatastreamVersionClass = 'IslandoraFedoraDatastreamVersion';
} }
/**
* Wraps tuques FedoraDatastream.
*/
class IslandoraFedoraDatastream extends FedoraDatastream { class IslandoraFedoraDatastream extends FedoraDatastream {
protected $fedoraRelsIntClass = 'IslandoraFedoraRelsInt'; protected $fedoraRelsIntClass = 'IslandoraFedoraRelsInt';
protected $fedoraDatastreamVersionClass = 'IslandoraFedoraDatastreamVersion'; protected $fedoraDatastreamVersionClass = 'IslandoraFedoraDatastreamVersion';
@ -610,20 +653,32 @@ class IslandoraFedoraDatastream extends FedoraDatastream {
} }
catch (Exception $e) { catch (Exception $e) {
watchdog('islandora', 'Failed to modify datastream @dsid from @pid</br>code: @code<br/>message: @msg', array( watchdog('islandora', 'Failed to modify datastream @dsid from @pid</br>code: @code<br/>message: @msg', array(
'@pid' => $this->parent->id, '@pid' => $this->parent->id,
'@dsid' => $this->id, '@dsid' => $this->id,
'@code' => $e->getCode(), '@code' => $e->getCode(),
'@msg' => $e->getMessage()), WATCHDOG_ERROR); '@msg' => $e->getMessage(),
), WATCHDOG_ERROR);
throw $e; throw $e;
} }
} }
} }
/**
* Wraps tuques FedoraDatastreamVersion.
*/
class IslandoraFedoraDatastreamVersion extends FedoraDatastreamVersion { class IslandoraFedoraDatastreamVersion extends FedoraDatastreamVersion {
protected $fedoraRelsIntClass = 'IslandoraFedoraRelsInt'; protected $fedoraRelsIntClass = 'IslandoraFedoraRelsInt';
protected $fedoraDatastreamVersionClass = 'IslandoraFedoraDatastreamVersion'; protected $fedoraDatastreamVersionClass = 'IslandoraFedoraDatastreamVersion';
} }
/**
* Wraps Tuques FedoraRelsExt.
*/
class IslandoraFedoraRelsExt extends FedoraRelsExt {} class IslandoraFedoraRelsExt extends FedoraRelsExt {}
/**
* Wraps Tuques FedoraRelsInt.
*/
class IslandoraFedoraRelsInt extends FedoraRelsInt {} class IslandoraFedoraRelsInt extends FedoraRelsInt {}

22
includes/utilities.inc

@ -13,7 +13,7 @@
* XXX: Shouldn't Drupal's format_size() be preferred? * XXX: Shouldn't Drupal's format_size() be preferred?
* *
* @param int $bytes * @param int $bytes
* Size in bytes to convert * Size in bytes to convert.
* @param int $precision * @param int $precision
* The amount of decimal precision to show. * The amount of decimal precision to show.
* *
@ -175,8 +175,6 @@ function islandora_describe_repository($url = NULL) {
* as MODULE_REFINEMENT_HOOK. Any additional arguments passed to this function * as MODULE_REFINEMENT_HOOK. Any additional arguments passed to this function
* will be passed as arguments to module_invoke_all(). * will be passed as arguments to module_invoke_all().
* *
* @see islandora_build_hook_list()
*
* @param string $hook * @param string $hook
* A hook to call. * A hook to call.
* @param array $refinements * @param array $refinements
@ -188,6 +186,8 @@ function islandora_describe_repository($url = NULL) {
* *
* @return array * @return array
* The merged results from all the hooks. * The merged results from all the hooks.
*
* @see islandora_build_hook_list())
*/ */
function islandora_invoke_hook_list($hook, array $refinements, array $args) { function islandora_invoke_hook_list($hook, array $refinements, array $args) {
$return = array(); $return = array();
@ -229,7 +229,7 @@ function islandora_invoke_hook_list($hook, array $refinements, array $args) {
* An array with each refinement escaped and concatenated with the base hook * An array with each refinement escaped and concatenated with the base hook
* name, in addition to the base hook name. * name, in addition to the base hook name.
*/ */
function islandora_build_hook_list($hook, $refinements = array()) { function islandora_build_hook_list($hook, array $refinements = array()) {
$refinements = array_unique($refinements); $refinements = array_unique($refinements);
$hooks = array($hook); $hooks = array($hook);
foreach ($refinements as $refinement) { foreach ($refinements as $refinement) {
@ -333,7 +333,7 @@ function islandora_get_parents_from_rels_ext(AbstractObject $object) {
// @todo some logging would be nice, not sure what this throws. // @todo some logging would be nice, not sure what this throws.
return array(); return array();
} }
$map = function($o) { $map = function ($o) {
return islandora_object_load($o['object']['value']); return islandora_object_load($o['object']['value']);
}; };
$collections = array_map($map, $collections); $collections = array_map($map, $collections);
@ -484,7 +484,7 @@ function islandora_get_datastreams_requirements_from_content_model(AbstractObjec
* @return NewFedoraObject * @return NewFedoraObject
* An ingestable NewFedoraObject. * An ingestable NewFedoraObject.
*/ */
function islandora_prepare_new_object($name_source = NULL, $label = NULL, $datastreams = array(), $content_models = array(), $relationships = array()) { function islandora_prepare_new_object($name_source = NULL, $label = NULL, array $datastreams = array(), array $content_models = array(), array $relationships = array()) {
global $user; global $user;
$tuque = islandora_get_tuque_connection(); $tuque = islandora_get_tuque_connection();
$object = isset($name_source) ? $tuque->repository->constructObject($name_source) : new IslandoraNewFedoraObject(NULL, $tuque->repository); $object = isset($name_source) ? $tuque->repository->constructObject($name_source) : new IslandoraNewFedoraObject(NULL, $tuque->repository);
@ -500,7 +500,7 @@ function islandora_prepare_new_object($name_source = NULL, $label = NULL, $datas
$dsid = $ds['dsid']; $dsid = $ds['dsid'];
$label = isset($ds['label']) ? $ds['label'] : ''; $label = isset($ds['label']) ? $ds['label'] : '';
$mimetype = isset($ds['mimetype']) ? $ds['mimetype'] : 'text/xml'; $mimetype = isset($ds['mimetype']) ? $ds['mimetype'] : 'text/xml';
// Default 'Managed' // Default 'Managed'.
$control_group = 'M'; $control_group = 'M';
$groups = array('X', 'M', 'R', 'E'); $groups = array('X', 'M', 'R', 'E');
if (isset($ds['control_group']) && in_array($ds['control_group'], $groups)) { if (isset($ds['control_group']) && in_array($ds['control_group'], $groups)) {
@ -735,14 +735,14 @@ function islandora_get_content_models($ignore_system_namespace = TRUE) {
* @param string $drupal_variable * @param string $drupal_variable
* the name of the Drupal variable holding selected content models * the name of the Drupal variable holding selected content models
* Content models held in this variable will appear at the top of * Content models held in this variable will appear at the top of
* the displayed list * the displayed list.
* @param array $default_values_array * @param array $default_values_array
* default values to display if $drupal_variable is unset * Default values to display if $drupal_variable is unset.
* *
* @return array * @return array
* Drupal form element allowing content model selection * Drupal form element allowing content model selection
*/ */
function islandora_content_model_select_table_form_element($drupal_variable, $default_values_array = array('')) { function islandora_content_model_select_table_form_element($drupal_variable, array $default_values_array = array('')) {
$defaults = array(); $defaults = array();
$rows = array(); $rows = array();
$content_models = array(); $content_models = array();
@ -835,7 +835,7 @@ function islandora_deprecated($release, $solution = NULL) {
* of strings, which we transform to renderable markup elements (by * of strings, which we transform to renderable markup elements (by
* reference). * reference).
*/ */
function islandora_as_renderable_array(&$markup_array) { function islandora_as_renderable_array(array &$markup_array) {
foreach ($markup_array as &$value) { foreach ($markup_array as &$value) {
if (!is_array($value)) { if (!is_array($value)) {
// Not a renderable array, just a string. Let's convert it to a // Not a renderable array, just a string. Let's convert it to a

86
islandora.api.php

@ -1,4 +1,5 @@
<?php <?php
/** /**
* @file * @file
* This file documents all available hook functions to manipulate data. * This file documents all available hook functions to manipulate data.
@ -8,7 +9,7 @@
* Generate a repository objects view. * Generate a repository objects view.
* *
* @param AbstractObject $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.
* @param string $page_number * @param string $page_number
@ -19,7 +20,7 @@
* @return array * @return array
* An array whose values are markup. * An array whose values are markup.
*/ */
function hook_islandora_view_object($object, $user, $page_number, $page_size) { function hook_islandora_view_object(AbstractObject $object, $user, $page_number, $page_size) {
$output = array(); $output = array();
if (in_array('islandora:sp_basic_image', $object->models)) { if (in_array('islandora:sp_basic_image', $object->models)) {
$resource_url = url("islandora/object/{$object->id}/datastream/OBJ/view"); $resource_url = url("islandora/object/{$object->id}/datastream/OBJ/view");
@ -30,7 +31,8 @@ function hook_islandora_view_object($object, $user, $page_number, $page_size) {
// Theme the image seperatly. // Theme the image seperatly.
$variables['islandora_img'] = theme('image', $params); $variables['islandora_img'] = theme('image', $params);
$output = theme('islandora_default_print', array( $output = theme('islandora_default_print', array(
'islandora_content' => $variables['islandora_img'])); 'islandora_content' => $variables['islandora_img'],
));
} }
return $output; return $output;
} }
@ -38,10 +40,10 @@ function hook_islandora_view_object($object, $user, $page_number, $page_size) {
/** /**
* Generate a print friendly page for the given object. * Generate a print friendly page for the given object.
* *
* @param object $object * @param AbstractObject $object
* The object form to print. * The object form to print.
*/ */
function hook_islandora_view_print_object($object) { function hook_islandora_view_print_object(AbstractObject $object) {
} }
@ -52,13 +54,13 @@ function hook_islandora_view_print_object($object) {
* create the hook name. * create the hook name.
* *
* @param AbstractObject $object * @param AbstractObject $object
* A Tuque FedoraObject * A Tuque FedoraObject.
* *
* @return array * @return array
* An array whose values are markup. * An array whose values are markup.
*/ */
function hook_cmodel_pid_islandora_view_object($object) { function hook_cmodel_pid_islandora_view_object(AbstractObject $object) {
return array();
} }
/** /**
@ -69,21 +71,21 @@ function hook_cmodel_pid_islandora_view_object($object) {
* @param array $rendered * @param array $rendered
* The array of rendered views. * The array of rendered views.
*/ */
function hook_islandora_view_object_alter(&$object, &$rendered) { function hook_islandora_view_object_alter(AbstractObject &$object, array &$rendered) {
} }
/** /**
* Alter display output if the object has the given model. * Alter display output if the object has the given model.
* *
* @see hook_islandora_view_object_alter()
*
* @param AbstractObject $object * @param AbstractObject $object
* A Tuque AbstractObject 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.
*
* @see hook_islandora_view_object_alter()
*/ */
function hook_cmodel_pid_islandora_view_object_alter(&$object, &$rendered) { function hook_cmodel_pid_islandora_view_object_alter(AbstractObject &$object, array &$rendered) {
} }
@ -91,13 +93,13 @@ function hook_cmodel_pid_islandora_view_object_alter(&$object, &$rendered) {
* Generate an object's datastreams management display. * Generate an object's datastreams management display.
* *
* @param AbstractObject $object * @param AbstractObject $object
* A Tuque FedoraObject * A Tuque FedoraObject.
* *
* @return array * @return array
* An array whose values are markup. * An array whose values are markup.
*/ */
function hook_islandora_edit_object($object) { function hook_islandora_edit_object(AbstractObject $object) {
return array();
} }
/** /**
@ -107,24 +109,24 @@ function hook_islandora_edit_object($object) {
* create the hook name. * create the hook name.
* *
* @param AbstractObject $object * @param AbstractObject $object
* A Tuque FedoraObject * A Tuque FedoraObject.
* *
* @return array * @return array
* An array whose values are markup. * An array whose values are markup.
*/ */
function hook_cmodel_pid_islandora_edit_object($object) { function hook_cmodel_pid_islandora_edit_object(AbstractObject $object) {
return array();
} }
/** /**
* Allow datastreams management display output to be altered. * Allow datastreams management display output to be altered.
* *
* @param AbstractObject $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.
*/ */
function hook_islandora_edit_object_alter(&$object, &$rendered) { function hook_islandora_edit_object_alter(AbstractObject &$object, array &$rendered) {
} }
@ -227,12 +229,12 @@ function hook_cmodel_pid_dsid_islandora_datastream_alter(AbstractObject $object,
* This hook is called after an object has been successfully ingested via a * This hook is called after an object has been successfully ingested via a
* FedoraRepository object. * FedoraRepository object.
* *
* @param AbstractObject $object
* The object that was ingested.
*
* @note * @note
* 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 AbstractObject $object
* The object that was ingested.
*/ */
function hook_islandora_object_ingested(AbstractObject $object) { function hook_islandora_object_ingested(AbstractObject $object) {
@ -301,14 +303,14 @@ function hook_cmodel_pid_islandora_object_purged($pid) {
* *
* This hook is called after the datastream has been successfully ingested. * This hook is called after the datastream has been successfully ingested.
* *
* @note
* 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.
*
* @param AbstractObject $object * @param AbstractObject $object
* The object the datastream belongs to. * The object the datastream belongs to.
* @param AbstractDatastream $datastream * @param AbstractDatastream $datastream
* The ingested datastream. * The ingested datastream.
*
* @note
* 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.
*/ */
function hook_islandora_datastream_ingested(AbstractObject $object, AbstractDatastream $datastream) { function hook_islandora_datastream_ingested(AbstractObject $object, AbstractDatastream $datastream) {
@ -394,7 +396,7 @@ function hook_cmodel_pid_dsid_islandora_datastream_purged(AbstractObject $object
* - name: A string containg a human-readable name for the entry. * - name: A string containg a human-readable name for the entry.
* - url: A string containing the URL to which to the user will be routed. * - url: A string containing the URL to which to the user will be routed.
*/ */
function hook_islandora_edit_datastream_registry($object, $dsid) { function hook_islandora_edit_datastream_registry(AbstractObject $object, $dsid) {
$routes = array(); $routes = array();
$routes[] = array( $routes[] = array(
'name' => t('My Awesome Edit Route'), 'name' => t('My Awesome Edit Route'),
@ -451,7 +453,7 @@ function hook_islandora_undeletable_datastreams(array $models) {
* *
* @param array $form_state * @param array $form_state
* An array containing the form_state, on which infomation from step storage * An array containing the form_state, on which infomation from step storage
* might be extracted. Note that the * might be extracted. Note that the.
* *
* @return array * @return array
* An associative array of associative arrays which define each step in the * An associative array of associative arrays which define each step in the
@ -511,7 +513,6 @@ function hook_islandora_ingest_steps(array $form_state) {
* *
* @param array $steps * @param array $steps
* An array of steps as generated by hook_islandora_ingest_steps(). * An array of steps as generated by hook_islandora_ingest_steps().
*
* @param array $form_state * @param array $form_state
* An array containing the Drupal form_state. * An array containing the Drupal form_state.
*/ */
@ -538,7 +539,6 @@ function hook_cmodel_pid_islandora_ingest_steps(array $form_state) {
* *
* @param array $steps * @param array $steps
* An array of steps as generated by hook_islandora_ingest_steps(). * An array of steps as generated by hook_islandora_ingest_steps().
*
* @param array $form_state * @param array $form_state
* An array containing the Drupal form_state. * An array containing the Drupal form_state.
*/ */
@ -557,13 +557,13 @@ function hook_cmodel_pid_islandora_ingest_steps_alter(array &$steps, array &$for
* @param object $user * @param object $user
* A loaded user object, as the global $user variable might contain. * A loaded user object, as the global $user variable might contain.
* *
* @return bool|NULL|array * @return bool|null|array
* Either boolean TRUE or FALSE to explicitly allow or deny the operation on * Either boolean TRUE or FALSE to explicitly allow or deny the operation on
* the given object, or NULL to indicate that we are making no assertion * the given object, or NULL to indicate that we are making no assertion
* about the outcome. Can also be an array containing multiple * about the outcome. Can also be an array containing multiple
* TRUE/FALSE/NULLs, due to how hooks work. * TRUE/FALSE/NULLs, due to how hooks work.
*/ */
function hook_islandora_object_access($op, $object, $user) { function hook_islandora_object_access($op, AbstractObject $object, $user) {
switch ($op) { switch ($op) {
case 'create stuff': case 'create stuff':
return TRUE; return TRUE;
@ -591,18 +591,18 @@ function hook_cmodel_pid_islandora_object_access($op, $object, $user) {
* @param string $op * @param string $op
* A string define an operation to check. Should be defined via * A string define an operation to check. Should be defined via
* hook_permission(). * hook_permission().
* @param AbstractDatastream $object * @param AbstractDatastream $ds
* An object to check the operation on. * An object to check the operation on.
* @param object $user * @param object $user
* A loaded user object, as the global $user variable might contain. * A loaded user object, as the global $user variable might contain.
* *
* @return bool|NULL|array * @return bool|null|array
* Either boolean TRUE or FALSE to explicitly allow or deny the operation on * Either boolean TRUE or FALSE to explicitly allow or deny the operation on
* the given object, or NULL to indicate that we are making no assertion * the given object, or NULL to indicate that we are making no assertion
* about the outcome. Can also be an array containing multiple * about the outcome. Can also be an array containing multiple
* TRUE/FALSE/NULLs, due to how hooks work. * TRUE/FALSE/NULLs, due to how hooks work.
*/ */
function hook_islandora_datastream_access($op, $object, $user) { function hook_islandora_datastream_access($op, AbstractDatastream $ds, $user) {
switch ($op) { switch ($op) {
case 'create stuff': case 'create stuff':
return TRUE; return TRUE;
@ -664,7 +664,7 @@ function hook_cmodel_pid_islandora_overview_object_alter(AbstractObject &$object
* hierarchy. * hierarchy.
* *
* @param AbstractObject $object * @param AbstractObject $object
* Optional object to which derivatives will be added * Optional object to which derivatives will be added.
* @param array $ds_modified_params * @param array $ds_modified_params
* An array that will contain the properties changed on the datastream if * An array that will contain the properties changed on the datastream if
* derivatives were triggered from a datastream_modified hook, as well as a * derivatives were triggered from a datastream_modified hook, as well as a
@ -703,7 +703,7 @@ function hook_cmodel_pid_islandora_overview_object_alter(AbstractObject &$object
* - file: A string denoting the path to the file where the function * - file: A string denoting the path to the file where the function
* is being called from. * is being called from.
*/ */
function hook_islandora_derivative(AbstractObject $object = NULL, $ds_modified_params = array()) { function hook_islandora_derivative(AbstractObject $object = NULL, array $ds_modified_params = array()) {
$derivatives[] = array( $derivatives[] = array(
'source_dsid' => 'OBJ', 'source_dsid' => 'OBJ',
'destination_dsid' => 'DERIV', 'destination_dsid' => 'DERIV',
@ -777,7 +777,7 @@ function hook_cmodel_pid_islandora_derivative_alter() {
* Retrieves PIDS of related objects for property updating. * Retrieves PIDS of related objects for property updating.
* *
* @param AbstractObject $object * @param AbstractObject $object
* AbstractObject representing deleted object * AbstractObject representing deleted object.
*/ */
function hook_islandora_update_related_objects_properties(AbstractObject $object) { function hook_islandora_update_related_objects_properties(AbstractObject $object) {
$related_objects = get_all_children_siblings_and_friends($object); $related_objects = get_all_children_siblings_and_friends($object);
@ -796,9 +796,9 @@ function hook_islandora_update_related_objects_properties(AbstractObject $object
* @param string $context * @param string $context
* Where the alter is originating from for distinguishing. * Where the alter is originating from for distinguishing.
* @param AbstractObject $object * @param AbstractObject $object
* (Optional) AbstractObject representing object providing breadcrumb path * (Optional) AbstractObject representing object providing breadcrumb path.
*/ */
function hook_islandora_breadcrumbs_alter(&$breadcrumbs, $context, $object = NULL) { function hook_islandora_breadcrumbs_alter(array &$breadcrumbs, $context, AbstractObject $object = NULL) {
} }
@ -883,7 +883,7 @@ function hook_islandora_get_breadcrumb_query_predicates() {
* - original_edit_registry: The original edit_registry prior to any * - original_edit_registry: The original edit_registry prior to any
* modifications. * modifications.
*/ */
function hook_islandora_edit_datastream_registry_alter(&$edit_registry, $context) { function hook_islandora_edit_datastream_registry_alter(array &$edit_registry, array $context) {
// Example: Remove xml form builder edit registry. // Example: Remove xml form builder edit registry.
if (isset($edit_registry['xml_form_builder_edit_form_registry'])) { if (isset($edit_registry['xml_form_builder_edit_form_registry'])) {
unset($edit_registry['xml_form_builder_edit_form_registry']); unset($edit_registry['xml_form_builder_edit_form_registry']);

58
islandora.module

@ -4,7 +4,7 @@
* @file * @file
* Defines all the hooks this module implements. * Defines all the hooks this module implements.
* *
* islandora.module: defines paths (drupal menu items) as entry points and acts * Islandora.module: defines paths (drupal menu items) as entry points and acts
* as a hub for dispatching tasks to other modules. * as a hub for dispatching tasks to other modules.
* *
* This file is part of Islandora. * This file is part of Islandora.
@ -75,7 +75,7 @@ const ISLANDORA_BREADCRUMB_LEGACY_BACKEND = 'islandora_breadcrumbs_legacy_sparql
* Implements hook_menu(). * Implements hook_menu().
* *
* We need some standard entry points so we can have consistent urls for * We need some standard entry points so we can have consistent urls for
* different Object actions * different Object actions.
*/ */
function islandora_menu() { function islandora_menu() {
$items = array(); $items = array();
@ -189,7 +189,8 @@ function islandora_menu() {
ISLANDORA_ADD_DS, ISLANDORA_ADD_DS,
ISLANDORA_PURGE, ISLANDORA_PURGE,
ISLANDORA_INGEST, ISLANDORA_INGEST,
), 2), ), 2,
),
); );
$items['islandora/object/%islandora_object/manage/overview'] = array( $items['islandora/object/%islandora_object/manage/overview'] = array(
'title' => 'Overview', 'title' => 'Overview',
@ -207,7 +208,8 @@ function islandora_menu() {
ISLANDORA_METADATA_EDIT, ISLANDORA_METADATA_EDIT,
ISLANDORA_ADD_DS, ISLANDORA_ADD_DS,
ISLANDORA_PURGE, ISLANDORA_PURGE,
), 2), ), 2,
),
'weight' => -10, 'weight' => -10,
); );
$items['islandora/object/%islandora_object/manage/properties'] = array( $items['islandora/object/%islandora_object/manage/properties'] = array(
@ -429,7 +431,7 @@ function islandora_admin_paths() {
* The theme entries 'islandora_objects' and 'islandora_objects_subset' * The theme entries 'islandora_objects' and 'islandora_objects_subset'
* utilize the same template file. When theming, be sure to utilize the theme * utilize the same template file. When theming, be sure to utilize the theme
* name, and not the template file names. Similar situation found here: * name, and not the template file names. Similar situation found here:
* @link https://jira.duraspace.org/browse/ISLANDORA-934. @endlink * @link https://jira.duraspace.org/browse/ISLANDORA-934. @endlink.
*/ */
function islandora_theme() { function islandora_theme() {
return array( return array(
@ -710,7 +712,7 @@ function islandora_print_object(AbstractObject $object) {
* FALSE if 'islandora_show_print_option' is not selected in islandora * FALSE if 'islandora_show_print_option' is not selected in islandora
* configuraton. * configuraton.
*/ */
function islandora_print_object_access($op, $object) { function islandora_print_object_access($op, AbstractObject $object) {
if (!variable_get('islandora_show_print_option', FALSE)) { if (!variable_get('islandora_show_print_option', FALSE)) {
return FALSE; return FALSE;
} }
@ -738,8 +740,6 @@ function islandora_forms($form_id) {
* Will check the given user or the user repersented by the GET token parameter, * Will check the given user or the user repersented by the GET token parameter,
* failing that it will use the global user. * failing that it will use the global user.
* *
* @global $user
*
* @param mixed $object_or_datastream * @param mixed $object_or_datastream
* The AbstractObject or AbstractDatastream 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.
@ -759,8 +759,10 @@ function islandora_forms($form_id) {
* @return bool * @return bool
* TRUE if the user is allowed to access this object/datastream, FALSE * TRUE if the user is allowed to access this object/datastream, FALSE
* otherwise. * otherwise.
*
* @global $user
*/ */
function islandora_user_access($object_or_datastream, array $permissions, $content_models = array(), $access_any = TRUE, $user = NULL) { function islandora_user_access($object_or_datastream, array $permissions, array $content_models = array(), $access_any = TRUE, $user = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$is_repository_accessible = &drupal_static(__FUNCTION__); $is_repository_accessible = &drupal_static(__FUNCTION__);
@ -848,7 +850,7 @@ function islandora_user_access($object_or_datastream, array $permissions, $conte
* Checks whether the user can access the given object. * Checks whether the user can access the given object.
* *
* Checks for object existance, accessiblitly, namespace permissions, * Checks for object existance, accessiblitly, namespace permissions,
* and user permissions * and user permissions.
* *
* @param string $perm * @param string $perm
* User permission to test for. * User permission to test for.
@ -859,7 +861,7 @@ function islandora_user_access($object_or_datastream, array $permissions, $conte
* @return bool * @return bool
* TRUE if the user is allowed to access this object, FALSE otherwise. * TRUE if the user is allowed to access this object, FALSE otherwise.
*/ */
function islandora_object_access_callback($perm, $object = NULL) { function islandora_object_access_callback($perm, AbstractObject $object = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
if (!$object && !islandora_describe_repository()) { if (!$object && !islandora_describe_repository()) {
@ -898,7 +900,7 @@ function islandora_object_datastream_tokened_access_callback($perm, $object = NU
* Checks whether the user can access the given object's manage tab. * Checks whether the user can access the given object's manage tab.
* *
* Checks for object existance, accessiblitly, namespace permissions, * Checks for object existance, accessiblitly, namespace permissions,
* and user permissions * and user permissions.
* *
* @param array $perms * @param array $perms
* Array of user permission to test for. * Array of user permission to test for.
@ -909,7 +911,7 @@ function islandora_object_datastream_tokened_access_callback($perm, $object = NU
* @return bool * @return bool
* TRUE if the user is allowed to access this object, FALSE otherwise. * TRUE if the user is allowed to access this object, FALSE otherwise.
*/ */
function islandora_object_manage_access_callback($perms, $object = NULL) { function islandora_object_manage_access_callback(array $perms, AbstractObject $object = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
if (!$object && !islandora_describe_repository()) { if (!$object && !islandora_describe_repository()) {
@ -1124,7 +1126,7 @@ function islandora_drupal_title(AbstractObject $object) {
* @return array * @return array
* The default rendering of the object view page, indexed at 'Default output'. * The default rendering of the object view page, indexed at 'Default output'.
*/ */
function islandora_default_islandora_view_object($object) { function islandora_default_islandora_view_object(AbstractObject $object) {
$output = theme('islandora_default', array('islandora_object' => $object)); $output = theme('islandora_default', array('islandora_object' => $object));
return array('Default output' => array('#markup' => $output)); return array('Default output' => array('#markup' => $output));
} }
@ -1140,7 +1142,7 @@ function islandora_default_islandora_view_object($object) {
* @return array * @return array
* A renderable array * A renderable array
*/ */
function islandora_default_islandora_printer_object($object, $alter) { function islandora_default_islandora_printer_object(AbstractObject $object, $alter) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
module_load_include('inc', 'islandora', 'includes/datastream'); module_load_include('inc', 'islandora', 'includes/datastream');
module_load_include('inc', 'islandora', 'includes/metadata'); module_load_include('inc', 'islandora', 'includes/metadata');
@ -1164,7 +1166,8 @@ function islandora_default_islandora_printer_object($object, $alter) {
'object' => $object, 'object' => $object,
'dc_array' => $variables, 'dc_array' => $variables,
'metadata' => $metadata, 'metadata' => $metadata,
'islandora_content' => $alter)); 'islandora_content' => $alter,
));
return array('Default output' => array('#markup' => $output)); return array('Default output' => array('#markup' => $output));
} }
@ -1261,7 +1264,7 @@ function islandora_object_load($object_id) {
* @return FedoraObject * @return FedoraObject
* A token authenticated object. @see islandora_object_load * A token authenticated object. @see islandora_object_load
*/ */
function islandora_tokened_object_load($object_id, $map) { function islandora_tokened_object_load($object_id, array $map) {
if (array_key_exists('token', $_GET)) { if (array_key_exists('token', $_GET)) {
$token = filter_input(INPUT_GET, 'token', FILTER_SANITIZE_STRING); $token = filter_input(INPUT_GET, 'token', FILTER_SANITIZE_STRING);
if ($token) { if ($token) {
@ -1288,7 +1291,7 @@ function islandora_tokened_object_load($object_id, $map) {
* islandora_tokened_datastream_load(DSID, DSID, PID) * islandora_tokened_datastream_load(DSID, DSID, PID)
* *
* @param mixed $datastream_id * @param mixed $datastream_id
* %islandora_tokened_datastream @see islandora_datastream_load * Menu path '%islandora_tokened_datastream' @see islandora_datastream_load.
* @param array $map * @param array $map
* Used to extract the Fedora object's PID at $map[2]. * Used to extract the Fedora object's PID at $map[2].
* *
@ -1297,7 +1300,7 @@ function islandora_tokened_object_load($object_id, $map) {
* *
* @see islandora_datastream_load * @see islandora_datastream_load
*/ */
function islandora_tokened_datastream_load($datastream_id, $map) { function islandora_tokened_datastream_load($datastream_id, array $map) {
return islandora_datastream_load($datastream_id, $map[2]); return islandora_datastream_load($datastream_id, $map[2]);
} }
@ -1313,7 +1316,6 @@ function islandora_tokened_datastream_load($datastream_id, $map) {
* @param string $datastream_id * @param string $datastream_id
* The DSID of the datastream specified as '%islandora_datastream' to fetch * The DSID of the datastream specified as '%islandora_datastream' to fetch
* from the given object in the menu path identified by '%islandora_object'. * from the given object in the menu path identified by '%islandora_object'.
*
* @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 IslandoraAbstractObject as it implements __toString() * an instantiated IslandoraAbstractObject as it implements __toString()
@ -1349,7 +1351,7 @@ function islandora_datastream_load($datastream_id, $object_id) {
* @return int * @return int
* The datastreams version if found, NULL otherwise. * The datastreams version if found, NULL otherwise.
*/ */
function islandora_get_islandora_datastream_version($object = NULL, $dsid = NULL, $datastream_file = NULL) { function islandora_get_islandora_datastream_version(AbstractObject $object = NULL, $dsid = NULL, $datastream_file = NULL) {
$return = NULL; $return = NULL;
// @TODO, need better check for $object // @TODO, need better check for $object
if ($object && $object[$dsid]) { if ($object && $object[$dsid]) {
@ -1484,15 +1486,15 @@ function islandora_delete_object(AbstractObject &$object) {
/** /**
* Delete's or purges the given datastream. * Delete's or purges the given datastream.
* *
* @throws Exception
* Which types are undefined, but more than likely because of the hooks
* there will be several kinds.
*
* @param AbstractDatastream $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.
*
* @throws Exception
* Which types are undefined, but more than likely because of the hooks
* there will be several kinds.
*/ */
function islandora_delete_datastream(AbstractDatastream &$datastream) { function islandora_delete_datastream(AbstractDatastream &$datastream) {
$object = $datastream->parent; $object = $datastream->parent;
@ -1625,7 +1627,7 @@ function islandora_entity_property_info() {
* Implements hook_file_mimetype_mapping_alter(). * Implements hook_file_mimetype_mapping_alter().
* *
* Grab custom Islandora mime type list * Grab custom Islandora mime type list
* and add any missing ext/mimes to the Drupal mapping * and add any missing ext/mimes to the Drupal mapping.
*/ */
function islandora_file_mimetype_mapping_alter(&$mapping) { function islandora_file_mimetype_mapping_alter(&$mapping) {
module_load_include('inc', 'islandora', 'includes/mimetype.utils'); module_load_include('inc', 'islandora', 'includes/mimetype.utils');
@ -1652,7 +1654,7 @@ function islandora_file_mimetype_mapping_alter(&$mapping) {
* @param string $op * @param string $op
* String identifying an operation to check. Should correspond to a * String identifying an operation to check. Should correspond to a
* permission declared via hook_permission(). * permission declared via hook_permission().
* @param AbstractObject $object * @param object $object
* An object to check for permissions. * An object to check for permissions.
* @param object $user * @param object $user
* An optional loaded user object. Defaults to the global $user. * An optional loaded user object. Defaults to the global $user.
@ -1994,7 +1996,7 @@ function islandora_islandora_datastream_access($op, AbstractDatastream $datastre
* Access for submenu items. * Access for submenu items.
* *
* @param string $package_name * @param string $package_name
* Name of the package * Name of the package.
* *
* @return bool * @return bool
* Access granted * Access granted

11
islandora.rules.inc

@ -2,7 +2,7 @@
/** /**
* @file * @file
* Does rule type stuff, * Does rule type stuff,.
*/ */
/** /**
@ -158,7 +158,6 @@ function islandora_rules_base_xpath_parameters() {
); );
} }
/** /**
* Implements hook_rules_condition_info(). * Implements hook_rules_condition_info().
*/ */
@ -397,7 +396,7 @@ function islandora_rules_datastream_load_domxpath($string) {
* A loaded Drupal taxonomy vocabulary object, in which terms are understood * A loaded Drupal taxonomy vocabulary object, in which terms are understood
* to be namespace prefixes and descriptions are the namespace URIs. * to be namespace prefixes and descriptions are the namespace URIs.
*/ */
function islandora_rules_datastream_load_namespace_vocab($xpath, $xpath_vocab) { function islandora_rules_datastream_load_namespace_vocab(DOMXPath $xpath, $xpath_vocab) {
foreach (taxonomy_get_tree($xpath_vocab->vid, 0, 1, FALSE) as $term) { foreach (taxonomy_get_tree($xpath_vocab->vid, 0, 1, FALSE) as $term) {
$xpath->registerNamespace($term->name, $term->description); $xpath->registerNamespace($term->name, $term->description);
} }
@ -499,7 +498,7 @@ function islandora_rules_data_info() {
* The object on which to set the property, described by $info['property']. * The object on which to set the property, described by $info['property'].
* @param array $options * @param array $options
* An array of options... Not sure how it's used? Not touched by us, in any * An array of options... Not sure how it's used? Not touched by us, in any
* case. :P * case. :P.
* @param string $name * @param string $name
* The name of the property to set, as used by Rules. * The name of the property to set, as used by Rules.
* @param string $type * @param string $type
@ -510,7 +509,7 @@ function islandora_rules_data_info() {
* - property: A string indicate the actual property on the $data we wish to * - property: A string indicate the actual property on the $data we wish to
* set. * set.
*/ */
function islandora_rules_property_get($data, array $options, $name, $type, $info) { function islandora_rules_property_get($data, array $options, $name, $type, array $info) {
return $data->$info['property']; return $data->$info['property'];
} }
@ -536,7 +535,7 @@ function islandora_rules_property_get($data, array $options, $name, $type, $info
* - property: A string indicate the actual property on the $data we wish to * - property: A string indicate the actual property on the $data we wish to
* set. * set.
*/ */
function islandora_rules_property_set(&$data, $name, $value, $langcode, $type, $info) { function islandora_rules_property_set(&$data, $name, $value, $langcode, $type, array $info) {
$data->$info['property'] = $value; $data->$info['property'] = $value;
} }

10
tests/authtokens.test

@ -1,10 +1,8 @@
<?php <?php
/** /**
* @file
* Test Authentication Tokens. * Test Authentication Tokens.
*/ */
class IslandoraAuthtokensTestCase extends IslandoraWebTestCase { class IslandoraAuthtokensTestCase extends IslandoraWebTestCase {
/** /**
@ -18,13 +16,6 @@ class IslandoraAuthtokensTestCase extends IslandoraWebTestCase {
); );
} }
/**
* Set up data for the tests.
*/
public function setUp() {
parent::setUp();
}
/** /**
* Test redeeming invalid tokens. * Test redeeming invalid tokens.
*/ */
@ -107,4 +98,5 @@ class IslandoraAuthtokensTestCase extends IslandoraWebTestCase {
public function testTokenedViewDatastreamWithXacml() { public function testTokenedViewDatastreamWithXacml() {
// We need to add this test. // We need to add this test.
} }
} }

5
tests/datastream_cache.test

@ -1,10 +1,8 @@
<?php <?php
/** /**
* @file
* Tests to verify the cache headers we provide. * Tests to verify the cache headers we provide.
*/ */
class IslandoraDatastreamCacheTestCase extends IslandoraWebTestCase { class IslandoraDatastreamCacheTestCase extends IslandoraWebTestCase {
/** /**
@ -134,7 +132,7 @@ class IslandoraDatastreamCacheTestCase extends IslandoraWebTestCase {
)); ));
$this->assertResponse(200); $this->assertResponse(200);
// Test combination of If-None-Match and If-Modified-Since // Test combination of If-None-Match and If-Modified-Since.
$result = $this->drupalGet("islandora/object/{$object->id}/datastream/{$datastream->id}/view", array(), array( $result = $this->drupalGet("islandora/object/{$object->id}/datastream/{$datastream->id}/view", array(), array(
'If-Modified-Since: ' . $datastream->createdDate->format('D, d M Y H:i:s \G\M\T'), 'If-Modified-Since: ' . $datastream->createdDate->format('D, d M Y H:i:s \G\M\T'),
format_string('If-None-Match: "!checksum"', array( format_string('If-None-Match: "!checksum"', array(
@ -157,4 +155,5 @@ class IslandoraDatastreamCacheTestCase extends IslandoraWebTestCase {
)); ));
$this->assertResponse(200); $this->assertResponse(200);
} }
} }

5
tests/datastream_validator_tests.test

@ -1,4 +1,5 @@
<?php <?php
/** /**
* @file * @file
* Tests for things that test tests. Madness. * Tests for things that test tests. Madness.
@ -22,6 +23,7 @@ class TestDatastreamValidator extends DatastreamValidator {
protected function assertSomethingFailed() { protected function assertSomethingFailed() {
$this->addResult(FALSE, 'boo you failed', $this->getAssertionCall()); $this->addResult(FALSE, 'boo you failed', $this->getAssertionCall());
} }
} }
/** /**
@ -222,7 +224,7 @@ class PrefixDatastreamValidatorTestCase extends IslandoraWebTestCase {
'dsid' => $prefix, 'dsid' => $prefix,
'path' => $this->path . $filename, 'path' => $this->path . $filename,
'control_group' => 'M', 'control_group' => 'M',
), ),
); );
$object = $this->ingestConstructedObject(array(), $datastreams); $object = $this->ingestConstructedObject(array(), $datastreams);
return $object; return $object;
@ -273,4 +275,5 @@ class PrefixDatastreamValidatorTestCase extends IslandoraWebTestCase {
} }
} }
} }
} }

5
tests/datastream_versions.test

@ -1,10 +1,8 @@
<?php <?php
/** /**
* @file * Tests that datastream versions code works as intended.
* Tests that datastream versions code works as intended
*/ */
class IslandoraDatastreamVersionTestCase extends IslandoraWebTestCase { class IslandoraDatastreamVersionTestCase extends IslandoraWebTestCase {
/** /**
@ -195,4 +193,5 @@ class IslandoraDatastreamVersionTestCase extends IslandoraWebTestCase {
$this->drupalGet("islandora/object/{$this->pid}/datastream/DC/version/0/delete"); $this->drupalGet("islandora/object/{$this->pid}/datastream/DC/version/0/delete");
$this->assertResponse(404); $this->assertResponse(404);
} }
} }

17
tests/derivatives.test

@ -1,7 +1,6 @@
<?php <?php
/** /**
* @file
* Tests to see if the hooks get called when appropriate. * Tests to see if the hooks get called when appropriate.
* *
* In the test module 'islandora_derivatives_test' there are implementations * In the test module 'islandora_derivatives_test' there are implementations
@ -10,7 +9,6 @@
* *
* To make sense of these tests reference islandora_derivatives_test.module. * To make sense of these tests reference islandora_derivatives_test.module.
*/ */
class IslandoraDerivativesTestCase extends IslandoraWebTestCase { class IslandoraDerivativesTestCase extends IslandoraWebTestCase {
/** /**
@ -156,7 +154,7 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase {
/** /**
* Tests derivative hook filtering based upon source_dsid. * Tests derivative hook filtering based upon source_dsid.
*/ */
public function testDerivativeFilteringOnSourceDSID() { public function testDerivativeFilteringOnSourceDsid() {
global $_islandora_derivative_test_derivative_functions; global $_islandora_derivative_test_derivative_functions;
$_islandora_derivative_test_derivative_functions = array(); $_islandora_derivative_test_derivative_functions = array();
$object = $this->constructBaseObject(); $object = $this->constructBaseObject();
@ -182,7 +180,7 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase {
/** /**
* Tests that only functions were the source_dsid is NULL are fired. * Tests that only functions were the source_dsid is NULL are fired.
*/ */
public function testNULLSourceDSID() { public function testNullSourceDsid() {
global $_islandora_derivative_test_derivative_functions; global $_islandora_derivative_test_derivative_functions;
$_islandora_derivative_test_derivative_functions = array(); $_islandora_derivative_test_derivative_functions = array();
$this->constructBaseObject(); $this->constructBaseObject();
@ -205,7 +203,7 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase {
/** /**
* Tests that when no source_dsid all derivative functions are called. * Tests that when no source_dsid all derivative functions are called.
*/ */
public function testNoSourceDSIDNoForce() { public function testNoSourceDsidNoForce() {
global $_islandora_derivative_test_derivative_functions; global $_islandora_derivative_test_derivative_functions;
$_islandora_derivative_test_derivative_functions = array(); $_islandora_derivative_test_derivative_functions = array();
$object = $this->constructBaseObject(); $object = $this->constructBaseObject();
@ -227,7 +225,7 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase {
/** /**
* Tests that when no source_dsid all derivative functions are called. * Tests that when no source_dsid all derivative functions are called.
*/ */
public function testNoSourceDSIDForce() { public function testNoSourceDsidForce() {
global $_islandora_derivative_test_derivative_functions; global $_islandora_derivative_test_derivative_functions;
$_islandora_derivative_test_derivative_functions = array(); $_islandora_derivative_test_derivative_functions = array();
$object = $this->constructBaseObject(); $object = $this->constructBaseObject();
@ -290,7 +288,7 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase {
* @return AbstractObject * @return AbstractObject
* The modified AbstractObject. * The modified AbstractObject.
*/ */
public function constructDERIVDatastream(AbstractObject $object) { public function constructDerivDatastream(AbstractObject $object) {
$dsid = 'DERIV'; $dsid = 'DERIV';
$ds = $object->constructDatastream($dsid); $ds = $object->constructDatastream($dsid);
$ds->label = 'Test'; $ds->label = 'Test';
@ -308,7 +306,7 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase {
* @return AbstractObject * @return AbstractObject
* The modified AbstractObject. * The modified AbstractObject.
*/ */
public function constructNOSOURCEDatastream(AbstractObject $object) { public function constructNosourceDatastream(AbstractObject $object) {
$dsid = 'NOSOURCE'; $dsid = 'NOSOURCE';
$ds = $object->constructDatastream($dsid); $ds = $object->constructDatastream($dsid);
$ds->label = 'Test'; $ds->label = 'Test';
@ -326,7 +324,7 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase {
* @return AbstractObject * @return AbstractObject
* The modified AbstractObject. * The modified AbstractObject.
*/ */
public function constructSOMEWEIRDDATASTREAMDatastream(AbstractObject $object) { public function constructSomeweirddatastreamDatastream(AbstractObject $object) {
$dsid = 'SOMEWEIRDDATASTREAM'; $dsid = 'SOMEWEIRDDATASTREAM';
$ds = $object->constructDatastream($dsid); $ds = $object->constructDatastream($dsid);
$ds->label = 'Test'; $ds->label = 'Test';
@ -334,4 +332,5 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase {
$object->ingestDatastream($ds); $object->ingestDatastream($ds);
return $object; return $object;
} }
} }

3
tests/hooked_access.test

@ -1,7 +1,6 @@
<?php <?php
/** /**
* @file
* Tests to see if the hooks get called when appropriate. * Tests to see if the hooks get called when appropriate.
* *
* In the test module 'islandora_hooked_access_test' there are implementations * In the test module 'islandora_hooked_access_test' there are implementations
@ -10,7 +9,6 @@
* *
* To make sense of these tests reference islandora_hooked_access_test.module. * To make sense of these tests reference islandora_hooked_access_test.module.
*/ */
class IslandoraHookedAccessTestCase extends IslandoraWebTestCase { class IslandoraHookedAccessTestCase extends IslandoraWebTestCase {
/** /**
@ -146,4 +144,5 @@ class IslandoraHookedAccessTestCase extends IslandoraWebTestCase {
public function testDenyDatastreamExplicit() { public function testDenyDatastreamExplicit() {
$this->assertFalse(islandora_datastream_access($this->denied_op, $this->object['asdf']), 'Explicit denial of datastream access.'); $this->assertFalse(islandora_datastream_access($this->denied_op, $this->object['asdf']), 'Explicit denial of datastream access.');
} }
} }

3
tests/hooks.test

@ -1,7 +1,6 @@
<?php <?php
/** /**
* @file
* Tests to see if the hooks get called when appropriate. * Tests to see if the hooks get called when appropriate.
* *
* In the test module 'islandora_hooks_test' there are implementations * In the test module 'islandora_hooks_test' there are implementations
@ -10,7 +9,6 @@
* *
* To make sense of these tests reference islandora_hooks_test.module. * To make sense of these tests reference islandora_hooks_test.module.
*/ */
class IslandoraHooksTestCase extends IslandoraWebTestCase { class IslandoraHooksTestCase extends IslandoraWebTestCase {
/** /**
@ -256,4 +254,5 @@ class IslandoraHooksTestCase extends IslandoraWebTestCase {
$this->assert($_SESSION['islandora_hooks']['hook'][ISLANDORA_DATASTREAM_INGESTED_HOOK], 'Called ISLANDORA_DATASTREAM_INGESTED_HOOK when ingesting via FedoraObject::ingestDatastream.'); $this->assert($_SESSION['islandora_hooks']['hook'][ISLANDORA_DATASTREAM_INGESTED_HOOK], 'Called ISLANDORA_DATASTREAM_INGESTED_HOOK when ingesting via FedoraObject::ingestDatastream.');
$this->repository->purgeObject($object->id); $this->repository->purgeObject($object->id);
} }
} }

50
tests/includes/datastream_validators.inc

@ -1,4 +1,5 @@
<?php <?php
/** /**
* @file * @file
* Classes and functions for datastream validation. * Classes and functions for datastream validation.
@ -16,7 +17,7 @@
* The hexidecimal string. * The hexidecimal string.
* *
* @throws Exception * @throws Exception
* if something horrible happens during the actual conversion. * If something horrible happens during the actual conversion.
* *
* @return bool|int * @return bool|int
* FALSE on failure, or the integer on success. * FALSE on failure, or the integer on success.
@ -221,14 +222,14 @@ class TIFFDatastreamValidator extends DatastreamValidator {
/** /**
* Asserts that the TIFF contains an appropriate header. * Asserts that the TIFF contains an appropriate header.
*/ */
public function assertTIFFHeaderHex() { public function assertTiffHeaderHex() {
$datastream_header_hex = self::getTIFFHeaderHex(); $datastream_header_hex = self::getTIFFHeaderHex();
if ($datastream_header_hex == "49492a00") { if ($datastream_header_hex == "49492a00") {
// In this case, the ingested TIFF is designated as using the "Intel // In this case, the ingested TIFF is designated as using the "Intel
// byte-order" (i.e. little-endian) by starting with the characters "II" // byte-order" (i.e. little-endian) by starting with the characters "II"
// (repeated so that byte order does not yet need to be significant). // (repeated so that byte order does not yet need to be significant).
// The number that follows is '42' in little-endian hex, a number of // The number that follows is '42' in little-endian hex, a number of
// 'deep philosophical significance' to the TIFF format creators.' // 'deep philosophical significance' to the TIFF format creators.'.
$this->addResult(TRUE, "{$this->datastream} datastream asserts that it is a valid Intel-byte-orderded TIF/TIFF file."); $this->addResult(TRUE, "{$this->datastream} datastream asserts that it is a valid Intel-byte-orderded TIF/TIFF file.");
} }
elseif ($datastream_header_hex == "4d4d002a") { elseif ($datastream_header_hex == "4d4d002a") {
@ -248,7 +249,7 @@ class TIFFDatastreamValidator extends DatastreamValidator {
* @return string * @return string
* The ... thing I just wrote up there. * The ... thing I just wrote up there.
*/ */
protected function getTIFFHeaderHex() { protected function getTiffHeaderHex() {
return substr(bin2hex($this->datastreamContent), 0, 8); return substr(bin2hex($this->datastreamContent), 0, 8);
} }
@ -265,7 +266,7 @@ class JP2DatastreamValidator extends DatastreamValidator {
* JP2 files begin with an offset header at the second 32-bit integer, * JP2 files begin with an offset header at the second 32-bit integer,
* 0x6A502020. This header is in all .jp2s, and we check for it here. * 0x6A502020. This header is in all .jp2s, and we check for it here.
*/ */
protected function assertJP2Header() { protected function assertJp2Header() {
$assertion = substr(bin2hex($this->datastreamContent), 8, 8) == '6a502020'; $assertion = substr(bin2hex($this->datastreamContent), 8, 8) == '6a502020';
$pass = "Datastream {$this->datastream} contains the appropriate JP2 header."; $pass = "Datastream {$this->datastream} contains the appropriate JP2 header.";
$fail = "Datastream {$this->datastream} does not contain the appropriate JP2 header."; $fail = "Datastream {$this->datastream} does not contain the appropriate JP2 header.";
@ -279,13 +280,14 @@ class JP2DatastreamValidator extends DatastreamValidator {
* JP2 files have their codestream capped with a marker, 0xFFD9. We're just * JP2 files have their codestream capped with a marker, 0xFFD9. We're just
* checking for it here to see if the .jp2 encoder finished okay. * checking for it here to see if the .jp2 encoder finished okay.
*/ */
protected function assertJP2Marker() { protected function assertJp2Marker() {
$assertion = substr(bin2hex($this->datastreamContent), strlen(bin2hex($this->datastreamContent)) - 4, 4) == 'ffd9'; $assertion = substr(bin2hex($this->datastreamContent), strlen(bin2hex($this->datastreamContent)) - 4, 4) == 'ffd9';
$pass = "Datastream {$this->datastream} contains the appropriate JP2 ending marker."; $pass = "Datastream {$this->datastream} contains the appropriate JP2 ending marker.";
$fail = "Datastream {$this->datastream} does not contain the appropriate JP2 ending marker. If this is the only JP2 validator that failed, it is likely that derivative generation was interrupted."; $fail = "Datastream {$this->datastream} does not contain the appropriate JP2 ending marker. If this is the only JP2 validator that failed, it is likely that derivative generation was interrupted.";
$message = $assertion ? $pass : $fail; $message = $assertion ? $pass : $fail;
$this->addResult($assertion, $message); $this->addResult($assertion, $message);
} }
} }
/** /**
@ -296,7 +298,7 @@ class PDFDatastreamValidator extends DatastreamValidator {
/** /**
* Validates the PDF signature. * Validates the PDF signature.
*/ */
protected function assertPDFSignature() { protected function assertPdfSignature() {
$assertion = substr($this->datastreamContent, 0, 5) == '%PDF-'; $assertion = substr($this->datastreamContent, 0, 5) == '%PDF-';
$pdf_version = substr($this->datastreamContent, 5, 3); $pdf_version = substr($this->datastreamContent, 5, 3);
$pass = "{$this->datastream} datastream asserts that it is a valid PDF file using PDF version {$pdf_version}"; $pass = "{$this->datastream} datastream asserts that it is a valid PDF file using PDF version {$pdf_version}";
@ -308,7 +310,7 @@ class PDFDatastreamValidator extends DatastreamValidator {
/** /**
* Counts the number of signatures in this PDF file and asserts there are any. * Counts the number of signatures in this PDF file and asserts there are any.
*/ */
protected function assertPDFStreamCount() { protected function assertPdfStreamCount() {
$pdf_stream_count = substr_count(bin2hex($this->datastreamContent), '0a73747265616d0a'); $pdf_stream_count = substr_count(bin2hex($this->datastreamContent), '0a73747265616d0a');
$assertion = $pdf_stream_count !== 0; $assertion = $pdf_stream_count !== 0;
$pass = "{$this->datastream} datastream reports the existence of {$pdf_stream_count} PDF streams. Note that an extremely low number could still indicate corruption."; $pass = "{$this->datastream} datastream reports the existence of {$pdf_stream_count} PDF streams. Note that an extremely low number could still indicate corruption.";
@ -319,17 +321,15 @@ class PDFDatastreamValidator extends DatastreamValidator {
/** /**
* Validates the PDF closing tag. * Validates the PDF closing tag.
*
* @return bool
* TRUE if it was present; FALSE otherwise.
*/ */
protected function assertPDFClosingTag() { protected function assertPdfClosingTag() {
$assertion = strpos(bin2hex($this->datastreamContent), '0a2525454f460a') == TRUE; $assertion = strpos(bin2hex($this->datastreamContent), '0a2525454f460a') == TRUE;
$pass = "{$this->datastream} datastream reports the existence of the closing 'EOF' tag required at the end of PDFs"; $pass = "{$this->datastream} datastream reports the existence of the closing 'EOF' tag required at the end of PDFs";
$fail = "{$this->datastream} datastream does not contain the closing 'EOF' tag. If this is the only PDF validation that failed, it is likely that derivative generation was interrupted."; $fail = "{$this->datastream} datastream does not contain the closing 'EOF' tag. If this is the only PDF validation that failed, it is likely that derivative generation was interrupted.";
$message = $assertion ? $pass : $fail; $message = $assertion ? $pass : $fail;
$this->addResult($assertion, $message); $this->addResult($assertion, $message);
} }
} }
/** /**
@ -340,6 +340,7 @@ class PDFDatastreamValidator extends DatastreamValidator {
* integer representing the number of times it should appear in the datastream. * integer representing the number of times it should appear in the datastream.
*/ */
class TextDatastreamValidator extends DatastreamValidator { class TextDatastreamValidator extends DatastreamValidator {
/** /**
* Constructor override; blow up if we don't have our two values. * Constructor override; blow up if we don't have our two values.
*/ */
@ -369,6 +370,7 @@ class TextDatastreamValidator extends DatastreamValidator {
protected function getTextStringCount() { protected function getTextStringCount() {
return substr_count($this->datastreamContent, $this->params[0]); return substr_count($this->datastreamContent, $this->params[0]);
} }
} }
/** /**
@ -401,7 +403,7 @@ class WAVDatastreamValidator extends DatastreamValidator {
/** /**
* Asserts that the datastream contains a valid WAV signature. * Asserts that the datastream contains a valid WAV signature.
*/ */
protected function assertWAVSignature() { protected function assertWavSignature() {
$signatures = str_split(substr($this->datastreamContent, 0, 24), 8); $signatures = str_split(substr($this->datastreamContent, 0, 24), 8);
$assertion = $signatures[0] == '52494646' && $signatures[2] == '57415645'; $assertion = $signatures[0] == '52494646' && $signatures[2] == '57415645';
$pass = "Header of the {$this->datastream} datastream contains a valid file signature."; $pass = "Header of the {$this->datastream} datastream contains a valid file signature.";
@ -413,7 +415,7 @@ class WAVDatastreamValidator extends DatastreamValidator {
/** /**
* Asserts that the chunksize in the header is correct. * Asserts that the chunksize in the header is correct.
*/ */
protected function assertWAVChunkSize() { protected function assertWavChunkSize() {
$assertion = islandora_hex2int(substr($this->datastreamContent, 8, 8)) === 36 + self::getDataSubChunkSize(); $assertion = islandora_hex2int(substr($this->datastreamContent, 8, 8)) === 36 + self::getDataSubChunkSize();
$pass = "{$this->datastream} datastream chunksize in WAV header is correct"; $pass = "{$this->datastream} datastream chunksize in WAV header is correct";
$fail = "{$this->datastream} datastream chunksize in WAV header does not match actual chunksize."; $fail = "{$this->datastream} datastream chunksize in WAV header does not match actual chunksize.";
@ -424,7 +426,7 @@ class WAVDatastreamValidator extends DatastreamValidator {
/** /**
* Asserts that the datastream contains a 'fmt' subchunk. * Asserts that the datastream contains a 'fmt' subchunk.
*/ */
protected function assertWAVFmtSubChunk() { protected function assertWavFmtSubChunk() {
$assertion = substr($this->datastreamContent, 24, 8) === '666d7420'; $assertion = substr($this->datastreamContent, 24, 8) === '666d7420';
$pass = "{$this->datastream} datastream contains a 'fmt' subchunk."; $pass = "{$this->datastream} datastream contains a 'fmt' subchunk.";
$fail = "{$this->datastream} datastream is missing the required 'fmt' subchunk."; $fail = "{$this->datastream} datastream is missing the required 'fmt' subchunk.";
@ -435,7 +437,7 @@ class WAVDatastreamValidator extends DatastreamValidator {
/** /**
* Asserts that the byterate reported by the WAV header is valid. * Asserts that the byterate reported by the WAV header is valid.
*/ */
protected function assertWAVByteRate() { protected function assertWavByteRate() {
$wav_samplerate = islandora_hex2int(substr($this->datastreamContent, 48, 8)); $wav_samplerate = islandora_hex2int(substr($this->datastreamContent, 48, 8));
$assertion = islandora_hex2int(substr($this->datastreamContent, 56, 8)) === $wav_samplerate * self::getNumChannels() * self::getBytesPerSample(); $assertion = islandora_hex2int(substr($this->datastreamContent, 56, 8)) === $wav_samplerate * self::getNumChannels() * self::getBytesPerSample();
$pass = "{$this->datastream} datastream byterate in the WAV header is correct."; $pass = "{$this->datastream} datastream byterate in the WAV header is correct.";
@ -447,7 +449,7 @@ class WAVDatastreamValidator extends DatastreamValidator {
/** /**
* Asserts that the block alignment is correct. * Asserts that the block alignment is correct.
*/ */
protected function assertWAVBlockAlignment() { protected function assertWavBlockAlignment() {
$assertion = islandora_hex2int(substr($this->datastreamContent, 64, 4)) === self::getNumChannels() * self::getBytesPerSample(); $assertion = islandora_hex2int(substr($this->datastreamContent, 64, 4)) === self::getNumChannels() * self::getBytesPerSample();
$pass = "{$this->datastream} datastream block alignment is set correctly."; $pass = "{$this->datastream} datastream block alignment is set correctly.";
$fail = "{$this->datastream} datastream block alignment is off."; $fail = "{$this->datastream} datastream block alignment is off.";
@ -460,7 +462,7 @@ class WAVDatastreamValidator extends DatastreamValidator {
* *
* Also asserts that the subchunk size is correct. * Also asserts that the subchunk size is correct.
*/ */
protected function assertWAVDataSubChunk() { protected function assertWavDataSubChunk() {
if (substr($this->datastreamContent, 72, 8) !== '64617461') { if (substr($this->datastreamContent, 72, 8) !== '64617461') {
$this->addResult(FALSE, "{$this->datastream} datastream is missing the 'data' subchunk."); $this->addResult(FALSE, "{$this->datastream} datastream is missing the 'data' subchunk.");
return; return;
@ -505,6 +507,7 @@ class WAVDatastreamValidator extends DatastreamValidator {
protected function getDataSubChunkSize() { protected function getDataSubChunkSize() {
return islandora_hex2int(substr($this->datastreamContent, 80, 8)); return islandora_hex2int(substr($this->datastreamContent, 80, 8));
} }
} }
/** /**
@ -526,7 +529,7 @@ class MP3DatastreamValidator extends DatastreamValidator {
* breaking my own rules here and using a single assert function so that I * breaking my own rules here and using a single assert function so that I
* can handle the weird logic. * can handle the weird logic.
*/ */
protected function assertValidMP3() { protected function assertValidMp3() {
$this->datastreamContent = bin2hex($this->datastreamContent); $this->datastreamContent = bin2hex($this->datastreamContent);
// If it's not a VBR MP3, we don't have to check much, so let's get that // If it's not a VBR MP3, we don't have to check much, so let's get that
@ -612,7 +615,7 @@ class MP4DatastreamValidator extends DatastreamValidator {
/** /**
* Asserts that the datastream is ISO-formatted video. * Asserts that the datastream is ISO-formatted video.
*/ */
protected function assertISOVideo() { protected function assertIsoVideo() {
$mp4_ftyp = substr(strpos($this->datastreamContent, 'ftyp'), 4, 4); $mp4_ftyp = substr(strpos($this->datastreamContent, 'ftyp'), 4, 4);
$assertion = strpos($this->datastreamContent, 'ftyp') !== 0; $assertion = strpos($this->datastreamContent, 'ftyp') !== 0;
$pass = "{$this->datastream} datastream asserts that it is a valid ISO-formatted video file using ftyp {$mp4_ftyp}"; $pass = "{$this->datastream} datastream asserts that it is a valid ISO-formatted video file using ftyp {$mp4_ftyp}";
@ -620,6 +623,7 @@ class MP4DatastreamValidator extends DatastreamValidator {
$message = $assertion ? $pass : $fail; $message = $assertion ? $pass : $fail;
$this->addResult($assertion, $message); $this->addResult($assertion, $message);
} }
} }
/** /**
@ -636,7 +640,7 @@ class OGGDatastreamValidator extends DatastreamValidator {
/** /**
* Asserts that the datastream contains ogg pages. * Asserts that the datastream contains ogg pages.
*/ */
protected function assertOGGPages() { protected function assertOggPages() {
$ogg_pages = substr_count($this->datastreamContent, 'OggS'); $ogg_pages = substr_count($this->datastreamContent, 'OggS');
$assertion = $ogg_pages !== 0; $assertion = $ogg_pages !== 0;
$pass = "{$this->datastream} datastream asserts that it contains {$ogg_pages} Ogg pages (even a very small file should contain several)."; $pass = "{$this->datastream} datastream asserts that it contains {$ogg_pages} Ogg pages (even a very small file should contain several).";
@ -666,6 +670,7 @@ class OGGDatastreamValidator extends DatastreamValidator {
$message = $assertion ? $pass : $fail; $message = $assertion ? $pass : $fail;
$this->addResult($assertion, $message); $this->addResult($assertion, $message);
} }
} }
/** /**
@ -683,7 +688,7 @@ class MKVDatastreamValidator extends DatastreamValidator {
/** /**
* Asserts that the datastream is an EBML-format file. * Asserts that the datastream is an EBML-format file.
*/ */
protected function assertEBMLFormat() { protected function assertEbmlFormat() {
$assertion = substr(bin2hex($this->datastreamContent), 0, 8) == '1a45dfa3'; $assertion = substr(bin2hex($this->datastreamContent), 0, 8) == '1a45dfa3';
$pass = "{$this->datastream} datastream asserts that it is an EBML-formatted file"; $pass = "{$this->datastream} datastream asserts that it is an EBML-formatted file";
$fail = "{$this->datastream} datastream is not an EBML-formatted file."; $fail = "{$this->datastream} datastream is not an EBML-formatted file.";
@ -701,4 +706,5 @@ class MKVDatastreamValidator extends DatastreamValidator {
$message = $assertion ? $pass : $fail; $message = $assertion ? $pass : $fail;
$this->addResult($assertion, $message); $this->addResult($assertion, $message);
} }
} }

7
tests/includes/islandora_unit_test_case.inc

@ -1,9 +1,8 @@
<?php <?php
/** /**
* @file
* Islandora extensions for DrupalUnitTestCase. * Islandora extensions for DrupalUnitTestCase.
*/ */
class IslandoraUnitTestCase extends DrupalUnitTestCase { class IslandoraUnitTestCase extends DrupalUnitTestCase {
/** /**
@ -21,7 +20,7 @@ class IslandoraUnitTestCase extends DrupalUnitTestCase {
* @param array $args * @param array $args
* The arguments for that method. * The arguments for that method.
*/ */
public function __call($method, $args) { public function __call($method, array $args) {
module_load_include('inc', 'islandora', 'tests/includes/utilities'); module_load_include('inc', 'islandora', 'tests/includes/utilities');
$params = array('db_access' => FALSE); $params = array('db_access' => FALSE);
$utilities = new IslandoraTestUtilities($this->configuration, $params); $utilities = new IslandoraTestUtilities($this->configuration, $params);
@ -40,7 +39,7 @@ class IslandoraUnitTestCase extends DrupalUnitTestCase {
* @param IslandoraTestUtilities $utility * @param IslandoraTestUtilities $utility
* An instance of IslandoraTestUtilities with populated results. * An instance of IslandoraTestUtilities with populated results.
*/ */
public function parseUtilityResults($utility) { public function parseUtilityResults(IslandoraTestUtilities $utility) {
foreach ($utility->getResults() as $result) { foreach ($utility->getResults() as $result) {
$this->assert($result->getType(), $result->getMessage(), 'Islandora', $result->getCaller()); $this->assert($result->getType(), $result->getMessage(), 'Islandora', $result->getCaller());
} }

29
tests/includes/islandora_web_test_case.inc

@ -1,10 +1,8 @@
<?php <?php
/** /**
* @file
* Defines the class IslandoraWebTestCase, which allows tests to access Fedora. * Defines the class IslandoraWebTestCase, which allows tests to access Fedora.
*/ */
class IslandoraWebTestCase extends DrupalWebTestCase { class IslandoraWebTestCase extends DrupalWebTestCase {
/** /**
@ -43,7 +41,7 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
* @return bool * @return bool
* TRUE if the result was a pass, or FALSE otherwise. * TRUE if the result was a pass, or FALSE otherwise.
*/ */
public function __call($method, $args) { public function __call($method, array $args) {
module_load_include('inc', 'islandora', 'tests/includes/utilities'); module_load_include('inc', 'islandora', 'tests/includes/utilities');
$params = array( $params = array(
'logged_in_user' => $this->loggedInUser, 'logged_in_user' => $this->loggedInUser,
@ -65,7 +63,7 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
* @param IslandoraTestUtilities $utility * @param IslandoraTestUtilities $utility
* An instance of IslandoraTestUtilities with populated results. * An instance of IslandoraTestUtilities with populated results.
*/ */
public function parseUtilityResults($utility) { public function parseUtilityResults(IslandoraTestUtilities $utility) {
foreach ($utility->getResults() as $result) { foreach ($utility->getResults() as $result) {
$this->assert($result->getType(), $result->getMessage(), 'Islandora', $result->getCaller()); $this->assert($result->getType(), $result->getMessage(), 'Islandora', $result->getCaller());
} }
@ -253,9 +251,9 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
* Deletes an object using the PID. This does the deletion using the UI. * Deletes an object using the PID. This does the deletion using the UI.
* *
* @param string $pid * @param string $pid
* The PID of the collection to be deleted * The PID of the collection to be deleted.
* @param string $button * @param string $button
* The label of the first 'Delete' button * The label of the first 'Delete' button.
* @param bool $safety * @param bool $safety
* If TRUE, this will only delete objects owned by users in $this->users. * If TRUE, this will only delete objects owned by users in $this->users.
* *
@ -284,11 +282,10 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
} }
} }
/** // These are a few quick helper functions to fill in a gap in the standard
* These are a few quick helper functions to fill in a gap in the standard // DrupalWebTestCase where no function exists to test for the simple existence
* DrupalWebTestCase where no function exists to test for the simple existence // or non-existence of an error.
* or non-existence of an error. // @codingStandardsIgnoreLine
*/
/** /**
* Asserts that an error is found in $this->content. * Asserts that an error is found in $this->content.
@ -373,8 +370,6 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
* button labels that don't have the ID we want, so that the only one left * button labels that don't have the ID we want, so that the only one left
* with the correct label is the one with the right ID. * with the correct label is the one with the right ID.
* *
* @see DrupalWebTestCase::drupalPost()
*
* @param string $path * @param string $path
* Location of the post form. * Location of the post form.
* @param array $edit * @param array $edit
@ -388,15 +383,17 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
* @param array $headers * @param array $headers
* An array containing additional HTTP request headers, each formatted as * An array containing additional HTTP request headers, each formatted as
* "name: value". * "name: value".
* @param null $form_html_id * @param mixed $form_html_id
* (optional) HTML ID of the form to be submitted. * (optional) HTML ID of the form to be submitted.
* @param null $extra_post * @param mixed $extra_post
* (optional) A string of additional data to append to the POST submission. * (optional) A string of additional data to append to the POST submission.
* *
* @return bool|string * @return bool|string
* The content from the POST request's curlExec, or FALSE on fail. * The content from the POST request's curlExec, or FALSE on fail.
*
* @see DrupalWebTestCase::drupalPost()
*/ */
public function drupalPostByID($path, $edit, $submit, $id, array $options = array(), array $headers = array(), $form_html_id = NULL, $extra_post = NULL) { public function drupalPostById($path, array $edit, $submit, $id, array $options = array(), array $headers = array(), $form_html_id = NULL, $extra_post = NULL) {
$buttons = $this->xpath("//input[@type=\"submit\" and @value=\"{$submit}\"]"); $buttons = $this->xpath("//input[@type=\"submit\" and @value=\"{$submit}\"]");
if (empty($buttons)) { if (empty($buttons)) {
$this->fail("No buttons found on the page with value '$submit'"); $this->fail("No buttons found on the page with value '$submit'");

2
tests/includes/test_utility_abstraction.inc

@ -1,4 +1,5 @@
<?php <?php
/** /**
* @file * @file
* Abstraction n' stuff for the test utilities and results. * Abstraction n' stuff for the test utilities and results.
@ -75,6 +76,7 @@ class IslandoraTestUtilityResult {
public function getType() { public function getType() {
return $this->type; return $this->type;
} }
} }
/** /**

9
tests/includes/utilities.inc

@ -1,6 +1,6 @@
<?php <?php
/** /**
* @file
* Utilities classes for simpletest. * Utilities classes for simpletest.
* *
* These utilities are shared between the Islandora Web and Unit test cases and * These utilities are shared between the Islandora Web and Unit test cases and
@ -12,7 +12,6 @@
* more methods for result-passing could potentially be added to this without * more methods for result-passing could potentially be added to this without
* breaking existing implementations. * breaking existing implementations.
*/ */
class IslandoraTestUtilities extends IslandoraTestUtilityClass { class IslandoraTestUtilities extends IslandoraTestUtilityClass {
protected $configuration; protected $configuration;
@ -31,7 +30,7 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass {
* @param array $params * @param array $params
* Any additional parameters the method called may need to function. * Any additional parameters the method called may need to function.
*/ */
public function __construct($configuration, array $params = array()) { public function __construct(array $configuration, array $params = array()) {
$this->configuration = $configuration; $this->configuration = $configuration;
$this->params = $params; $this->params = $params;
$connection = new RepositoryConnection($this->configuration['fedora_url'], $this->configuration['admin_user'], $this->configuration['admin_pass']); $connection = new RepositoryConnection($this->configuration['fedora_url'], $this->configuration['admin_user'], $this->configuration['admin_pass']);
@ -111,7 +110,7 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass {
* @return bool * @return bool
* TRUE on success, FALSE on fail. * TRUE on success, FALSE on fail.
*/ */
public function assertDatastreams($object, array $datastreams) { public function assertDatastreams(AbstractObject $object, array $datastreams) {
if (!self::assertFedoraObject($object)) { if (!self::assertFedoraObject($object)) {
$this->addResult(FALSE, "Failed. Object passed in is invalid.", 'Islandora'); $this->addResult(FALSE, "Failed. Object passed in is invalid.", 'Islandora');
} }
@ -136,7 +135,7 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass {
* @param array $datastreams * @param array $datastreams
* An array of datastreams to confirm not present. * An array of datastreams to confirm not present.
*/ */
public function assertNoDatastreams($object, array $datastreams) { public function assertNoDatastreams(AbstractObject $object, array $datastreams) {
if (!self::assertFedoraObject($object)) { if (!self::assertFedoraObject($object)) {
$this->addResult(FALSE, "Failed. Object passed in is invalid.", 'Islandora'); $this->addResult(FALSE, "Failed. Object passed in is invalid.", 'Islandora');
return; return;

2
tests/ingest.test

@ -1,7 +1,6 @@
<?php <?php
/** /**
* @file
* Tests to see if the hooks get called when appropriate. * Tests to see if the hooks get called when appropriate.
* *
* In the test module 'islandora_hooks_test' there are implementations * In the test module 'islandora_hooks_test' there are implementations
@ -10,7 +9,6 @@
* *
* To make sense of these tests reference islandora_hooks_test.module. * To make sense of these tests reference islandora_hooks_test.module.
*/ */
class IslandoraIngestsTestCase extends IslandoraWebTestCase { class IslandoraIngestsTestCase extends IslandoraWebTestCase {
/** /**

6
tests/islandora_derivatives_test.module

@ -71,6 +71,7 @@ function islandora_derivatives_test_some_cmodel_islandora_derivative_alter(&$der
* An AbstractObject representing a Fedora object. * An AbstractObject representing a Fedora object.
* @param bool $force * @param bool $force
* Whether or not derivative generation is to be forced. * Whether or not derivative generation is to be forced.
*
* @return array * @return array
* An array detailing the success of the operation. * An array detailing the success of the operation.
* *
@ -131,6 +132,7 @@ function islandora_derivatives_test_create_stanley_datastream(AbstractObject $ob
* An AbstractObject representing a Fedora object. * An AbstractObject representing a Fedora object.
* @param bool $force * @param bool $force
* Whether or not derivative generation is to be forced. * Whether or not derivative generation is to be forced.
*
* @return array * @return array
* An array detailing the success of the operation. * An array detailing the success of the operation.
* *
@ -226,13 +228,13 @@ function islandora_derivatives_test_add_datastream(AbstractObject $object, $dsid
/** /**
* Returns a message if we failed to add a derivative. * Returns a message if we failed to add a derivative.
* *
* @see hook_islandora_derivative()
*
* @param string $message * @param string $message
* The error message to be returned back. * The error message to be returned back.
* *
* @return array * @return array
* An array describing the outcome of our failure. * An array describing the outcome of our failure.
*
* @see hook_islandora_derivative()
*/ */
function islandora_derivatives_test_failed_adding($message) { function islandora_derivatives_test_failed_adding($message) {
return array( return array(

2
tests/islandora_hooked_access_test.module

@ -2,7 +2,7 @@
/** /**
* @file * @file
* Hook implementations tested in hooked_access.test * Hook implementations tested in hooked_access.test.
*/ */
/** /**

2
tests/islandora_hooks_test.module

@ -2,7 +2,7 @@
/** /**
* @file * @file
* Implements hooks that get tested by islandora_hooks.test * Implements hooks that get tested by islandora_hooks.test.
*/ */
/** /**

2
tests/islandora_ingest_test.module

@ -2,7 +2,7 @@
/** /**
* @file * @file
* Implements hooks that get tested by islandora_hooks.test * Implements hooks that get tested by islandora_hooks.test.
*/ */
/** /**

3
tests/islandora_manage_permissions.test

@ -1,10 +1,8 @@
<?php <?php
/** /**
* @file
* Tests islandora permissions, and permission related funcitons. * Tests islandora permissions, and permission related funcitons.
*/ */
class IslandoraPermissionsTestCase extends IslandoraWebTestCase { class IslandoraPermissionsTestCase extends IslandoraWebTestCase {
/** /**
@ -133,4 +131,5 @@ class IslandoraPermissionsTestCase extends IslandoraWebTestCase {
$ret = islandora_user_access($object['DC'], array(ISLANDORA_VIEW_OBJECTS), array(), TRUE, $user); $ret = islandora_user_access($object['DC'], array(ISLANDORA_VIEW_OBJECTS), array(), TRUE, $user);
$this->assertTrue($ret, 'User access granted for matching permissions, with a datastream given instead of an object.'); $this->assertTrue($ret, 'User access granted for matching permissions, with a datastream given instead of an object.');
} }
} }

3
tests/islandora_manage_temp_file.test

@ -1,10 +1,8 @@
<?php <?php
/** /**
* @file
* Tests for our islandora_temp_file_entry() function. * Tests for our islandora_temp_file_entry() function.
*/ */
class IslandoraManageTempfileTestCase extends IslandoraWebTestCase { class IslandoraManageTempfileTestCase extends IslandoraWebTestCase {
/** /**
@ -80,4 +78,5 @@ class IslandoraManageTempfileTestCase extends IslandoraWebTestCase {
$this->baseFileHelper($this->tempUri); $this->baseFileHelper($this->tempUri);
$this->baseFileHelper($this->publicUri); $this->baseFileHelper($this->publicUri);
} }
} }

1
theme/islandora-dublin-core-description.tpl.php

@ -1,4 +1,5 @@
<?php <?php
/** /**
* @file * @file
* This is the template file for the Dublin Core metadata description. * This is the template file for the Dublin Core metadata description.

27
theme/islandora-dublin-core-display.tpl.php

@ -1,18 +1,19 @@
<?php <?php
/** /**
* @file * @file
* This is the template file for the object page for large image * This is the template file for the object page for large image.
* *
* Available variables: * Available variables:
* - $islandora_object: The Islandora object rendered in this template file * - $islandora_object: The Islandora object rendered in this template file
* - $islandora_dublin_core: The DC datastream object * - $islandora_dublin_core: The DC datastream object
* - $dc_array: The DC datastream object values as a sanitized array. This * - $dc_array: The DC datastream object values as a sanitized array. This
* includes label, value and class name. * includes label, value and class name.
* - $islandora_object_label: The sanitized object label. * - $islandora_object_label: The sanitized object label.
* *
* @see template_preprocess_islandora_dublin_core_display() * @see template_preprocess_islandora_dublin_core_display()
* @see theme_islandora_dublin_core_display() * @see theme_islandora_dublin_core_display()
*/ */
?> ?>
<fieldset <?php $print ? print('class="islandora islandora-metadata"') : print('class="islandora islandora-metadata collapsible collapsed"');?>> <fieldset <?php $print ? print('class="islandora islandora-metadata"') : print('class="islandora islandora-metadata collapsible collapsed"');?>>
<legend><span class="fieldset-legend"><?php print t('Details'); ?></span></legend> <legend><span class="fieldset-legend"><?php print t('Details'); ?></span></legend>

4
theme/islandora-object-edit.tpl.php

@ -4,11 +4,11 @@
* @file * @file
* The default manage datastreams view for objects. * The default manage datastreams view for objects.
* *
* islandora_object is a fedora tuque Object * Islandora_object is a fedora tuque Object
* $object->label * $object->label
* $object->id * $object->id
* to get the contents of a datastream * to get the contents of a datastream
* $object['dsid']->content * $object['dsid']->content.
* *
* $dublin_core is a DublinCore object * $dublin_core is a DublinCore object
* which is an array of elements, such as dc.title * which is an array of elements, such as dc.title

1
theme/islandora-object-print.tpl.php

@ -3,7 +3,6 @@
/** /**
* @file * @file
* The default view to print objects. * The default view to print objects.
*
*/ */
?> ?>
<div> <div>

30
theme/islandora-object.tpl.php

@ -86,11 +86,31 @@
</tr> </tr>
<?php foreach($datastreams as $key => $value): ?> <?php foreach($datastreams as $key => $value): ?>
<tr> <tr>
<td><?php if(isset($value['id'])): ?><?php print $value['id']; ?><?php endif; ?></td> <td>
<td><?php if(isset($value['label_link'])): ?><?php print $value['label_link']; ?><?php endif; ?></td> <?php if(isset($value['id'])): ?>
<td><?php if(isset($value['size'])): ?><?php print $value['size']; ?><?php endif; ?></td> <?php print $value['id']; ?>
<td><?php if(isset($value['mimetype'])): ?><?php print $value['mimetype']; ?><?php endif; ?></td> <?php endif; ?>
<td><?php if(isset($value['created_date'])): ?><?php print $value['created_date']; ?><?php endif; ?></td> </td>
<td>
<?php if(isset($value['label_link'])): ?>
<?php print $value['label_link']; ?>
<?php endif; ?>
</td>
<td>
<?php if(isset($value['size'])): ?>
<?php print $value['size']; ?>
<?php endif; ?>
</td>
<td>
<?php if(isset($value['mimetype'])): ?>
<?php print $value['mimetype']; ?>
<?php endif; ?>
</td>
<td>
<?php if(isset($value['created_date'])): ?>
<?php print $value['created_date']; ?>
<?php endif; ?>
</td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>

6
theme/islandora-objects.tpl.php

@ -9,9 +9,9 @@
<span class="islandora-objects-display-switch"> <span class="islandora-objects-display-switch">
<?php <?php
print theme('links', array( print theme('links', array(
'links' => $display_links, 'links' => $display_links,
'attributes' => array('class' => array('links', 'inline')), 'attributes' => array('class' => array('links', 'inline')),
) )
); );
?> ?>
</span> </span>

8
theme/theme.inc

@ -168,7 +168,7 @@ function template_preprocess_islandora_default(&$variables) {
*/ */
function template_preprocess_islandora_object_print(array &$variables) { function template_preprocess_islandora_object_print(array &$variables) {
// Apply the print CSS in non print context. // Apply the print CSS in non print context.
$only_print_media = function($o) { $only_print_media = function ($o) {
return $o['media'] == 'print'; return $o['media'] == 'print';
}; };
$css = array_filter(drupal_add_css(), $only_print_media); $css = array_filter(drupal_add_css(), $only_print_media);
@ -313,8 +313,6 @@ function islandora_objects_object_mapper($object_id) {
* *
* A variant of "islandora_objects" which accepts a subset of object to theme. * A variant of "islandora_objects" which accepts a subset of object to theme.
* *
* @see template_preprocess_islandora_objects()
*
* @param array $variables * @param array $variables
* An associative array containing: * An associative array containing:
* - objects: An array of PIDs to render for the given page. * - objects: An array of PIDs to render for the given page.
@ -333,8 +331,10 @@ function islandora_objects_object_mapper($object_id) {
* be toggled between a "grid" and "list" view. * be toggled between a "grid" and "list" view.
* - pager: A renderable array for the pager. * - pager: A renderable array for the pager.
* - content: A renderable array for the main content of the page. * - content: A renderable array for the main content of the page.
*
* @see template_preprocess_islandora_objects()
*/ */
function template_preprocess_islandora_objects_subset(&$variables) { function template_preprocess_islandora_objects_subset(array &$variables) {
$display = (empty($_GET['display'])) ? $variables['display'] : $_GET['display']; $display = (empty($_GET['display'])) ? $variables['display'] : $_GET['display'];
$grid_display = $display == 'grid'; $grid_display = $display == 'grid';
$list_display = !$grid_display; $list_display = !$grid_display;

Loading…
Cancel
Save