Browse Source

Merge branch '6.x' of git://github.com/Islandora/islandora into 6.x

pull/92/head
ppound 13 years ago
parent
commit
b3c2849a75
  1. 264
      BatchIngest.inc
  2. 17
      CollectionClass.inc
  3. 401
      CollectionManagement.inc
  4. 12
      CollectionPolicy.inc
  5. 19
      ObjectHelper.inc
  6. 34
      SecurityClass.inc
  7. 7
      api/fedora_item.inc
  8. 57
      api/fedora_utils.inc
  9. 3
      fedora_repository.info
  10. 54
      fedora_repository.module
  11. 7
      plugins/FedoraObjectDetailedContent.inc
  12. 2
      plugins/fedora_imageapi.info
  13. 2
      plugins/slide_viewer.inc
  14. 2
      xsl/convertQDC.xsl
  15. 5
      xsl/mods_to_dc.xsl
  16. 59
      xsl/sparql_to_html.xsl

264
BatchIngest.inc

@ -1,264 +0,0 @@
<?php
/**
* batch creation form submit
* @global type $user
* @param array $form
* @param array $form_state
* @param array $content_models
*/
function batch_creation_form(&$form_state, $collection_pid, $content_models) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
$cm_options = array();
$name_mappings = array();
foreach ($content_models as $content_model) {
if ($content_model->pid != "islandora:collectionCModel") {
$cm_options[$content_model->pid] = $content_model->name;
$name_mappings[] = $content_model->pid . '^' . $content_model->pid_namespace;
}
}
$mappings = implode('~~~', $name_mappings);
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['titlebox'] = array(
'#type' => 'item',
'#value' => t("Batch ingest into $collection_pid"),
);
$form['collection_pid'] = array(
'#type' => 'hidden',
'#value' => $collection_pid,
);
$form['namespace_mappings'] = array(
'#type' => 'hidden',
'#value' => $mappings,
);
$form['content_model'] = array(
'#title' => "Choose content model to be associated with objects ingested",
'#type' => 'select',
'#options' => $cm_options,
'#required' => TRUE,
'#description' => t("Content models describe the behaviours of objects with which they are associated."),
);
$form['indicator']['file-location'] = array(
'#type' => 'file',
'#title' => t('Upload zipped folder'),
'#size' => 48,
'#description' => t('The zipped folder should contain all files necessary to build objects.<br .>
Related files must have the same filename, but with differing extensions to indicate mimetypes.<br />
ie. <em>myFile.xml</em> and <em>myFile.jpg</em>'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Create Objects ')
);
return($form);
}
/**
* @param array $form
* @param array $form_state
*/
function batch_creation_form_validate($form, &$form_state) {
$field_name = 'file-location';
if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name'][$field_name])) {
$file = file_save_upload($field_name);
if ($file->filemime != 'application/zip') {
form_set_error($field_name, 'Input file must be a .zip file');
return;
}
if (!$file) {
form_set_error($field_name, 'Error uploading file.');
return;
}
$form_state['values']['file'] = $file;
}
else {
// set error
form_set_error($field_name, 'Error uploading file.');
return;
}
}
function batch_creation_form_submit($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'ContentModel');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
global $user;
$namespace_mappings = array();
$content_model = $form_state['values']['content_model'];
$metadata = $form_state['values']['metadata_type'];
$collection_pid = $form_state['values']['collection_pid'];
$namespace_process = explode('~~~', $form_state['values']['namespace_mappings']);
foreach ($namespace_process as $line) {
$line_parts = explode('^', $line);
$namespace_mappings[$line_parts[0]] = $line_parts[1];
}
$namespace = $namespace_mappings[$content_model];
$namespace = preg_replace('/:.*/', '', $namespace);
$dir_name = "temp" . $user->uid;
$tmp_dir = file_directory_path() . '/' . $dir_name . '/';
mkdir($tmp_dir);
$file = $form_state['values']['file'];
$fileName = $file->filepath;
$file_list = array();
$cmdString = "unzip -q -o -d $tmp_dir \"$fileName\"";
system($cmdString, $retVal);
$dirs = array();
$do_not_add = array('.', '..', '__MACOSX');
array_push($dirs, $tmp_dir);
$files = scandir($tmp_dir);
foreach ($files as $file) {
if (is_dir("$tmp_dir/$file") & !in_array($file, $do_not_add)) {
array_push($dirs, $tmp_dir . $file);
}
}
foreach ($dirs as $directory) {
if ($inputs = opendir($directory)) {
while (FALSE !== ($file_name = readdir($inputs))) {
if (!in_array($file_name, $do_not_add) && is_dir($file_name) == FALSE) {
$ext = strrchr($file_name, '.');
$base = preg_replace("/$ext$/", '', $file_name);
$ext = substr($ext, 1);
if ($ext) {
if ($directory[strlen($directory)-1] != '/'){
$directory .= '/';
}
$file_list[$base][$ext] = "$directory" . $file_name;
}
}
}
closedir($inputs);
}
}
if (($cm = ContentModel::loadFromModel($content_model, 'ISLANDORACM')) === FALSE) {
drupal_set_message("$content_model not found", "error");
return;
}
$batch = array(
'title' => 'Ingesting Objects',
'operations' => array(),
'file' => drupal_get_path('module', 'fedora_repository') . '/BatchIngest.inc',
);
foreach ($file_list as $label => $object_files) {
$batch['operations'][] = array('create_batch_objects', array($label, $content_model, $object_files, $collection_pid, $namespace, $metadata));
}
$batch['operations'][] = array('recursive_directory_delete', array($tmp_dir));
batch_set($batch);
batch_process();
}
/**
*
* @param <string> $label
* @param <string> $content_model
* @param <array> $object_files
* @param <string> $collection_pid
* @param <string> $namespace
* @param <string> $metadata
*/
function create_batch_objects($label, $content_model, $object_files, $collection_pid, $namespace, $metadata) {
module_load_include('inc', 'fedora_repository', 'ContentModel');
module_load_include('inc', 'fedora_repository', 'MimeClass');
module_load_include('inc', 'fedora_reppository', 'api/fedora_item');
$cm = ContentModel::loadFromModel($content_model, 'ISLANDORACM');
$allowed_mime_types = $cm->getMimetypes();
$mime_helper = new MimeClass();
$pid = fedora_item::get_next_PID_in_namespace($namespace);
$item = Fedora_item::ingest_new_item($pid, 'A', $label, $owner);
$item->add_relationship('hasModel', $content_model, FEDORA_MODEL_URI);
$item->add_relationship('isMemberOfCollection', $collection_pid);
if ($object_files['xml']) {
$data = file_get_contents($object_files['xml']);
$xml = simplexml_load_string($data);
$identifier = $xml->getName();
if ($identifier == 'dc') {
$item->modify_datastream_by_value($data, 'DC', "Dublin Core", 'text/xml');
}
if ($identifier == 'mods') {
$item->add_datastream_from_string($mods_xml, 'MODS');
$dc_xml = batch_create_dc_from_mods($mods_xml);
$item->modify_datastream_by_value($dc_xml, 'DC', "Dublin Core", 'text/xml');
}
}
unset($object_files['xml']);
foreach ($object_files as $ext => $filename) {
$file_mimetype = $mime_helper->get_mimetype($filename);
if (in_array($file_mimetype, $allowed_mime_types)) {
$added = $cm->execIngestRules($filename, $file_mimetype);
}
else {
$item->purge("$pid $label not ingested. $file_mimetype not permitted in objects associated with $content_model");
continue;
}
$item->add_datastream_from_file($filename, "Source_File");
if (!empty($_SESSION['fedora_ingest_files'])) {
foreach ($_SESSION['fedora_ingest_files'] as $dsid => $datastream_file) {
$item->add_datastream_from_file($datastream_file, $dsid);
}
}
}
}
/**
* transforms mods to dc
* @param <string> $mods_xml
* @return <string>
*/
function batch_create_dc_from_mods($mods_xml) {
$path = drupal_get_path('module', 'fedora_repository');
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'CollectionClass');
if ($xmlstr == NULL || strlen($xmlstr) < 5) {
return " ";
}
try {
$proc = new XsltProcessor();
} catch (Exception $e) {
drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error');
return " ";
}
$xsl = new DomDocument();
$xsl->load($path . '/xsl/mods_to_dc.xsl');
$input = new DomDocument();
$input->loadXML(trim($xmlstr));
$xsl = $proc->importStylesheet($xsl);
$newdom = $proc->transformToDoc($input);
$dc_xml = $newdom->saveXML();
return $dc_xml;
}
/**
*
* @param <string> $dir
* @return <boolean>
*/
function recursive_directory_delete($dir) {
if (!file_exists($dir))
return TRUE;
if (!is_dir($dir))
return unlink($dir);
foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..')
continue;
if (!recursive_directory_delete($dir . DIRECTORY_SEPARATOR . $item))
return FALSE;
}
return rmdir($dir);
}

