@ -28,6 +28,9 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
}
}
$collection_namespace = substr($this_collection_pid, 0, strpos($this_collection_pid, ":"));
$content_models = get_content_models_as_option_array();
unset($content_models['islandora:collectionCModel']);
$form['child_creation']['titlebox'] = array(
'#type' => 'item',
@ -73,6 +76,13 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
'#value' => $this_collection_pid,
);
$form['child_creation']['content_models'] = array(
'#title' => "Choose allowable content models for this collection",
'#type' => 'checkboxes',
'#options' => $content_models,
'#description' => t("Content models describe the behaviours of objects with which they are associated."),
);
$form['child_creation']['submit'] = array(
'#type' => 'submit',
'#value' => t('Create collection'),
@ -86,16 +96,42 @@ function islandora_create_child_collection_form_validate($form, &$form_state) {
}
function islandora_create_child_collection_form_submit($form, & $form_state) {
global $base_url ;
global $base_root ;
module_load_include('inc', 'islandora', '/includes/islandora.ingest');
$thumbnail = $base_url . '/' . drupal_get_path('module', 'islandora_basic_collection') . '/Crystal_Clear_filesystem_folder_grey.png';
$thumbnail = $base_root . '/' . drupal_get_path('module', 'islandora_basic_collection') . '/Crystal_Clear_filesystem_folder_grey.png';
$new_collection_pid = $form_state['values']['new_collection_pid'];
$new_collection_label = $form_state['values']['collection_name'];
$namespace = $form_state['values']['collection_namespace'];
// $all_cModels = get_content_models_as_option_array();
$content_models = array(array('pid' => 'islandora:collectionCModel'));
$relationship = 'isMemberOfCollection';
$content_models = array('islandora:collectionCModel');
$relationship = array(
'uri' => FEDORA_RELS_EXT_URI,
'value' => 'isMemberOfCollection',
);
$collection_policy = '<? xml version = "1.0" encoding = "UTF-8" ?>
< collection_policy xmlns = "http://www.islandora.ca" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" name = "" xsi:schemaLocation = "http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd" >
< content_models >
< content_model dsid = "ISLANDORACM" name = "Islandora Collection Model ~ islandora:collectionCModel" namespace = "islandora:1" pid = "islandora:collectionCModel" / >
< / content_models >
< search_terms >
< / search_terms >
< staging_area > < / staging_area >
< relationship > isMemberOfCollection< / relationship >
< / collection_policy > ';
$content_models = $form_state['values']['content_models'];
$collection_policy_xml = new SimpleXMLElement($collection_policy);
foreach ($content_models as $content_model) {
if ($content_model) {
$node = $collection_policy_xml->content_models->addChild('content_model');
$node->addAttribute('dsid', 'ISLANDORACM');
$node->addAttribute('name', $all_cModels[$content_model]);
$node->addAttribute('namespace', $pid_namespace . ':1');
$node->addAttribute('pid', $content_model);
}
}
$fedora_object = islandora_ingest_get_object($content_models, $form_state['values']['current'], $relationship, $new_collection_pid);
$fedora_object->label = $new_collection_label;
$thumbnail_datastream = $fedora_object->constructDatastream('TN');
@ -103,18 +139,11 @@ function islandora_create_child_collection_form_submit($form, &$form_state) {
$thumbnail_datastream->label = 'Thumbnail';
$thumbnail_datastream->mimetype = 'image/png';
$fedora_object->ingestDatastream($thumbnail_datastream);
$policy_datastream = $fedora_object->constructDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'), 'X');
$policy_datastream->setContentFromString($collection_policy_xml->saveXML());
$policy_datastream->label = 'Collection policy';
$fedora_object->ingestDatastream($policy_datastream);
$new_fedora_object = islandora_ingest_add_object($fedora_object);
// $content_models = $form_state['values']['content_models'];
// $collection_policy_xml = simplexml_load_string($collection_policy);
// foreach ($content_models as $content_model) {
// if ($content_model) {
// $node = $collection_policy_xml->content_models->addChild('content_model');
// $node->addAttribute('dsid', 'ISLANDORACM');
// $node->addAttribute('name', $all_cModels[$content_model]);
// $node->addAttribute('namespace', $pid_namespace . ':1');
// $node->addAttribute('pid', $content_model);
// }
// }
drupal_goto('/islandora/object/' . $new_collection_pid);
}