diff --git a/module/VuFind/src/VuFind/Config/Upgrade.php b/module/VuFind/src/VuFind/Config/Upgrade.php index faa2c6b3198a3a81e5f0c9c8d9b7bf4c7eca667b..77187d31435438d0de745ed85abfbfc273f1bf4c 100644 --- a/module/VuFind/src/VuFind/Config/Upgrade.php +++ b/module/VuFind/src/VuFind/Config/Upgrade.php @@ -882,6 +882,18 @@ class Upgrade ); $this->applyOldSettings('WorldCat.ini', $groups); + // we need to fix an obsolete search setting for authors + foreach (array('Basic_Searches', 'Advanced_Searches') as $section) { + $new = array(); + foreach ($this->newConfigs['WorldCat.ini'][$section] as $k => $v) { + if ($k == 'srw.au:srw.pn:srw.cn') { + $k = 'srw.au'; + } + $new[$k] = $v; + } + $this->newConfigs['WorldCat.ini'][$section] = $new; + } + // save the file $this->saveModifiedConfig('WorldCat.ini'); } diff --git a/module/VuFind/tests/fixtures/configs/worldcatupgrades/WorldCat.ini b/module/VuFind/tests/fixtures/configs/worldcatupgrades/WorldCat.ini new file mode 100644 index 0000000000000000000000000000000000000000..5342a6d59a1872667c6c5ed4daa2a5407b01cc13 --- /dev/null +++ b/module/VuFind/tests/fixtures/configs/worldcatupgrades/WorldCat.ini @@ -0,0 +1,47 @@ +; This section contains global settings affecting search behavior. +[General] +; This setting controls the default sort order of search results; the selected +; option should be one of the options present in the [Sorting] section below. +default_sort = relevance + +; This section shows which search types will display in the basic search box at +; the top of WorldCat pages. The name of each setting below corresponds with one +; or more indices defined in the WorldCat API (multiple values are separated by +; colons). The value of each setting is the text to display on screen. All +; on-screen text will be run through the translator, so be sure to update language +; files if necessary. The order of these settings will be maintained in the +; drop-down list in the UI. +; +; For a complete list of legal values, see the SRU Explain page here: +; http://worldcat.org/webservices/catalog/ +[Basic_Searches] +srw.kw = "All Fields" +srw.ti:srw.se = Title +srw.au:srw.pn:srw.cn = Author +srw.su = Subject +srw.dd:srw.lc = "Call Number" +srw.bn:srw.in = "ISBN/ISSN" + +; This section defines which search options will be included on the advanced +; search screen. All the notes above [Basic_Searches] also apply here. +[Advanced_Searches] +srw.kw = adv_search_all +srw.ti:srw.se = adv_search_title +srw.au:srw.pn:srw.cn = adv_search_author +srw.su = adv_search_subject +srw.dd:srw.lc = adv_search_callnumber +srw.bn:srw.in = adv_search_isn +srw.pb = adv_search_publisher +srw.se = adv_search_series +srw.yr = adv_search_year + +; This section defines the sort options available on WorldCat search results. +; Values on the left of the equal sign are WorldCat API sort values. Values +; on the right of the equal sign are text that will be run through the +; translation module and displayed on screen. +[Sorting] +relevance = sort_relevance +Date,,0 = sort_year +Date = "sort_year asc" +Author = sort_author +Title = sort_title diff --git a/module/VuFind/tests/fixtures/configs/worldcatupgrades/config.ini b/module/VuFind/tests/fixtures/configs/worldcatupgrades/config.ini new file mode 100644 index 0000000000000000000000000000000000000000..7017b9d297e822fe5dab95200bd7f4f819674fce --- /dev/null +++ b/module/VuFind/tests/fixtures/configs/worldcatupgrades/config.ini @@ -0,0 +1,2 @@ +[WorldCat] +apiKey = fake \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php index c21e3c2cd7d8a1f0a4a70f12f5384b20b8c53744..2b3bf4fc01bff1ec6bb2ea005718f437a8761d80 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php @@ -304,6 +304,26 @@ class UpgradeTest extends \VuFindTest\Unit\TestCase ); } + /** + * Test WorldCat-specific upgrades. + * + * @return void + */ + public function testWorldCatUpgrades() + { + $upgrader = $this->getUpgrader('worldcatupgrades'); + $upgrader->run(); + $results = $upgrader->getNewConfigs(); + $this->assertEquals( + 'Author', + $results['WorldCat.ini']['Basic_Searches']['srw.au'] + ); + $this->assertEquals( + 'adv_search_author', + $results['WorldCat.ini']['Advanced_Searches']['srw.au'] + ); + } + /** * Test "meaningful line" detection in SolrMarc properties files. *