From 0bb04444145c620bc2f841bb2dd441797852698f Mon Sep 17 00:00:00 2001 From: Diego Pino Navarro Date: Mon, 19 Dec 2016 22:28:02 -0500 Subject: [PATCH] Fixes incorrect assumption (#664) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not all step based ingest workflows required to have a parent COLLECTION object. Even when it’s common, there are concrete cases, like newspapers and books, where the parent object is not a collection. And more over, it does not require such because the resulting ingested object are not children of such. This pull request fixes an error introduced by a recent pull which enabled Contextual CMODEL labels on step forms and broke book and newspaper drupal tests. Also adds the ability to enable/disable those contextual messages since the use case could not be global. --- includes/admin.form.inc | 6 ++++++ includes/ingest.form.inc | 16 ++++++++++++---- islandora.install | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/includes/admin.form.inc b/includes/admin.form.inc index 3293c343..6736596b 100644 --- a/includes/admin.form.inc +++ b/includes/admin.form.inc @@ -96,6 +96,12 @@ function islandora_repository_admin(array $form, array &$form_state) { useful if derivatives are to be created by an external service.'), '#default_value' => variable_get('islandora_defer_derivatives_on_ingest', FALSE), ), + 'islandora_render_context_ingeststep' => array( + '#type' => 'checkbox', + '#title' => t('Render applicable Content Model label(s) during ingest steps'), + '#description' => t('This enables contextual titles, displaying Content Model label(s), to be added on top of ingest forms.'), + '#default_value' => variable_get('islandora_render_context_ingeststep', FALSE), + ), 'islandora_show_print_option' => array( '#type' => 'checkbox', '#title' => t('Show print option on objects'), diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index 5e50313a..d4d7e895 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -477,9 +477,10 @@ function islandora_ingest_form_stepify(array $form, array &$form_state, array $s $form['hidden_next']['#suffix'] = ''; } - // Add active CModel header to the form. - islandora_ingest_form_add_step_context($form, $form_state); - + if (variable_get('islandora_render_context_ingeststep', FALSE)) { + // Add active CModel header to the form. + islandora_ingest_form_add_step_context($form, $form_state); + } // Allow for a hook_form_FORM_ID_alter(). drupal_alter(array('form_' . $step['form_id'], 'form'), $form, $form_state, $step['form_id']); return $form; @@ -495,7 +496,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) { $items = array(); - $get_label = function(AbstractObject $collection, AbstractObject $fedora_cmodel) { + $get_label = function(AbstractObject $collection = NULL, AbstractObject $fedora_cmodel) { if (isset($collection['COLLECTION_POLICY'])) { $policy = new CollectionPolicy($collection['COLLECTION_POLICY']->content); $policy_content_models = $policy->getContentModels(); @@ -505,6 +506,13 @@ function islandora_ingest_form_add_step_context(array &$form, array $form_state) $fedora_cmodel->label; }; $shared_storage = islandora_ingest_form_get_shared_storage($form_state); + + // Ingest steps also work for newspaper children and + // pages of books which don't pass a collection object + // and of course don't use collection policies. + if (!isset($shared_storage['collection'])) { + $shared_storage['collection'] = NULL; + } foreach ($shared_storage['models'] as $key => $value) { $fedora_cmodel = islandora_object_load($value); if ($fedora_cmodel) { diff --git a/islandora.install b/islandora.install index d993f80c..95cca708 100644 --- a/islandora.install +++ b/islandora.install @@ -59,6 +59,7 @@ function islandora_uninstall() { 'islandora_semaphore_period', 'islandora_require_obj_upload', 'islandora_breadcrumbs_backends', + 'islandora_render_context_ingeststep', ); array_walk($variables, 'variable_del'); }