diff --git a/includes/admin.form.inc b/includes/admin.form.inc index 51116f5c..cf0b8f69 100644 --- a/includes/admin.form.inc +++ b/includes/admin.form.inc @@ -74,6 +74,12 @@ function islandora_repository_admin(array $form, array &$form_state) { '#description' => t('Displays an extra print tab, allowing an object to be printed'), '#default_value' => variable_get('islandora_show_print_option', FALSE), ), + 'islandora_render_drupal_breadcrumbs' => array( + '#type' => 'checkbox', + '#title' => t('Render Drupal breadcrumbs'), + '#description' => t('Larger sites may experience a notable performance improvement when disabled due to how breadcrumbs are constructed.'), + '#default_value' => variable_get('islandora_render_drupal_breadcrumbs', TRUE), + ), ), 'islandora_namespace' => array( '#type' => 'fieldset', diff --git a/includes/breadcrumb.inc b/includes/breadcrumb.inc index e3eb2782..38c0970e 100644 --- a/includes/breadcrumb.inc +++ b/includes/breadcrumb.inc @@ -25,10 +25,13 @@ * drupal_set_breadcrumb(). */ function islandora_get_breadcrumbs($object) { - $breadcrumbs = islandora_get_breadcrumbs_recursive($object->id, $object->repository); - array_pop($breadcrumbs); - $context = 'islandora'; - drupal_alter('islandora_breadcrumbs', $breadcrumbs, $context, $object); + $breadcrumbs = array(); + if (variable_get('islandora_render_drupal_breadcrumbs', TRUE)) { + $breadcrumbs = islandora_get_breadcrumbs_recursive($object->id, $object->repository); + array_pop($breadcrumbs); + $context = 'islandora'; + drupal_alter('islandora_breadcrumbs', $breadcrumbs, $context, $object); + } return $breadcrumbs; } diff --git a/includes/delete_datastream.form.inc b/includes/delete_datastream.form.inc index ce1959df..b88ef0da 100644 --- a/includes/delete_datastream.form.inc +++ b/includes/delete_datastream.form.inc @@ -19,15 +19,44 @@ * The drupal form definition. */ function islandora_delete_datastream_form(array $form, array &$form_state, AbstractDatastream $datastream) { + // XXX: Stashed version of datastream is deprecated... Use object and + // datastream IDs from 'datastream_info' to acquire. $form_state['datastream'] = $datastream; + + $form_state['datastream_info'] = array( + 'object_id' => $datastream->parent->id, + 'datastream_id' => $datastream->id, + ); $object = $datastream->parent; $dsid = $datastream->id; - $derivs = implode(', ', islandora_datastream_to_purge($object, $dsid)); + $dsids = array_merge(array($dsid), islandora_datastream_to_purge($object, $dsid)); + $dsids = array_unique($dsids); $form['delete_derivatives'] = array( '#title' => t('Delete Derviatives'), '#type' => 'checkbox', '#default_value' => 0, - '#description' => t('Derivatives can be regenerated at a later time.
Datastream(s) to be purged:
@dsid, @derivs', array('@dsid' => $datastream->id, '@derivs' => $derivs)), + '#description' => t('Derivatives can be regenerated at a later time.'), + ); + $form['base_info'] = array( + '#type' => 'item', + '#title' => t('Datastream to be purged'), + '#markup' => $dsid, + '#states' => array( + 'invisible' => array( + ':input[name="delete_derivatives"]' => array('checked' => TRUE), + ), + ), + ); + $form['derivative_info'] = array( + '#type' => 'item', + '#title' => t('Datastream(s) to be purged'), + '#description' => t('Including detectable derivatives.'), + '#markup' => implode(', ', $dsids), + '#states' => array( + 'visible' => array( + ':input[name="delete_derivatives"]' => array('checked' => TRUE), + ), + ), ); return confirm_form($form, t('Are you sure you want to delete the %dsid datastream?', array('%dsid' => $datastream->id)), @@ -87,9 +116,10 @@ function islandora_datastream_derivatives_purged(AbstractObject $object, $dsid) * The Drupal form state. */ function islandora_delete_datastream_form_submit(array $form, array &$form_state) { - $datastream = $form_state['datastream']; - $datastream_id = $datastream->id; - $object = $datastream->parent; + $object = islandora_object_load($form_state['datastream_info']['object_id']); + $datastream_id = $form_state['datastream_info']['datastream_id']; + $datastream = $object[$datastream_id]; + $deleted = FALSE; if ($form_state['values']['delete_derivatives']) { islandora_datastream_derivatives_purged($object, $datastream_id); diff --git a/includes/tuque_wrapper.inc b/includes/tuque_wrapper.inc index d14a86b3..ef2a2991 100644 --- a/includes/tuque_wrapper.inc +++ b/includes/tuque_wrapper.inc @@ -56,7 +56,7 @@ function islandora_alter_datastream(AbstractObject $object, AbstractDatastream $ } /** - * Constructs a list of hooks from the given paramenters and invokes them. + * Constructs a list of hooks from the given parameters and invokes them. */ function islandora_invoke_object_hooks($hook, array $models) { module_load_include('inc', 'islandora', 'includes/utilities'); @@ -64,7 +64,7 @@ function islandora_invoke_object_hooks($hook, array $models) { } /** - * Constructs a list of hooks from the given paramenters and invokes them. + * Constructs a list of hooks from the given parameters and invokes them. */ function islandora_invoke_datastream_hooks($hook, array $models, $dsid) { module_load_include('inc', 'islandora', 'includes/utilities'); @@ -233,6 +233,54 @@ class IslandoraFedoraObject extends FedoraObject { throw $e; } } + + /** + * Purge a datastream. + * + * Invokes datastream altered/purged hooks and calls the API-M method. + * + * @see FedoraObject::purgeObject() + */ + public function purgeDatastream($id) { + $this->populateDatastreams(); + + if (!array_key_exists($id, $this->datastreams)) { + return FALSE; + } + $context = array( + 'action' => 'purge', + 'purge' => TRUE, + 'delete' => FALSE, + 'block' => FALSE, + ); + try { + islandora_alter_datastream($this, $this[$id], $context); + $action = $context['block'] ? 'block' : FALSE; + $action = (!$action && $context['delete']) ? 'delete' : $action; + $action = !$action ? 'purge' : $action; + switch ($action) { + case 'block': + throw new Exception('Purge Datastream was blocked.'); + + case 'delete': + $this[$id]->state = 'D'; + return array(); + + default: + $to_return = parent::purgeDatastream($id); + islandora_invoke_datastream_hooks(ISLANDORA_DATASTREAM_PURGED_HOOK, $this->models, $id, $this, $id); + return $to_return; + } + } + catch (Exception $e) { + watchdog('islandora', 'Failed to purge datastream @dsid from @pidcode: @code