From 99fc4257709c158cb455e03cd67918ff353ee7a9 Mon Sep 17 00:00:00 2001 From: Clinton Graham Date: Thu, 11 Feb 2021 18:26:13 -0500 Subject: [PATCH 1/5] add plugin to export paged object content --- plugins/plugin_object_ds_paged.inc | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 plugins/plugin_object_ds_paged.inc diff --git a/plugins/plugin_object_ds_paged.inc b/plugins/plugin_object_ds_paged.inc new file mode 100644 index 0000000..ee69e6c --- /dev/null +++ b/plugins/plugin_object_ds_paged.inc @@ -0,0 +1,56 @@ + $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; + } +} From 01483667aad9327f7813ef569a94cc8b19c1ee1e Mon Sep 17 00:00:00 2001 From: Clinton Graham Date: Fri, 12 Feb 2021 14:22:29 -0500 Subject: [PATCH 2/5] limit paged content to select cmodels --- plugins/plugin_object_ds_paged.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/plugin_object_ds_paged.inc b/plugins/plugin_object_ds_paged.inc index ee69e6c..bc2896a 100644 --- a/plugins/plugin_object_ds_paged.inc +++ b/plugins/plugin_object_ds_paged.inc @@ -22,6 +22,11 @@ * if no datastream files are present. */ function islandora_bagit_plugin_object_ds_paged_init($islandora_object, $tmp_ds_directory) { + // What Content Models have pages? + $supported_cmodels = array('islandora:manuscriptCModel','islandora:bookCModel','islandora:newspaperIssueCModel'); + if (empty(array_intersect($islandora_object->models, $supported_cmodels))) { + return FALSE; + } if (module_load_include('inc', 'islandora_paged_content', 'includes/utilities') === FALSE) { return FALSE; } From 597626d56cec8bff52b543a8a48f59f51fccbb1a Mon Sep 17 00:00:00 2001 From: Clinton Graham Date: Thu, 25 Mar 2021 12:52:13 -0400 Subject: [PATCH 3/5] stage paged datastreams into individual subfolders; clear PHP5-era code linting for empty() --- plugins/plugin_object_ds_paged.inc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/plugin_object_ds_paged.inc b/plugins/plugin_object_ds_paged.inc index bc2896a..658153e 100644 --- a/plugins/plugin_object_ds_paged.inc +++ b/plugins/plugin_object_ds_paged.inc @@ -24,7 +24,8 @@ function islandora_bagit_plugin_object_ds_paged_init($islandora_object, $tmp_ds_directory) { // What Content Models have pages? $supported_cmodels = array('islandora:manuscriptCModel','islandora:bookCModel','islandora:newspaperIssueCModel'); - if (empty(array_intersect($islandora_object->models, $supported_cmodels))) { + $found_cmodels = array_intersect($islandora_object->models, $supported_cmodels); + if (empty($found_cmodels)) { return FALSE; } if (module_load_include('inc', 'islandora_paged_content', 'includes/utilities') === FALSE) { @@ -32,9 +33,15 @@ function islandora_bagit_plugin_object_ds_paged_init($islandora_object, $tmp_ds_ } $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']); - $ds_files = islandora_bagit_retrieve_datastreams($page_object, $tmp_ds_directory); + $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 From c90c3f899a3b82bcc3a21a3b091c6506cb4ea2f2 Mon Sep 17 00:00:00 2001 From: Clinton Graham Date: Thu, 25 Mar 2021 14:09:48 -0500 Subject: [PATCH 4/5] Address Drupal coding standards for array specification --- plugins/plugin_object_ds_paged.inc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/plugin_object_ds_paged.inc b/plugins/plugin_object_ds_paged.inc index 658153e..d1b3576 100644 --- a/plugins/plugin_object_ds_paged.inc +++ b/plugins/plugin_object_ds_paged.inc @@ -23,7 +23,11 @@ */ function islandora_bagit_plugin_object_ds_paged_init($islandora_object, $tmp_ds_directory) { // What Content Models have pages? - $supported_cmodels = array('islandora:manuscriptCModel','islandora:bookCModel','islandora:newspaperIssueCModel'); + $supported_cmodels = array( + 'islandora:manuscriptCModel', + 'islandora:bookCModel', + 'islandora:newspaperIssueCModel' + ); $found_cmodels = array_intersect($islandora_object->models, $supported_cmodels); if (empty($found_cmodels)) { return FALSE; From b2188626021932ad5af169287b1b657b4bb402a3 Mon Sep 17 00:00:00 2001 From: Clinton Graham Date: Thu, 25 Mar 2021 14:46:06 -0500 Subject: [PATCH 5/5] Trailing array element comma for Drupal Coding Standards --- plugins/plugin_object_ds_paged.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/plugin_object_ds_paged.inc b/plugins/plugin_object_ds_paged.inc index d1b3576..476399f 100644 --- a/plugins/plugin_object_ds_paged.inc +++ b/plugins/plugin_object_ds_paged.inc @@ -26,7 +26,7 @@ function islandora_bagit_plugin_object_ds_paged_init($islandora_object, $tmp_ds_ $supported_cmodels = array( 'islandora:manuscriptCModel', 'islandora:bookCModel', - 'islandora:newspaperIssueCModel' + 'islandora:newspaperIssueCModel', ); $found_cmodels = array_intersect($islandora_object->models, $supported_cmodels); if (empty($found_cmodels)) {