|
|
@ -79,28 +79,26 @@ function islandora_run_derivatives(AbstractObject $object, $dsid) { |
|
|
|
* watchdog if not defined. |
|
|
|
* watchdog if not defined. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function islandora_do_derivatives(AbstractObject $object, array $options) { |
|
|
|
function islandora_do_derivatives(AbstractObject $object, array $options) { |
|
|
|
module_load_include('inc', 'islandora', 'includes/utilities'); |
|
|
|
|
|
|
|
$options += array( |
|
|
|
|
|
|
|
'force' => FALSE, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
$hooks = islandora_invoke_hook_list(ISLANDORA_DERIVATIVE_CREATION_HOOK, $object->models, array($object)); |
|
|
|
|
|
|
|
uasort($hooks, 'drupal_sort_weight'); |
|
|
|
|
|
|
|
$results = array(); |
|
|
|
$results = array(); |
|
|
|
$hooks = islandora_filter_derivatives($hooks, $options, $object); |
|
|
|
$derivatives = islandora_get_derivative_list($object, $options); |
|
|
|
|
|
|
|
foreach ($derivatives as $derivative) { |
|
|
|
foreach ($hooks as $hook) { |
|
|
|
if (isset($derivative['file'])) { |
|
|
|
if (isset($hook['file'])) { |
|
|
|
require_once $derivative['file']; |
|
|
|
require_once $hook['file']; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
foreach ($hook['function'] as $function) { |
|
|
|
foreach ($derivative['function'] as $function) { |
|
|
|
if (function_exists($function)) { |
|
|
|
if (function_exists($function)) { |
|
|
|
$logging = call_user_func($function, $object, $options['force'], $hook); |
|
|
|
$logging = call_user_func($function, $object, $options['force'], $derivative); |
|
|
|
if (!empty($logging)) { |
|
|
|
if (!empty($logging)) { |
|
|
|
$results[] = $logging; |
|
|
|
$results[] = $logging; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
watchdog('islandora', 'Unable to call derivative function @function as it was not found!', array('@function' => $function), WATCHDOG_ERROR); |
|
|
|
watchdog( |
|
|
|
|
|
|
|
'islandora', |
|
|
|
|
|
|
|
'Unable to call derivative function @function as it was not found!', |
|
|
|
|
|
|
|
array('@function' => $function), |
|
|
|
|
|
|
|
WATCHDOG_ERROR |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -172,21 +170,14 @@ function islandora_derivative_logging(array $logging_results) { |
|
|
|
* An array of operations to be called from within a batch. |
|
|
|
* An array of operations to be called from within a batch. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function islandora_do_batch_derivatives(AbstractObject $object, array $options) { |
|
|
|
function islandora_do_batch_derivatives(AbstractObject $object, array $options) { |
|
|
|
module_load_include('inc', 'islandora', 'includes/utilities'); |
|
|
|
|
|
|
|
$options += array( |
|
|
|
|
|
|
|
'force' => FALSE, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
$hooks = islandora_invoke_hook_list(ISLANDORA_DERIVATIVE_CREATION_HOOK, $object->models, array($object)); |
|
|
|
|
|
|
|
uasort($hooks, 'drupal_sort_weight'); |
|
|
|
|
|
|
|
$operations = array(); |
|
|
|
$operations = array(); |
|
|
|
|
|
|
|
$derivatives = islandora_get_derivative_list($object, $options); |
|
|
|
$hooks = islandora_filter_derivatives($hooks, $options, $object); |
|
|
|
foreach ($derivatives as $derivative) { |
|
|
|
foreach ($hooks as $hook) { |
|
|
|
|
|
|
|
$file = FALSE; |
|
|
|
$file = FALSE; |
|
|
|
if (isset($hook['file'])) { |
|
|
|
if (isset($derivative['file'])) { |
|
|
|
$file = $hook['file']; |
|
|
|
$file = $derivative['file']; |
|
|
|
} |
|
|
|
} |
|
|
|
foreach ($hook['function'] as $function) { |
|
|
|
foreach ($derivative['function'] as $function) { |
|
|
|
$operations[] = array( |
|
|
|
$operations[] = array( |
|
|
|
'islandora_derivative_perform_batch_operation', |
|
|
|
'islandora_derivative_perform_batch_operation', |
|
|
|
array( |
|
|
|
array( |
|
|
@ -194,7 +185,7 @@ function islandora_do_batch_derivatives(AbstractObject $object, array $options) |
|
|
|
$file, |
|
|
|
$file, |
|
|
|
$object->id, |
|
|
|
$object->id, |
|
|
|
$options['force'], |
|
|
|
$options['force'], |
|
|
|
$hook, |
|
|
|
$derivative, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -284,3 +275,32 @@ function islandora_remove_defer_derivatives_flag(AbstractObject $object) { |
|
|
|
RELS_TYPE_PLAIN_LITERAL |
|
|
|
RELS_TYPE_PLAIN_LITERAL |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the list of derivatives. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param AbstractObject $object |
|
|
|
|
|
|
|
* The object to find derivatives for. |
|
|
|
|
|
|
|
* @param &array $options |
|
|
|
|
|
|
|
* Options for derivatives, will be updated to default force to FALSE. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
function islandora_get_derivative_list(AbstractObject $object, &$options) { |
|
|
|
|
|
|
|
module_load_include('inc', 'islandora', 'includes/utilities'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$options += array( |
|
|
|
|
|
|
|
'force' => FALSE, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$derivatives = islandora_invoke_hook_list( |
|
|
|
|
|
|
|
ISLANDORA_DERIVATIVE_CREATION_HOOK, |
|
|
|
|
|
|
|
$object->models, |
|
|
|
|
|
|
|
array($object) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (islandora_build_hook_list(ISLANDORA_DERIVATIVE_CREATION_HOOK, $object->models) as $hook) { |
|
|
|
|
|
|
|
drupal_alter($hook, $derivatives, $object); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uasort($derivatives, 'drupal_sort_weight'); |
|
|
|
|
|
|
|
return islandora_filter_derivatives($derivatives, $options, $object); |
|
|
|
|
|
|
|
} |
|
|
|