Browse Source

Added collection managedment form

pull/112/head
rwincewicz 13 years ago
parent
commit
14c9b9c5b7
  1. 494
      islandora_basic_collection/includes/CollectionManagement.inc
  2. 94
      islandora_basic_collection/includes/CollectionManagerTable.inc
  3. 108
      islandora_basic_collection/includes/DeleteCollection.inc
  4. 62
      islandora_basic_collection/includes/MoveCollection.inc
  5. 93
      islandora_basic_collection/islandora_basic_collection.module

494
islandora_basic_collection/includes/CollectionManagement.inc

@ -0,0 +1,494 @@
<?php
/**
* collection creation form
* @param array $form_state
* @param string $parent_collection_pid
* @param string $content_models
* @return array
*/
function collection_management_form($this_collection_pid, $content_models) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
$restricted = FALSE;
if (variable_get('fedora_namespace_restriction_enforced', TRUE)) {
$restricted = TRUE;
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string);
foreach ($namespaces as $namespace) {
if ($namespace) {
$allowed[trim($namespace)] = trim($namespace);
}
}
}
$collection_policy = CollectionPolicy::loadFromCollection($this_collection_pid);
if ($collection_policy) {
$supported_collection_models = $collection_policy->getContentModels();
}
$collection_namespace = substr($this_collection_pid, 0, strpos($this_collection_pid, ":"));
$represented_content_models = get_represented_content_models($this_collection_pid);
$item = new Fedora_Item($this_collection_pid);
$collection_name = $item->objectProfile->objLabel;
$new_content_models = get_content_models_as_option_array();
$current_models_in_policy = array();
if ($supported_collection_models) {
foreach ($supported_collection_models as $supported_model) {
$current_models_in_policy[$supported_model->pid] = $supported_model->pid;
}
}
$cm_options = array();
$name_mappings = array();
foreach ($content_models as $content_model) {
if ($content_model->pid != "islandora:collectionCModel") {
$item = new fedora_item($content_model->pid);
$cm_name = $item->objectProfile->objLabel;
$cm_options[$content_model->pid] = $cm_name;
}
}
if (!empty($current_models_in_policy)) {
$show_delete = TRUE;
}
$content_models = get_content_models_as_option_array();
unset($content_models['islandora:collectionCModel']);
$form['child_creation'] = array(
'#title' => "Create Child Collection",
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['child_creation']['titlebox'] = array(
'#type' => 'item',
'#value' => t("Create New Child Collection within $this_collection_pid"),
);
$form['child_creation']['collection_name'] = array(
'#title' => "Collection Name",
'#type' => 'textfield',
'#description' => t("Human readable name for this collection"),
);
$form['child_creation']['new_collection_pid'] = array(
'#title' => "Collection PID",
'#type' => 'textfield',
'#size' => 15,
'#default_value' => Fedora_Item::get_next_PID_in_namespace($collection_namespace),
'#description' => t("Unique PID for this collection. <br />Pids take the general form of namespace:collection eg islandora:pamphlets"),
);
if (!$restricted) {
$form['child_creation']['collection_namespace'] = array(
'#title' => "Collection Namespace",
'#type' => 'textfield',
'#size' => 15,
'#default_value' => $collection_namespace,
'#description' => t("Namespace for objects in this collection."),
);
}
else {
$form['child_creation']['collection_namespace'] = array(
'#title' => "Collection Namespace",
'#type' => 'select',
'#options' => $allowed,
'#default_value' => 'default',
'#description' => t("Namespace for objects in this collection."),
);
}
$form['parent_collection'] = array(
'#type' => 'hidden',
'#value' => $this_collection_pid,
);
$form['collection_pid'] = array(
'#type' => 'hidden',
'#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'),
'#id' => 'create_child'
);
$form['manage_collection_policy'] = array(
'#title' => "Manage Collection Policies",
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['manage_collection_policy']['add'] = array(
'#title' => "Add Content Model to Collection Policy",
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => $show_delete,
);
$new_options = array();
if (is_array($content_models) && is_array($cm_options)) {
$new_options = array_diff_key($content_models, $cm_options);
}
$form ['manage_collection_policy']['add']['content_model_to_add'] = array(
'#title' => "Choose Content Model",
'#type' => 'select',
'#options' => $new_options,
'#description' => t("Choose content model to add to this collection policy."),
);
$form ['manage_collection_policy']['add']['new_cp_namespace'] = array(
'#title' => "Choose Namespace",
'#type' => 'textfield',
'#size' => 15,
'#default_value' => $collection_namespace,
'#description' => t("Choose namespace for objects in this collection associated with this content model"),
);
$form['manage_collection_policy']['add']['submit'] = array(
'#type' => 'submit',
'#value' => t('Add Content Model to Collection Policy'),
'#id' => 'add_cm'
);
if (count($current_models_in_policy) > 0) {
$form['manage_collection_policy']['remove'] = array(
'#title' => "Delete Content Model from Collection Policy",
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form ['manage_collection_policy']['remove']['content_models_to_remove'] = array(
'#title' => "Choose Content Model to Remove",
'#type' => 'checkboxes',
'#options' => $current_models_in_policy,
'#description' => t("Choose content models to remove from this collection policy."),
);
$form['manage_collection_policy']['remove']['submit'] = array(
'#type' => 'submit',
'#value' => t('Remove Content Model From Collection Policy'),
'#id' => 'remove_cm'
);
}
$form['change_cmodel'] = array(
'#title' => "Change Content Models",
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['change_cmodel']['titlebox'] = array(
'#type' => 'item',
'#value' => t("Change Content Models within $this_collection_pid"),
);
$form['change_cmodel']['current_content_model'] = array(
'#title' => "Choose content model to be changed",
'#type' => 'select',
'#options' => $represented_content_models,
'#description' => t("All objects in this collection with the selected content model will be changed."),
);
$form['change_cmodel']['new_content_model'] = array(
'#title' => "Choose new content model",
'#type' => 'select',
'#options' => $new_content_models,
'#description' => t("The new content model to be assigned to selected objects."),
);
$form['change_cmodel']['collection_pid'] = array(
'#type' => 'hidden',
'#value' => $this_collection_pid,
);
$form['change_cmodel']['submit'] = array(
'#type' => 'submit',
'#value' => t('Change Content Model Associations'),
'#id' => 'change_model',
);
return($form);
}
/**
* collection creation form validate
* @param array $form
* @param array $form_state
*/
function collection_management_form_validate($form, &$form_state) {
if ($form_state['clicked_button']['#id'] == 'create_child') {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$pid = $form_state['values']['new_collection_pid'];
$item = new fedora_item($pid);
$needs_model = FALSE;
foreach ($form_state['values']['content_models'] as $key => $value) {
if (is_string($value)) {
$needs_model = FALSE;
}
}
$checked = array_values($form_state['values']['content_models']);
if ($item->exists()) {
form_set_error('new_collection_pid', t("$pid already exists within your repository. the PID must be unique. Click on 'Manage This Collection' tab and enter new value."));
return;
}
if (!valid_pid($pid)) {
form_set_error('new_collection_pid', t("$pid is not a valid identifier. Click on 'Manage This Collection' tab and enter new value."));
return;
}
if ($needs_model) {
form_set_error('content_models', t("At least one content model must be selected. Click on 'Manage This Collection' tab and enter content model."));
return;
}
}
if ($form_state['clicked_button']['#id'] == 'add_cm') {
$name_parts = explode(":", $form_state['values']['new_cp_namespace']);
$namespace = $name_parts[0] . ":1";
if (!valid_pid($namespace)) {
form_set_error('new_cp_namespace', t("Namespace must be valid. Click on 'Manage This Collection' tab and enter new value."));
return;
}
$form_state['values']['new_cp_namespace'] = $namespace;
}
}
/**
* collection creation form submit
* @global user $user
* @param arary $form
* @param array $form_state
*/
function collection_management_form_submit($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'api/fedora_collection');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/dublin_core');
global $user;
$collection_pid = $form_state['values']['parent_collection'];
$policy = CollectionPolicy::loadFromCollection($collection_pid, TRUE);
$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>';
// add child collection to policy
if ($form_state['clicked_button']['#id'] == 'create_child') {
$module_path = drupal_get_path('module', 'fedora_repository');
$thumbnail = drupal_get_path('module', 'Fedora_Repository') . '/images/Crystal_Clear_filesystem_folder_grey.png';
$new_collection_pid = $form_state['values']['new_collection_pid'];
$new_collection_label = $form_state['values']['collection_name'];
$pid_namespace = $form_state['values']['collection_namespace'];
$all_cModels = get_content_models_as_option_array();
$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);
}
}
$item = fedora_item::ingest_new_item($new_collection_pid, 'A', $new_collection_label, $user->name);
$item->add_relationship('isMemberOfCollection', $collection_pid, RELS_EXT_URI);
$item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI);
$item->add_datastream_from_string($collection_policy_xml->saveXML(), 'COLLECTION_POLICY', 'COLLECTION_POLICY', 'text/xml', 'X');
$item->add_datastream_from_file($thumbnail, 'TN');
drupal_goto("/fedora/repository/$new_collection_pid");
}
// add content model to collection policy
if ($form_state['clicked_button']['#id'] == 'add_cm') {
if (!$policy) {
$item = new Fedora_Item($collection_pid);
$item->add_datastream_from_string($collection_policy, 'COLLECTION_POLICY', 'COLLECTION_POLICY', 'text/xml', 'X');
$policy = CollectionPolicy::loadFromCollection($collection_pid, TRUE);
}
$cp_namespace = $form_state['values']['new_cp_namespace'];
$cp_content_model = $form_state['values']['content_model_to_add'];
$policy->addModel(ContentModel::loadFromModel($cp_content_model), $cp_namespace);
$policy->saveToFedora();
drupal_set_message("Collection model successfully added");
}
//remove content model from collection policy
if ($form_state['clicked_button']['#id'] == 'remove_cm') {
$candidates = $form_state['values']['content_models_to_remove'];
$count = 0;
foreach ($candidates as $candidate) {
if (is_string($candidate)) {
$policy->removeModel(ContentModel::loadFromModel($candidate));
$count++;
}
}
if ($count > 0) {
$policy->saveToFedora();
if ($count > 1) {
$s = 's';
}
drupal_set_message("$count collection model$s removed");
}
}
//change content model on selected objects
if ($form_state['clicked_button']['#id'] == 'change_model') {
$current_content_model = $form_state['values']['current_content_model'];
$new_content_model = $form_state['values']['new_content_model'];
$add_to_policy = TRUE;
$policy_cms = $policy->getContentModels();
foreach ($policy_cms as $policy_cm) {
if ($policy_cm->pid == $current_content_model) {
$namespace = $policy_cm->pid_namespace;
}
if ($policy_cm->pid == $new_content_model) {
$add_to_policy = FALSE;
}
}
if ($add_to_policy) {
$policy->addModel(ContentModel::loadFromModel($new_content_model), $namespace);
$policy->saveToFedora();
}
$query = "select \$object from <#ri>
where (\$object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/$current_content_model>
and (\$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid>
or \$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/$collection_pid>)
and \$object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)";
$query = htmlentities(urlencode($query));
$content = '';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=TRUE&format=csv&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query;
$content .= do_curl($url);
$results = explode("\n", $content);
$object_pids = preg_replace('/^info:fedora\/|"object"/', '', $results);
$count = 0;
foreach ($object_pids as $object_pid) {
if (!$object_pid) {
continue;
}
$item = new fedora_item($object_pid);
$item->purge_relationship('hasModel', $current_content_model);
$item->add_relationship('hasModel', $new_content_model, FEDORA_MODEL_URI);
$count++;
}
drupal_set_message("$current_content_model changed to $new_content_model on $count objects");
}
}
/**
* deletes PID
* @param string $pid
*/
function delete_objects_as_batch($pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$name = $user->name;
$item_to_delete = new Fedora_Item($pid);
$item_to_delete->purge("$object purged by $name");
}
/**
* removes association of this object to this collection
* @param string $pid
*/
function remove_collection_association($pid, $collection_pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new Fedora_Item($pid);
$item->purge_relationship('isMemberOfCollection', $collection_pid);
}
/**
* returns content models associated with all objects in a collection
* @param string $pid
* @return arrau
*/
function get_represented_content_models($pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$query = "select \$model from <#ri>
where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/$pid>
or \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$pid>)
and \$object <info:fedora/fedora-system:def/model#hasModel> \$model";
$query = htmlentities(urlencode($query));
$content = '';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=TRUE&format=csv&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query;
$content .= do_curl($url);
$results = explode("\n", $content);
$model_pids = preg_replace('/^info:fedora\/|"model"/', '', $results);
$represented_models = array();
foreach ($model_pids as $model_pid) {
if ($model_pid && $model_pid != 'fedora-system:FedoraObject-3.0') {
$item = new fedora_item($model_pid);
$label = $item->objectProfile->objLabel;
$represented_models[$model_pid] = "$model_pid ~ $label";
}
}
return $represented_models;
}
function get_child_collections($collection_pid) {
$query = <<<EOD
select \$object from <#ri>
where \$object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel>
and \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid>
EOD;
$query = htmlentities(urlencode($query));
$content = '';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=TRUE&format=csv&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query;
$content .= do_curl($url);
$results = explode("\n", $content);
$lines = preg_replace('/info:fedora\/|"object"/', '', $results);
$collection_pids = array_values(array_filter($lines));
return $collection_pids;
}
function Islandora_collections_get_collection_from_pid($pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$query_string = 'select $parent from <#ri>
where ($object <fedora-rels-ext:isMemberOf> $parent
or $object <fedora-rels-ext:isMemberOfCollection> $parent)
and $object <dc:identifier> \'' . $pid . '\'
order by $object';
$query_string = htmlentities(urlencode($query_string));
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= '?type=tuples&flush=true&format=csv&limit=13000&lang=itql&stream=on&query=' . $query_string;
$content = do_curl($url, TRUE);
$results = explode("\n", $content);
$object_pids = preg_replace('/^info:fedora\/|"parent"| /', '', $results);
$object_pids = array_values(array_filter($object_pids));
return $object_pids;
}

