Skip to content

Commit

Permalink
Fixes incorrect assumption (Islandora#664)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DiegoPino authored and dannylamb committed Dec 20, 2016
1 parent 424e6dd commit 0bb0444
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions includes/admin.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
16 changes: 12 additions & 4 deletions includes/ingest.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,10 @@ function islandora_ingest_form_stepify(array $form, array &$form_state, array $s
$form['hidden_next']['#suffix'] = '</div>';
}

// 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;
Expand All @@ -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();
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions islandora.install
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit 0bb0444

Please sign in to comment.