diff --git a/plugins/plugin_object_ds_paged.inc b/plugins/plugin_object_ds_paged.inc new file mode 100644 index 0000000..476399f --- /dev/null +++ b/plugins/plugin_object_ds_paged.inc @@ -0,0 +1,72 @@ +models, $supported_cmodels); + if (empty($found_cmodels)) { + return FALSE; + } + if (module_load_include('inc', 'islandora_paged_content', 'includes/utilities') === FALSE) { + return FALSE; + } + $files_to_add = array(); + $pages = islandora_paged_content_get_pages($islandora_object); + $page_count = 0; + foreach ($pages as $page) { + $page_object = islandora_object_load($page['pid']); + $page_count++; + $tmp_ds_subdir = $tmp_ds_directory . DIRECTORY_SEPARATOR . 'p' . $page_count; + if (!file_exists($tmp_ds_subdir)) { + mkdir($tmp_ds_subdir, 0777, TRUE); + } + $ds_files = islandora_bagit_retrieve_datastreams($page_object, $tmp_ds_subdir); + + // Add file source and dest paths for each datastream to the $files_to_add + // array. $files_to_add['dest'] must be relative to the Bag's data + // subdirectory. + foreach ($ds_files as $ds_filename) { + // Add each file in the directory to $files_to_add. + $source_file_to_add = $ds_filename; + if (file_exists($source_file_to_add) && is_file($source_file_to_add)) { + $files_to_add[] = array( + 'source' => $source_file_to_add, + // Each page becomes a subdirectory in the Bag's 'data' directory. + 'dest' => str_replace(array(':', '-'), '_', $page['pid']) . DIRECTORY_SEPARATOR . basename($ds_filename), + ); + } + } + } + + if (count($files_to_add)) { + return $files_to_add; + } + else { + return FALSE; + } +}