Commit 918d4b48 authored by Mark Jordan's avatar Mark Jordan
Browse files

Made the islandora_bagit_extended_baginfo do something useful.

parent b840bc60
......@@ -161,7 +161,6 @@ Some submodules it would be useful to have include:
* A submodule to generate Bags for paged content
* A submodule to generate Bags for compound objects
* A submodule to generate a Bag containing multiple objects, e.g. all objects in a collection.
* A submodule to add data from an object's MODS or DC datastreams to the `External-Description` bag-info.txt tag
* A submodule to generate PID files for all objects in a collection, with a given namespace, etc.
## License
......@@ -61,9 +61,8 @@ function hook_islandora_bagit_bag_created($pid, $bag_path) {
function mymodule_islandora_bagit_bag_alter($bag, $islandora_object) {
// Add some custom metadata to bag-info.txt.
$bag->setBagInfoData('Some-Arbitrary-Field', 'Foo bar baz');
if ($islandora_object['DC']) {
$bag->setBagInfoData('External-Description', $islandora_object['DC']->content);
// Or a propery from the object.
$bag->setBagInfoData('External-Description', $islandora_object->label);
// Add a file that is not managed by a plugin.
$bag->addFile('/path/to/file.txt', 'myfile.txt');
......@@ -8,11 +8,20 @@
* Implements hook_islandora_bagit_bag_alter().
function islandora_bagit_extended_baginfo_islandora_bagit_bag_alter($bag, $islandora_object) {
// Add some custom metadata to bag-info.txt.
if ($islandora_object['DC']) {
$bag->setBagInfoData('External-Description', $islandora_object['DC']->content);
if (strlen($islandora_object['DC']->content)) {
// Get the valud of dc.description.
$dom = new DOMDocument;
$elements = $dom->getElementsByTagNameNS('', 'description');
$description_values = '';
foreach ($elements as $e) {
$description_values .= $e->nodeValue;
if (strlen($description_values)) {
$bag->setBagInfoData('External-Description', $description_values);
// Update the Bag.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment