|
|
@ -80,10 +80,6 @@ function islandora_ingest_form(array $form, array &$form_state, array $configura |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function islandora_ingest_form_init_form_state_storage(array &$form_state, array $configuration) { |
|
|
|
function islandora_ingest_form_init_form_state_storage(array &$form_state, array $configuration) { |
|
|
|
if (empty($form_state['islandora'])) { |
|
|
|
if (empty($form_state['islandora'])) { |
|
|
|
$objects = isset($configuration['objects']) ? $configuration['objects'] : array(); |
|
|
|
|
|
|
|
if (empty($objects)) { |
|
|
|
|
|
|
|
$objects[] = islandora_ingest_form_prepare_new_object($configuration); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$configuration['models'] = isset($configuration['models']) ? $configuration['models'] : array(); |
|
|
|
$configuration['models'] = isset($configuration['models']) ? $configuration['models'] : array(); |
|
|
|
// Make sure the models actually exist. |
|
|
|
// Make sure the models actually exist. |
|
|
|
foreach ($configuration['models'] as $key => $model) { |
|
|
|
foreach ($configuration['models'] as $key => $model) { |
|
|
@ -91,15 +87,15 @@ function islandora_ingest_form_init_form_state_storage(array &$form_state, array |
|
|
|
unset($configuration['models'][$key]); |
|
|
|
unset($configuration['models'][$key]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// No need to persist the 'objects' within the configuration. |
|
|
|
|
|
|
|
unset($configuration['objects']); |
|
|
|
|
|
|
|
// Required for step hooks. |
|
|
|
// Required for step hooks. |
|
|
|
$form_state['islandora'] = array( |
|
|
|
$form_state['islandora'] = array( |
|
|
|
'step_id' => NULL, |
|
|
|
'step_id' => NULL, |
|
|
|
'objects' => $objects, |
|
|
|
'objects' => $configuration['objects'], |
|
|
|
'shared_storage' => $configuration, |
|
|
|
'shared_storage' => $configuration, |
|
|
|
'step_storage' => array(), |
|
|
|
'step_storage' => array(), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
// No need to persist the 'objects' within the configuration. |
|
|
|
|
|
|
|
unset($configuration['objects']); |
|
|
|
// Must be called after $form_state['islandora'] is initialized, otherwise, |
|
|
|
// Must be called after $form_state['islandora'] is initialized, otherwise, |
|
|
|
// the values in 'islandora' would not be availible to the step hooks. |
|
|
|
// the values in 'islandora' would not be availible to the step hooks. |
|
|
|
$form_state['islandora']['step_id'] = islandora_ingest_form_get_first_step_id($form_state); |
|
|
|
$form_state['islandora']['step_id'] = islandora_ingest_form_get_first_step_id($form_state); |
|
|
@ -136,33 +132,6 @@ function islandora_ingest_form_get_last_step_id(array &$form_state) { |
|
|
|
return array_pop($keys); |
|
|
|
return array_pop($keys); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Prepares a new object based on the given configuration. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param array $configuration |
|
|
|
|
|
|
|
* The list of key/value pairs of configuration. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return NewFedoraObject |
|
|
|
|
|
|
|
* The new object. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
function islandora_ingest_form_prepare_new_object(array $configuration) { |
|
|
|
|
|
|
|
module_load_include('inc', 'islandora', 'includes/utilities'); |
|
|
|
|
|
|
|
if (empty($configuration['object'])) { |
|
|
|
|
|
|
|
$message = islandora_deprecated('7.x-1.2', t('Please use "objects" as the default ingest form configuration property.')); |
|
|
|
|
|
|
|
trigger_error(filter_xss($message), E_USER_DEPRECATED); |
|
|
|
|
|
|
|
// ID is more specific than namespace so it will take precedence. |
|
|
|
|
|
|
|
$id = isset($configuration['namespace']) ? $configuration['namespace'] : 'islandora'; |
|
|
|
|
|
|
|
$id = isset($configuration['id']) ? $configuration['id'] : $id; |
|
|
|
|
|
|
|
$label = isset($configuration['label']) ? $configuration['label'] : 'New Object'; |
|
|
|
|
|
|
|
$relationship_map = function($o) { |
|
|
|
|
|
|
|
return array('relationship' => 'isMemberOfCollection', 'pid' => $o); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
$relationships = empty($configuration['collections']) ? array() : array_map($relationship_map, $configuration['collections']); |
|
|
|
|
|
|
|
return islandora_prepare_new_object($id, $label, array(), array(), $relationships); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $configuration['object']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Gets the given/current step. |
|
|
|
* Gets the given/current step. |
|
|
|
* |
|
|
|
* |
|
|
|