diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php index a1930a7da3d24149c5f714be15f9ed36092cec82..471bedac04675c5b26d1b080f0a736a52eb7096a 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php @@ -772,56 +772,67 @@ class SolrMarc extends SolrDefault } } - // Normalize blank relationship indicator to 0: - $relationshipIndicator = $field->getIndicator('2'); - if ($relationshipIndicator == ' ') { - $relationshipIndicator = '0'; - } - - // Assign notes based on the relationship type - switch ($value) { - case '780': - if (in_array($relationshipIndicator, range('0', '7'))) { - $value .= '_' . $relationshipIndicator; - } - break; - case '785': - if (in_array($relationshipIndicator, range('0', '8'))) { - $value .= '_' . $relationshipIndicator; - } - break; - } - // Get data for field - $tmp = $this->getFieldData($field, $value); + $tmp = $this->getFieldData($field); if (is_array($tmp)) { $retVal[] = $tmp; } } } } - if (empty($retVal)) { - $retVal = null; + return empty($retVal) ? null : $retVal; + } + + /** + * Support method for getFieldData() -- factor the relationship indicator + * into the field number where relevant to generate a note to associate + * with a record link. + * + * @param File_MARC_Data_Field $field Field to examine + * + * @return string + */ + protected function getRecordLinkNote($field) + { + // Normalize blank relationship indicator to 0: + $relationshipIndicator = $field->getIndicator('2'); + if ($relationshipIndicator == ' ') { + $relationshipIndicator = '0'; + } + + // Assign notes based on the relationship type + $value = $field->getTag(); + switch ($value) { + case '780': + if (in_array($relationshipIndicator, range('0', '7'))) { + $value .= '_' . $relationshipIndicator; + } + break; + case '785': + if (in_array($relationshipIndicator, range('0', '8'))) { + $value .= '_' . $relationshipIndicator; + } + break; } - return $retVal; + + return 'note_' . $value; } /** * Returns the array element for the 'getAllRecordLinks' method * * @param File_MARC_Data_Field $field Field to examine - * @param string $value Field name for use in label * * @return array|bool Array on success, boolean false if no * valid link could be found in the data. */ - protected function getFieldData($field, $value) + protected function getFieldData($field) { // Make sure that there is a t field to be displayed: if ($title = $field->getSubfield('t')) { $title = $title->getData(); } else { - return; + return false; } $linkTypeSetting = isset($this->mainConfig->Record->marc_links_link_types) @@ -883,9 +894,11 @@ class SolrMarc extends SolrDefault } } // Make sure we have something to display: - return isset($link) - ? array('title' => 'note_' . $value, 'value' => $title, 'link' => $link) - : false; + return !isset($link) ? false : array( + 'title' => $this->getRecordLinkNote($field), + 'value' => $title, + 'link' => $link + ); } /**