Browse Source

Added hooks for processing XMLBased form's during ingestion

pull/3/merge
Nigel Banks 13 years ago
parent
commit
3c4de73302
  1. 246
      fedora_repository.module
  2. 31
      formClass.inc

246
fedora_repository.module

@ -22,8 +22,6 @@ function fedora_repository_admin() {
return $adminForm->createAdminForm(); return $adminForm->createAdminForm();
} }
/** /**
* drupal hook * drupal hook
* calls the fedora_repositorys_admin form * calls the fedora_repositorys_admin form
@ -55,10 +53,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);
@ -122,42 +119,52 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
function fedora_repository_ingest_form_submit($form, &$form_state) { function fedora_repository_ingest_form_submit($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 (module_exists('xml_form_api')) {
global $base_url; module_load_include('inc', 'xml_form_api', 'XMLForm');
module_load_include('inc', 'fedora_repository', 'CollectionClass'); $form = new XMLForm($form_state);
module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); $doc = $form->submit($drupal_form, $form_state);
module_load_include('inc', 'fedora_repository', 'ContentModel'); $document = $doc->document;
dom_document_pretty_print($document);
$contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); exit();
$contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); }
$err = TRUE; else {
$redirect = TRUE; if ($form_state['clicked_button']['#id'] == 'edit-submit') {
if (($cp = CollectionPolicy::loadFromCollection($form_state['values']['collection_pid'])) !== FALSE) { global $base_url;
$relationship = $cp->getRelationship(); module_load_include('inc', 'fedora_repository', 'CollectionClass');
module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { module_load_include('inc', 'fedora_repository', 'ContentModel');
$pid = $cp->getNextPid($contentModelDsid);
global $user; $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']);
$form_state['values']['user_id'] = $user->name; $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']);
$form_state['values']['pid'] = $pid; $err = TRUE;
$form_state['values']['content_model_pid'] = $contentModelPid; $redirect = TRUE;
$form_state['values']['relationship'] = $relationship; if (($cp = CollectionPolicy::loadFromCollection($form_state['values']['collection_pid'])) !== FALSE) {
$relationship = $cp->getRelationship();
$err = (!$cm->execFormHandler($form_state['values'], $form_state));
if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) {
$_SESSION['fedora_ingest_files'] = ''; //empty this variable $pid = $cp->getNextPid($contentModelDsid);
global $user;
$attr = $cm->getIngestFormAttributes(); $form_state['values']['user_id'] = $user->name;
$redirect = $attr['redirect']; $form_state['values']['pid'] = $pid;
$form_state['values']['content_model_pid'] = $contentModelPid;
if ($redirect) { $form_state['values']['relationship'] = $relationship;
$form_state['storage'] = NULL;
$err = (!$cm->execFormHandler($form_state['values'], $form_state));
$_SESSION['fedora_ingest_files'] = ''; //empty this variable
$attr = $cm->getIngestFormAttributes();
$redirect = $attr['redirect'];
if ($redirect) {
$form_state['storage'] = NULL;
}
} }
} }
}
if ($redirect) { if ($redirect) {
$form_state['redirect'] = ($err) ? ' ' : $base_url . "/fedora/repository/{$form_state['values']['collection_pid']}"; $form_state['redirect'] = ($err) ? ' ' : $base_url . "/fedora/repository/{$form_state['values']['collection_pid']}";
}
} }
} }
} }
@ -172,7 +179,12 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
break; break;
case 2: case 2:
// XML based form.
if (module_exists('xml_form_api')) {
module_load_include('inc', 'xml_form_api', 'XMLForm');
$xml_form = new XMLForm($form_state);
$xml_form->validate($form, $form_state);
}
// Get the uploaded file. // Get the uploaded file.
$validators = array(); $validators = array();
@ -394,9 +406,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;
@ -435,7 +446,7 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
} }
elseif (empty($collectionPid) && !empty($_SESSION['fedora_collection']) && $_SESSION['fedora_collection'] != $pid) { elseif (empty($collectionPid) && !empty($_SESSION['fedora_collection']) && $_SESSION['fedora_collection'] != $pid) {
$collectionPid = $_SESSION['fedora_collection']; $collectionPid = $_SESSION['fedora_collection'];
$form_state['redirect'] = "fedora/repository/$collectionPid/"; $form_state['redirect'] = "fedora/repository/$collectionPid/";
} }
else { else {
@ -527,14 +538,14 @@ function fedora_repository_replace_stream_form_submit($form, &$form_state) {
$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);
$dsLabel .= substr($file->filename, strrpos($file->filename, '.')); // Add the file extention to the end of the label.; $dsLabel .= substr($file->filename, strrpos($file->filename, '.')); // Add the file extention to the end of the label.;
} }
module_load_include('inc', 'Fedora_Repository', 'MimeClass'); module_load_include('inc', 'Fedora_Repository', 'MimeClass');
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$file_basename = basename($file->filepath); $file_basename = basename($file->filepath);
$file_directory = dirname($file->filepath); $file_directory = dirname($file->filepath);
$streamUrl = $base_url . '/' . $file_directory . '/' . urlencode($file_basename); $streamUrl = $base_url . '/' . $file_directory . '/' . urlencode($file_basename);
@ -546,11 +557,10 @@ function fedora_repository_replace_stream_form_submit($form, &$form_state) {
$dformat = $mimetype->getType($file->filepath); $dformat = $mimetype->getType($file->filepath);
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
$item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat); $item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat);
$form_state['redirect'] = 'fedora/repository/' . $pid;
$form_state['redirect'] = 'fedora/repository/' . $pid;
} }
function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) { function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) {
@ -608,7 +618,7 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
} }
function fedora_repository_edit_qdc_form_validate($form, &$form_state) { function fedora_repository_edit_qdc_form_validate($form, &$form_state) {
} }
/** /**
@ -726,8 +736,8 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
drupal_set_message('The Fedora repository server is currently unavailable. Please contact the site administrator.', 'warning', FALSE); drupal_set_message('The Fedora repository server is currently unavailable. Please contact the site administrator.', 'warning', FALSE);
return ''; return '';
} }
if ($pid &!validPid($pid)) { if ($pid & !validPid($pid)) {
drupal_set_message(t("Invalid PID!"), 'error'); drupal_set_message(t("Invalid PID!"), 'error');
return ' '; return ' ';
@ -806,8 +816,8 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
$obj = new FedoraObject($pid); $obj = new FedoraObject($pid);
$object_details = $obj->showFieldSets(); $object_details = $obj->showFieldSets();
$cmodels_tabs = array_merge($cmodels_tabs, $object_details); $cmodels_tabs = array_merge($cmodels_tabs, $object_details);
//$content .= $objectHelper //$content .= $objectHelper
//$content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber); //$content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber);
//the below is for islandlives we should be able to do this in the xslt though //the below is for islandlives we should be able to do this in the xslt though
@ -1180,7 +1190,6 @@ function fedora_repository_theme() {
'arguments' => array( 'arguments' => array(
'element' => NULL 'element' => NULL
), ),
'fedora_repository_solution_packs_list' => array( 'fedora_repository_solution_packs_list' => array(
'arguments' => array( 'arguments' => array(
'solution_packs' => NULL, 'solution_packs' => NULL,
@ -1263,10 +1272,10 @@ function fedora_repository_demo_objects_form() {
); );
foreach (array( foreach (array(
'islandora:collectionCModel' => 'Islandora default content models', 'islandora:collectionCModel' => 'Islandora default content models',
'islandora:top' => 'Islandora top-level collection', 'islandora:top' => '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 {
@ -1403,7 +1412,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
$tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_mimetype_pdf.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_mimetype_pdf.png', 'TN', 'Thumbnail.png', 'image/png', 'M');
drupal_set_message("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:demos\">islandora:demos</a>.", 'message'); drupal_set_message("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:demos\">islandora:demos</a>.", 'message');
} catch (exception $e) { } catch (exception $e) {
} }
} }
@ -1413,19 +1422,19 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
$smiley_stuff->add_relationship('isMemberOfCollection', 'info:fedora/islandora:demos'); $smiley_stuff->add_relationship('isMemberOfCollection', 'info:fedora/islandora:demos');
$tn = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/smileytn.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); $tn = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/smileytn.png', 'TN', 'Thumbnail.png', 'image/png', 'M');
$cp = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/JPG-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy.xml', 'application/xml', 'X'); $cp = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/JPG-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy.xml', 'application/xml', 'X');
$cm = new Fedora_Item('demo:DualResImage'); $cm = new Fedora_Item('demo:DualResImage');
try { try {
$cmstream = $cm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STANDARD JPG.xml', 'ISLANDORACM', 'Content Model.xml', 'application/xml', 'X'); $cmstream = $cm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STANDARD JPG.xml', 'ISLANDORACM', 'Content Model.xml', 'application/xml', 'X');
} catch (exception $e) { } catch (exception $e) {
} }
$dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection'); $dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection');
try { try {
$cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); $cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X');
drupal_set_message("Successfully installed <a href=\"" . $base_url . "/fedora/repository/demo:SmileyStuff\">demo:SmileyStuff</a> collection view.", 'message'); drupal_set_message("Successfully installed <a href=\"" . $base_url . "/fedora/repository/demo:SmileyStuff\">demo:SmileyStuff</a> collection view.", 'message');
} catch (exception $e) { } catch (exception $e) {
} }
} }
@ -1454,16 +1463,15 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
} }
} }
function fedora_repository_required_fedora_objects() { function fedora_repository_required_fedora_objects() {
// array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required) // array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required)
$module_path = drupal_get_path('module', 'fedora_repository'); $module_path = drupal_get_path('module', 'fedora_repository');
return array ( return array(
'fedora_repository' => array( 'fedora_repository' => array(
'module' => 'fedora_repository', 'module' => 'fedora_repository',
'title' => 'Islandora Core', 'title' => 'Islandora Core',
'objects' => array ( 'objects' => array(
array ( array(
'pid' => 'islandora:collectionCModel', 'pid' => 'islandora:collectionCModel',
'label' => 'Islandora Collection Content Model', 'label' => 'Islandora Collection Content Model',
'dsid' => 'ISLANDORACM', 'dsid' => 'ISLANDORACM',
@ -1471,7 +1479,7 @@ 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:strict_pdf', 'pid' => 'islandora:strict_pdf',
'label' => 'Islandora strict PDF content model', 'label' => 'Islandora strict PDF content model',
'dsid' => 'ISLANDORACM', 'dsid' => 'ISLANDORACM',
@ -1482,85 +1490,85 @@ function fedora_repository_required_fedora_objects() {
'pid' => 'islandora:top', 'pid' => 'islandora:top',
'label' => 'Islandora Top-level Collection', 'label' => 'Islandora Top-level Collection',
'cmodel' => 'islandora:collectionCModel', 'cmodel' => 'islandora:collectionCModel',
'datastreams' => array ( 'datastreams' => array(
array ( array(
'dsid' => 'COLLECTION_POLICY', 'dsid' => 'COLLECTION_POLICY',
'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml", 'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml",
), ),
array ( array(
'dsid' => 'TN', 'dsid' => 'TN',
'datastream_file' => "$module_path/images/Gnome-emblem-photos.png", 'datastream_file' => "$module_path/images/Gnome-emblem-photos.png",
'mimetype' => 'image/png', 'mimetype' => 'image/png',
), ),
), ),
), ),
array ( array(
'pid' => 'islandora:ContentModelCollection', 'pid' => 'islandora:ContentModelCollection',
'label' => 'Collection of installed content models', 'label' => 'Collection of installed content models',
'cmodel' => 'islandora:collectionCModel', 'cmodel' => 'islandora:collectionCModel',
'parent' => 'islandora:top', 'parent' => 'islandora:top',
'datastreams' => array ( 'datastreams' => array(
array ( array(
'dsid' => 'COLLECTION_VIEW', 'dsid' => 'COLLECTION_VIEW',
'datastream_file' => "$module_path/collection_views/simple_list_view.xml", 'datastream_file' => "$module_path/collection_views/simple_list_view.xml",
), ),
array ( array(
'dsid' => 'TN', 'dsid' => 'TN',
'datastream_file' => "$module_path/images/contentModel.jpg", 'datastream_file' => "$module_path/images/contentModel.jpg",
'mimetype' => 'image/jpeg', 'mimetype' => 'image/jpeg',
), ),
array ( array(
'dsid' => 'QUERY', 'dsid' => 'QUERY',
'datastream_file' => "$module_path/collection_views/cmodel_collection_query.txt", 'datastream_file' => "$module_path/collection_views/cmodel_collection_query.txt",
'mimetype' => 'text/plain', 'mimetype' => 'text/plain',
), ),
), ),
), ),
array ( array(
'pid' => 'islandora:demos', 'pid' => 'islandora:demos',
'label' => 'Islandora demos collection', 'label' => 'Islandora demos collection',
'cmodel' => 'islandora:collectionCModel', 'cmodel' => 'islandora:collectionCModel',
'parent' => 'islandora:top', 'parent' => 'islandora:top',
'datastreams' => array ( 'datastreams' => array(
array ( array(
'dsid' => 'TN', 'dsid' => 'TN',
'datastream_file' => "$module_path/images/Gnome-emblem-photos.png", 'datastream_file' => "$module_path/images/Gnome-emblem-photos.png",
'mimetype' => 'image/png', 'mimetype' => 'image/png',
), ),
array ( array(
'dsid' => 'COLLECTION_POLICY', 'dsid' => 'COLLECTION_POLICY',
'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml", 'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml",
), ),
), ),
), ),
array ( array(
'pid' => 'islandora:pdf_collection', 'pid' => 'islandora:pdf_collection',
'label' => 'Islandora Demo PDF Collection', 'label' => 'Islandora Demo PDF Collection',
'cmodel' => 'islandora:collectionCModel', 'cmodel' => 'islandora:collectionCModel',
'parent' => 'islandora:demos', 'parent' => 'islandora:demos',
'datastreams' => array ( 'datastreams' => array(
array ( array(
'dsid' => 'TN', 'dsid' => 'TN',
'datastream_file' => "$module_path/images/Crystal_Clear_mimetype_pdf.png", 'datastream_file' => "$module_path/images/Crystal_Clear_mimetype_pdf.png",
'mimetype' => 'image/png', 'mimetype' => 'image/png',
), ),
array ( array(
'dsid' => 'COLLECTION_POLICY', 'dsid' => 'COLLECTION_POLICY',
'datastream_file' => "$module_path/collection_policies/PDF-COLLECTION POLICY.xml", 'datastream_file' => "$module_path/collection_policies/PDF-COLLECTION POLICY.xml",
), ),
), ),
), ),
array ( array(
'pid' => 'demo:DualResImage', 'pid' => 'demo:DualResImage',
'foxml_file' => "$module_path/content_models/demo_DualResImage.xml", 'foxml_file' => "$module_path/content_models/demo_DualResImage.xml",
'datastreams' => array( 'datastreams' => array(
array ( array(
'dsid' => 'ISLANDORACM', 'dsid' => 'ISLANDORACM',
'datastream_file' => "$module_path/content_models/STANDARD JPG.xml", 'datastream_file' => "$module_path/content_models/STANDARD JPG.xml",
), ),
), ),
), ),
array ( array(
'pid' => 'demo:DualResImageCollection', 'pid' => 'demo:DualResImageCollection',
'foxml_file' => "$module_path/content_models/demo_DualResImageCollection.xml", 'foxml_file' => "$module_path/content_models/demo_DualResImageCollection.xml",
'datastreams' => array( 'datastreams' => array(
@ -1570,51 +1578,51 @@ function fedora_repository_required_fedora_objects() {
), ),
), ),
), ),
array ( array(
'pid' => 'demo:DualResolution', 'pid' => 'demo:DualResolution',
'foxml_file' => "$module_path/content_models/demo_DualResolution.xml", 'foxml_file' => "$module_path/content_models/demo_DualResolution.xml",
), ),
array ( array(
'pid' => 'demo:DualResImageImpl', 'pid' => 'demo:DualResImageImpl',
'foxml_file' => "$module_path/content_models/demo_DualResImageImpl.xml", 'foxml_file' => "$module_path/content_models/demo_DualResImageImpl.xml",
), ),
array ( array(
'pid' => 'demo:CollectionImpl', 'pid' => 'demo:CollectionImpl',
'foxml_file' => "$module_path/content_models/demo_CollectionImpl.xml", 'foxml_file' => "$module_path/content_models/demo_CollectionImpl.xml",
), ),
array ( array(
'pid' => 'demo:Collection', 'pid' => 'demo:Collection',
'foxml_file' => "$module_path/content_models/demo_Collection.xml", 'foxml_file' => "$module_path/content_models/demo_Collection.xml",
), ),
array ( array(
'pid' => 'islandora:demo_image_collection', 'pid' => 'islandora:demo_image_collection',
'label' => 'Demo Image Collection', 'label' => 'Demo Image Collection',
'cmodel' => 'demo:DualResImageCollection', 'cmodel' => 'demo:DualResImageCollection',
'parent' => 'islandora:demos', 'parent' => 'islandora:demos',
'datastreams' => array ( 'datastreams' => array(
array ( array(
'dsid' => 'COLLECTION_POLICY', 'dsid' => 'COLLECTION_POLICY',
'datastream_file' => "$module_path/collection_policies/JPG-COLLECTION POLICY.xml", 'datastream_file' => "$module_path/collection_policies/JPG-COLLECTION POLICY.xml",
), ),
array ( array(
'dsid' => 'TN', 'dsid' => 'TN',
'datastream_file' => "$module_path/images/Gnome-emblem-photos.png", 'datastream_file' => "$module_path/images/Gnome-emblem-photos.png",
'mimetype' => 'image/png', 'mimetype' => 'image/png',
), ),
array ( array(
'dsid' => 'COLLECTION_VIEW', 'dsid' => 'COLLECTION_VIEW',
'datastream_file' => "$module_path/collection_views/standard_jpeg_collection_view.xml", 'datastream_file' => "$module_path/collection_views/standard_jpeg_collection_view.xml",
), ),
array ( array(
'dsid' => 'QUERY', 'dsid' => 'QUERY',
'datastream_file' => "$module_path/collection_views/standard_jpeg_collection_query.txt", 'datastream_file' => "$module_path/collection_views/standard_jpeg_collection_query.txt",
'mimetype' => 'text/plain', 'mimetype' => 'text/plain',
), ),
array ( array(
'dsid' => 'DC', 'dsid' => 'DC',
'datastream_file' => "$module_path/collection_views/demo_image_collection_dc_record.xml", 'datastream_file' => "$module_path/collection_views/demo_image_collection_dc_record.xml",
), ),
), ),
), ),
), ),
), ),
@ -1792,7 +1800,7 @@ function theme_fedora_repository_basket_form($form) {
} }
function fedora_repository_basket_form_validate($form, &$form_state) { function fedora_repository_basket_form_validate($form, &$form_state) {
} }
function fedora_repository_basket_form_submit($form, &$form_state) { function fedora_repository_basket_form_submit($form, &$form_state) {
@ -1939,9 +1947,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)
); );
} }
@ -1964,7 +1970,6 @@ function fedora_repository_display_schema($file) {
return; return;
} }
function fedora_repository_batch_reingest_object($object, &$context) { function fedora_repository_batch_reingest_object($object, &$context) {
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');
@ -1989,8 +1994,8 @@ function fedora_repository_batch_reingest_object($object, &$context) {
} }
} }
if (!empty($object['dsid']) && !empty($object['datastream_file'])) { if (!empty($object['dsid']) && !empty($object['datastream_file'])) {
$datastreams = array ( $datastreams = array(
array ( array(
'dsid' => $object['dsid'], 'dsid' => $object['dsid'],
'datastream_file' => $object['datastream_file'], 'datastream_file' => $object['datastream_file'],
) )
@ -1999,19 +2004,19 @@ function fedora_repository_batch_reingest_object($object, &$context) {
elseif (!empty($object['datastreams'])) { elseif (!empty($object['datastreams'])) {
$datastreams = $object['datastreams']; $datastreams = $object['datastreams'];
} }
if (!empty($datastreams) && is_array($datastreams)) { if (!empty($datastreams) && is_array($datastreams)) {
$label = !empty($object['label']) ? $object['label'] : ''; $label = !empty($object['label']) ? $object['label'] : '';
if (empty($object['foxml_file']) && !defined($new_item)) { if (empty($object['foxml_file']) && !defined($new_item)) {
$new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label); $new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label);
} }
if (!empty($object['cmodel'])) { if (!empty($object['cmodel'])) {
$new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI); $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI);
} }
if (!empty($object['parent'])) { if (!empty($object['parent'])) {
$new_item->add_relationship('isMemberOfCollection', $object['parent']); $new_item->add_relationship('isMemberOfCollection', $object['parent']);
} }
foreach($datastreams as $ds) { foreach ($datastreams as $ds) {
if ($ds['dsid'] == 'DC') { if ($ds['dsid'] == 'DC') {
$new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml'); $new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml');
} }
@ -2037,13 +2042,14 @@ function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid
$return = NULL; $return = NULL;
if (isset($item)) { if (isset($item)) {
$doc = simplexml_load_string($item->get_datastream_dissemination($dsid)); $doc = simplexml_load_string($item->get_datastream_dissemination($dsid));
} elseif (isset($datastream_file)) { }
elseif (isset($datastream_file)) {
$doc = simplexml_load_file($datastream_file); $doc = simplexml_load_file($datastream_file);
} }
if (!empty($doc)) { if (!empty($doc)) {
$attrs = $doc->attributes(); $attrs = $doc->attributes();
foreach($attrs as $name => $value) { foreach ($attrs as $name => $value) {
if ($name == 'version') { if ($name == 'version') {
$return = (int) $value; $return = (int) $value;
break; break;
@ -2052,18 +2058,18 @@ function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid
} }
return $return; return $return;
} }
function theme_fedora_repository_solution_packs_list($solution_packs) { function theme_fedora_repository_solution_packs_list($solution_packs) {
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');
$output = ''; $output = '';
$header = array(); $header = array();
$rows = array(); $rows = array();
drupal_add_css(drupal_get_path('module', 'update') .'/update.css'); drupal_add_css(drupal_get_path('module', 'update') . '/update.css');
return $output; return $output;
} }

31
formClass.inc

@ -531,23 +531,26 @@ class formClass {
$contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']);
$contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']);
// XML Forms // XML Forms
module_load_include('inc', 'xml_form_api', 'XMLForm'); if (module_exists('xml_form_api')) {
$xml_form = new XMLForm($form_state); module_load_include('inc', 'xml_form_api', 'XMLForm');
if (isset($form_state['values']['forms']) || $xml_form->isInitialized()) { $xml_form = new XMLForm($form_state);
if (!$xml_form->isInitialized()) { if (isset($form_state['values']['forms']) || $xml_form->isInitialized()) {
module_load_include('inc', 'xml_form_api', 'XMLFormDefinition'); if (!$xml_form->isInitialized()) {
module_load_include('inc', 'xml_form_builder', 'FormBuilder'); module_load_include('inc', 'xml_form_api', 'XMLFormDefinition');
$form_name = $form_state['values']['forms']; module_load_include('inc', 'xml_form_builder', 'FormBuilder');
$definition = FormBuilder::GetFormDefinition($form_name); $form_name = $form_state['values']['forms'];
$form = XMLFormDefinition::GetDrupalForm($definition); $definition = FormBuilder::GetFormDefinition($form_name);
$properties = XMLFormDefinition::GetFormProperties($definition); $form = XMLFormDefinition::GetDrupalForm($definition);
$document = new XMLDocument($properties['document']['root'], $properties['document']['namespaces'], $properties['document']['schema']); $properties = XMLFormDefinition::GetFormProperties($definition);
$xml_form->initialize($form, $document); $document = new XMLDocument($properties['document']['root'], $properties['document']['namespaces'], $properties['document']['schema']);
$xml_form->initialize($form, $document);
}
$form = $xml_form->toArray();
break;
} }
$form = $xml_form->toArray();
} }
// End XML forms // End XML forms
else if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) {
$form = $cm->buildIngestForm($form, $form_state); $form = $cm->buildIngestForm($form, $form_state);
if ($form === FALSE) { if ($form === FALSE) {

Loading…
Cancel
Save