|
|
|
@ -2,18 +2,29 @@
|
|
|
|
|
|
|
|
|
|
// $Id$ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @file |
|
|
|
|
* ModsFormBuilder class |
|
|
|
|
*/ |
|
|
|
|
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ModsFormBuilder class ??? |
|
|
|
|
*/ |
|
|
|
|
class ModsFormBuilder extends FormBuilder { |
|
|
|
|
|
|
|
|
|
static $MODS_NS = 'http://www.loc.gov/mods/v3'; |
|
|
|
|
protected $cm; |
|
|
|
|
protected $item; |
|
|
|
|
protected $pid; |
|
|
|
|
|
|
|
|
|
function __construct($pid=null) |
|
|
|
|
{ |
|
|
|
|
/** |
|
|
|
|
* Constructor |
|
|
|
|
* @param type $pid |
|
|
|
|
*/ |
|
|
|
|
function __construct($pid=null) { |
|
|
|
|
parent::__construct(); |
|
|
|
|
if ($pid !== null) |
|
|
|
|
{ |
|
|
|
|
if ($pid !== null) { |
|
|
|
|
module_load_include('inc', 'fedora_repository', 'ContentModel'); |
|
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
|
|
|
|
|
|
|
|
@ -23,8 +34,13 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function handleEditMetadataForm(&$form_id, &$form_values, &$soap_client) |
|
|
|
|
{ |
|
|
|
|
/** |
|
|
|
|
* Handle Edit Metadata Form ??? |
|
|
|
|
* @param &$form_id |
|
|
|
|
* @param &$form_values |
|
|
|
|
* @param &$soap_client |
|
|
|
|
*/ |
|
|
|
|
function handleEditMetadataForm(&$form_id, &$form_values, &$soap_client) { |
|
|
|
|
$dom = new DomDocument("1.0", "UTF-8"); |
|
|
|
|
$dom->formatOutput = TRUE; |
|
|
|
|
$mods = $this->modsFromForm($form_values, $dom); |
|
|
|
@ -36,8 +52,11 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
drupal_goto('/fedora/repository/' . $this->pid); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function buildEditMetadataForm() |
|
|
|
|
{ |
|
|
|
|
/** |
|
|
|
|
* Build Edit Metadata Form |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
function buildEditMetadataForm() { |
|
|
|
|
$form['#multistep'] = TRUE; // used so that it triggers a form rebuild every time. |
|
|
|
|
$form['indicator2'] = array( |
|
|
|
|
'#type' => 'fieldset', |
|
|
|
@ -92,25 +111,24 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
// echo $nodeList->item(0)->nodeValue.' '; |
|
|
|
|
// echo '<br/>'; |
|
|
|
|
|
|
|
|
|
if (is_string($nodeList)) |
|
|
|
|
{ |
|
|
|
|
if (is_string($nodeList)) { |
|
|
|
|
$el['#default_value'] = $nodeList; |
|
|
|
|
} else if ($nodeList->length > 1) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
else if ($nodeList->length > 1) { |
|
|
|
|
$el['#default_value'] = array(); |
|
|
|
|
foreach ($nodeList as $node) |
|
|
|
|
{ |
|
|
|
|
foreach ($nodeList as $node) { |
|
|
|
|
$el['#default_value'][] = $node->nodeValue; |
|
|
|
|
} |
|
|
|
|
} else if ($nodeList->length > 0) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
else if ($nodeList->length > 0) { |
|
|
|
|
if ($el['#type'] == 'list') { |
|
|
|
|
$values = array(); |
|
|
|
|
for ($i = 0; $i < $nodeList->length; $i++) { |
|
|
|
|
$values[] = $nodeList->item($i)->nodeValue; |
|
|
|
|
} |
|
|
|
|
$el['#default_value'] = join('; ', $values); |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
$el['#default_value'] = $nodeList->item(0)->nodeValue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -120,11 +138,9 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
if ($key != '#sticky') { |
|
|
|
|
$el[$key] = $val; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($element['type'] == 'people') |
|
|
|
|
{ |
|
|
|
|
if ($element['type'] == 'people') { |
|
|
|
|
|
|
|
|
|
$names = $xpath->evaluate('/mods:mods/mods:name'); |
|
|
|
|
$people = array(); |
|
|
|
@ -134,20 +150,23 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
$role = $mname->getElementsByTagName('roleTerm')->item(0)->nodeValue; |
|
|
|
|
|
|
|
|
|
$nameParts = $mname->getElementsByTagName('namePart'); |
|
|
|
|
foreach ($nameParts as $namePart) |
|
|
|
|
{ |
|
|
|
|
foreach ($nameParts as $namePart) { |
|
|
|
|
switch ($namePart->getAttribute('type')) { |
|
|
|
|
case 'given': $given = $namePart->nodeValue; break; |
|
|
|
|
case 'family': $family = $namePart->nodeValue; break; |
|
|
|
|
case 'termsOfAddress': $title = $namePart->nodeValue; break; |
|
|
|
|
case 'date': $date = $namePart->nodeValue; break; |
|
|
|
|
default: $name = $namePart->nodeValue; break; |
|
|
|
|
case 'given': $given = $namePart->nodeValue; |
|
|
|
|
break; |
|
|
|
|
case 'family': $family = $namePart->nodeValue; |
|
|
|
|
break; |
|
|
|
|
case 'termsOfAddress': $title = $namePart->nodeValue; |
|
|
|
|
break; |
|
|
|
|
case 'date': $date = $namePart->nodeValue; |
|
|
|
|
break; |
|
|
|
|
default: $name = $namePart->nodeValue; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$person = array('role' => $role); |
|
|
|
|
switch ($type) |
|
|
|
|
{ |
|
|
|
|
switch ($type) { |
|
|
|
|
case 'personal': |
|
|
|
|
if (isset($given) && isset($family) && !isset($name)) { |
|
|
|
|
$name = (isset($title) ? $title . ' ' : '') . $family . ', ' . $family; |
|
|
|
@ -172,20 +191,23 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
$type = $mname->getAttribute('type'); |
|
|
|
|
|
|
|
|
|
$nameParts = $mname->getElementsByTagName('namePart'); |
|
|
|
|
foreach ($nameParts as $namePart) |
|
|
|
|
{ |
|
|
|
|
foreach ($nameParts as $namePart) { |
|
|
|
|
switch ($namePart->getAttribute('type')) { |
|
|
|
|
case 'given': $given = $namePart->nodeValue; break; |
|
|
|
|
case 'family': $family = $namePart->nodeValue; break; |
|
|
|
|
case 'termsOfAddress': $title = $namePart->nodeValue; break; |
|
|
|
|
case 'date': $date = $namePart->nodeValue; break; |
|
|
|
|
default: $name = $namePart->nodeValue; break; |
|
|
|
|
case 'given': $given = $namePart->nodeValue; |
|
|
|
|
break; |
|
|
|
|
case 'family': $family = $namePart->nodeValue; |
|
|
|
|
break; |
|
|
|
|
case 'termsOfAddress': $title = $namePart->nodeValue; |
|
|
|
|
break; |
|
|
|
|
case 'date': $date = $namePart->nodeValue; |
|
|
|
|
break; |
|
|
|
|
default: $name = $namePart->nodeValue; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$person = array('subject' => 1); |
|
|
|
|
switch ($type) |
|
|
|
|
{ |
|
|
|
|
switch ($type) { |
|
|
|
|
case 'personal': |
|
|
|
|
if (isset($given) && isset($family) && !isset($name)) { |
|
|
|
|
$name = (isset($title) ? $title . ' ' : '') . $family . ', ' . $family; |
|
|
|
@ -205,7 +227,6 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$el['#default_value'] = $people; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -225,12 +246,15 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return $form; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Handle Mods Form |
|
|
|
|
* @param &$form_values |
|
|
|
|
* @param &$form_state |
|
|
|
|
*/ |
|
|
|
|
function handleModsForm(&$form_values, &$form_state) { |
|
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
|
|
|
|
module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); |
|
|
|
@ -291,15 +315,19 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
file_delete($form_values['ingest-file-location']); |
|
|
|
|
} |
|
|
|
|
catch (exception $e) { |
|
|
|
|
} catch (exception $e) { |
|
|
|
|
drupal_set_message(t('Error ingesting object: !e', array('!e' => $e->getMessage())), 'error'); |
|
|
|
|
watchdog(t("Fedora_Repository"), t("Error ingesting object: !e", array('!e' => $e->getMessage())), NULL, WATCHDOG_ERROR); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create Collection Policy ?? |
|
|
|
|
* @param $form_values |
|
|
|
|
* @param &$dom |
|
|
|
|
* @param &$rootElement |
|
|
|
|
*/ |
|
|
|
|
function createCollectionPolicy($form_values, &$dom, &$rootElement) { |
|
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
|
|
|
|
$model = new fedora_item($form_values['content_model_pid']); |
|
|
|
@ -329,6 +357,12 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create Workflow Stream ?? |
|
|
|
|
* @param $form_values |
|
|
|
|
* @param &$dom |
|
|
|
|
* @param &$rootElement |
|
|
|
|
*/ |
|
|
|
|
function createWorkflowStream($form_values, &$dom, &$rootElement) { |
|
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
|
|
|
|
$model = new fedora_item($form_values['content_model_pid']); |
|
|
|
@ -358,6 +392,12 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create mods Stream ?? |
|
|
|
|
* @param $form_values |
|
|
|
|
* @param &$dom |
|
|
|
|
* @param &$rootElement |
|
|
|
|
*/ |
|
|
|
|
function createModsStream($form_values, &$dom, &$rootElement) { |
|
|
|
|
|
|
|
|
|
$datastream = $dom->createElement("foxml:datastream"); |
|
|
|
@ -378,9 +418,13 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
$rootElement->appendChild($datastream); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function modsFromForm(&$form_values,&$dom) |
|
|
|
|
{ |
|
|
|
|
/** |
|
|
|
|
* Mods From From ????? |
|
|
|
|
* @param type $form_values |
|
|
|
|
* @param type $dom |
|
|
|
|
* @return type |
|
|
|
|
*/ |
|
|
|
|
function modsFromForm(&$form_values, &$dom) { |
|
|
|
|
|
|
|
|
|
///begin writing MODS |
|
|
|
|
$mods = $dom->createElement("mods:mods"); |
|
|
|
@ -489,7 +533,8 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
} |
|
|
|
|
$originInfo->appendChild($date); |
|
|
|
|
$addOriginInfo = TRUE; |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
if (isset($form_values['mods_createdDate'])) { |
|
|
|
|
$date = $dom->createElement('mods:createdDate', htmlspecialchars(trim($form_values['mods_createdDate']))); |
|
|
|
|
$originInfo->appendChild($date); |
|
|
|
@ -513,7 +558,6 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
$originInfo->appendChild($date); |
|
|
|
|
$addOriginInfo = TRUE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isset($form_values['mods_pubinfo_journalFreq']) && trim($form_values['mods_pubinfo_journalFreq']) != '') { |
|
|
|
@ -550,11 +594,9 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($form_values['mods_language']) && trim($form_values['mods_language']) != '') |
|
|
|
|
{ |
|
|
|
|
if (isset($form_values['mods_language']) && trim($form_values['mods_language']) != '') { |
|
|
|
|
$languageList = explode(';', htmlspecialchars($form_values['mods_language'])); |
|
|
|
|
foreach ($languageList as $lang) |
|
|
|
|
{ |
|
|
|
|
foreach ($languageList as $lang) { |
|
|
|
|
$language = $dom->createElement('mods:language'); |
|
|
|
|
$langTerm = $dom->createElement('mods:languageTerm', htmlspecialchars($lang)); |
|
|
|
|
$langTerm->setAttribute('type', 'text'); |
|
|
|
@ -637,6 +679,7 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
$modifications = trim($form_values['mods_cc']['cc']['cc_modifications']); |
|
|
|
|
$jurisdiction = trim($form_values['mods_cc']['cc']['cc_jurisdiction']); |
|
|
|
|
|
|
|
|
|
// Include islandora form elements only if needed ?? |
|
|
|
|
module_load_include('inc', 'islandora_form_elements', 'includes/creative_commons.inc'); |
|
|
|
|
|
|
|
|
|
if (!isset(CreativeCommons::$cc_jurisdiction_vals[$jurisdiction])) |
|
|
|
@ -648,8 +691,6 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
$accessCondition = $dom->createElement('mods:accessCondition', htmlspecialchars($license)); |
|
|
|
|
$accessCondition->setAttribute('type', 'Creative Commons License'); |
|
|
|
|
$mods->appendChild($accessCondition); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isset($form_values['mods_rights']) && trim($form_values['mods_rights']) != '') { |
|
|
|
@ -706,11 +747,11 @@ class ModsFormBuilder extends FormBuilder {
|
|
|
|
|
if (isset($val['subject'])) { |
|
|
|
|
$subject->appendChild($name); |
|
|
|
|
$hasSubject = TRUE; |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
$mods->appendChild($name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|