94
islandora_basic_collection/includes/CollectionManagerTable.inc

@ -0,0 +1,94 @@
<?php
/**
* Returns a formatted table listing all members of the collection
* defined by the $collection_pid parameter
* @param string $collection_pid
* @return array
*/
function islandora_collection_table($collection_pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$query = "select \$object \$title from <#ri>
where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/$collection_pid>
or \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid>)
and \$object <dc:title> \$title";
$query = htmlentities(urlencode($query));
$content = '';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=TRUE&format=csv&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query;
$content .= do_curl($url);
$results = explode("\n", $content);
$lines = preg_replace('/info:fedora\/|"object","title"/', '', $results);
$lines = array_values(array_filter($lines));
$keys = array();
$object = array();
foreach ($lines as $line) {
$line_parts = explode(',', $line);
$objects[$line_parts[0]] = $line_parts[1];
$keys[] = $line_parts[0];
}
$form['list'] = array(
'#value' => $list,
);
$table = array(
'#header' => array(theme('table_select_header_cell'), t('Select All'), ''),
'#theme' => 'islandora_collection_management_form_table',
'#tree' => TRUE,
'rows' => array(),
'selections' => array(
'#type' => 'checkboxes',
'#options' => array_fill_keys($keys, ''),
),
);
$rows = &$table['rows'];
if(empty($objects)){
return;
}
foreach ($objects as $key => $object) {
$rows[] = array(
'#pid' => $key,
'pid' => array('#value' => l($key, 'fedora/repository/' . $key)),
'title' => array('#value' => $object),
);
}
return $table;
}
/**
* themes the form table.
*
* @param array $element Drupal Form Element.
* @return string
*/
function theme_islandora_collection_management_form_table(array $element) {
$rows = array();
foreach (element_children($element['rows']) as $child) {
$setting = $element['rows'][$child];
$pid = $setting['#pid'];
$fields = array(
drupal_render($element['selections'][$pid]) // First field is a checkbox
);
foreach (element_children($setting) as $property) {
$field = $setting[$property];
$fields[] = drupal_render($field);
}
$rows[] = array(
'data' => $fields,
'class' => isset($setting['#attributes']['class']) ? $setting['#attributes']['class'] : NULL
);
}
$attributes = isset($element['#id']) ? array('id' => $element['#id']) : NULL;
return theme_table($element['#header'], $rows, $attributes);
}