17
CollectionClass.inc

@ -517,8 +517,9 @@ class CollectionClass {
$show_ingest_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_ingest_form'); $show_ingest_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_ingest_form');
$add_to_collection = $this->getIngestInterface(); $add_to_collection = $this->getIngestInterface();
$show_batch_tab = TRUE; $show_batch_tab = FALSE;
$policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); $policy = CollectionPolicy::loadFromCollection($this->pid, TRUE);
if(!empty($policy)){ if(!empty($policy)){
$content_models = $policy->getContentModels(); $content_models = $policy->getContentModels();
} }
@ -528,7 +529,7 @@ class CollectionClass {
if (!$show_ingest_tab) { if (!$show_ingest_tab) {
$view_selected = TRUE; $view_selected = TRUE;
} }
if(!$collection_items){ if (!$collection_items) {
$view_selected = FALSE; $view_selected = FALSE;
$add_selected = TRUE; $add_selected = TRUE;
} }
@ -540,7 +541,6 @@ class CollectionClass {
'#title' => 'View', '#title' => 'View',
'#selected' => $view_selected, '#selected' => $view_selected,
'#content' => $collection_items, '#content' => $collection_items,
); );
$tabset['add_tab'] = array( $tabset['add_tab'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
@ -549,16 +549,7 @@ class CollectionClass {
// This will be the content of the tab. // This will be the content of the tab.
'#content' => $add_to_collection, '#content' => $add_to_collection,
); );
if (user_access('manage collections')) {
$tabset['add_collection_tab'] = array(
// #type and #title are the minimum requirements.
'#type' => 'tabpage',
'#title' => t('Manage This Collection'),
// This will be the content of the tab.
'#content' => drupal_get_form('collection_management_form', $this->pid, $content_models),
'#selected' => FALSE,
);
}
if ($show_batch_tab && user_access('create batch process')) { if ($show_batch_tab && user_access('create batch process')) {
$tabset['batch_ingest_tab'] = array( $tabset['batch_ingest_tab'] = array(
// #type and #title are the minimum requirements. // #type and #title are the minimum requirements.

401
CollectionManagement.inc

@ -1,401 +0,0 @@
<?php
/**
* collection creation form
* @param array $form_state
* @param string $parent_collection_pid
* @param string $content_models
* @return array
*/
function collection_management_form(&$form_state, $this_collection_pid, $content_models) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$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);
}
}
}
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
$item = new Fedora_Item($this_collection_pid);
$collection_name = $item->objectProfile->objLabel;
$new_content_models = get_content_models_as_option_array();
$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($cm_options)) {
$show_delete = TRUE;
}
$content_models = get_content_models_as_option_array();
$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,
'#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' => 'default',
'#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_class'
);
$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",
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => $show_delete,
);
$form ['manage_collection_policy']['add']['content_model_to_add'] = array(
'#title' => "Choose Content Model",
'#type' => 'select',
'#options' => array_diff_key($content_models, $cm_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,
'#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 ($show_delete) {
$form['manage_collection_policy']['remove'] = array(
'#title' => "Delete Content Model",
'#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' => $cm_options,
'#description' => t("Choose content models to remove from this collection policy."),
);
$form['manage_collection_policy']['remove']['submit'] = array(
'#type' => 'submit',
'#value' => t('Remove Content 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' => $cm_options,
'#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',
);
if (user_access('delete entire collections')) {
$form['delete_collection'] = array(
'#title' => "Permanently Delete $collection_name",
'#type' => 'fieldset',
'#description' => t("Clicking this button will delete all objects within $collection_name. <br /> <strong>This action cannot be undone.</strong>"),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['delete_collection']['confirm'] = array(
'#title' => "Are you sure?",
'#type' => 'fieldset',
'#description' => t('<strong>Clicking the delete button will permanantly remove all objects from this collection. <br /> <strong>This action cannot be undone.</strong> '),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['delete_collection']['confirm']['submit'] = array(
'#type' => 'submit',
'#value' => t('Delete this collection'),
'#id' => 'delete_collection',
);
}
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_class') {
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);
if ($item->exists()) {
form_set_error('new_collection_pid', t("$pid already exists within your repository. the PID must be unique"));
return;
}
if (!valid_pid($pid)) {
form_set_error('new_collection_pid', t("$pid is not a valid identifier"));
return;
}
}
if ($form_state['clicked_button']['#id'] == 'add_cm') {
if (!valid_pid($form_state['values']['new_cp_namespace'])) {
form_set_error('new_cp_namespace', t("Namespace must be a valid PID"));
return;
}
}
}
/**
* collection creation form submit
* @global type $user
* @param type $form
* @param type $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);
if ($form_state['clicked_button']['#id'] == 'create_class') {
$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();
$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_models>
<search_terms>
</search_terms>
<staging_area></staging_area>
<relationship>isMemberOfCollection</relationship>
</collection_policy>';
$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');
$item->add_datastream_from_file($thumbnail, 'TN');
drupal_goto("/fedora/repository/$new_collection_pid");
}
if ($form_state['clicked_button']['#id'] == 'add_cm') {
$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");
}
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");
}
}
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>
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");
}
if ($form_state['clicked_button']['#id'] == 'delete_collection') {
$collection_name = $form_state['values']['collection_name'];
$pids = get_related_items_as_array($collection_pid, 'isMemberOfCollection');
$batch = array(
'title' => "Deleting Objects from $name",
'operations' => array(),
'file' => drupal_get_path('module', 'fedora_repository') . '/CollectionManagement.inc',
);
foreach ($pids as $pid) {
$batch['operations'][] = array('delete_objects_as_batch', array($pid));
}
batch_set($batch);
batch_process('/fedora/repository');
}
}
/**
* deletes PID if pid is not collection
* @param <type> $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);
$models = $item_to_delete->get_models();
foreach ($models as $model) {
if ($model['object'] != 'islandora:collectionCModel') {
$item_to_delete->purge("$object purged by $name");
}
}
}

12
CollectionPolicy.inc

@ -244,8 +244,8 @@ class CollectionPolicy extends XMLDatastream {
$rootEl->appendChild($relationshipEl); $rootEl->appendChild($relationshipEl);
$newDom->appendChild($rootEl); $newDom->appendChild($rootEl);
$this->xml = new DOMDocument();
$this->xml = DOMDocument::loadXML($newDom->saveXml()); $this->xml->loadXML($newDom->saveXml());
} }
/** /**
@ -360,13 +360,14 @@ class CollectionPolicy extends XMLDatastream {
* @param string $dsid * @param string $dsid
* @return string $nextPid * @return string $nextPid
*/ */
public function getNextPid($dsid) { public function getNextPid($dsid, $content_model = null) {
$ret = FALSE; $ret = FALSE;
if (self::valid_dsid($dsid) && $this->validate()) { if (self::valid_dsid($dsid) && $this->validate()) {
$content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model'); $content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model');
$namespace = FALSE; $namespace = FALSE;
for ($i = 0; $namespace === FALSE && $i < $content_models->length; $i++) { for ($i = 0; $namespace === FALSE && $i < $content_models->length; $i++) {
if (strtolower($content_models->item($i)->getAttribute('dsid')) == strtolower($dsid)) { if (strtolower($content_models->item($i)->getAttribute('dsid')) == strtolower($dsid) && (strtolower($content_models->item($i)->getAttribute('pid') == $content_model) || $content_model == null)) {
$namespace = $content_models->item($i)->getAttribute('namespace'); $namespace = $content_models->item($i)->getAttribute('namespace');
} }
} }
@ -426,7 +427,8 @@ class CollectionPolicy extends XMLDatastream {
if ($this->xml == NULL) { if ($this->xml == NULL) {
$fedoraItem = new Fedora_Item($this->pid); $fedoraItem = new Fedora_Item($this->pid);
$ds = $fedoraItem->get_datastream_dissemination($this->dsid); $ds = $fedoraItem->get_datastream_dissemination($this->dsid);
$this->xml = DOMDocument::loadXML($ds); $this->xml = new DOMDocument();
$this->xml->loadXML($ds);
} }

19
ObjectHelper.inc

@ -19,9 +19,6 @@ class ObjectHelper {
public static $INGEST_FEDORA_OBJECTS = 'ingest new fedora objects'; public static $INGEST_FEDORA_OBJECTS = 'ingest new fedora objects';
public static $EDIT_TAGS_DATASTREAM = 'edit tags datastream'; public static $EDIT_TAGS_DATASTREAM = 'edit tags datastream';
public static $VIEW_DETAILED_CONTENT_LIST = 'view detailed list of content'; public static $VIEW_DETAILED_CONTENT_LIST = 'view detailed list of content';
public static $MANAGE_COLLECTIONS = 'manage collections';
public static $DELETE_ENTIRE_COLLECTIONS = 'delete entire collections';
public static $CREATE_BATCH_PROCESS = 'create batch process';
public static $DISPLAY_ALWAYS = 0; public static $DISPLAY_ALWAYS = 0;
public static $DISPLAY_NEVER = 1; public static $DISPLAY_NEVER = 1;
public static $DISPLAY_NO_MODEL_OUTPUT = 2; public static $DISPLAY_NO_MODEL_OUTPUT = 2;
@ -339,11 +336,12 @@ class ObjectHelper {
$versions = $item->get_datastream_history($id); $versions = $item->get_datastream_history($id);
if (is_array($versions)) { if (is_array($versions)) {
$downloadVersion = '<form method="GET" action="' . $action . '" onsubmit="this.action=\'' . $action . '\' + \'/\'+this.version.value;">'; $downloadVersion = '<form method="GET" action="' . $action . '" onsubmit="this.action=\'' . $action . '\' + \'/\'+this.version.value;">';
$downloadVersion .= '<input type="submit" value="' . t('Download') . '">';
$downloadVersion .= '<select name="version">'; $downloadVersion .= '<select name="version">';
foreach ($versions as $version) { foreach ($versions as $version) {
$downloadVersion .= '<option>' . $version->createDate . '</option>'; $downloadVersion .= '<option>' . $version->createDate . '</option>';
} }
$downloadVersion .= '</select><input type="submit" value="' . t('Download') . '"></form>'; $downloadVersion .= '</select></form>';
} }
} }
@ -549,6 +547,7 @@ class ObjectHelper {
*/ */
function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) { function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) {
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
module_load_include('inc', 'fedora_repository', 'ContentModel');
$collectionHelper = new CollectionClass(); $collectionHelper = new CollectionClass();
$pids = array(); $pids = array();
$query = 'select $object from <#ri> $query = 'select $object from <#ri>
@ -937,7 +936,7 @@ class ObjectHelper {
or <info:fedora/' . $pid . '> <fedora-rels-ext:isPartOf> $parentObject) or <info:fedora/' . $pid . '> <fedora-rels-ext:isPartOf> $parentObject)
and $parentObject <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $parentObject <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by $title'; order by $title desc';
$query_string = htmlentities(urlencode($query_string)); $query_string = htmlentities(urlencode($query_string));
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
@ -946,9 +945,13 @@ class ObjectHelper {
$result = preg_split('/[\r\n]+/', do_curl($url)); $result = preg_split('/[\r\n]+/', do_curl($url));
array_shift($result); // throw away first line array_shift($result); // throw away first line
$matches = str_getcsv(join("\n", $result)); $matches = str_getcsv(join("\n", $result));
if ($matches !== FALSE) { if (count($matches) >= 2) {
$parent = preg_replace('/^info:fedora\//', '', $matches[0]); $parent = preg_replace('/^info:fedora\//', '', $matches[0]);
if (0 == strlen($matches[1])) {
$matches[1] = "Unlabeled Object";
}
$breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid); $breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid);
if ($parent == variable_get('fedora_repository_pid', 'islandora:root')) { if ($parent == variable_get('fedora_repository_pid', 'islandora:root')) {
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); $breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
@ -958,6 +961,10 @@ class ObjectHelper {
$this->getBreadcrumbs($parent, $breadcrumbs, $level - 1); $this->getBreadcrumbs($parent, $breadcrumbs, $level - 1);
} }
} }
else {
$breadcrumbs[] = l("Path Calculation Error", 'fedora/repository/' . $pid);
}
} }
} }

34
SecurityClass.inc

@ -34,7 +34,6 @@ class SecurityClass {
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
// get the childsecurity policy from the collection. // get the childsecurity policy from the collection.
$policyStream = $objectHelper->getStream($collection_pid, SECURITYCLASS :: $SECURITY_CLASS_SECURITY_STREAM, FALSE); $policyStream = $objectHelper->getStream($collection_pid, SECURITYCLASS :: $SECURITY_CLASS_SECURITY_STREAM, FALSE);
if ($policyStream == NULL) { if ($policyStream == NULL) {
// no child policy stream so collection is wide open to anyone to ingest, that has the permission ingest in Drupal. // no child policy stream so collection is wide open to anyone to ingest, that has the permission ingest in Drupal.
// maybe we should return FALSE here?? would be more secure. // maybe we should return FALSE here?? would be more secure.
@ -79,34 +78,23 @@ class SecurityClass {
} }
$xml->registerXPathNamespace('default', 'urn:oasis:names:tc:xacml:1.0:policy'); $xml->registerXPathNamespace('default', 'urn:oasis:names:tc:xacml:1.0:policy');
$conditions = $xml->xpath("//default:Condition"); $roles = $xml->xpath('//default:SubjectAttributeDesignator[@AttributeId="fedoraRole"]/../default:Apply/default:AttributeValue');
$users = $xml->xpath('//default:SubjectAttributeDesignator[@AttributeId="urn:fedora:names:fedora:2.1:subject:loginId"]/../default:Apply/default:AttributeValue');
foreach ($conditions as $condition) {
$designator = $condition->Apply->SubjectAttributeDesignator;
if (empty($designator)) {//$disignator may be wrapped by an or
$designator = $condition->Apply->Apply->SubjectAttributeDesignator;
}
$attributeId = strip_tags($designator['AttributeId']);
if ($attributeId == "fedoraRole") { if($roles) {
foreach ($condition->Apply->Apply->AttributeValue as $attributeValue) { foreach($roles as $role) {
$allowedRoles[] = strip_tags($attributeValue->asXML()); $allowedRoles[] = (string)$role;
}
foreach ($condition->Apply->Apply->Apply->AttributeValue as $attributeValue) {
$allowedRoles[] = strip_tags($attributeValue->asXML());
}
} }
if ($attributeId == "urn:fedora:names:fedora:2.1:subject:loginId") { }
foreach ($condition->Apply->Apply->AttributeValue as $attributeValue) { if($users) {
$allowedUsers[] = strip_tags($attributeValue->asXML()); foreach($users as $user) {
} $allowedUsers[] = (string)$user;
foreach ($condition->Apply->Apply->Apply->AttributeValue as $attributeValue) {
$allowedUsers[] = strip_tags($attributeValue->asXML());
}
} }
} }
$usersAndRoles['users'] = $allowedUsers; $usersAndRoles['users'] = $allowedUsers;
$usersAndRoles['roles'] = $allowedRoles; $usersAndRoles['roles'] = $allowedRoles;
return $usersAndRoles; return $usersAndRoles;
} }

7
api/fedora_item.inc

@ -297,18 +297,17 @@ class Fedora_Item {
$i++; $i++;
$url = variable_get('fedora_base_url', 'http://localhost:8080/fedora'); $url = variable_get('fedora_base_url', 'http://localhost:8080/fedora');
if ($cursor == 0) { if ($cursor == 0) {
$url .= "/objects?query=$field~$pattern&pid=TRUE&title=TRUE&resultFormat=xml&maxResults=$max_results"; $url .= "/objects?query=$field~$pattern&pid=true&title=TRUE&resultFormat=xml&maxResults=$max_results";
} }
else { else {
$url .= "/objects?pid=TRUE&title=TRUEsessionToken=$session_token&resultFormat=xml&maxResults=$max_results"; $url .= "/objects?pid=true&title=true&sessionToken=$session_token&resultFormat=xml&maxResults=$max_results";
} }
if (count($resultFields) > 0) { if (count($resultFields) > 0) {
$url .= '&' . join('=TRUE&', $resultFields) . '=TRUE'; $url .= '&' . join('=true&', $resultFields) . '=true';
} }
$resultxml = do_curl($url); $resultxml = do_curl($url);
libxml_use_internal_errors(TRUE); libxml_use_internal_errors(TRUE);
$resultelements = simplexml_load_string($resultxml); $resultelements = simplexml_load_string($resultxml);
if ($resultelements === FALSE) { if ($resultelements === FALSE) {

57
api/fedora_utils.inc

@ -235,6 +235,7 @@ function fix_dsid($dsid) {
*/ */
function get_collections_as_option_array() { function get_collections_as_option_array() {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
$query = 'select $object $title from <#ri> $query = 'select $object $title from <#ri>
where ($object <dc:title> $title where ($object <dc:title> $title
and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel> and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel>
@ -265,41 +266,41 @@ function get_collections_as_option_array() {
* @return array * @return array
*/ */
function get_content_models_as_option_array() { function get_content_models_as_option_array() {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string); $namespaces = explode(':', $allowed_string);
foreach ($namespaces as $namespace) { foreach ($namespaces as $namespace) {
if ($namespace) { if ($namespace) {
$allowed[] = trim($namespace); $allowed[] = trim($namespace);
}
} }
} $query = 'select $object $title from <#ri>
$query = 'select $object $title from <#ri>
where ($object <dc:title> $title where ($object <dc:title> $title
and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0> and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0>
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>) or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title'; order by $title';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query="; $url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query=";
$content = do_curl($url . htmlentities(urlencode($query))); $content = do_curl($url . htmlentities(urlencode($query)));
$list = explode("\n", $content); $list = explode("\n", $content);
array_shift($list); array_shift($list);
$list = preg_replace('/info:fedora\//', '', $list); $list = preg_replace('/info:fedora\//', '', $list);
foreach ($list as $item) { //removes blanks foreach ($list as $item) { //removes blanks
if ($item) { if ($item) {
$parts = explode(',', $item); $parts = explode(',', $item);
$item = new fedora_item($parts[0]); $nameparts = explode(':', $parts[0]);
$nameparts = explode(':', $parts[0]); if (!$restricted || in_array($nameparts[0], $allowed)) {
if (!$restricted || in_array($nameparts[0], $allowed))
$datastreams = array_keys($item->get_datastreams_list_as_array()); if (!preg_match('/fedora-system/', $nameparts[0])) {
if (in_array('ISLANDORACM', $datastreams)) { $options[$parts[0]] = $parts[1] . ' ~ ' . $parts[0];
$options[$parts[0]] = $parts[1] . ' ~ ' . $parts[0]; }
} }
}
} }
}
return $options; return $options;
} }

3
fedora_repository.info

@ -1,9 +1,8 @@
; $Id$
name = Islandora Repository name = Islandora Repository
dependencies[] = imageapi dependencies[] = imageapi
dependencies[] = tabs dependencies[] = tabs
dependencies[] = islandora_content_model_forms dependencies[] = islandora_content_model_forms
description = Shows a list of items in a fedora collection. description = Shows a list of items in a fedora collection.
package = Islandora package = Islandora
version = 11.2.0 version = 11.3.1
core = 6.x core = 6.x

54
fedora_repository.module

@ -55,8 +55,8 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) {
return ''; return '';
} }
$output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', array( $output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', array(
'%name' => $name, '%name' => $name,
'%pid' => $pid) '%pid' => $pid)
); );
$output .= drupal_get_form('fedora_repository_purge_object_form', $pid); $output .= drupal_get_form('fedora_repository_purge_object_form', $pid);
@ -142,6 +142,10 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
*/ */
function fedora_repository_ingest_form_submit(array $form, array &$form_state) { function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
//only validate the form if the submit button was pressed (other buttons may be used for AHAH //only validate the form if the submit button was pressed (other buttons may be used for AHAH
if ($form_state['ahah_submission']) {
$form_state['submitted'] = false;
return;
}
if ($form_state['storage']['xml']) { if ($form_state['storage']['xml']) {
if (module_exists('islandora_content_model_forms')) { if (module_exists('islandora_content_model_forms')) {
module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm');
@ -197,7 +201,11 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
*/ */
function fedora_repository_ingest_form_validate($form, &$form_state) { function fedora_repository_ingest_form_validate($form, &$form_state) {
//only validate the form if the submit button was pressed (other buttons may be used for AHAH //only validate the form if the submit button was pressed (other buttons may be used for AHAH
if ($form_state['clicked_button']['#id'] == 'edit-submit') { if ($form_state['ahah_submission']) {
$form_state['submitted'] = false;
return;
}
if ($form_state['clicked_button']['#id'] == 'edit-submit' && $form_state['ahah_submission'] != 1) {
switch ($form_state['storage']['step']) { switch ($form_state['storage']['step']) {
case 1: case 1:
$form_state['storage']['step']++; $form_state['storage']['step']++;
@ -317,7 +325,7 @@ function fedora_repository_purge_object_form(&$form_state, $pid, $referrer = NUL
if (!empty($collectionPid)) { if (!empty($collectionPid)) {
$collectionPid = $_SESSION['fedora_collection']; $collectionPid = $_SESSION['fedora_collection'];
} }
//$form['#redirect'] = $referrer; //$form['#rebuild'] = $false;
return $form; return $form;
} }
@ -435,7 +443,7 @@ function add_stream_form_validate($form, &$form_state) {
return FALSE; return FALSE;
} }
if (!(preg_match("/^[a-zA-Z]/", $dsid))) { if (!(preg_match("/^[a-zA-Z]/", $dsid))) {
form_set_error('', t("Data stream ID (@dsid) has to start with a letter.", array( '@dsid' => check_plain($dsid)))); form_set_error('', t("Data stream ID (@dsid) has to start with a letter.", array('@dsid' => check_plain($dsid))));
return FALSE; return FALSE;
} }
if (strlen($dsLabel) > 64) { if (strlen($dsLabel) > 64) {
@ -447,9 +455,9 @@ function add_stream_form_validate($form, &$form_state) {
return FALSE; return FALSE;
} }
$validators = array( $validators = array(
// 'file_validate_is_image' => array(), // 'file_validate_is_image' => array(),
// 'file_validate_image_resolution' => array('85x85'), // 'file_validate_image_resolution' => array('85x85'),
// 'file_validate_size' => array(30 * 1024), // 'file_validate_size' => array(30 * 1024),
); );
$fileObject = file_save_upload('add-stream-file-location', $validators); $fileObject = file_save_upload('add-stream-file-location', $validators);
@ -482,12 +490,29 @@ function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL)
} }
$output = t('Are you sure you wish to purge this datastream %name<br />', array( $output = t('Are you sure you wish to purge this datastream %name<br />', array(
'%name' => $name) '%name' => $name)
); );
$output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId); $output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId);
return $output; return $output;
} }
function fedora_repository_purge_object_form_validate($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'api/fedora_collection');
$pid = $form_state['values']['pid'];
$objectHelper = new ObjectHelper();
$contentModels = $objectHelper->get_content_models_list($pid);
foreach ($contentModels as $contentModel) {
if ($contentModel->pid == 'islandora:collectionCModel') {
$member_pids = get_related_items_as_array($pid, 'isMemberOfCollection');
if (is_array($member_pids) && ! empty($member_pids)){
form_set_error('new_collection_pid', t("Please purge all members of this collection before deleting the collection itself."));
return;
}
}
}
}
/** /**
* fedora repository purge object form submit * fedora repository purge object form submit
* @param type $form * @param type $form
@ -659,7 +684,7 @@ function fedora_repository_replace_stream_form_submit($form, &$form_state) {
$pid = $form_state['values']['pid']; $pid = $form_state['values']['pid'];
$dsid = $form_state['values']['dsId']; $dsid = $form_state['values']['dsId'];
$dsLabel = $form_state['values']['dsLabel']; $dsLabel = $form_state['values']['dsLabel'];
// Remove the original file extension from the label and add the new one // Remove the original file extension from the label and add the new one
$indexOfDot = strrpos($dsLabel, '.'); //use strrpos to get the last dot $indexOfDot = strrpos($dsLabel, '.'); //use strrpos to get the last dot
if ($indexOfDot !== FALSE) { if ($indexOfDot !== FALSE) {
$dsLabel = substr($dsLabel, 0, $indexOfDot); $dsLabel = substr($dsLabel, 0, $indexOfDot);
@ -732,6 +757,7 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
$soapHelper = new ConnectionHelper(); $soapHelper = new ConnectionHelper();
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
// Check if there is a custom edit metadata function defined in the content model. // Check if there is a custom edit metadata function defined in the content model.
$breadcrumbs = array(); $breadcrumbs = array();
@ -828,9 +854,6 @@ function fedora_repository_perm() {
OBJECTHELPER::$INGEST_FEDORA_OBJECTS, OBJECTHELPER::$INGEST_FEDORA_OBJECTS,
OBJECTHELPER::$EDIT_TAGS_DATASTREAM, OBJECTHELPER::$EDIT_TAGS_DATASTREAM,
OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST, OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST,
OBJECTHELPER::$MANAGE_COLLECTIONS,
OBJECTHELPER::$DELETE_ENTIRE_COLLECTIONS,
OBJECTHELPER::$CREATE_BATCH_PROCESS,
); );
} }
@ -989,14 +1012,15 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
$obj = new FedoraObjectDetailedContent($pid); $obj = new FedoraObjectDetailedContent($pid);
$object_details = $obj->showFieldSets(); $object_details = $obj->showFieldSets();
if ($object_details['fedora_object_details']['#selected'] == TRUE) { if ($object_details['fedora_object_details']['#selected'] == TRUE) {
foreach ($cmodels_tabs as $cmodel_tab) { foreach ($cmodels_tabs as &$cmodel_tab) {
if (is_array($cmodel_tab)) { if (is_array($cmodel_tab)) {
$cmodel_tab['#selected'] = FALSE; $cmodel_tab['#selected'] = FALSE;
} }
} }
} }
$cmodels_tabs = array_merge($cmodels_tabs, $object_details);
$hook_tabs = module_invoke_all('islandora_tabs', $content_models, $pid);
$cmodels_tabs = array_merge($cmodels_tabs, $object_details, $hook_tabs);
return tabs_render($cmodels_tabs); return tabs_render($cmodels_tabs);
} }

7
plugins/FedoraObjectDetailedContent.inc

@ -1,7 +1,5 @@
<?php <?php
/** /**
* @file * @file
* FedoraObjectDetailedContent class * FedoraObjectDetailedContent class
@ -34,16 +32,17 @@ class FedoraObjectDetailedContent {
*/ */
public function showFieldSets() { public function showFieldSets() {
global $user; global $user;
drupal_set_title($this->item->objectProfile->objLabel);
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
$tabset = array(); $tabset = array();
$show_purge_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_purge_object_form'); $show_purge_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_purge_object_form');
$show_edit_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_edit_qdc_form'); $show_edit_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_edit_qdc_form');
$purge_form = drupal_get_form('fedora_repository_purge_object_form', $this->pid, check_plain(substr(request_uri(), strlen(base_path())))); $purge_form = drupal_get_form('fedora_repository_purge_object_form', $this->pid, check_plain(substr(request_uri(), strlen(base_path()))));
$details_selected = ($show_purge_tab || $show_edit_tab);
$tabset['fedora_object_details'] = array( $tabset['fedora_object_details'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('Object Details'), '#title' => t('Object Details'),
'#selected' => $show_purge_tab, '#selected' => $details_selected,
); );
$tabset['fedora_object_details']['tabset'] = array( $tabset['fedora_object_details']['tabset'] = array(
'#type' => 'tabset', '#type' => 'tabset',

2
plugins/fedora_imageapi.info

@ -3,5 +3,5 @@ description = Adds image manipulation support through a REST interface
package = Islandora Dependencies package = Islandora Dependencies
dependencies[] = fedora_repository dependencies[] = fedora_repository
dependencies[] = imageapi dependencies[] = imageapi
version = 11.2.0 version = 11.3.1
core = 6.x core = 6.x

2
plugins/slide_viewer.inc

@ -1,7 +1,5 @@
<?php <?php
/** /**
* @file * @file
* ShowSlideStreamsInFieldSets class * ShowSlideStreamsInFieldSets class

2
xsl/convertQDC.xsl

@ -21,7 +21,7 @@
<xsl:value-of select="substring-after(name(),':')"/> = <xsl:value-of select="text()"/> <xsl:value-of select="substring-after(name(),':')"/> = <xsl:value-of select="text()"/>
</div> </div>
</xsl:for-each> </xsl:for-each>
</td><td><a href="{$baseUrl}/search/fedora_repository/dc.{$FIELD}:{$DATA}"><img title="Find Similar by {$FIELD}" src="{$PATH}/images/view.gif" alt="Find Similar by {$FIELD}" /></a></td></tr> </td></tr>
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>

5
xsl/mods_to_dc.xsl

@ -39,7 +39,8 @@ Version 1.0 2007-05-04 Tracy Meehleib <tmee@loc.gov>
<srw_dc:dcCollection xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/dc-schema.xsd"> <srw_dc:dcCollection xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/dc-schema.xsd">
<xsl:apply-templates/> <xsl:apply-templates/>
<xsl:for-each select="mods:modsCollection/mods:mods"> <xsl:for-each select="mods:modsCollection/mods:mods">
<srw_dc:dc xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/dc-schema.xsd"> :67
<srw_dc:dc xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/dc-schema.xsd">
<xsl:apply-templates/> <xsl:apply-templates/>
</srw_dc:dc> </srw_dc:dc>
@ -66,8 +67,10 @@ Version 1.0 2007-05-04 Tracy Meehleib <tmee@loc.gov>
</xsl:if> </xsl:if>
<xsl:value-of select="mods:title"/> <xsl:value-of select="mods:title"/>
<xsl:if test="mods:subTitle"> <xsl:if test="mods:subTitle">
<xsl:if test="text() [normalize-space(.) ]">
<xsl:text>: </xsl:text> <xsl:text>: </xsl:text>
<xsl:value-of select="mods:subTitle"/> <xsl:value-of select="mods:subTitle"/>
</xsl:if>
</xsl:if> </xsl:if>
<xsl:if test="mods:partNumber"> <xsl:if test="mods:partNumber">

59
xsl/sparql_to_html.xsl

@ -8,7 +8,7 @@
<xsl:value-of select="$path"/> <xsl:value-of select="$path"/>
</xsl:variable> </xsl:variable>
<xsl:variable name="thisPid" select="$collectionPid"/> <xsl:variable name="thisPid" select="$collectionPid"/>
<xsl:variable name="size" select="20"/> <xsl:variable name="size" select="20"/>
<xsl:variable name="page" select="$hitPage"/> <xsl:variable name="page" select="$hitPage"/>
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> <xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/>
<xsl:variable name="end" select="($start - 1) + number($size)"/> <xsl:variable name="end" select="($start - 1) + number($size)"/>
@ -72,23 +72,23 @@
</td></tr> </td></tr>
<!--<xsl:for-each select="/sparql/results/result[position()>=$start and position() &lt;=$end]"> <!--<xsl:for-each select="/sparql/results/result[position()>=$start and position() &lt;=$end]">
<xsl:variable name='OBJECTURI' select="object/@uri"/> <xsl:variable name='OBJECTURI' select="object/@uri"/>
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> <xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/>
<tr> <tr>
<td> <td>
<img> <img>
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN <xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN
</xsl:attribute> </xsl:attribute>
</img> </img>
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="title"/> <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="title"/>
</xsl:attribute> </xsl:attribute>
<xsl:value-of select="title"/> <xsl:value-of select="title"/>
</a> </a>
</td> </td>
</tr> </tr>
</xsl:for-each>- </xsl:for-each>-
--> -->
<xsl:apply-templates select="s:sparql/s:results"/> <xsl:apply-templates select="s:sparql/s:results"/>
</table><br clear="all" /> </table><br clear="all" />
<!-- start previous next --> <!-- start previous next -->
@ -172,7 +172,7 @@
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<!--the below is an example of going straight to a datastream instead of the details page. <!--the below is an example of going straight to a datastream instead of the details page.
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>--> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>-->
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
@ -185,23 +185,23 @@
<img> <img>
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN <xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="$newTitle" disable-output-escaping="yes"/> <xsl:attribute name="alt"><xsl:value-of select="$newTitle" disable-output-escaping="yes"/>
</xsl:attribute> </xsl:attribute>
</img> </a> <br clear="all" /> </img> </a> <br clear="all" />
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$linkUrl"/> <xsl:attribute name="href"><xsl:value-of select="$linkUrl"/>
</xsl:attribute> </xsl:attribute>
<xsl:value-of select="$newTitle" disable-output-escaping="yes" /> <xsl:value-of select="$newTitle" disable-output-escaping="yes" />
</a> </a>
<!-- example of a url that would drill down to the details page if the url above went directly to a datastream <!-- example of a url that would drill down to the details page if the url above went directly to a datastream
<xsl:if test="($CONTENTMODEL!='islandora:collectionCModel')"> <xsl:if test="($CONTENTMODEL!='islandora:collectionCModel')">
<br />[[ <a> <br />[[ <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/>
</xsl:attribute> </xsl:attribute>
DETAILS DETAILS
</a> ]] </a> ]]
</xsl:if>--> </xsl:if>-->
</td> </td>
<xsl:if test="(position() = last()) and (position() &lt; $cellsPerRow)"> <xsl:if test="(position() = last()) and (position() &lt; $cellsPerRow)">
@ -245,3 +245,4 @@
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

Loading…
Cancel
Save