Browse Source

Ingest functionality of the ingest form is now a callback.

pull/317/head
Jordan Dukart 12 years ago
parent
commit
a462a4448c
  1. 22
      includes/ingest.form.inc
  2. 2
      islandora.api.php
  3. 18
      islandora.module

22
includes/ingest.form.inc

@ -288,7 +288,9 @@ function islandora_ingest_form_execute_step(array $form, array &$form_state, $st
break;
case 'callback':
call_user_func_array($step['do_function']['function'], $step['do_function']['args']);
$args = array(&$form_state);
$args = isset($step['do_function']['args']) ? array_merge($args, $step['do_function']['args']) : $args;
call_user_func_array($step['do_function']['function'], $args);
$next_step = islandora_ingest_form_get_next_step_id($form_state);
if ($next_step) {
islandora_ingest_form_increment_step($form_state);
@ -470,7 +472,9 @@ function islandora_ingest_form_callback_previous(array $form, array &$form_state
$step = islandora_ingest_form_get_step($form_state, $keys[$current_step]);
islandora_ingest_form_decrement_step($form_state);
if ($step['type'] === 'callback') {
call_user_func_array($step['undo_function']['function'], $step['undo_function']['args']);
$args = array(&$form_state);
$args = isset($step['undo_function']['args']) ? array_merge($args, $step['undo_function']['args']) : $args;
call_user_func_array($step['undo_function']['function'], $args);
}
else {
$form = TRUE;
@ -583,7 +587,10 @@ function islandora_ingest_form_ingest_button(array &$form_state) {
$validate_callback = $form_id . '_validate';
$validate = function_exists($validate_callback) ? array($validate_callback) : NULL;
$submit_callback = $form_id . '_submit';
$submit = function_exists($submit_callback) ? array($submit_callback, 'islandora_ingest_form_submit') : array('islandora_ingest_form_submit');
$submit = array();
if (function_exists($submit_callback)) {
$submit[] = $submit_callback;
}
// Because of callback shananigans we have to check if there are a chain of
// n callbacks that are weighted after the current step.
@ -607,12 +614,10 @@ function islandora_ingest_form_ingest_button(array &$form_state) {
*
* Attempts to ingest every object built by the previous steps.
*
* @param array $form
* The Drupal form.
* @param array $form_state
* The Drupal form state.
*/
function islandora_ingest_form_submit(array $form, array &$form_state) {
function islandora_ingest_form_ingest(array &$form_state) {
foreach ($form_state['islandora']['objects'] as $object) {
try {
islandora_add_object($object);
@ -644,7 +649,9 @@ function islandora_ingest_form_callback_ingest(array $form, array &$form_state)
// Execute our n chain of callbacks.
while ($current_step < count($steps)) {
$step = islandora_ingest_form_get_step($form_state, $keys[$current_step]);
call_user_func_array($step['do_function']['function'], $step['do_function']['args']);
$args = array(&$form_state);
$args = isset($step['do_function']['args']) ? array_merge($args, $step['do_function']['args']) : $args;
call_user_func_array($step['do_function']['function'], $args);
$current_step++;
}
}
@ -790,7 +797,6 @@ function islandora_ingest_form_get_steps(array &$form_state) {
'@module' => $step['module'],
'@step' => $key,
), WATCHDOG_ERROR);
dd('errorsaursu');
unset($steps[$key]);
}
}

2
islandora.api.php

@ -405,7 +405,7 @@ function hook_islandora_undeletable_datastreams(array $models) {
* end of the process while smaller(/"lighter") values are executed first.
* Both types may optionally include:
* - module: A module from which we want to load an include.
* "Form type" may optionally include:
* "Form" type may optionally include:
* - file: A file to include (relative to the module's path, including the
* file's extension).
*/

18
islandora.module

@ -1097,3 +1097,21 @@ function islandora_download_clip(AbstractObject $object) {
}
exit();
}
/**
* Implements hook_islandora_ingest_steps().
*/
function islandora_islandora_ingest_steps(&$form_state) {
return array(
'islandora_ingest_form_submit' => array(
'type' => 'callback',
'weight' => 50,
'do_function' => array(
'function' => 'islandora_ingest_form_ingest',
),
'undo_function' => array(
'function' => 'islandora_ingest_form_undo_ingest',
),
),
);
}

Loading…
Cancel
Save