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. 16
      plugins/ModsFormBuilder.inc

16
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];
} }
@ -214,7 +214,7 @@ class ModsFormBuilder extends FormBuilder {
} }
if ($includeEl) { if ($includeEl) {
$elLocation[join('][', $name)] = $el; $elLocation[join('][', $elname)] = $el;
} }
} }
@ -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,6 +692,7 @@ 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;
} }
} }
@ -699,13 +702,14 @@ class ModsFormBuilder extends FormBuilder {
$name->appendChild($namePart); $name->appendChild($namePart);
} }
if ($appendName) {
if (isset($val['subject'])) { 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