Browse Source

Fixed a bug with populating the entity editor. The variable was used as the name of an element and later as a name of an entity, causing the former to be overwritten by the latter.

pull/105/head
mroy 14 years ago
parent
commit
9a1c407c9f
  1. 54
      plugins/ModsFormBuilder.inc

54
plugins/ModsFormBuilder.inc

@ -69,9 +69,9 @@ class ModsFormBuilder extends FormBuilder {
); );
$includeEl = true; $includeEl = true;
$name = explode('][', $element['name']); $elname = explode('][', $element['name']);
$elLocation = &$form['indicator2']; $elLocation = &$form['indicator2'];
while (isset($elLocation[$name[0]]) && ($partial = array_shift($name)) != NULL) { while (isset($elLocation[$name[0]]) && ($partial = array_shift($elname)) != NULL) {
$elLocation = &$elLocation[$partial]; $elLocation = &$elLocation[$partial];
} }
@ -136,13 +136,13 @@ class ModsFormBuilder extends FormBuilder {
$nameParts = $mname->getElementsByTagName('namePart'); $nameParts = $mname->getElementsByTagName('namePart');
foreach ($nameParts as $namePart) foreach ($nameParts as $namePart)
{ {
switch ($namePart->getAttribute('type')) { switch ($namePart->getAttribute('type')) {
case 'given': $given = $namePart->nodeValue; break; case 'given': $given = $namePart->nodeValue; break;
case 'family': $family = $namePart->nodeValue; break; case 'family': $family = $namePart->nodeValue; break;
case 'termsOfAddress': $title = $namePart->nodeValue; break; case 'termsOfAddress': $title = $namePart->nodeValue; break;
case 'date': $date = $namePart->nodeValue; break; case 'date': $date = $namePart->nodeValue; break;
default: $name = $namePart->nodeValue; break; default: $name = $namePart->nodeValue; break;
} }
} }
$person=array('role'=>$role); $person=array('role'=>$role);
@ -213,8 +213,8 @@ class ModsFormBuilder extends FormBuilder {
$el['#options']= isset($element['authoritative_list'])?$element['authoritative_list']:array(); $el['#options']= isset($element['authoritative_list'])?$element['authoritative_list']:array();
} }
if ($includeEl) { if ($includeEl) {
$elLocation[join('][', $name)] = $el; $elLocation[join('][', $elname)] = $el;
} }
} }
@ -272,8 +272,8 @@ class ModsFormBuilder extends FormBuilder {
} }
$this->createPolicy($collectionPid, &$dom, &$rootElement); $this->createPolicy($collectionPid, &$dom, &$rootElement);
// header('Content-type: application/xml'); // header('Content-type: application/xml');
// echo $dom->saveXML(); exit(); // echo $dom->saveXML(); exit();
try { try {
$object = Fedora_Item::ingest_from_FOXML($dom); $object = Fedora_Item::ingest_from_FOXML($dom);
@ -661,7 +661,7 @@ class ModsFormBuilder extends FormBuilder {
if (isset($form_values['mods_people']) && isset($form_values['mods_people']['people']) && is_array($form_values['mods_people']['people']) ) { if (isset($form_values['mods_people']) && isset($form_values['mods_people']['people']) && is_array($form_values['mods_people']['people']) ) {
foreach ($form_values['mods_people']['people'] as $key => $val) { foreach ($form_values['mods_people']['people'] as $key => $val) {
$name = $dom->createElement('mods:name'); $name = $dom->createElement('mods:name');
$appendName=FALSE;
if (isset($val['role'])) { if (isset($val['role'])) {
$role = $dom->createElement('mods:role'); $role = $dom->createElement('mods:role');
$roleTerm = $dom->createElement('mods:roleTerm', htmlspecialchars(trim($val['role']))); $roleTerm = $dom->createElement('mods:roleTerm', htmlspecialchars(trim($val['role'])));
@ -676,6 +676,7 @@ class ModsFormBuilder extends FormBuilder {
if (trim($val['organization']) != '') { if (trim($val['organization']) != '') {
$namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['organization']))); $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['organization'])));
$name->appendChild($namePart); $name->appendChild($namePart);
$appendName=TRUE;
} }
} }
elseif (isset($val['conference'])) { elseif (isset($val['conference'])) {
@ -683,6 +684,7 @@ class ModsFormBuilder extends FormBuilder {
if (trim($val['conference']) != '') { if (trim($val['conference']) != '') {
$namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['conference']))); $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['conference'])));
$name->appendChild($namePart); $name->appendChild($namePart);
$appendName=TRUE;
} }
} }
else { else {
@ -690,22 +692,24 @@ class ModsFormBuilder extends FormBuilder {
if (trim($val['name']) != '') { if (trim($val['name']) != '') {
$namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['name']))); $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['name'])));
$name->appendChild($namePart); $name->appendChild($namePart);
$appendName=TRUE;
} }
} }
if (isset($val['date'])) { if (isset($val['date'])) {
$namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['date']))); $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['date'])));
$namePart->setAttribute('type','date'); $namePart->setAttribute('type','date');
$name->appendChild($namePart); $name->appendChild($namePart);
} }
if (isset($val['subject'])) { if ($appendName) {
if (isset($val['subject'])) {
$subject->appendChild($name); $subject->appendChild($name);
$hasSubject=TRUE; $hasSubject=TRUE;
} else } else {
{
$mods->appendChild($name); $mods->appendChild($name);
} }
}
} }
} }

Loading…
Cancel
Save