@ -5,9 +5,9 @@
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder');
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder');
class ModsFormBuilder extends FormBuilder {
class ModsFormBuilder extends FormBuilder {
static $MODS_NS = 'http://www.loc.gov/mods/v3';
static $MODS_NS = 'http://www.loc.gov/mods/v3';
private $cm;
protected $cm;
private $item;
protected $item;
private $pid;
protected $pid;
function __construct($pid=null)
function __construct($pid=null)
{
{
@ -85,9 +85,12 @@ class ModsFormBuilder extends FormBuilder {
$includeEl=FALSE;
$includeEl=FALSE;
break;
break;
case '#edit_metadata_xpath':
case '#edit_metadata_xpath':
$nodeList = $xpath->evaluate($val);
$nodeList = $xpath->evaluate($val);
// echo $val. ' '.$nodeList->length.' '. $nodeList. '< br / > ';
// echo $val. ' '.$nodeList->length.' ';
// echo $nodeList->item(0)->nodeValue.' ';
// echo '< br / > ';
if (is_string($nodeList))
if (is_string($nodeList))
{
{
@ -101,7 +104,15 @@ class ModsFormBuilder extends FormBuilder {
}
}
} else if ($nodeList->length > 0)
} else if ($nodeList->length > 0)
{
{
$el['#default_value'] = $nodeList->item(0)->nodeValue;
if ($el['#type'] == 'list') {
$values=array();
for ($i=0;$i< $nodeList->length;$i++) {
$values[]=$nodeList->item($i)->nodeValue;
}
$el['#default_value']=join('; ',$values);
} else {
$el['#default_value'] = $nodeList->item(0)->nodeValue;
}
}
}
break;
break;
}
}
@ -389,19 +400,19 @@ class ModsFormBuilder extends FormBuilder {
$titles=preg_split('/\s+\;\s+/',trim($form_values['mods_alternative_titles']));
$titles=preg_split('/\s+\;\s+/',trim($form_values['mods_alternative_titles']));
foreach ($titles as $t) {
foreach ($titles as $t) {
$titleinfo = $dom->createElement('mods:titleInfo');
$titleinfo = $dom->createElement('mods:titleInfo');
$titleinfo->setAttribute('alternative') ;
$titleinfo->setAttribute('type',' alternative') ;
$title = $dom->createElement('mods:title',$t);
$title = $dom->createElement('mods:title',$t);
$titleI nfo->appendChild($title);
$titlei nfo->appendChild($title);
$mods->appendChild($title);
$mods->appendChild($titleinfo );
}
}
}
}
if (isset($form_values['mods_alternative_title']) & & trim($form_values['mods_alternative_title']) != '') {
if (isset($form_values['mods_alternative_title']) & & trim($form_values['mods_alternative_title']) != '') {
$titleinfo = $dom->createElement('mods:titleInfo');
$titleinfo = $dom->createElement('mods:titleInfo');
$titleinfo->setAttribute('alternative') ;
$titleinfo->setAttribute('type',' alternative') ;
$title = $dom->createElement('mods:title',trim($form_values['mods_alternative_title']));
$title = $dom->createElement('mods:title',trim($form_values['mods_alternative_title']));
$titleI nfo->appendChild($title);
$titlei nfo->appendChild($title);
$mods->appendChild($title);
$mods->appendChild($titleinfo );
}
}
if (isset($form_values['mods_description']) & & trim($form_values['mods_description']) != '') {
if (isset($form_values['mods_description']) & & trim($form_values['mods_description']) != '') {
@ -463,6 +474,7 @@ class ModsFormBuilder extends FormBuilder {
$addOriginInfo = TRUE;
$addOriginInfo = TRUE;
}
}
if (isset($form_values['mods_pubinfo_date']) & & trim($form_values['mods_pubinfo_date']) != '' & &
if (isset($form_values['mods_pubinfo_date']) & & trim($form_values['mods_pubinfo_date']) != '' & &
isset($form_values['mods_pubinfo_dateType']) & & trim($form_values['mods_pubinfo_dateType']) != '') {
isset($form_values['mods_pubinfo_dateType']) & & trim($form_values['mods_pubinfo_dateType']) != '') {
if (in_array($form_values['mods_pubinfo_dateType'], array('issued', 'created', 'copyright', 'captured'))) {
if (in_array($form_values['mods_pubinfo_dateType'], array('issued', 'created', 'copyright', 'captured'))) {
@ -475,18 +487,45 @@ class ModsFormBuilder extends FormBuilder {
}
}
$originInfo->appendChild($date);
$originInfo->appendChild($date);
$addOriginInfo = TRUE;
$addOriginInfo = TRUE;
} else {
if (isset($form_values['mods_createdDate'])) {
$date = $dom->createElement('mods:createdDate',htmlspecialchars(trim($form_values['mods_createdDate'])));
$originInfo->appendChild($date);
$addOriginInfo = TRUE;
}
if (isset($form_values['mods_issuedDate'])) {
$date = $dom->createElement('mods:issuedDate',htmlspecialchars(trim($form_values['mods_issuedDate'])));
$originInfo->appendChild($date);
$addOriginInfo = TRUE;
}
if (isset($form_values['mods_copyrightDate'])) {
$date = $dom->createElement('mods:copyrightDate',htmlspecialchars(trim($form_values['mods_copyrightDate'])));
$originInfo->appendChild($date);
$addOriginInfo = TRUE;
}
if (isset($form_values['mods_capturedDate'])) {
$date = $dom->createElement('mods:capturedDate',htmlspecialchars(trim($form_values['mods_capturedDate'])));
$originInfo->appendChild($date);
$addOriginInfo = TRUE;
}
}
}
if (isset($form_values['mods_pubinfo_journalFreq']) & & trim($form_values['mods_pubinfo_journalFreq']) != '') {
if (isset($form_values['mods_pubinfo_journalFreq']) & & trim($form_values['mods_pubinfo_journalFreq']) != '') {
$frequency = $dom->createElement('mods:frequency', htmlspecialchars(trim($form_values['mods_pubinfo_journalFreq'])));
$frequency = $dom->createElement('mods:frequency', htmlspecialchars(trim($form_values['mods_pubinfo_journalFreq'])));
$originInfo->appendChild($frequency);
$originInfo->appendChild($frequency);
$issuance= $dom->createElement('mods:issuance', 'journal');
$issuance= $dom->createElement('mods:issuance', 'journal');
$originInfo->appendChild($issuance);
$addOriginInfo = TRUE;
$addOriginInfo = TRUE;
}
}
else {
elseif (isset($form_values['mods_pubinfo_journalFreq'])) {
$issuance= $dom->createElement('mods:issuance', 'monographic');
$issuance= $dom->createElement('mods:issuance', 'monographic');
$originInfo->appendChild($issuance);
}
}
$originInfo->appendChild($issuance);
if ($addOriginInfo) {
if ($addOriginInfo) {
$mods->appendChild($originInfo);
$mods->appendChild($originInfo);