Browse Source

Merge pull request #165 from DannyJoris-islandora/7.x

coder cleanup
pull/166/merge
Jonathan Green 12 years ago
parent
commit
ca161685ec
  1. 31
      admin/islandora.admin.inc
  2. 13
      includes/breadcrumb.inc
  3. 86
      includes/datastream.inc
  4. 6
      includes/ingest-menu.inc
  5. 7
      includes/islandora.ingest.inc
  6. 16
      includes/islandora_dublin_core.inc
  7. 2
      includes/mime.detect.inc
  8. 26
      includes/object_properties.inc
  9. 7
      includes/purge.form.inc
  10. 18
      includes/tuque.inc
  11. 63
      includes/utilities.inc
  12. 86
      islandora.api.php
  13. 6
      islandora.install
  14. 58
      islandora.module
  15. 46
      theme/islandora-object-edit.tpl.php
  16. 26
      theme/islandora-object.tpl.php
  17. 11
      theme/islandora.theme.inc

31
admin/islandora.admin.inc

@ -1,11 +1,14 @@
<?php <?php
/** /**
* @file islandora.admin.inc * @file
* Create admin form * islandora.admin.inc: This file contains the general islandora admin form and callback functions.
* @return array
*/ */
/**
* Create admin form
* @return array
*/
function islandora_repository_admin($form, &$form_state) { function islandora_repository_admin($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/tuque'); module_load_include('inc', 'islandora', 'includes/tuque');
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
@ -17,7 +20,7 @@ function islandora_repository_admin($form, &$form_state) {
$form = array(); $form = array();
if(isset($form_state['values']['islandora_base_url'])) { if (isset($form_state['values']['islandora_base_url'])) {
$url = $form_state['values']['islandora_base_url']; $url = $form_state['values']['islandora_base_url'];
} }
else { else {
@ -33,7 +36,7 @@ function islandora_repository_admin($form, &$form_state) {
$info = FALSE; $info = FALSE;
} }
if($info) { if ($info) {
try { try {
$dc = $connection->api->m->getDatastream('fedora-system:ContentModel-3.0', 'DC'); $dc = $connection->api->m->getDatastream('fedora-system:ContentModel-3.0', 'DC');
} }
@ -41,9 +44,9 @@ function islandora_repository_admin($form, &$form_state) {
$dc = FALSE; $dc = FALSE;
} }
} }
if($info) { if ($info) {
if($dc) { if ($dc) {
$confirmation_message = '<img src="' . url('misc/watchdog-ok.png') . '"/>' $confirmation_message = '<img src="' . url('misc/watchdog-ok.png') . '"/>'
. t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion'])); . t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion']));
} }
@ -77,7 +80,7 @@ function islandora_repository_admin($form, &$form_state) {
'#type' => 'textfield', '#type' => 'textfield',
'#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), '#description' => t('The URL to use for REST connections <br />' . $confirmation_message),
'#required' => TRUE, '#required' => TRUE,
'#ajax' => array( '#ajax' => array(
'callback' => 'islandora_update_url_div', 'callback' => 'islandora_update_url_div',
@ -121,20 +124,20 @@ function islandora_repository_admin($form, &$form_state) {
'progress' => array('type' => 'throbber'), 'progress' => array('type' => 'throbber'),
), ),
); );
if(isset($form_state['values']['islandora_namespace_restriction_enforced'])) { if (isset($form_state['values']['islandora_namespace_restriction_enforced'])) {
$namespaces = $form_state['values']['islandora_namespace_restriction_enforced']; $namespaces = $form_state['values']['islandora_namespace_restriction_enforced'];
} }
else { else {
$namespaces = variable_get('islandora_namespace_restriction_enforced', FALSE); $namespaces = variable_get('islandora_namespace_restriction_enforced', FALSE);
} }
if($namespaces) { if ($namespaces) {
$form['islandora_tabs']['islandora_namespace']['wrapper']['islandora_pids_allowed'] = array( $form['islandora_tabs']['islandora_namespace']['wrapper']['islandora_pids_allowed'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('PID namespaces allowed in this Drupal install'), '#title' => t('PID namespaces allowed in this Drupal install'),
'#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: ilives: islandora-book: books: newspapers: '), '#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: ilives: islandora-book: books: newspapers: '),
'#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos. <br> islandora: is reserved and is always allowed.'), '#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos. <br /> islandora: is reserved and is always allowed.'),
'#weight' => 0, '#weight' => 0,
); );
} }
@ -158,6 +161,6 @@ function islandora_update_url_div($form, $form_state) {
function islandora_update_namespace_div($form, $form_state) { function islandora_update_namespace_div($form, $form_state) {
unset($form_state['submit_handlers']); unset($form_state['submit_handlers']);
$form_state['rebuild'] = TRUE; $form_state['rebuild'] = TRUE;
return $form['islandora_tabs']['islandora_namespace']['wrapper']; return $form['islandora_tabs']['islandora_namespace']['wrapper'];
} }

13
includes/breadcrumb.inc

@ -1,11 +1,16 @@
<?php <?php
/**
* @file
* This file contains functions to create breadcrumbs on Islandora object pages.
*/
function islandora_get_breadcrumbs($object) { function islandora_get_breadcrumbs($object) {
$breadcrumbs = array(); $breadcrumbs = array();
islandora_get_breadcrumbs_recursive($object->id, $breadcrumbs, $object->repository); islandora_get_breadcrumbs_recursive($object->id, $breadcrumbs, $object->repository);
if(isset($breadcrumbs[0])) { if (isset($breadcrumbs[0])) {
unset($breadcrumbs[0]); unset($breadcrumbs[0]);
} }
@ -69,8 +74,8 @@ function islandora_get_breadcrumbs_recursive($pid, &$breadcrumbs, $repository) {
islandora_get_breadcrumbs_recursive($parent, $breadcrumbs, $repository); islandora_get_breadcrumbs_recursive($parent, $breadcrumbs, $repository);
} }
else { else {
$breadcrumbs[] = '...'; //Add an non-link, as we don't know how to get back to the root. $breadcrumbs[] = '...'; // Add an non-link, as we don't know how to get back to the root.
islandora_get_breadcrumbs_recursive($root, $breadcrumbs, $repository); //And render the last two links and break (on the next pass). islandora_get_breadcrumbs_recursive($root, $breadcrumbs, $repository); // And render the last two links and break (on the next pass).
} }
} }
} }

86
includes/datastream.inc

