Skip to content
Snippets Groups Projects
Commit 02a66dd8 authored by Demian Katz's avatar Demian Katz
Browse files

Moved shared support method to better location.

parent 03a632fb
No related merge requests found
...@@ -269,56 +269,6 @@ trait MarcAdvancedTrait ...@@ -269,56 +269,6 @@ trait MarcAdvancedTrait
return in_array('785', $fieldsNames) ? [] : parent::getNewerTitles(); return in_array('785', $fieldsNames) ? [] : parent::getNewerTitles();
} }
/**
* Get the item's publication information
*
* @param string $subfield The subfield to retrieve ('a' = location, 'c' = date)
*
* @return array
*/
protected function getPublicationInfo($subfield = 'a')
{
// Get string separator for publication information:
$separator = isset($this->mainConfig->Record->marcPublicationInfoSeparator)
? $this->mainConfig->Record->marcPublicationInfoSeparator : ' ';
// First check old-style 260 field:
$results = $this->getFieldArray('260', [$subfield], true, $separator);
// Now track down relevant RDA-style 264 fields; we only care about
// copyright and publication places (and ignore copyright places if
// publication places are present). This behavior is designed to be
// consistent with default SolrMarc handling of names/dates.
$pubResults = $copyResults = [];
$fields = $this->getMarcRecord()->getFields('264');
if (is_array($fields)) {
foreach ($fields as $currentField) {
$currentVal = $this
->getSubfieldArray($currentField, [$subfield], true, $separator);
if (!empty($currentVal)) {
switch ($currentField->getIndicator('2')) {
case '1':
$pubResults = array_merge($pubResults, $currentVal);
break;
case '4':
$copyResults = array_merge($copyResults, $currentVal);
break;
}
}
}
}
$replace260 = isset($this->mainConfig->Record->replaceMarc260)
? $this->mainConfig->Record->replaceMarc260 : false;
if (count($pubResults) > 0) {
return $replace260 ? $pubResults : array_merge($results, $pubResults);
} elseif (count($copyResults) > 0) {
return $replace260 ? $copyResults : array_merge($results, $copyResults);
}
return $results;
}
/** /**
* Get the item's places of publication. * Get the item's places of publication.
* *
......
...@@ -33,6 +33,8 @@ namespace VuFind\RecordDriver; ...@@ -33,6 +33,8 @@ namespace VuFind\RecordDriver;
* *
* Assumption: raw MARC data can be found in $this->fields['fullrecord']. * Assumption: raw MARC data can be found in $this->fields['fullrecord'].
* *
* Assumption: VuFind config available as $this->mainConfig
*
* @category VuFind * @category VuFind
* @package RecordDrivers * @package RecordDrivers
* @author Demian Katz <demian.katz@villanova.edu> * @author Demian Katz <demian.katz@villanova.edu>
...@@ -137,6 +139,56 @@ trait MarcReaderTrait ...@@ -137,6 +139,56 @@ trait MarcReaderTrait
$matches[0] : null; $matches[0] : null;
} }
/**
* Get the item's publication information
*
* @param string $subfield The subfield to retrieve ('a' = location, 'c' = date)
*
* @return array
*/
protected function getPublicationInfo($subfield = 'a')
{
// Get string separator for publication information:
$separator = isset($this->mainConfig->Record->marcPublicationInfoSeparator)
? $this->mainConfig->Record->marcPublicationInfoSeparator : ' ';
// First check old-style 260 field:
$results = $this->getFieldArray('260', [$subfield], true, $separator);
// Now track down relevant RDA-style 264 fields; we only care about
// copyright and publication places (and ignore copyright places if
// publication places are present). This behavior is designed to be
// consistent with default SolrMarc handling of names/dates.
$pubResults = $copyResults = [];
$fields = $this->getMarcRecord()->getFields('264');
if (is_array($fields)) {
foreach ($fields as $currentField) {
$currentVal = $this
->getSubfieldArray($currentField, [$subfield], true, $separator);
if (!empty($currentVal)) {
switch ($currentField->getIndicator('2')) {
case '1':
$pubResults = array_merge($pubResults, $currentVal);
break;
case '4':
$copyResults = array_merge($copyResults, $currentVal);
break;
}
}
}
}
$replace260 = isset($this->mainConfig->Record->replaceMarc260)
? $this->mainConfig->Record->replaceMarc260 : false;
if (count($pubResults) > 0) {
return $replace260 ? $pubResults : array_merge($results, $pubResults);
} elseif (count($copyResults) > 0) {
return $replace260 ? $copyResults : array_merge($results, $copyResults);
}
return $results;
}
/** /**
* Return an array of non-empty subfield values found in the provided MARC * Return an array of non-empty subfield values found in the provided MARC
* field. If $concat is true, the array will contain either zero or one * field. If $concat is true, the array will contain either zero or one
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment