Browse Source

Does this actually work

pull/46/head
Ben Woodhead 13 years ago
parent
commit
bba29d761a
  1. 56
      fedora_repository.module

56
fedora_repository.module

@ -54,10 +54,9 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) {
drupal_set_message(t('You must specify an object pid to purge an object.'), 'error'); drupal_set_message(t('You must specify an object pid to purge an object.'), 'error');
return ''; return '';
} }
$output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', $output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', array(
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);
@ -115,7 +114,7 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
$collection_pid = urldecode($collection_pid); $collection_pid = urldecode($collection_pid);
} }
else { else {
drupal_set_message(t("This collection PID @collection_pid is not valid", check_plain($collection_pid )), 'error'); drupal_set_message(t("This collection PID @collection_pid is not valid", check_plain($collection_pid)), 'error');
return ' '; return ' ';
} }
} }
@ -150,7 +149,7 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
$xml_form->submit($form, $form_state); $xml_form->submit($form, $form_state);
} }
} }
else if ($form_state['clicked_button']['#id'] == 'edit-submit') { elseif ($form_state['clicked_button']['#id'] == 'edit-submit') {
global $base_url; global $base_url;
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
@ -240,14 +239,14 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
if (!empty($file)) { if (!empty($file)) {
if (!in_array($dformat, $allowedMimeTypes)) { if (!in_array($dformat, $allowedMimeTypes)) {
form_set_error('ingest-file-location', t('The uploaded file\'s mimetype (' . $dformat . ') is not associated with this Content Model. The allowed types are ' . form_set_error('ingest-file-location', t('The uploaded file\'s mimetype (' . $dformat . ') is not associated with this Content Model. The allowed types are ' .
implode(' ', $allowedMimeTypes))); implode(' ', $allowedMimeTypes)));
file_delete($file); file_delete($file);
return; return;
} }
elseif (!$cm->execIngestRules($file, $dformat)) { elseif (!$cm->execIngestRules($file, $dformat)) {
drupal_set_message(t('Error following Content Model Rules'), 'error'); drupal_set_message(t('Error following Content Model Rules'), 'error');
foreach (ContentModel::$errors as $err) { foreach (ContentModel::$errors as $err) {
drupal_set_message($err, 'error'); drupal_set_message(check_plain($err), 'error');
} }
} }
} }
@ -400,7 +399,7 @@ function add_stream_form_submit($form, &$form_state) {
file_delete($file); file_delete($file);
} catch (exception $e) { } catch (exception $e) {
drupal_set_message(t($e->getMessage()), 'error'); drupal_set_message(t(check_plain($e->getMessage())), 'error');
return; return;
} }
$form_state['rebuild'] = TRUE; $form_state['rebuild'] = TRUE;
@ -448,9 +447,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,9 +481,8 @@ function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL)
return ' '; return ' ';
} }
$output = t('Are you sure you wish to purge this datastream %name<br />', $output = t('Are you sure you wish to purge this datastream %name<br />', array(
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;
@ -909,12 +907,12 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
drupal_set_message(t('The Fedora repository server is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); drupal_set_message(t('The Fedora repository server is currently unavailable. Please contact the site administrator.'), 'warning', FALSE);
return ''; return '';
} }
if (!risearch_available()) { if (!risearch_available()) {
drupal_set_message(t('The Fedora resource index search is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); drupal_set_message(t('The Fedora resource index search is currently unavailable. Please contact the site administrator.'), 'warning', FALSE);
return ''; return '';
} }
if ($pid == NULL) { if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:root'); $pid = variable_get('fedora_repository_pid', 'islandora:root');
} }
@ -990,12 +988,11 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
// Add a 'manage object' tab for all objects, where detailed list of content is shown. // Add a 'manage object' tab for all objects, where detailed list of content is shown.
$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); $cmodels_tabs = array_merge($cmodels_tabs, $object_details);
@ -1468,10 +1465,10 @@ function fedora_repository_demo_objects_form() {
); );
foreach (array( foreach (array(
'islandora:collectionCModel' => 'Islandora default content models', 'islandora:collectionCModel' => 'Islandora default content models',
'islandora:root' => 'Islandora top-level collection', 'islandora:root' => 'Islandora top-level collection',
'islandora:demos' => 'Islandora demos collection', 'islandora:demos' => 'Islandora demos collection',
'islandora:largeimages' => 'Sample large image content model (requires <a href="http://sourceforge.net/projects/djatoka/">Djatoka</a> and <a href="http://www.kakadusoftware.com/index.php?option=com_content&task=view&id=26&Itemid=22">Kakadu</a>.)', 'islandora:largeimages' => 'Sample large image content model (requires <a href="http://sourceforge.net/projects/djatoka/">Djatoka</a> and <a href="http://www.kakadusoftware.com/index.php?option=com_content&task=view&id=26&Itemid=22">Kakadu</a>.)',
) )
as $available_demo => $available_demo_desc) { as $available_demo => $available_demo_desc) {
try { try {
@ -1643,7 +1640,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
if (!empty($form_state['values']['demo_collections']['islandora:largeimages'])) { if (!empty($form_state['values']['demo_collections']['islandora:largeimages'])) {
$error = ''; $error = '';
foreach (array('islandora_jp2Sdep-slideCModel.xml', 'islandora_mods2htmlSdef.xml', 'islandora_mods2htmlSdep.xml', foreach (array('islandora_jp2Sdep-slideCModel.xml', 'islandora_mods2htmlSdef.xml', 'islandora_mods2htmlSdep.xml',
'islandora_slideCModel.xml', 'islandora_viewerSdep-slideCModel.xml', 'ilives_jp2Sdef.xml', 'ilives_viewerSdef.xml') as $foxml_file) { 'islandora_slideCModel.xml', 'islandora_viewerSdep-slideCModel.xml', 'ilives_jp2Sdef.xml', 'ilives_viewerSdef.xml') as $foxml_file) {
try { try {
$item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/' . $foxml_file); $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/' . $foxml_file);
} catch (exception $e) { } catch (exception $e) {
@ -1685,7 +1682,6 @@ function fedora_repository_required_fedora_objects() {
'dsversion' => 2, 'dsversion' => 2,
'cmodel' => 'fedora-system:ContentModel-3.0', 'cmodel' => 'fedora-system:ContentModel-3.0',
), ),
array( array(
'pid' => 'islandora:root', 'pid' => 'islandora:root',
'label' => 'Islandora Top-level Collection', 'label' => 'Islandora Top-level Collection',
@ -1701,7 +1697,7 @@ function fedora_repository_required_fedora_objects() {
'mimetype' => 'image/png', 'mimetype' => 'image/png',
), ),
), ),
), ),
), ),
), ),
); );
@ -2085,9 +2081,7 @@ function theme_add_to_basket_link($pid, $type = 'object') {
*/ */
if (!_is_added_to_basket($pid)) { if (!_is_added_to_basket($pid)) {
return l( return l(
theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))), theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))), "fedora/repository/addToBasket/" . $path, array('html' => TRUE)
"fedora/repository/addToBasket/" . $path,
array('html' => TRUE)
); );
} }

Loading…
Cancel
Save