108
islandora_basic_collection/includes/DeleteCollection.inc

@ -0,0 +1,108 @@
<?php
/**
*
* @param array $form_state
* @param string $pid
*
* @return string
*/
function islandora_collection_deletion_form(&$form_state, $pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
module_load_include('inc', 'islandora_collection_manager', 'CollectionManagerTable');
$potential_collections = get_collections_as_option_array();
$table = islandora_collection_table($pid);
$deletion_message = ($table) ? "Delete Members of this Collection" : "Delete Collection";
$submit_text_message = ($table) ? "Delete Selected Objects" : "Delete Collection";
$form = array();
$form['collection_delete'] = array(
'#title' => $deletion_message,
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
if ($table) {
$form['collection_delete']['table'] = array(
'table' => $table,
);
}
else {
$form['collection_delete']['delete_root'] = array(
'#type' => 'checkbox',
'#title' => "Remove this empty collection?",
'#id' => 'delete_collection',
);
}
$form['current'] = array(
'#type' => 'hidden',
'#value' => $pid,
);
$form['collection_delete']['message'] = array(
'#type' => 'item',
'#value' => t("This action is permanant and cannot be undone."),
);
$form['collection_delete']['submit'] = array(
'#type' => 'submit',
'#description' => t("This action is permanant and cannot be undone."),
'#value' => t($submit_text_message),
);
if (user_access('delete entire collections')) {
return $form;
}
}
function islandora_collection_deletion_form_submit($form, &$form_state) {
global $user;
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_collection');
$collection_pid = $form_state['values']['current'];
$parents = Islandora_collections_get_collection_from_pid($collection_pid);
$collection_pid = $form_state['values']['current'];
if ($form_state['values']['delete_root'] == 1) {
delete_root_collection($collection_pid);
drupal_goto("fedora/repository/" .$parents[0]);
}
$child_collections = get_child_collections($collection_pid);
$populated_child_collections = array();
$pids = @array_filter($form_state['values']['table']['selections']);
if (!empty($child_collections)) {
foreach ($child_collections as $child) {
$child_pids = get_related_items_as_array($child, 'isMemberOfCollection');
if (!empty($child_pids)) {
$populated_child_collections[] = $child;
}
}
}
if (!empty($populated_child_collections)) {
$conflict = false;
foreach ($populated_child_collections as $collection) {
if (in_array($collection, $pids)) {
$conflict = true;
drupal_set_message("Populated child collections were not deleted.");
}
}
}
$pids_to_delete = array_diff($pids, $populated_child_collections);
foreach ($pids_to_delete as $pid_to_delete) {
$item = new Fedora_Item($pid_to_delete);
$item->purge("Purged by " . $user->name);
}
drupal_goto("fedora/repository/" .$parents[0]);
}
function delete_root_collection($pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new Fedora_Item($pid);
$item->purge();
drupal_set_message("$pid deleted.");
}

62
islandora_basic_collection/includes/MoveCollection.inc

@ -0,0 +1,62 @@
<?php
/**
*
* @param array $form_state
* @param string $pid
*
* @return string
*/
function islandora_collection_migrate_form(&$form_state, $pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
module_load_include('inc', 'islandora_collection_manager', 'CollectionManagerTable');
$potential_collections = get_collections_as_option_array();
$table = islandora_collection_table($pid);
if (!$table) {
return;
}
$form = array();
$form['migrate'] = array(
'#title' => "Migrate Members",
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['migrate']['new_collection'] = array(
'#title' => t('New Collection'),
'#description' => t("All content will be migrated from $pid to the selected collection"),
'#type' => 'select',
'#options' => $potential_collections,
);
$form['migrate']['table'] = array(
'table' => $table,
);
$form['current'] = array(
'#type' => 'hidden',
'#value' => $pid,
);
$form['migrate']['message'] = array(
'#type' => 'item',
'#value' => t(""),
);
$form['migrate']['submit'] = array(
'#type' => 'submit',
'#value' => t('Migrate selected objects'),
);
return $form;
}
function islandora_collection_migrate_form_submit($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$pids = array_filter($form_state['values']['table']['selections']);
$new_collection = $form_state['values']['new_collection'];
$current = $form_state['values']['current'];
foreach ($pids as $pid) {
$item = new Fedora_Item($pid);
$item->add_relationship('isMemberOfCollection', $new_collection, RELS_EXT_URI);
$item->purge_relationship('isMemberOfCollection', $current);
}
}

93
islandora_basic_collection/islandora_basic_collection.module

@ -66,7 +66,91 @@ function islandora_basic_collection_menu() {
* @return type
*/
function islandora_basic_collection_manage_object($object_id) {
return 'Collection CModel edit function ' . $object_id;
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionManagement');
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionManagerTable');
module_load_include('inc', 'islandora_basic_collection', 'includes/DeleteCollection');
module_load_include('inc', 'islandora_basic_collection', 'includes/MoveCollection');
drupal_add_library('system', 'drupal.vertical-tabs');
drupal_load_stylesheet('misc/vertical-tabs-rtl.css');
$form['additional_settings'] = array(
'#type' => 'vertical_tabs',
'#weight' => 99,
);
$form['create_child_collection'] = array(
'#type' => 'fieldset',
'#title' => t('Create Child Collection'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#group' => 'additional_settings',
'#tree' => TRUE,
'#weight' => -2,
);
$form['create_child_collection']['form'] = array(
// '#content' => drupal_get_form('collection_management_form', $object_id),
);
$form['manage_policies'] = array(
'#type' => 'fieldset',
'#title' => t('Manage Collection Policies'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#group' => 'additional_settings',
'#tree' => TRUE,
'#weight' => -3,
);
$form['manage_policies']['form'] = array(
// '#content' => drupal_get_form($form_id),
);
$form['change_content_models'] = array(
'#type' => 'fieldset',
'#title' => t('Change Content Models'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#group' => 'additional_settings',
'#tree' => TRUE,
'#weight' => -3,
);
$form['change_content_models']['form'] = array(
// '#content' => drupal_get_form($form_id),
);
$form['migrate_members'] = array(
'#type' => 'fieldset',
'#title' => t('Migrate Members'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#group' => 'additional_settings',
'#tree' => TRUE,
'#weight' => -3,
);
$form['migrate_members']['form'] = array(
'#content' => drupal_get_form('islandora_collection_migrate_form', $object_id),
);
$form['delete_members'] = array(
'#type' => 'fieldset',
'#title' => t('Delete Members of this Collection'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#group' => 'additional_settings',
'#tree' => TRUE,
'#weight' => -3,
);
$form['delete_members']['form'] = array(
'#content' => drupal_get_form('islandora_collection_deletion_form', $object_id),
);
return $form;
// return 'Collection CModel edit function ' . $object_id;
}
/**
@ -206,7 +290,7 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari
$associated_objects_array[$pid]['dc_array'] = $dc_object->as_formatted_array();
} catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error');
}
}
$object_url = 'islandora/object/' . $pid;
$thumbnail_img = '<img src="' . $base_path . $object_url . '/datastream/TN/view"' . '/>';
$title = $variables['islandora_associated_objects'][$key]['title']['value'];
@ -214,9 +298,10 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari
$associated_objects_array[$pid]['path'] = $object_url;
$associated_objects_array[$pid]['title'] = $title;
$associated_objects_array[$pid]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $pid));
if(isset($fc_object['TN'])){
if (isset($fc_object['TN'])) {
$thumbnail_img = '<img src="' . $base_path . $object_url . '/datastream/TN/view"' . '/>';
} else {
}
else {
$thumbnail_img = '<img src="http://codesprint-centos.islandora.ca/islandora/object/islandora%3A52/datastream/TN"' . '/>';
}
$associated_objects_array[$pid]['thumbnail'] = $thumbnail_img;

Loading…
Cancel
Save