@ -1,26 +1,28 @@
<?php <?php
/** /**
* @file datastream.inc * @file
* This file contains the admin form and callback functions for datastream manipulations.
*/ */
define('DS_COMP_STREAM', 'DS-COMPOSITE-MODEL'); define('DS_COMP_STREAM', 'DS-COMPOSITE-MODEL');
/** /**
* Callback function to view or download a datastream.
* *
* @global object $user * @global object $user
* @param string $object_id * @param string $object_id
* @param string $dsid * @param string $dsid
* @return stream * @return stream
* prints datastream to browser * prints datastream to browser
*/ */
function islandora_view_datastream($object, $dsid, $method = 'view') { function islandora_view_datastream($object, $dsid, $method = 'view') {
// if the object exists but the datastream doesn't // if the object exists but the datastream doesn't
if(!isset($object[$dsid])) { if (!isset($object[$dsid])) {
return drupal_not_found(); return drupal_not_found();
} }
header('Content-type: ' . $object[$dsid]->mimetype); header('Content-type: ' . $object[$dsid]->mimetype);
if($object[$dsid]->controlGroup == 'M' || $object[$dsid]->controlGroup == 'X') { if ($object[$dsid]->controlGroup == 'M' || $object[$dsid]->controlGroup == 'X') {
header('Content-length: ' . $object[$dsid]->size); header('Content-length: ' . $object[$dsid]->size);
} }
@ -45,7 +47,7 @@ function islandora_datastream_get_parents($islandora_object) {
} }
$collections = array_merge($collections1, $collections2); $collections = array_merge($collections1, $collections2);
foreach($collections as $collection) { foreach ($collections as $collection) {
try { try {
$pid = $collection['object']['value']; $pid = $collection['object']['value'];
$object = $repository->getObject($collection['object']['value']); $object = $repository->getObject($collection['object']['value']);
@ -55,7 +57,9 @@ function islandora_datastream_get_parents($islandora_object) {
$parent_collections[$pid]['label'] = $object->label; $parent_collections[$pid]['label'] = $object->label;
$parent_collections[$pid]['label_link'] = l($parent_collections[$pid]['label'], $parent_collections[$pid]['url']); $parent_collections[$pid]['label_link'] = l($parent_collections[$pid]['label'], $parent_collections[$pid]['url']);
} }
catch (RepositoryException $e) {} catch (RepositoryException $e) {
}
} }
return $parent_collections; return $parent_collections;
@ -65,13 +69,13 @@ function islandora_datastream_get_parents($islandora_object) {
* *
* @param array $arr * @param array $arr
* an array of dsids that are defined by this objects cmodels * an array of dsids that are defined by this objects cmodels
* @param string $ds_comp_stream * @param string $ds_comp_stream
* the dscomposite stream as xml * the dscomposite stream as xml
*/ */
function islandora_get_defined_dsids_array(&$arr, $ds_comp_stream) { function islandora_get_defined_dsids_array(&$arr, $ds_comp_stream) {
$sxml = new SimpleXMLElement($ds_comp_stream); $sxml = new SimpleXMLElement($ds_comp_stream);
foreach ($sxml->dsTypeModel as $ds) { foreach ($sxml->dsTypeModel as $ds) {
//$arr[$ds['ID']] //$arr[$ds['ID']]
$mimes = array(); $mimes = array();
foreach ($ds->form as $form) { foreach ($ds->form as $form) {
$mimetype = (string) $form['MIME']; $mimetype = (string) $form['MIME'];
@ -88,13 +92,13 @@ function islandora_get_defined_dsids_array(&$arr, $ds_comp_stream) {
* *
* @global type $user * @global type $user
* @param string $object_id * @param string $object_id
* @return string|array * @return string|array
*/ */
function islandora_get_unused_dsids($object) { function islandora_get_unused_dsids($object) {
$defined_dsids = array(); $defined_dsids = array();
if(!$object) { if (!$object) {
return $defined_dsids; return $defined_dsids;
} }
@ -124,11 +128,11 @@ function islandora_get_unused_dsids($object) {
* buids the default add datastream form * buids the default add datastream form
* @param string $object_id * @param string $object_id
* @param array $form_state * @param array $form_state
* @return array * @return array
* a form ready to be rendered with a call to Drupal render * a form ready to be rendered with a call to Drupal render
*/ */
function islandora_get_add_datastream_form($object, &$form_state) { function islandora_get_add_datastream_form($object, &$form_state) {
$unused_dsids = islandora_get_unused_dsids($object); $unused_dsids = islandora_get_unused_dsids($object);
$form = array(); $form = array();
$form['add_fieldset'] = array( $form['add_fieldset'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -168,9 +172,9 @@ function islandora_get_add_datastream_form($object, &$form_state) {
); );
if (!empty($unused_dsids)) { if (!empty($unused_dsids)) {
$dsidsForForm = array(); $dsids_for_form = array();
foreach ($unused_dsids as $key => $value) { foreach ($unused_dsids as $key => $value) {
$dsidsForForm[$key] = $key; $dsids_for_form[$key] = $key;
} }
$form['add_fieldset']['stream_id'] = array( $form['add_fieldset']['stream_id'] = array(
'#type' => 'select', '#type' => 'select',
@ -179,7 +183,7 @@ function islandora_get_add_datastream_form($object, &$form_state) {
'#weight' => '-1', '#weight' => '-1',
'#description' => t('Datastream IDs defined by the content model.'), '#description' => t('Datastream IDs defined by the content model.'),
); );
$form['add_fieldset']['stream_id']['#options'] = $dsidsForForm; $form['add_fieldset']['stream_id']['#options'] = $dsids_for_form;
} }
else { else {
$form['add_fieldset']['stream_id'] = array( $form['add_fieldset']['stream_id'] = array(
@ -201,7 +205,7 @@ function islandora_get_add_datastream_form($object, &$form_state) {
* Drupal user * Drupal user
* @param array $form * @param array $form
* @param array $form_state * @param array $form_state
* @return type * @return type
*/ */
function islandora_add_datastream_form_submit($form, &$form_state) { function islandora_add_datastream_form_submit($form, &$form_state) {
global $base_url; global $base_url;
@ -212,7 +216,7 @@ function islandora_add_datastream_form_submit($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/mime.detect'); module_load_include('inc', 'islandora', 'includes/mime.detect');
$mimetype = new MimeDetect(); $mimetype = new MimeDetect();
$file = $form_state['values']['add-stream-file-location']; $file = $form_state['values']['add-stream-file-location'];
$file = drupal_realpath($file); $file = drupal_realpath($file);
@ -220,11 +224,11 @@ function islandora_add_datastream_form_submit($form, &$form_state) {
$dsid = $form_state['values']['stream_id']; $dsid = $form_state['values']['stream_id'];
$ds_label = $form_state['values']['stream_label']; $ds_label = $form_state['values']['stream_label'];
$dformat = $mimetype->getMimeType($file); $dformat = $mimetype->getMimeType($file);
$controlGroup = "M"; $control_group = "M";
try { try {
$fedora_object = islandora_object_load($object_id); $fedora_object = islandora_object_load($object_id);
$ds = $fedora_object->constructDatastream($dsid, $controlGroup); $ds = $fedora_object->constructDatastream($dsid, $control_group);
$ds->label = $ds_label; $ds->label = $ds_label;
$ds->mimetype = $dformat; $ds->mimetype = $dformat;
$ds->setContentFromFile($file); $ds->setContentFromFile($file);
@ -235,16 +239,16 @@ function islandora_add_datastream_form_submit($form, &$form_state) {
drupal_set_message(t('@message', array('@message' => check_plain($e->getMessage()))), 'error'); drupal_set_message(t('@message', array('@message' => check_plain($e->getMessage()))), 'error');
return; return;
} }
drupal_set_message("Successfully Added Datastream!"); drupal_set_message(t("Successfully Added Datastream!"));
drupal_goto("islandora/object/$object_id"); drupal_goto("islandora/object/$object_id");
} }
/** /**
* validates this datastream id against its allowed mimetypes in the dscomposite * validates this datastream id against its allowed mimetypes in the dscomposite
* of its content models. * of its content models.
* @param array $form * @param array $form
* @param array $form_state * @param array $form_state
* @return boolean * @return boolean
*/ */
function islandora_add_datastream_form_validate($form, &$form_state) { function islandora_add_datastream_form_validate($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/mime.detect'); module_load_include('inc', 'islandora', 'includes/mime.detect');
@ -254,8 +258,8 @@ function islandora_add_datastream_form_validate($form, &$form_state) {
return; return;
} }
$dsid = $form_state['values']['stream_id']; $dsid = $form_state['values']['stream_id'];
$dsLabel = $form_state['values']['stream_label']; $ds_label = $form_state['values']['stream_label'];
if (strlen($dsid) > 64) { if (drupal_strlen($dsid) > 64) {
form_set_error('', t('Data stream ID cannot be more than 64 characters.')); form_set_error('', t('Data stream ID cannot be more than 64 characters.'));
return FALSE; return FALSE;
} }
@ -263,11 +267,11 @@ function islandora_add_datastream_form_validate($form, &$form_state) {
form_set_error('', t("Data stream ID (@dsid) has to start with a letter.", array('@dsid' => check_plain($dsid)))); form_set_error('', t("Data stream ID (@dsid) has to start with a letter.", array('@dsid' => check_plain($dsid))));
return FALSE; return FALSE;
} }
if (strlen($dsLabel) > 64) { if (drupal_strlen($ds_label) > 64) {
form_set_error('', t('Data stream Label cannot be more than 64 characters.')); form_set_error('', t('Data stream Label cannot be more than 64 characters.'));
return FALSE; return FALSE;
} }
if (strpos($dsLabel, '/')) { if (strpos($ds_label, '/')) {
form_set_error('', t('Data stream Label cannot contain a "/".')); form_set_error('', t('Data stream Label cannot contain a "/".'));
return FALSE; return FALSE;
} }
@ -275,7 +279,7 @@ function islandora_add_datastream_form_validate($form, &$form_state) {
$object_id = $form_state['values']['pid']; $object_id = $form_state['values']['pid'];
$fedora_object = islandora_object_load($object_id); $fedora_object = islandora_object_load($object_id);
if(isset($fedora_object[$dsid])) { if (isset($fedora_object[$dsid])) {
form_set_error('', t('Data stream ID already exists in object.')); form_set_error('', t('Data stream ID already exists in object.'));
return FALSE; return FALSE;
} }
@ -283,7 +287,7 @@ function islandora_add_datastream_form_validate($form, &$form_state) {
$mimetype = new MimeDetect(); $mimetype = new MimeDetect();
$object = islandora_object_load($form_state['values']['pid']); $object = islandora_object_load($form_state['values']['pid']);
$unused_dsids = islandora_get_unused_dsids($object); $unused_dsids = islandora_get_unused_dsids($object);
if(isset($unused_dsids[$dsid])) { if (isset($unused_dsids[$dsid])) {
$types_allowed = $unused_dsids[$dsid]; $types_allowed = $unused_dsids[$dsid];
$arr = array(); $arr = array();
foreach ($types_allowed as $type) { foreach ($types_allowed as $type) {
@ -295,7 +299,7 @@ function islandora_add_datastream_form_validate($form, &$form_state) {
// http://api.drupal.org/api/drupal/includes!file.inc/function/file_save_upload/7 // http://api.drupal.org/api/drupal/includes!file.inc/function/file_save_upload/7
$arr = array(); $arr = array();
} }
$file = file_save_upload('add-stream-file-location', array('file_validate_extensions' => $arr)); $file = file_save_upload('add-stream-file-location', array('file_validate_extensions' => $arr));
if ($file) { if ($file) {
@ -312,7 +316,7 @@ function islandora_add_datastream_form_validate($form, &$form_state) {
* buids the default add datastream form * buids the default add datastream form
* @param string $object_id * @param string $object_id
* @param array $form_state * @param array $form_state
* @return array * @return array
* a form ready to be rendered with a call to Drupal render * a form ready to be rendered with a call to Drupal render
*/ */
function islandora_add_datastream_form($form, &$form_state, $object) { function islandora_add_datastream_form($form, &$form_state, $object) {
@ -356,19 +360,19 @@ function islandora_add_datastream_form($form, &$form_state, $object) {
); );
$unused_dsids = islandora_get_unused_dsids($object); $unused_dsids = islandora_get_unused_dsids($object);
$dsidsForForm = ''; $dsids_for_form = '';
$i = 0; $i = 0;
foreach ($unused_dsids as $key => $value) { foreach ($unused_dsids as $key => $value) {
if($i++) { if ($i++) {
$dsidsForForm .= ", "; $dsids_for_form .= ", ";
} }
$dsidsForForm .= "'$key'"; $dsids_for_form .= "'$key'";
} }
$form['add_fieldset']['stream_id'] = array( $form['add_fieldset']['stream_id'] = array(
'#title' => 'Datastream ID', '#title' => 'Datastream ID',
'#required' => 'TRUE', '#required' => 'TRUE',
'#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores. Datastreams that are defined by the content model dont currently exist: <b>' . $dsidsForForm . '</b>.'), '#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores. Datastreams that are defined by the content model dont currently exist: <b>' . $dsids_for_form . '</b>.'),
'#type' => 'textfield', '#type' => 'textfield',
'#weight' => -1, '#weight' => -1,
'#autocomplete_path' => "islandora/object/$object->id/manage/datastreams/add/autocomplete", '#autocomplete_path' => "islandora/object/$object->id/manage/datastreams/add/autocomplete",
@ -379,13 +383,13 @@ function islandora_add_datastream_form($form, &$form_state, $object) {
function islandora_datastream_autocomplete_callback($object, $string = '') { function islandora_datastream_autocomplete_callback($object, $string = '') {
$dsids = islandora_get_unused_dsids($object); $dsids = islandora_get_unused_dsids($object);
$output = array(); $output = array();
foreach($dsids as $id => $ds) { foreach ($dsids as $id => $ds) {
if(trim($string) == '') { if (trim($string) == '') {
$output[$id] = $id; $output[$id] = $id;
} }
else { else {
$ret = stripos($id, $string); $ret = stripos($id, $string);
if($ret !== FALSE) { if ($ret !== FALSE) {
$output[$id] = $id; $output[$id] = $id;
} }
} }
@ -397,7 +401,7 @@ function islandora_datastream_get_human_readable_size($ds) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
// we return - if we don't have a size // we return - if we don't have a size
if($ds->controlGroup == 'M' || $ds->controlGroup == 'X') { if ($ds->controlGroup == 'M' || $ds->controlGroup == 'X') {
return islandora_convert_bytes_to_human_readable($ds->size); return islandora_convert_bytes_to_human_readable($ds->size);
} }
else { else {
@ -406,7 +410,7 @@ function islandora_datastream_get_human_readable_size($ds) {
} }
function islandora_datastream_get_url($ds, $type = 'download') { function islandora_datastream_get_url($ds, $type = 'download') {
if($ds->controlGroup == 'R') { if ($ds->controlGroup == 'R') {
return $ds->url; return $ds->url;
} }
else { else {
@ -417,7 +421,7 @@ function islandora_datastream_get_url($ds, $type = 'download') {
function islandora_datastream_get_delete_link($ds) { function islandora_datastream_get_delete_link($ds) {
$datastreams = module_invoke_all('islandora_undeletable_datastreams', $ds->parent->models); $datastreams = module_invoke_all('islandora_undeletable_datastreams', $ds->parent->models);
if(in_array($ds->id, $datastreams)) { if (in_array($ds->id, $datastreams)) {
return ''; return '';
} }
else { else {

6
includes/ingest-menu.inc

@ -11,13 +11,13 @@
* @param string $pid * @param string $pid
*/ */
function islandora_ingest_callback($collection_object) { function islandora_ingest_callback($collection_object) {
if(!$collection_object) { if (!$collection_object) {
return drupal_not_found(); return drupal_not_found();
} }
$ingest_registry = module_invoke_all('islandora_ingest_registry', $collection_object); $ingest_registry = module_invoke_all('islandora_ingest_registry', $collection_object);
$registry_count = count($ingest_registry); $registry_count = count($ingest_registry);
if ($registry_count == 0) { if ($registry_count == 0) {
// No ingest implementations. // No ingest implementations.
drupal_set_message(t('There are no ingest methods specified for @name.', array('@name', $collection_object->label))); drupal_set_message(t('There are no ingest methods specified for @name.', array('@name', $collection_object->label)));
@ -33,7 +33,7 @@ function islandora_ingest_callback($collection_object) {
} }
} }
//@TODO: theme // @TODO: theme
function islandora_ingest_registry_render($ingest_registry) { function islandora_ingest_registry_render($ingest_registry) {
$output = array( $output = array(
'#type' => 'markup', '#type' => 'markup',

7
includes/islandora.ingest.inc

@ -1,5 +1,10 @@
<?php <?php
/**
* @file
* This file contains ingest callback functions
*/
function islandora_ingest_get_information(AbstractFedoraObject $collection_object) { function islandora_ingest_get_information(AbstractFedoraObject $collection_object) {
$models = $collection_object->models; $models = $collection_object->models;
$collection_info = module_invoke_all('islandora_ingest_get_information', $models, $collection_object); $collection_info = module_invoke_all('islandora_ingest_get_information', $models, $collection_object);
@ -12,7 +17,7 @@ function islandora_ingest_get_object($content_models, $collection_pid, $relation
global $user; global $user;
$connection = new IslandoraTuque($user); $connection = new IslandoraTuque($user);
$object = $connection->repository->constructObject($namespace); $object = $connection->repository->constructObject($namespace);
foreach($content_models as $content_model) { foreach ($content_models as $content_model) {
$object->relationships->add(FEDORA_MODEL_URI, 'hasModel', $content_model['pid']); $object->relationships->add(FEDORA_MODEL_URI, 'hasModel', $content_model['pid']);
} }
$object->relationships->add(FEDORA_RELS_EXT_URI, $relationship, $collection_pid); $object->relationships->add(FEDORA_RELS_EXT_URI, $relationship, $collection_pid);

16
includes/islandora_dublin_core.inc

@ -70,7 +70,7 @@ class Dublin_Core {
/** /**
* Serialize this object to XML and return it. * Serialize this object to XML and return it.
* @param type $with_preamble * @param type $with_preamble
* @return type * @return type
*/ */
function as_xml($with_preamble = FALSE) { function as_xml($with_preamble = FALSE) {
$dc_xml = new DomDocument(); $dc_xml = new DomDocument();
@ -96,7 +96,7 @@ class Dublin_Core {
* Create dc from dict ( does nothing ) * Create dc from dict ( does nothing )
*/ */
static function create_dc_from_dict() { static function create_dc_from_dict() {
} }
function as_formatted_array() { function as_formatted_array() {
@ -108,9 +108,9 @@ class Dublin_Core {
if (is_array($values)) { if (is_array($values)) {
$value = ''; $value = '';
$i = 0; $i = 0;
foreach($values as $piece) { foreach ($values as $piece) {
if(!empty($piece)) { if (!empty($piece)) {
if($i++) { if ($i++) {
$value .= ", "; $value .= ", ";
} }
$value .= $piece; $value .= $piece;
@ -121,16 +121,16 @@ class Dublin_Core {
$value = $values; $value = $values;
} }
$dc_label = explode(':', $field); $dc_label = explode(':', $field);
$element_label = ucfirst($dc_label[1]); $element_label = drupal_ucfirst($dc_label[1]);
$dc_array[$field]['label'] = $element_label; $dc_array[$field]['label'] = $element_label;
$dc_array[$field]['value'] = $value; $dc_array[$field]['value'] = $value;
$dc_array[$field]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $field)); $dc_array[$field]['class'] = drupal_strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $field));
} }
} }
} }
return $dc_array; return $dc_array;
} }
/** /**
* Creates a new instance of the class by parsing dc_xml * Creates a new instance of the class by parsing dc_xml

2
includes/mime.detect.inc

@ -227,7 +227,7 @@ class MimeDetect {
public function getMimetype($filename, $debug = FALSE) { public function getMimetype($filename, $debug = FALSE) {
$file_name_and_extension = explode('.', $filename); $file_name_and_extension = explode('.', $filename);
$ext = strtolower(array_pop($file_name_and_extension)); $ext = drupal_strtolower(array_pop($file_name_and_extension));
if (!empty($this->protectedMimeTypes[$ext])) { if (!empty($this->protectedMimeTypes[$ext])) {
if (TRUE === $debug) { if (TRUE === $debug) {

26
includes/object_properties.inc

@ -1,13 +1,20 @@
<?php <?php
/** /**
* may want more validation here the only restrictions i see on * @file
* Contains admin form functions for object properties
*/
/**
* Validate function for object properties admin form.
*
* @TODO: may want more validation here the only restrictions i see on
* the object label and owner is the foxml schema says they should be * the object label and owner is the foxml schema says they should be
* an xsd:string there maybe further restrictions such as length but they aren't * an xsd:string there maybe further restrictions such as length but they aren't
* defined in the schema. * defined in the schema.
* @param array $form * @param array $form
* @param array $form_state * @param array $form_state
* @return boolean * @return boolean
*/ */
function islandora_edit_properties_form_validate($form, &$form_state) { function islandora_edit_properties_form_validate($form, &$form_state) {
$islandora_object = islandora_object_load($form_state['values']['pid']); $islandora_object = islandora_object_load($form_state['values']['pid']);
@ -18,9 +25,10 @@ function islandora_edit_properties_form_validate($form, &$form_state) {
} }
/** /**
* Submit function for object properties admin form.
* *
* @param array $form * @param array $form
* @param array $form_state * @param array $form_state
*/ */
function islandora_edit_properties_form_submit($form, &$form_state) { function islandora_edit_properties_form_submit($form, &$form_state) {
$islandora_object = islandora_object_load($form_state['values']['pid']); $islandora_object = islandora_object_load($form_state['values']['pid']);
@ -32,7 +40,7 @@ function islandora_edit_properties_form_submit($form, &$form_state) {
$islandora_object->owner = $owner; $islandora_object->owner = $owner;
drupal_set_message(t('Successfully updated owner %s', array('%s' => $owner))); drupal_set_message(t('Successfully updated owner %s', array('%s' => $owner)));
} catch (Exception $e) { } catch (Exception $e) {
form_set_error('object_owner',t('Error updating owner %s', array('%s'=> $e->getMessage()))); form_set_error('object_owner', t('Error updating owner %s', array('%s' => $e->getMessage())));
} }
} }
if (isset($state) && $state != $islandora_object->state) { if (isset($state) && $state != $islandora_object->state) {
@ -40,7 +48,7 @@ function islandora_edit_properties_form_submit($form, &$form_state) {
$islandora_object->state = $state; $islandora_object->state = $state;
drupal_set_message(t('Successfully updated state %s', array('%s' => $state))); drupal_set_message(t('Successfully updated state %s', array('%s' => $state)));
} catch (Exception $e) { } catch (Exception $e) {
form_set_error('object_state',t('Error updating state %s', array('%s'=> $e->getMessage()))); form_set_error('object_state', t('Error updating state %s', array('%s' => $e->getMessage())));
} }
} }
if (isset($label) && $label != $islandora_object->label) { if (isset($label) && $label != $islandora_object->label) {
@ -53,18 +61,22 @@ function islandora_edit_properties_form_submit($form, &$form_state) {
} }
} }
/**
* Callback function for object properties admin form delete button.
*/
function islandora_edit_properties_form_delete($form, &$form_state) { function islandora_edit_properties_form_delete($form, &$form_state) {
$islandora_object = $form_state['values']['pid']; $islandora_object = $form_state['values']['pid'];
drupal_goto("islandora/object/$islandora_object/delete"); drupal_goto("islandora/object/$islandora_object/delete");
} }
/** /**
* Object properties admin form.
* *
* @param array $form * @param array $form
* @param array $form_state * @param array $form_state
* @param string $object_id * @param string $object_id
* an object id * an object id
* @return array * @return array
*/ */
function islandora_edit_properties_form($form, &$form_state, $object) { function islandora_edit_properties_form($form, &$form_state, $object) {
$form = array(); $form = array();
@ -111,5 +123,3 @@ function islandora_edit_properties_form($form, &$form_state, $object) {
); );
return $form; return $form;
} }
?>

7
includes/purge.form.inc

@ -1,5 +1,10 @@
<?php <?php
/**
* @file
* This file contains the admin (confirmation) form and callback functions to purge an object.
*/
/** /**
* Gives the option of deleting or purging and object. * Gives the option of deleting or purging and object.
* *
@ -154,7 +159,7 @@ function islandora_purge_datastream_submit($form, &$form_state) {
} }
} }
//notify modules post deletion //notify modules post deletion
module_invoke_all('islandora_post_purge_datastream', $object, $datastream_id); module_invoke_all('islandora_post_purge_datastream', $object, $datastream_id);
drupal_set_message(t('%d datastream sucessfully purged from Islandora object %o', array('%d' => $datastream_id, '%o' => $object->label))); drupal_set_message(t('%d datastream sucessfully purged from Islandora object %o', array('%d' => $datastream_id, '%o' => $object->label)));
drupal_goto('islandora/object/' . $object->id); drupal_goto('islandora/object/' . $object->id);
} }

18
includes/tuque.inc

@ -1,5 +1,10 @@
<?php <?php
/**
* @file
* This file contains a class to include the Tuque php library.
*/
$islandora_module_path = drupal_get_path('module', 'islandora'); $islandora_module_path = drupal_get_path('module', 'islandora');
//do this until we expost these in a module or library //do this until we expost these in a module or library
@ -54,14 +59,15 @@ class IslandoraTuque {
public $repository = NULL; public $repository = NULL;
function __construct($user = NULL, $url = NULL) { function __construct($user = NULL, $url = NULL) {
if(!isset($user)) { if (!isset($user)) {
global $user; global $user;
} }
if(!isset($user) || $user->uid == 0){ if (!isset($user) || $user->uid == 0) {
$user_string = 'anonymous'; $user_string = 'anonymous';
$pass_string = 'anonymous'; $pass_string = 'anonymous';
} else { }
else {
$user_string = $user->name; $user_string = $user->name;
$pass_string = $user->pass; $pass_string = $user->pass;
} }
@ -70,7 +76,7 @@ class IslandoraTuque {
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
} }
if(self::exists()) { if (self::exists()) {
$this->connection = new RepositoryConnection($url, $user_string, $pass_string); $this->connection = new RepositoryConnection($url, $user_string, $pass_string);
$this->connection->reuseConnection = TRUE; $this->connection->reuseConnection = TRUE;
$this->api = new FedoraApi($this->connection); $this->api = new FedoraApi($this->connection);
@ -87,7 +93,7 @@ class IslandoraTuque {
$islandora_doc_link = l(t('Islandora documentation'), 'https://wiki.duraspace.org/display/ISLANDORA/Islandora'); $islandora_doc_link = l(t('Islandora documentation'), 'https://wiki.duraspace.org/display/ISLANDORA/Islandora');
$tuque_link = l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque'); $tuque_link = l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque');
$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($message, 'error', FALSE); drupal_set_message(filter_xss($message), 'error', FALSE);
} }
} }

63
includes/utilities.inc

@ -1,39 +1,44 @@
<?php <?php
/**
* @file
* Contains islandora utility functions
*/
/** /**
* Convert bytes to human readable format * Convert bytes to human readable format
* *
* @param integer bytes Size in bytes to convert * @param integer bytes Size in bytes to convert
* @return string * @return string
*/ */
function islandora_convert_bytes_to_human_readable($bytes, $precision = 2) function islandora_convert_bytes_to_human_readable($bytes, $precision = 2) {
{ $kilobyte = 1024;
$kilobyte = 1024; $megabyte = $kilobyte * 1024;
$megabyte = $kilobyte * 1024; $gigabyte = $megabyte * 1024;
$gigabyte = $megabyte * 1024; $terabyte = $gigabyte * 1024;
$terabyte = $gigabyte * 1024;
if (($bytes >= 0) && ($bytes < $kilobyte)) {
return $bytes . ' B';
} elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) { if (($bytes >= 0) && ($bytes < $kilobyte)) {
return round($bytes / $kilobyte, $precision) . ' KB'; return $bytes . ' B';
}
} elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) { elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) {
return round($bytes / $megabyte, $precision) . ' MB'; return round($bytes / $kilobyte, $precision) . ' KB';
}
} elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) { elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) {
return round($bytes / $gigabyte, $precision) . ' GB'; return round($bytes / $megabyte, $precision) . ' MB';
}
} elseif ($bytes >= $terabyte) { elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) {
return round($bytes / $terabyte, $precision) . ' TB'; return round($bytes / $gigabyte, $precision) . ' GB';
} else { }
return $bytes . ' B'; elseif ($bytes >= $terabyte) {
} return round($bytes / $terabyte, $precision) . ' TB';
}
else {
return $bytes . ' B';
}
} }
function islandora_control_group_to_human_readable($control_group) { function islandora_control_group_to_human_readable($control_group) {
switch($control_group) { switch ($control_group) {
case 'M': case 'M':
return '<b>M</b>anaged'; return '<b>M</b>anaged';
case 'X': case 'X':
@ -54,7 +59,7 @@ function islandora_control_group_to_human_readable($control_group) {
*/ */
function islandora_validate_pid($pid) { function islandora_validate_pid($pid) {
$valid = FALSE; $valid = FALSE;
if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) { if (drupal_strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) {
$valid = TRUE; $valid = TRUE;
} }
@ -68,7 +73,7 @@ function islandora_validate_pid($pid) {
*/ */
function islandora_validate_dsid($dsid) { function islandora_validate_dsid($dsid) {
$valid = FALSE; $valid = FALSE;
if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) { if (drupal_strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) {
$valid = TRUE; $valid = TRUE;
} }
@ -76,9 +81,9 @@ function islandora_validate_dsid($dsid) {
} }
/* Helper function to describe a Fedora repository. /* Helper function to describe a Fedora repository.
* *
* Can be used to check if Fedora is available. * Can be used to check if Fedora is available.
* *
* @param $url * @param $url
* A url to a Fedora repository. * A url to a Fedora repository.
* @return * @return
@ -86,7 +91,7 @@ function islandora_validate_dsid($dsid) {
* or if the url is incorrect. * or if the url is incorrect.
*/ */
function islandora_describe_repository($url) { function islandora_describe_repository($url) {
$connection = new IslandoraTuque(NULL, $url); $connection = new IslandoraTuque(NULL, $url);
try { try {
$info = $connection->api->a->describeRepository(); $info = $connection->api->a->describeRepository();

86
islandora.api.php

@ -1,83 +1,89 @@
<?php <?php
/**
* @file
* This file lists and documents all available hook functions to manipulate data.
*/
/** /**
* remove a datastream from a repository object * remove a datastream from a repository object
* @param object $fedora_object * @param object $fedora_object
* tuque FedoraObject * tuque FedoraObject
* @param string $datastream_id * @param string $datastream_id
*/ */
function hook_islandora_purge_datastream ($fedora_object, $datastream_id){} function hook_islandora_purge_datastream($fedora_object, $datastream_id) {}
/** /**
* *
* @param type $object * @param type $object
* tuque FedoraObject * tuque FedoraObject
*/ */
function hook_islandora_purge_object($islandora_object) {} function hook_islandora_purge_object($islandora_object) {}
/** /**
* allows modules to add to a repository objects display. If you implement this * allows modules to add to a repository objects display. If you implement this
* hook you should also register your module for view with the get types hook. * hook you should also register your module for view with the get types hook.
* *
* islandora gets all displays back in an array and iterates over them. the order * islandora gets all displays back in an array and iterates over them. the order
* they are displayed is based on the order of the key of the array that each * they are displayed is based on the order of the key of the array that each
* module returns. * module returns.
* *
* your module may also want to register a varible that says whether or not it * your module may also want to register a varible that says whether or not it
* should be part of the default display. Modules can also add secondary tabs as * should be part of the default display. Modules can also add secondary tabs as
* a way to add there output to an islandora display. the basic image module has * a way to add there output to an islandora display. the basic image module has
* samples of both (the secondary tabs examples are commented out) * samples of both (the secondary tabs examples are commented out)
* *
* @param type $islandora_object * @param type $islandora_object
* tuque FedoraObject * tuque FedoraObject
*/ */
function hook_islandora_view_object($islandora_object){} function hook_islandora_view_object($islandora_object) {}
/** /**
* returns an array listing object types provided by sub modules * returns an array listing object types provided by sub modules
* Ex. array($types['islandora:collectionCModel'][ISLANDORA_VIEW_HOOK] = variable_get('islandora_basic_collection_use_for_default_tab', TRUE); * Ex. array($types['islandora:collectionCModel'][ISLANDORA_VIEW_HOOK] = variable_get('islandora_basic_collection_use_for_default_tab', TRUE);
* $types['islandora:collectionCModel'][ISLANDORA_EDIT_HOOK] = FALSE; * $types['islandora:collectionCModel'][ISLANDORA_EDIT_HOOK] = FALSE;
* *
* @return array * @return array
*/ */
function hook_islandora_get_types(){} function hook_islandora_get_types() {}
/** /**
* allows modules to define an object edit page by cmodel * allows modules to define an object edit page by cmodel
* *
* your module should return true for ISLANDORA_EDIT_HOOK in its get_types function * your module should return true for ISLANDORA_EDIT_HOOK in its get_types function
* *
* islandora provides a default implementation that should work for most use cases * islandora provides a default implementation that should work for most use cases
* @param string $islandora_object * @param string $islandora_object
* @return string * @return string
* *
*/ */
function hook_islandora_edit_object($islandora_object){} function hook_islandora_edit_object($islandora_object) {}
/** /**
* allows modules to alter the fedora object before it is pass through the edit * allows modules to alter the fedora object before it is pass through the edit
* hooks * hooks
* @param type $islandora_object * @param type $islandora_object
* a tugue FedoraObject * a tugue FedoraObject
*/ */
function islandora_islandora_edit_object_alter ($islandora_object){} function islandora_islandora_edit_object_alter($islandora_object) {}
/** /**
* creates and populates a php Fedora object. * creates and populates a php Fedora object.
*/ */
function hook_islandora_preingest_alter(){} function hook_islandora_preingest_alter() {}
/** /**
* modules can implement this hook to add or remove datastreams after an * modules can implement this hook to add or remove datastreams after an
* object has been ingested. * object has been ingested.
* *
* Each module should check for the newly ingested repository objects content * Each module should check for the newly ingested repository objects content
* model to make sure it is a type of object they want to act on. * model to make sure it is a type of object they want to act on.
* *
* @param type $islandora_object * @param type $islandora_object
* tugue FeodoraObject * tugue FeodoraObject
*/ */
function hook_islandora_postingest($islandora_object){} function hook_islandora_postingest($islandora_object) {}
/** /**
* Register potential ingest routes. Implementations should return an array containing possible routes. * Register potential ingest routes. Implementations should return an array containing possible routes.
@ -96,25 +102,25 @@ function hook_islandora_edit_datastream_registry($islandora_object, $ds_id) {}
/** /**
* alter an object before it gets used further down the stack * alter an object before it gets used further down the stack
* @param type $object * @param type $object
* a tuque FedoraObject * a tuque FedoraObject
*/ */
function hook_islandora_object_alter ($fedora_object){} function hook_islandora_object_alter($fedora_object) {}
/** /**
* insert or remove rendered elements by implementing this function * insert or remove rendered elements by implementing this function
* in your module * in your module
* @param type $arr * @param type $arr
* an arr of rendered views * an arr of rendered views
*/ */
function hook_islandora_display_alter ($arr){} function hook_islandora_display_alter($arr) {}
/** /**
* *
* @param type $islandora_object * @param type $islandora_object
* a tuque FedoraObject * a tuque FedoraObject
* @param array $content_models * @param array $content_models
* @param string $collection_pid * @param string $collection_pid
*/ */
function hook_islandora_ingest_pre_ingest($islandora_object, $content_models, $collection_pid){} function hook_islandora_ingest_pre_ingest($islandora_object, $content_models, $collection_pid) {}

6
islandora.install

@ -0,0 +1,6 @@
<?php
/**
* @file
* This file contains all install functions.
*/

58
islandora.module

@ -1,28 +1,28 @@
<?php <?php
/* /*
* @file islandora.module * @file
* defines paths (drupal menu items) as entry points and acts as a hub for dispatching tasks to other modules. *
* * islandora.module: defines paths (drupal menu items) as entry points and acts as a hub for dispatching tasks to other modules.
* *
* This file is part of Islandora. * This file is part of Islandora.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with the program. If not, see <http ://www.gnu.org/licenses/>. * along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/ */
//Permissions // Permissions
define('FEDORA_VIEW', 'view fedora repository'); define('FEDORA_VIEW', 'view fedora repository');
define('FEDORA_METADATA_EDIT', 'edit fedora metadata'); define('FEDORA_METADATA_EDIT', 'edit fedora metadata');
define('FEDORA_ADD_DS', 'add fedora datastreams'); define('FEDORA_ADD_DS', 'add fedora datastreams');
@ -31,12 +31,12 @@ define('FEDORA_PURGE', 'delete fedora objects and datastreams');
define('FEDORA_MODIFY_STATE', 'modify fedora state'); define('FEDORA_MODIFY_STATE', 'modify fedora state');
define('FEDORA_MANAGE', 'manage fedora items'); define('FEDORA_MANAGE', 'manage fedora items');
//hooks // hooks
define('ISLANDORA_VIEW_HOOK', 'islandora_view_object'); define('ISLANDORA_VIEW_HOOK', 'islandora_view_object');
define('ISLANDORA_EDIT_HOOK', 'islandora_edit_object'); define('ISLANDORA_EDIT_HOOK', 'islandora_edit_object');
/** /**
* Implementation of hook_menu. * Implements hook_menu().
* we need some standard entry points so we can have consistent urls for different Object actions * we need some standard entry points so we can have consistent urls for different Object actions
*/ */
function islandora_menu() { function islandora_menu() {
@ -215,20 +215,20 @@ function islandora_admin_paths() {
* @param string $op * @param string $op
* @param string $pid * @param string $pid
* *
* @return boolean * @return boolean
*/ */
function islandora_access_callback($object = NULL, $perm = NULL) { function islandora_access_callback($object = NULL, $perm = NULL) {
if(!$object || !$perm) { if (!$object || !$perm) {
return FALSE; return FALSE;
} }
$isRestricted = variable_get('islandora_namespace_restriction_enforced', FALSE); $isRestricted = variable_get('islandora_namespace_restriction_enforced', FALSE);
if (!$isRestricted) { if (!$isRestricted) {
$namespace_access = TRUE; $namespace_access = TRUE;
} }
else { else {
$pid_namespace = substr($object->id, 0, strpos($object->id, ':') + 1); //Get the namespace (with colon) $pid_namespace = substr($object->id, 0, strpos($object->id, ':') + 1); // Get the namespace (with colon)
$allowed_namespaces = explode(" ", variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $allowed_namespaces = explode(" ", variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$namespace_access = in_array($pid_namespace, $allowed_namespaces); $namespace_access = in_array($pid_namespace, $allowed_namespaces);
} }
@ -238,7 +238,7 @@ function islandora_access_callback($object = NULL, $perm = NULL) {
/** /**
* returns an array listing object types provided by sub modules * returns an array listing object types provided by sub modules
* @return array * @return array
*/ */
function islandora_get_types() { function islandora_get_types() {
return module_invoke_all('islandora_get_types'); return module_invoke_all('islandora_get_types');
@ -255,10 +255,10 @@ function islandora_init() {
* that handle this function this module will build a default page. * that handle this function this module will build a default page.
* @global object $user * @global object $user
* @param string $object_id * @param string $object_id
* @return string * @return string
*/ */
function islandora_edit_object($object) { function islandora_edit_object($object) {
if(!$object) { if (!$object) {
return drupal_not_found(); return drupal_not_found();
} }
drupal_alter('islandora_edit_object', $object); drupal_alter('islandora_edit_object', $object);
@ -274,7 +274,7 @@ function islandora_edit_object($object) {
/** /**
* edit properties form * edit properties form
* @param type $object_id * @param type $object_id
* @return string * @return string
*/ */
function islandora_edit_properties($object_id) { function islandora_edit_properties($object_id) {
$object = islandora_object_load($object_id); $object = islandora_object_load($object_id);
@ -290,7 +290,7 @@ function islandora_edit_properties($object_id) {
/** /**
* builds a default page for the edit tab * builds a default page for the edit tab
* *
* @param object $fedora_object * @param object $fedora_object
* A tuque Fedora Object * A tuque Fedora Object
*/ */
function islandora_islandora_edit_object($fedora_object) { function islandora_islandora_edit_object($fedora_object) {
@ -315,14 +315,14 @@ function islandora_view_default_object() {
* their modules want to provide a view for. * their modules want to provide a view for.
* @global object $user * @global object $user
* @param string $object_id * @param string $object_id
* *
* @return string * @return string
*/ */
function islandora_view_object($fedora_object = NULL) { function islandora_view_object($fedora_object = NULL) {
module_load_include('inc', 'islandora', 'includes/breadcrumb'); module_load_include('inc', 'islandora', 'includes/breadcrumb');
global $user; global $user;
if(!$fedora_object) { if (!$fedora_object) {
return drupal_not_found(); return drupal_not_found();
} }
@ -348,10 +348,10 @@ function islandora_view_object($fedora_object = NULL) {
} }
/** /**
* the default view hook. If there are no modules registered to handle this objects cmodels or there are * the default view hook. If there are no modules registered to handle this objects cmodels or there are
* not any cmodels specified this will create a default display. * not any cmodels specified this will create a default display.
* @param string $object_id * @param string $object_id
* @return string * @return string
*/ */
function islandora_islandora_view_object($object) { function islandora_islandora_view_object($object) {
$supported_models = islandora_get_types(); $supported_models = islandora_get_types();
@ -425,17 +425,17 @@ function islandora_permission() {
* a helper function to get a connection and return an object * a helper function to get a connection and return an object
* @global object $user * @global object $user
* @param string $object_id * @param string $object_id
* @return FedoraObject * @return FedoraObject
*/ */
function islandora_object_load($object_id) { function islandora_object_load($object_id) {
module_load_include('inc', 'islandora', 'includes/tuque'); module_load_include('inc', 'islandora', 'includes/tuque');
static $islandora_tuque = NULL; static $islandora_tuque = NULL;
if(!$islandora_tuque) { if (!$islandora_tuque) {
$islandora_tuque = new IslandoraTuque(); $islandora_tuque = new IslandoraTuque();
} }
if(IslandoraTuque::exists()) { if (IslandoraTuque::exists()) {
try { try {
$fedora_object = $islandora_tuque->repository->getObject($object_id); $fedora_object = $islandora_tuque->repository->getObject($object_id);
} catch (Exception $e) { } catch (Exception $e) {
@ -450,13 +450,13 @@ function islandora_object_load($object_id) {
} }
function islandora_ingest_access_callback($object, $perm) { function islandora_ingest_access_callback($object, $perm) {
if(islandora_access_callback($object, $perm) === FALSE) { if (islandora_access_callback($object, $perm) === FALSE) {
return FALSE; return FALSE;
} }
$ingest_registry = module_invoke_all('islandora_ingest_registry', $object); $ingest_registry = module_invoke_all('islandora_ingest_registry', $object);
if(count($ingest_registry) > 0) { if (count($ingest_registry) > 0) {
return TRUE; return TRUE;
} }
else { else {

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

@ -1,50 +1,24 @@
<?php <?php
/* /**
* islandora-object-edit.tpl.php * @file
* * islandora-object-edit.tpl.php: This is a template for objects that do not have
* a module to registered to build their display.
* *
*
* This file is part of Islandora.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/
?>
<?php
/*
* this is a template for objects that do not have a module to registered to build their display.
*
* 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 Dublin_Core object * $dublin_core is a Dublin_Core object
* which is an array of elements, such as dc.title * which is an array of elements, such as dc.title
* and each element has an array of values. dc.title can have none, one or many titles * and each element has an array of values. dc.title can have none, one or many titles
* this is the case for all dc elements. * this is the case for all dc elements.
* *
*
*
*/ */
//dsm($object);
drupal_set_title($islandora_object->label);
//print($islandora_object->label . ' ' . $islandora_object->id);
print (theme_table($variables['datastream_table']));
?> ?>
<?php drupal_set_title($islandora_object->label); ?>
<?php print (theme_table($variables['datastream_table'])); ?>

26
theme/islandora-object.tpl.php

@ -1,30 +1,8 @@
<?php <?php
/* /*
* islandora-object.tpl.php * @file
* * This is a template for objects that do not have a module to registered to build their display.
*
*
* This file is part of Islandora.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/
?>
<?php
/*
* this is a template for objects that do not have a module to registered to build their display.
* *
* islandora_object is a fedora tuque Object * islandora_object is a fedora tuque Object
* $object->label - The label for this object. * $object->label - The label for this object.

11
theme/islandora.theme.inc

@ -1,5 +1,10 @@
<?php <?php
/**
* @file
* This file contains all theme and preprocess functions.
*/
/** /**
* preprocess the edit template * preprocess the edit template
* @global string $base_url * @global string $base_url
@ -72,9 +77,11 @@ function islandora_preprocess_islandora_default(&$variables) {
$datastreams[$id]['mimetype'] = $ds->mimetype; $datastreams[$id]['mimetype'] = $ds->mimetype;
$datastreams[$id]['size'] = islandora_datastream_get_human_readable_size($ds); $datastreams[$id]['size'] = islandora_datastream_get_human_readable_size($ds);
$datastreams[$id]['created_date'] = $ds->createdDate->format("Y-m-d"); $datastreams[$id]['created_date'] = $ds->createdDate->format("Y-m-d");
$datastreams[$id]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id)); $datastreams[$id]['class'] = drupal_strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id));
}
catch (RepositoryException $e) {
} }
catch (RepositoryException $e) {}
} }
$variables['datastreams'] = $datastreams; $variables['datastreams'] = $datastreams;
try { try {

Loading…
Cancel
Save