diff --git a/config/vufind/config.ini b/config/vufind/config.ini index ed924d1eb1c59b5b9d74f7ff865e8b8554435131..9cbda6c4936a5ea361ba067a6b1ae885d98cf5c1 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -695,13 +695,19 @@ show_full_status = false next_prev_navigation = false ; You can enable this setting to show links to related MARC records using certain -; 7XX fields. Just enter a comma-separated list of the MARC fields that you wish -; to make use of. This relies on subfield w containing either a reference to a bib -; number or an OCLC number prefixed by (OCoLC). Do not enable this option if your -; data is unable to support it! Also note that turning on the 780 and 785 fields -; may result in redundant information in the display, since the Solr title_old and -; title_new fields are likely to contain the same information. +; 7XX fields. Just enter a comma-separated list of the MARC fields that you wish +; to make use of. ;marc_links = "760,765,770,772,774,773,775,777,780,785" +; In the marc_links_link_types enter the fields you want the module to use to +; construct the links. The module will run through the link types in order +; until it finds one that matches. If you don't have id numbers in the fields, +; you can also use title to construct a title based search. id represents a raw +; bib id, dlc represents an LCCN. Default setting: +;marc_links_link_types = id,oclc,dlc,isbn,issn,title +; Set use_visibility_indicator to false if you want to show links that are marked as +; "Do not show" in the MARC record (indicator 1). Otherwise, these links will be +; suppressed. (Default = true) +;marc_links_use_visibility_indicator = false ; You can use this setting to hide holdings information for particular named locations ; as returned by the catalog. diff --git a/languages/en-gb.ini b/languages/en-gb.ini index 56bf29e89ed69d6376b72ae4998b491036751b0f..81ab8394f02b4e31a49d16ae4036a9003ecdca5e 100644 --- a/languages/en-gb.ini +++ b/languages/en-gb.ini @@ -645,9 +645,21 @@ note_775 = "Other edition available" note_777 = "Issued with" note_780_0 = "Continues" note_780_1 = "Continues in part" +note_780_2 = "Supersedes" +note_780_3 = "Supersedes in part" +note_780_4 = "Formed by" note_780_5 = "Absorbed" +note_780_6 = "Absorbed in part" +note_780_7 = "Separated from" note_785_0 = "Continued by" +note_785_1 = "Continued in part by" +note_785_2 = "Superseded by" +note_785_3 = "Superseded in part by" +note_785_4 = "Absorbed by" +note_785_5 = "Absorbed in part by" +note_785_6 = "Split into" note_785_7 = "Merged with" +note_785_8 = "Changed back to" of = of on_reserve = "Reserves - Ask at Circulation" or create a new list = "or create a new list" diff --git a/languages/en.ini b/languages/en.ini index 7df08689af3f68219aadac11fc7109bf6355d8cb..efd334440a70e5b40a28574bcb6b03c97a494b7e 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -645,9 +645,21 @@ note_775 = "Other edition available" note_777 = "Issued with" note_780_0 = "Continues" note_780_1 = "Continues in part" +note_780_2 = "Supersedes" +note_780_3 = "Supersedes in part" +note_780_4 = "Formed by" note_780_5 = "Absorbed" +note_780_6 = "Absorbed in part" +note_780_7 = "Separated from" note_785_0 = "Continued by" +note_785_1 = "Continued in part by" +note_785_2 = "Superseded by" +note_785_3 = "Superseded in part by" +note_785_4 = "Absorbed by" +note_785_5 = "Absorbed in part by" +note_785_6 = "Split into" note_785_7 = "Merged with" +note_785_8 = "Changed back to" of = of on_reserve = "Reserves - Ask at Circulation" or create a new list = "or create a new list" diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php index b0414d434e7b830773182237d68a31f4727aaae8..0455866089620cb229a8e95cf925e88a534d347c 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php @@ -643,31 +643,56 @@ class SolrMarc extends SolrDefault */ public function getAllRecordLinks() { + // Load configurations: $config = ConfigReader::getConfig(); - $fieldsNames = isset($config->Record->marc_links) ? explode(',', $config->Record->marc_links) : array(); + $useVisibilityIndicator + = isset($config->Record->marc_links_use_visibility_indicator) + ? $config->Record->marc_links_use_visibility_indicator : true; + $retVal = array(); foreach ($fieldsNames as $value) { $value = trim($value); $fields = $this->marcRecord->getFields($value); if (!empty($fields)) { foreach ($fields as $field) { - $indicator = $field->getIndicator('2'); + // Check to see if we should display at all + if ($useVisibilityIndicator) { + $visibilityIndicator = $field->getIndicator('1'); + if ($visibilityIndicator == '1') { + continue; + } + } + // The relationship type is one of the following and there is a + // 580 field, the 580 field should be shown instead see: + // http://www.loc.gov/marc/bibliographic/bd580.html + $has580 = $this->marcRecord->getFields('580'); + + $relationshipIndicator = $field->getIndicator('2'); + if ($has580 + && (($value == '780') && ($relationshipIndicator == '4')) + || (($value == '785') && (($relationshipIndicator == '6') + || ($relationshipIndicator =='7'))) + ) { + continue; + } + + // Assign notes based on the relationship type switch ($value) { case '780': - if ($indicator == '0' || $indicator == '1' - || $indicator == '5' - ) { - $value .= '_' . $indicator; + if (in_array($relationshipIndicator, range('0', '7'))) { + $value .= '_' . $relationshipIndicator; } break; case '785': - if ($indicator == '0' || $indicator == '7') { - $value .= '_' . $indicator; + if (in_array($relationshipIndicator, range('0', '8'))) { + $value .= '_' . $relationshipIndicator; } break; } + + // Get data for field $tmp = $this->getFieldData($field, $value); if (is_array($tmp)) { $retVal[] = $tmp; @@ -692,44 +717,104 @@ class SolrMarc extends SolrDefault */ protected function getFieldData($field, $value) { - // There are two possible ways we may want to link to a record -- either - // we will have a raw bibliographic record in subfield w, or else we will - // have an OCLC number prefixed by (OCoLC). If we have both, we want to - // favor the bib number over the OCLC number. If we have an unrecognized - // parenthetical prefix to the number, we should simply ignore it. - $bib = $oclc = ''; + // Make sure that there is a t field to be displayed: + if ($title = $field->getSubfield('t')) { + $title = $title->getData(); + } else { + return; + } + + $config = ConfigReader::getConfig(); + $linkTypeSetting = isset($config->Record->marc_links_link_types) + ? $config->Record->marc_links_link_types : 'id,oclc,dlc,isbn,issn,title'; + $linkTypes = explode(',', $linkTypeSetting); $linkFields = $field->getSubfields('w'); - foreach ($linkFields as $current) { - $text = $current->getData(); - // Extract parenthetical prefixes: - if (preg_match('/\(([^)]+)\)(.+)/', $text, $matches)) { - // Is it an OCLC number? - if ($matches[1] == 'OCoLC') { - $oclc = $matches[2]; + + // Run through the link types specified in the config. + // For each type, check field for reference + // If reference found, exit loop and go straight to end + // If no reference found, check the next link type instead + foreach ($linkTypes as $linkType) { + switch (trim($linkType)){ + case 'oclc': + foreach ($linkFields as $current) { + if ($oclc = $this->getIdFromLinkingField($current, 'OCoLC')) { + $link = array('type' => 'oclc', 'value' => $oclc); + } + } + break; + case 'dlc': + foreach ($linkFields as $current) { + if ($dlc = $this->getIdFromLinkingField($current, 'DLC', true)) { + $link = array('type' => 'dlc', 'value' => $dlc); + } + } + break; + case 'id': + foreach ($linkFields as $current) { + if ($bibLink = $this->getIdFromLinkingField($current)) { + $link = array('type' => 'bib', 'value' => $bibLink); + } + } + break; + case 'isbn': + if ($isbn = $field->getSubfield('z')) { + $link = array( + 'type' => 'isn', 'value' => trim($isbn->getData()), + 'exclude' => $this->getUniqueId() + ); + } + break; + case 'issn': + if ($issn = $field->getSubfield('x')) { + $link = array( + 'type' => 'isn', 'value' => trim($issn->getData()), + 'exclude' => $this->getUniqueId() + ); } - } else { - // No parenthetical prefix found -- assume raw bib number: - $bib = $text; + break; + case 'title': + $link = array('type' => 'title', 'value' => $title); + break; + } + // Exit loop if we have a link + if (isset($link)) { + break; } } - - // Check which link type we found in the code above... and fail if we - // found nothing! - if (!empty($bib)) { - $link = array('type' => 'bib', 'value' => $bib); - } else if (!empty($oclc)) { - $link = array('type' => 'oclc', 'value' => $oclc); - } else { - return false; - } - - $titleField = $field->getSubfield('t'); - $title = $titleField ? $titleField->getData() : false; - return $title + // Make sure we have something to display: + return isset($link) ? array('title' => 'note_' . $value, 'value' => $title, 'link' => $link) : false; } + /** + * Returns an id extracted from the identifier subfield passed in + * + * @param \File_MARC_Subfield $idField MARC field containing id information + * @param string $prefix Prefix to search for in id field + * @param bool $raw Return raw match, or normalize? + * + * @return string|bool ID on success, false on failure + */ + protected function getIdFromLinkingField($idField, $prefix = null, $raw = false) + { + $text = $idField->getData(); + if (preg_match('/\(([^)]+)\)(.+)/', $text, $matches)) { + // If prefix matches, return ID: + if ($matches[1] == $prefix) { + // Special case -- LCCN should not be stripped: + return $raw + ? $matches[2] + : trim(str_replace(range('a', 'z'), '', ($matches[2]))); + } + } else if ($prefix == null) { + // If no prefix was given or found, we presume it is a raw bib record + return $text; + } + return false; + } + /** * Get Status/Holdings Information from the internally stored MARC Record * (support method used by the NoILS driver). diff --git a/module/VuFind/src/VuFind/Theme/Root/Helper/RecordLink.php b/module/VuFind/src/VuFind/Theme/Root/Helper/RecordLink.php index 6663997a87a35aafacce1f8a07c483b133d4c37e..5da6905dfe001d38e2d29ff2ccb0e476d581997f 100644 --- a/module/VuFind/src/VuFind/Theme/Root/Helper/RecordLink.php +++ b/module/VuFind/src/VuFind/Theme/Root/Helper/RecordLink.php @@ -53,13 +53,31 @@ class RecordLink extends AbstractHelper $urlHelper = $this->getView()->plugin('url'); switch ($link['type']) { case 'bib': - $url = $urlHelper('record', array('id' => $link['value'])); + $url = $urlHelper('search-results') + . '?lookfor=' . urlencode($link['value']) + . '&type=id&jumpto=1'; + break; + case 'dlc': + $url = $urlHelper('search-results') + . '?lookfor=' . urlencode('"' . $link['value'] . '"') + . '&type=lccn&jumpto=1'; + break; + case 'isn': + $url = $urlHelper('search-results') + . '?join=AND&bool0[]=AND&lookfor0[]=' + . urlencode($link['value']) . '&type0[]=isn&bool1[]=NOT&lookfor1[]=' + . urlencode($link['exclude']) . '&type1[]=id&sort=title&view=list'; break; case 'oclc': $url = $urlHelper('search-results') . '?lookfor=' . urlencode($link['value']) . '&type=oclc_num&jumpto=1'; break; + case 'title': + $url = $urlHelper('search-results') + . '?lookfor=' . urlencode($link['value']) + . '&type=title'; + break; default: throw new \Exception('Unexpected link type: ' . $link['type']); } diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml b/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml index b2cc42c90cdcc9bf508748d66143e9b13a246855..0b68ff60916f24c202ebb572dc44137d0f18df17 100644 --- a/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml +++ b/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml @@ -179,12 +179,15 @@ <? endif; ?> <? $recordLinks = $this->driver->getAllRecordLinks(); if (!empty($recordLinks)): ?> - <? foreach ($recordLinks as $recordLink): ?> - <tr valign="top"> - <th><?=$this->transEsc($recordLink['title'])?>: </th> - <td><a href="<?=$this->recordLink()->related($recordLink['link'])?>"><?=$this->escapeHtml($recordLink['value'])?></a></td> - </tr> - <? endforeach; ?> + <tr valign="top"> + <th><?=$this->transEsc('Related Items')?></th> + <td> + <? foreach ($recordLinks as $recordLink): ?> + <?=$this->transEsc($recordLink['title'])?>: + <a href="<?=$this->recordLink()->related($recordLink['link'])?>"><?=$this->escapeHtml($recordLink['value'])?></a><br /> + <? endforeach; ?> + </td> + </tr> <? endif; ?> <? $tagList = $this->driver->getTags(); ?> diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/core.phtml b/themes/jquerymobile/templates/RecordDriver/SolrDefault/core.phtml index 990c20e7380e2681dbdfa049a6e280cf62d9a8bd..22bcae161d0f2050de6dcb31ca84437a31593838 100644 --- a/themes/jquerymobile/templates/RecordDriver/SolrDefault/core.phtml +++ b/themes/jquerymobile/templates/RecordDriver/SolrDefault/core.phtml @@ -158,6 +158,18 @@ </dd> <? endif; ?> + <? $recordLinks = $this->driver->getAllRecordLinks(); if (!empty($recordLinks)): ?> + <dt><?=$this->transEsc('Related Items')?></dt> + <dd> + <? foreach ($recordLinks as $recordLink): ?> + <p> + <?=$this->transEsc($recordLink['title'])?>: + <a href="<?=$this->recordLink()->related($recordLink['link'])?>"><?=$this->escapeHtml($recordLink['value'])?></a> + </p> + <? endforeach; ?> + </dd> + <? endif; ?> + <? $tagList = $this->driver->getTags(); ?> <? if (count($tagList) > 0): ?> <dt><?=$this->transEsc('Tags')?>: </dt>