diff --git a/module/VuFind/src/VuFind/Autocomplete/Solr.php b/module/VuFind/src/VuFind/Autocomplete/Solr.php index 1efe1406eb80c27b3d0360569a6a5f76892e1bc8..98190426b8fc46ce08f2ff2ffd69346505a87cb7 100644 --- a/module/VuFind/src/VuFind/Autocomplete/Solr.php +++ b/module/VuFind/src/VuFind/Autocomplete/Solr.php @@ -96,13 +96,13 @@ class Solr implements AutocompleteInterface, ServiceLocatorAwareInterface { // Get the search manager: $sm = $this->getServiceLocator()->getServiceLocator()->get('SearchManager'); - $sm->setSearchClassId($this->searchClassId); // Build a new search object: - $params = $sm->getParams(); + $params = $sm->setSearchClassId($this->searchClassId)->getParams(); $params->getOptions()->spellcheckEnabled(false); $params->recommendationsEnabled(false); - $this->searchObject = $sm->getResults($params); + $this->searchObject = $sm->setSearchClassId($this->searchClassId) + ->getResults($params); } /** @@ -181,7 +181,7 @@ class Solr implements AutocompleteInterface, ServiceLocatorAwareInterface { $results = array(); foreach ($searchResults as $object) { - $current = $object->getAllFields(); + $current = $object->getRawData(); foreach ($this->displayField as $field) { if (isset($current[$field])) { $bestMatch = $this->pickBestMatch( diff --git a/module/VuFind/src/VuFind/Controller/AbstractSearch.php b/module/VuFind/src/VuFind/Controller/AbstractSearch.php index 8b4eeac0046524a92641546cf2b6c4de88168d30..d3b82aff2a08f1c5b1770883d72ca1ab96c98950 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractSearch.php +++ b/module/VuFind/src/VuFind/Controller/AbstractSearch.php @@ -149,8 +149,8 @@ class AbstractSearch extends AbstractBase return $this->redirectToSavedSearch($savedId); } - $manager = $this->getSearchManager()->setSearchClassId($this->searchClassId); - $params = $manager->getParams(); + $manager = $this->getSearchManager(); + $params = $manager->setSearchClassId($this->searchClassId)->getParams(); $params->recommendationsEnabled(true); // Send both GET and POST variables to search class: @@ -164,7 +164,11 @@ class AbstractSearch extends AbstractBase // Attempt to perform the search; if there is a problem, inspect any Solr // exceptions to see if we should communicate to the user about them. try { - $results = $manager->getResults($params); + // We need to reset the searchClassId here because it may have been + // changed if recommendation modules initialized by the params object + // manipulated the shared search manager object. + $results = $manager->setSearchClassId($this->searchClassId) + ->getResults($params); // Explicitly execute search within controller -- this allows us to // catch exceptions more reliably: diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php index 343889fac9dd0a2ee31f0cde634f4e91782d2e28..4ddbcb322b9acb000ab539e7d21bc53552886cf5 100644 --- a/module/VuFind/src/VuFind/Controller/AjaxController.php +++ b/module/VuFind/src/VuFind/Controller/AjaxController.php @@ -107,13 +107,13 @@ class AjaxController extends AbstractBase // Process recommendations -- for now, we assume Solr-based search objects, // since deferred recommendations work best for modules that don't care about // the details of the search objects anyway: - $sm = $this->getSearchManager()->setSearchClassId('Solr'); + $sm = $this->getSearchManager(); $rm = $this->getServiceLocator()->get('RecommendPluginManager'); $module = clone($rm->get($this->params()->fromQuery('mod'))); $module->setConfig($this->params()->fromQuery('params')); - $params = $sm->getParams(); + $params = $sm->setSearchClassId('Solr')->getParams(); $module->init($params, $this->getRequest()->getQuery()); - $results = $sm->getResults($params); + $results = $sm->setSearchClassId('Solr')->getResults($params); $module->process($results); // Set headers: @@ -669,10 +669,10 @@ class AjaxController extends AbstractBase */ public function getMapData($fields = array('long_lat')) { - $sm = $this->getSearchManager()->setSearchClassId('Solr'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Solr')->getParams(); $params->initFromRequest($this->getRequest()->getQuery()); - $results = $sm->getResults($params); + $results = $sm->setSearchClassId('Solr')->getResults($params); $facets = $results->getFullFieldFacets($fields, false); @@ -709,10 +709,10 @@ class AjaxController extends AbstractBase // Set layout to render the page inside a lightbox: $this->layout()->setTemplate('layout/lightbox'); - $sm = $this->getSearchManager()->setSearchClassId('Solr'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Solr')->getParams(); $params->initFromRequest($this->getRequest()->getQuery()); - $results = $sm->getResults($params); + $results = $sm->setSearchClassId('Solr')->getResults($params); return $this->createViewModel( array( @@ -736,10 +736,10 @@ class AjaxController extends AbstractBase */ public function getVisData($fields = array('publishDate')) { - $sm = $this->getSearchManager()->setSearchClassId('Solr'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Solr')->getParams(); $params->initFromRequest($this->getRequest()->getQuery()); - $results = $sm->getResults($params); + $results = $sm->setSearchClassId('Solr')->getResults($params); $filters = $params->getFilters(); $dateFacets = $this->params()->fromQuery('facetFields'); $dateFacets = empty($dateFacets) ? array() : explode(':', $dateFacets); diff --git a/module/VuFind/src/VuFind/Controller/BrowseController.php b/module/VuFind/src/VuFind/Controller/BrowseController.php index 3aa3b2c41622b46bf897928df2ddf6cef68bc9ce..b1f68442daecc6bb163e1da8296d3a026482caf4 100644 --- a/module/VuFind/src/VuFind/Controller/BrowseController.php +++ b/module/VuFind/src/VuFind/Controller/BrowseController.php @@ -559,8 +559,8 @@ class BrowseController extends AbstractBase protected function getFacetList($facet, $category = null, $sort = 'count', $query = '[* TO *]' ) { - $sm = $this->getSearchManager()->setSearchClassId('Solr'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Solr')->getParams(); $params->addFacet($facet); if ($category != null) { $query = $category . ':' . $query; @@ -568,7 +568,10 @@ class BrowseController extends AbstractBase $query = $facet . ':' . $query; } $params->setOverrideQuery($query); - $searchObject = $sm->getResults($params); + $params->getOptions()->disableHighlighting(); + $params->getOptions()->spellcheckEnabled(false); + $params->recommendationsEnabled(false); + $searchObject = $sm->setSearchClassId('Solr')->getResults($params); // Get limit from config $params->setFacetLimit($this->config->Browse->result_limit); $params->setLimit(0); diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index 29f38853020f450adebf09ca829e2e9e5046ad2e..2f40ed866bbe233961fca32ccba5783527330c6b 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -530,8 +530,8 @@ class MyResearchController extends AbstractBase // If we got this far, we just need to display the favorites: try { - $sm = $this->getSearchManager()->setSearchClassId('Favorites'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Favorites')->getParams(); $params->setAuthManager($this->getAuthManager()); // We want to merge together GET, POST and route parameters to @@ -544,7 +544,7 @@ class MyResearchController extends AbstractBase ) ); - $results = $sm->getResults($params); + $results = $sm->setSearchClassId('Favorites')->getResults($params); $results->performAndProcessSearch(); return $this->createViewModel(array('results' => $results)); } catch (ListPermissionException $e) { @@ -732,7 +732,8 @@ class MyResearchController extends AbstractBase } $record = SolrResults::getRecord($current['id']); } catch (RecordMissingException $e) { - $record = new \VuFind\RecordDriver\Missing( + $record = new \VuFind\RecordDriver\Missing(); + $record->setRawData( array('id' => isset($current['id']) ? $current['id'] : null) ); } diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index 2dea03953a3b6b9fd8e5a4d162e825051005ae4a..163ab32c620229d08e5d7819cfb392f416b7d193 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -343,8 +343,8 @@ class SearchController extends AbstractSearch $resultPages = 10; } $catalog = ConnectionManager::connectToCatalog(); - $sm = $this->getSearchManager()->setSearchClassId('Solr'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Solr')->getParams(); $perPage = $params->getLimit(); $newItems = $catalog->getNewItems(1, $perPage * $resultPages, $range, $dept); @@ -431,10 +431,10 @@ class SearchController extends AbstractSearch */ public function reservessearchAction() { - $sm = $this->getSearchManager()->setSearchClassId('SolrReserves'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('SolrReserves')->getParams(); $params->initFromRequest($this->getRequest()->getQuery()); - $results = $sm->getResults($params); + $results = $sm->setSearchClassId('SolrReserves')->getResults($params); return $this->createViewModel(array('results' => $results)); } @@ -458,8 +458,8 @@ class SearchController extends AbstractSearch $bibIDs = array_unique(array_map($callback, $result)); // Truncate the list if it is too long: - $sm = $this->getSearchManager()->setSearchClassId('Solr'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Solr')->getParams(); $limit = $params->getQueryIDLimit(); if (count($bibIDs) > $limit) { $bibIDs = array_slice($bibIDs, 0, $limit); @@ -505,15 +505,15 @@ class SearchController extends AbstractSearch // we may want to make this more flexible later. Also keep in mind that // the template is currently looking for certain hard-coded fields; this // should also be made smarter. - $sm = $this->getSearchManager()->setSearchClassId('Solr'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Solr')->getParams(); $params->initAdvancedFacets(); // We only care about facet lists, so don't get any results (this helps // prevent problems with serialized File_MARC objects in the cache): $params->setLimit(0); - $results = $sm->getResults($params); + $results = $sm->setSearchClassId('Solr')->getResults($params); $results->getResults(); // force processing for cache // Temporarily remove the service manager so we can cache the diff --git a/module/VuFind/src/VuFind/Controller/SummonController.php b/module/VuFind/src/VuFind/Controller/SummonController.php index 4a3de1e7c91a21d07feb548f49c4e61efcba5903..d52165428d9d9ee0b8537480edf0fb2ee6793c83 100644 --- a/module/VuFind/src/VuFind/Controller/SummonController.php +++ b/module/VuFind/src/VuFind/Controller/SummonController.php @@ -127,16 +127,17 @@ class SummonController extends AbstractSearch // Check if we have facet results cached, and build them if we don't. $cache = CacheManager::getInstance()->getCache('object'); if (!($results = $cache->getItem('summonSearchHomeFacets'))) { - $sm = $this->getSearchManager()->setSearchClassId('Summon'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Summon')->getParams(); $params->addFacet('Language,or,1,20'); $params->addFacet('ContentType,or,1,20', 'Format'); // We only care about facet lists, so don't get any results: $params->setLimit(0); - $results = $sm->getResults($params); - $results->getResults(); // force processing for cache + $results = $sm->setSearchClassId('Summon')->getResults($params); + // force processing for cache + $results->getResults(); // Temporarily remove the service manager so we can cache the // results (otherwise we'll get errors about serializing closures): diff --git a/module/VuFind/src/VuFind/OAI/Server.php b/module/VuFind/src/VuFind/OAI/Server.php index 200ecc4d3ce098ebf978edcc40349589e918d29b..1845be2367b06ba67d4212e6239f6c20088b81b0 100644 --- a/module/VuFind/src/VuFind/OAI/Server.php +++ b/module/VuFind/src/VuFind/OAI/Server.php @@ -183,7 +183,7 @@ class Server } // Check for sets: - $fields = $record->getAllFields(); + $fields = $record->getRawData(); if (!is_null($this->setField) && !empty($fields[$this->setField])) { $sets = $fields[$this->setField]; } else { @@ -507,9 +507,10 @@ class Server // we'll assume that this list is short enough to load in a single response; // it may be necessary to implement a resumption token mechanism if this // proves not to be the case: - $this->searchManager->setSearchClassId($this->searchClassId); - $params = $this->searchManager->getParams(); - $results = $this->searchManager->getResults($params); + $params = $this->searchManager->setSearchClassId($this->searchClassId) + ->getParams(); + $results = $this->searchManager->setSearchClassId($this->searchClassId) + ->getResults($params); try { $facets = $results->getFullFieldFacets(array($this->setField)); } catch (\Exception $e) { diff --git a/module/VuFind/src/VuFind/Recommend/AuthorFacets.php b/module/VuFind/src/VuFind/Recommend/AuthorFacets.php index a06a3bd588e9d19f7592d14427338f82948071f9..9183257677a8edee8554185d9854d01bbff9d99a 100644 --- a/module/VuFind/src/VuFind/Recommend/AuthorFacets.php +++ b/module/VuFind/src/VuFind/Recommend/AuthorFacets.php @@ -141,11 +141,11 @@ class AuthorFacets extends AbstractSearchManagerAwareModule // Initialize an AuthorFacets search object using parameters from the // current Solr search object. - $params = $sm->getParams($options); + $params = $sm->setSearchClassId('SolrAuthorFacets')->getParams($options); $params->initFromRequest(new Parameters(array('lookfor' => $lookfor))); // Send back the results: - $results = $sm->getResults($params); + $results = $sm->setSearchClassId('SolrAuthorFacets')->getResults($params); return array( // Total authors (currently there is no way to calculate this without // risking out-of-memory errors or slow results, so we set this to diff --git a/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php b/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php index cbfe4aa57c95e3c889fd998bb29aaef5243e4930..3ad1c0f910e7d915827d656caaafb3fb1f7ca50c 100644 --- a/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php +++ b/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php @@ -135,13 +135,13 @@ class AuthorityRecommend extends AbstractSearchManagerAwareModule // Initialise and process search (ignore Solr errors -- no reason to fail // just because search syntax is not compatible with Authority core): try { - $sm = $this->getSearchManager()->setSearchClassId('SolrAuth'); - $authParams = $sm->getParams(); + $sm = $this->getSearchManager(); + $authParams = $sm->setSearchClassId('SolrAuth')->getParams(); $authParams->initFromRequest($request); foreach ($this->filters as $filter) { $authParams->getOptions()->addHiddenFilter($filter); } - $authResults = $sm->getResults($authParams); + $authResults = $sm->setSearchClassId('SolrAuth')->getResults($authParams); $results = $authResults->getResults(); } catch (SolrException $e) { return; diff --git a/module/VuFind/src/VuFind/Recommend/SearchObject.php b/module/VuFind/src/VuFind/Recommend/SearchObject.php index 7233f1d878a3a56a2ac985bf06e40d51f5440ac3..470f3ccf0ebed8270a41ba7b6cb543acb270d957 100644 --- a/module/VuFind/src/VuFind/Recommend/SearchObject.php +++ b/module/VuFind/src/VuFind/Recommend/SearchObject.php @@ -85,7 +85,8 @@ abstract class SearchObject extends AbstractSearchManagerAwareModule $params->setBasicSearch($request->get($this->requestParam)); // Perform the search: - $this->results = $sm->getResults($params); + $this->results = $sm->setSearchClassId($this->getSearchClassId()) + ->getResults($params); $this->results->performAndProcessSearch(); } diff --git a/module/VuFind/src/VuFind/Recommend/SummonDatabases.php b/module/VuFind/src/VuFind/Recommend/SummonDatabases.php index 2fb03d579ebe5993acb2576f707e8ff1ce7f58ab..954279f29a9974b5502d3ec4dc427658140c4b28 100644 --- a/module/VuFind/src/VuFind/Recommend/SummonDatabases.php +++ b/module/VuFind/src/VuFind/Recommend/SummonDatabases.php @@ -97,10 +97,10 @@ class SummonDatabases extends AbstractSearchManagerAwareModule // to create a new Summon search object using the specified request // parameter for search terms. if ($results->getParams()->getSearchClassId() != 'Summon') { - $sm = $this->getSearchManager()->setSearchClassId('Summon'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Summon')->getParams(); $params->setBasicSearch($this->lookfor); - $results = $sm->getResults($params); + $results = $sm->setSearchClassId('Summon')->getResults($params); $results->performAndProcessSearch(); } $this->databases = $results->getDatabaseRecommendations(); diff --git a/module/VuFind/src/VuFind/Record/Loader.php b/module/VuFind/src/VuFind/Record/Loader.php index 63b7b33ece6901f7a3a89f3acda2f9365f30387f..1c44cb02dca91fabdbaa597dc39a8c0f0a24c349 100644 --- a/module/VuFind/src/VuFind/Record/Loader.php +++ b/module/VuFind/src/VuFind/Record/Loader.php @@ -133,8 +133,8 @@ class Loader $fields = isset($details['extra_fields']) ? $details['extra_fields'] : array(); $fields['id'] = $details['id']; - $retVal[$i] - = new \VuFind\RecordDriver\Missing($fields); + $retVal[$i] = new \VuFind\RecordDriver\Missing(); + $retVal[$i]->setRawData($fields); } } diff --git a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php index dbbdec8092a26485692bdc40bbb565cb05121ee7..87e2b9bc34b52dd57f98ee6587d326a913e4cd5c 100644 --- a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php +++ b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php @@ -52,18 +52,34 @@ abstract class AbstractBase protected $resourceSource = 'VuFind'; // Used for identifying database records protected $extraDetails = array(); // For storing extra data with record protected $recordIni = null; // ini file for record settings + protected $fields = array(); /** - * Constructor. + * Set raw data to initialize the object. * - * @param array|object $data Raw data representing the record; Record Model + * @param mixed $data Raw data representing the record; Record Model * objects are normally constructed by Record Driver objects using data * passed in from a Search Results object. The exact nature of the data may * vary depending on the data source -- the important thing is that the - * Record Model + Record Driver + Search Results objects work together - * correctly. + * Record Driver + Search Results objects work together correctly. + * + * @return void */ - abstract public function __construct($data); + public function setRawData($data) + { + $this->fields = $data; + } + + /** + * Retrieve raw data from object (primarily for use in staff view and + * autocomplete; avoid using whenever possible). + * + * @return mixed + */ + public function getRawData() + { + return $this->fields; + } /** * Get text that can be displayed to represent this record in breadcrumbs. diff --git a/module/VuFind/src/VuFind/RecordDriver/Missing.php b/module/VuFind/src/VuFind/RecordDriver/Missing.php index c6d774566c6a660640f1387827152a22f43bae5c..405e59241ccd0c7a810bb634b1003f8857ca9d45 100644 --- a/module/VuFind/src/VuFind/RecordDriver/Missing.php +++ b/module/VuFind/src/VuFind/RecordDriver/Missing.php @@ -42,17 +42,10 @@ class Missing extends SolrDefault { /** * Constructor. - * - * @param array $data Raw data from the Solr index representing the record; - * Solr Record Model objects are normally constructed by Solr Record Driver - * objects using data passed in from a Solr Search Results object. */ - public function __construct($data = null) + public function __construct() { - if (!is_array($data)) { - $data = array(); - } - parent::__construct($data); $this->resourceSource = 'missing'; + parent::__construct(); } } diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php b/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php index 0bd30b9ce4600f2faf1ff08f2c7a61b6c49bb4c0..9e5b89b054910daacd8e499b09862c4061e82db0 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php @@ -43,8 +43,6 @@ use VuFind\Code\ISBN, VuFind\Config\Reader as ConfigReader; */ class SolrDefault extends AbstractBase { - protected $fields; - /** * These Solr fields should be used for snippets if available (listed in order * of preference). @@ -93,15 +91,9 @@ class SolrDefault extends AbstractBase /** * Constructor. - * - * @param array $data Raw data from the Solr index representing the record; - * Solr Record Model objects are normally constructed by Solr Record Driver - * objects using data passed in from a Solr Search Results object. */ - public function __construct($data) + public function __construct() { - $this->fields = $data; - // Turn on highlighting/snippets as needed: $searchSettings = ConfigReader::getConfig('searches'); $this->highlight = !isset($searchSettings->General->highlighting) @@ -184,17 +176,6 @@ class SolrDefault extends AbstractBase return null; } - /** - * Get an associative array of all fields (primarily for use in staff view and - * autocomplete; avoid using whenever possible). - * - * @return array - */ - public function getAllFields() - { - return $this->fields; - } - /** * Get award notes for the record. * @@ -1050,6 +1031,9 @@ class SolrDefault extends AbstractBase */ public function getUniqueID() { + if (!isset($this->fields['id'])) { + throw new \Exception('ID not set!'); + } return $this->fields['id']; } diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php index c3151ebb0aab25bfc2df49df500d692976685632..ff4d19025fda14d306e2d905fcbfe48866c58a26 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php @@ -48,16 +48,19 @@ class SolrMarc extends SolrDefault protected $marcRecord; /** - * Constructor. + * Set raw data to initialize the object. * - * @param array $data Raw data from the Solr index representing the record; - * Solr Record Model objects are normally constructed by Solr Record Driver - * objects using data passed in from a Solr Search Results object. + * @param mixed $data Raw data representing the record; Record Model + * objects are normally constructed by Record Driver objects using data + * passed in from a Search Results object. In this case, $data is a Solr record + * array containing MARC data in the 'fullrecord' field. + * + * @return void */ - public function __construct($data) + public function setRawData($data) { - // Call the parent's constructor... - parent::__construct($data); + // Call the parent's set method... + parent::setRawData($data); // Also process the MARC record: $marc = trim($data['fullrecord']); diff --git a/module/VuFind/src/VuFind/RecordDriver/Summon.php b/module/VuFind/src/VuFind/RecordDriver/Summon.php index 1ba1ffd6ac0b7b7ae900df2331e49e348ed640cf..71ab60c36c9075e2916b50fbdf33cbbf318569c6 100644 --- a/module/VuFind/src/VuFind/RecordDriver/Summon.php +++ b/module/VuFind/src/VuFind/RecordDriver/Summon.php @@ -43,13 +43,9 @@ class Summon extends SolrDefault { /** * Constructor. - * - * @param array $data Raw data from the Summon index representing the record. */ - public function __construct($data) + public function __construct() { - $this->fields = $data; - // Turn on highlighting as needed: $searchSettings = ConfigReader::getConfig('Summon'); $this->highlight = !isset($searchSettings->General->highlighting) diff --git a/module/VuFind/src/VuFind/RecordDriver/TestHarness.php b/module/VuFind/src/VuFind/RecordDriver/TestHarness.php index a03209644fea30a6a1a3ea19639e9208c438a996..8e0ceed187b3199cbc6bd6d9fce385a21d4d6ac6 100644 --- a/module/VuFind/src/VuFind/RecordDriver/TestHarness.php +++ b/module/VuFind/src/VuFind/RecordDriver/TestHarness.php @@ -38,18 +38,6 @@ namespace VuFind\RecordDriver; */ class TestHarness extends AbstractBase { - protected $fields; - - /** - * Constructor. - * - * @param array $data Raw test data. - */ - public function __construct($data = array()) - { - $this->fields = $data; - } - /** * Magic method to set/retrieve fields. * diff --git a/module/VuFind/src/VuFind/RecordDriver/WorldCat.php b/module/VuFind/src/VuFind/RecordDriver/WorldCat.php index 1b33cd5a52fc7de4a16c2de9cd63396cef5a742c..08a28521b39d860e074831633365cf2300a7cab5 100644 --- a/module/VuFind/src/VuFind/RecordDriver/WorldCat.php +++ b/module/VuFind/src/VuFind/RecordDriver/WorldCat.php @@ -42,11 +42,29 @@ class WorldCat extends SolrMarc protected $marcRecord; /** - * Constructor. + * Constructor + */ + public function __construct() + { + // Set the correct resource source for database entries: + $this->resourceSource = 'WorldCat'; + + // Use the WorldCat.ini file instead of config.ini for loading record + // settings (i.e. "related" record handlers): + $this->recordIni = 'WorldCat'; + } + + /** + * Set raw data to initialize the object. + * + * @param mixed $data Raw data representing the record; Record Model + * objects are normally constructed by Record Driver objects using data + * passed in from a Search Results object. In this case, $data is a MARCXML + * document. * - * @param array $data Raw data from WorldCat representing the record. + * @return void */ - public function __construct($data) + public function setRawData($data) { // Make sure the XML has an appropriate header: if (strlen($data) > 2 && substr($data, 0, 2) != '<?') { @@ -55,14 +73,7 @@ class WorldCat extends SolrMarc // Map the WorldCat response into a format that the parent Solr-based // record driver can understand. - parent::__construct(array('fullrecord' => $data)); - - // Set the correct resource source for database entries: - $this->resourceSource = 'WorldCat'; - - // Use the WorldCat.ini file instead of config.ini for loading record - // settings (i.e. "related" record handlers): - $this->recordIni = 'WorldCat'; + parent::setRawData(array('fullrecord' => $data)); } /** diff --git a/module/VuFind/src/VuFind/Search/Minified.php b/module/VuFind/src/VuFind/Search/Minified.php index a7743cc230e18560ab787f89437ff2da3271ef10..fc9491c4ab881433fbf5fa62577a89de1b1a0167 100644 --- a/module/VuFind/src/VuFind/Search/Minified.php +++ b/module/VuFind/src/VuFind/Search/Minified.php @@ -132,10 +132,9 @@ class Minified $this->populateClassNames(); // Deminify everything: - $manager->setSearchClassId($this->cl); - $params = $manager->getParams(); + $params = $manager->setSearchClassId($this->cl)->getParams(); $params->deminify($this); - $results = $manager->getResults($params); + $results = $manager->setSearchClassId($this->cl)->getResults($params); $results->deminify($this); return $results; diff --git a/module/VuFind/src/VuFind/Search/Solr/Results.php b/module/VuFind/src/VuFind/Search/Solr/Results.php index e12128633eee5d91393477529d3ba163f8a12c37..189bb36f39a3bd620a0942cd954b151b836dc6a7 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Results.php +++ b/module/VuFind/src/VuFind/Search/Solr/Results.php @@ -550,7 +550,9 @@ class Results extends BaseResults // Build the object: if (class_exists($driver)) { - return new $driver($data); + $obj = new $driver(); + $obj->setRawData($data); + return $obj; } throw new \Exception('Cannot find record driver -- ' . $driver); diff --git a/module/VuFind/src/VuFind/Search/SolrAuth/Results.php b/module/VuFind/src/VuFind/Search/SolrAuth/Results.php index fdeb771832dfa9d25eee53aae9a17e70e076d7fa..239caa23a74c2a950be48d3cd5e90be83d67bfe5 100644 --- a/module/VuFind/src/VuFind/Search/SolrAuth/Results.php +++ b/module/VuFind/src/VuFind/Search/SolrAuth/Results.php @@ -26,8 +26,7 @@ * @link http://www.vufind.org Main Page */ namespace VuFind\Search\SolrAuth; -use VuFind\RecordDriver\SolrAuth as SolrAuthRecord, - VuFind\Search\Base\Params as BaseParams, +use VuFind\Search\Base\Params as BaseParams, VuFind\Search\Solr\Results as SolrResults; /** @@ -77,6 +76,8 @@ class Results extends SolrResults */ protected static function initRecordDriver($data) { - return new SolrAuthRecord($data); + $driver = new \VuFind\RecordDriver\SolrAuth(); + $driver->setRawData($data); + return $driver; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Search/SolrReserves/Results.php b/module/VuFind/src/VuFind/Search/SolrReserves/Results.php index 01f2e17a51f9862c72b5366a31b8a15fbb851226..ba362f8961e8148daf05d47e4f28d20c4677e8d9 100644 --- a/module/VuFind/src/VuFind/Search/SolrReserves/Results.php +++ b/module/VuFind/src/VuFind/Search/SolrReserves/Results.php @@ -27,8 +27,7 @@ * @link http://www.vufind.org Main Page */ namespace VuFind\Search\SolrReserves; -use VuFind\RecordDriver\SolrReserves as SolrReservesRecord, - VuFind\Search\Base\Params as BaseParams, +use VuFind\Search\Base\Params as BaseParams, VuFind\Search\Solr\Results as SolrResults; /** @@ -80,6 +79,8 @@ class Results extends SolrResults */ protected static function initRecordDriver($data) { - return new SolrReservesRecord($data); + $driver = new \VuFind\RecordDriver\SolrReserves(); + $driver->setRawData($data); + return $driver; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Search/Summon/Results.php b/module/VuFind/src/VuFind/Search/Summon/Results.php index 89b374bc621c61cfd6cb512d95134318792c4e28..81eb07ed322f685a58f674eae8a2fd18faed91db 100644 --- a/module/VuFind/src/VuFind/Search/Summon/Results.php +++ b/module/VuFind/src/VuFind/Search/Summon/Results.php @@ -30,7 +30,6 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Connection\Summon as SummonConnection, VuFind\Connection\Summon\Query as SummonQuery, VuFind\Exception\RecordMissing as RecordMissingException, - VuFind\RecordDriver\Summon as SummonRecord, VuFind\Search\Base\Results as BaseResults, VuFind\Translator\Translator; @@ -159,7 +158,9 @@ class Results extends BaseResults */ protected static function initRecordDriver($data) { - return new SummonRecord($data); + $driver = new \VuFind\RecordDriver\Summon(); + $driver->setRawData($data); + return $driver; } /** diff --git a/module/VuFind/src/VuFind/Search/WorldCat/Results.php b/module/VuFind/src/VuFind/Search/WorldCat/Results.php index 930a663fbd96a97e79c321f60b8b841fe93e5b6a..eb5e232d6057e82182013f245dc014b55ecd48ec 100644 --- a/module/VuFind/src/VuFind/Search/WorldCat/Results.php +++ b/module/VuFind/src/VuFind/Search/WorldCat/Results.php @@ -29,7 +29,6 @@ namespace VuFind\Search\WorldCat; use VuFind\Config\Reader as ConfigReader, VuFind\Connection\WorldCat as WorldCatConnection, VuFind\Exception\RecordMissing as RecordMissingException, - VuFind\RecordDriver\WorldCat as WorldCatRecord, VuFind\Search\Base\Results as BaseResults; /** @@ -128,7 +127,9 @@ class Results extends BaseResults */ protected static function initRecordDriver($data) { - return new WorldCatRecord($data); + $driver = new \VuFind\RecordDriver\WorldCat(); + $driver->setRawData($data); + return $driver; } /** diff --git a/module/VuFind/tests/Theme/Root/Helper/CitationTest.php b/module/VuFind/tests/Theme/Root/Helper/CitationTest.php index 9a4d6f653d3a9d5218aa790227dcb978175f65c5..61d49fe0774e388c910aa781255aef2937c176e3 100644 --- a/module/VuFind/tests/Theme/Root/Helper/CitationTest.php +++ b/module/VuFind/tests/Theme/Root/Helper/CitationTest.php @@ -285,8 +285,9 @@ class CitationTest extends \VuFind\Tests\ViewHelperTestCase { $citation = new Citation(); $citation->setView($this->getPhpRenderer()); + $driver = new \VuFind\RecordDriver\TestHarness(); foreach ($this->citations as $current) { - $driver = new \VuFind\RecordDriver\TestHarness($current['raw']); + $driver->setRawData($current['raw']); $cb = $citation->__invoke($driver); // Normalize whitespace: diff --git a/module/VuFind/tests/Theme/Root/Helper/ResultFeedTest.php b/module/VuFind/tests/Theme/Root/Helper/ResultFeedTest.php index de7aa5a21c1a088fef01df47284f775facb9d2a6..22c6f7a021e1baa071a295d1ce71e675c61613e4 100644 --- a/module/VuFind/tests/Theme/Root/Helper/ResultFeedTest.php +++ b/module/VuFind/tests/Theme/Root/Helper/ResultFeedTest.php @@ -70,11 +70,11 @@ class ResultFeedTest extends \VuFind\Tests\ViewHelperTestCase $request->set('sort', 'title'); $request->set('view', 'rss'); - $sm = $this->getSearchManager()->setSearchClassId('Solr'); - $params = $sm->getParams(); + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Solr')->getParams(); $params->initFromRequest($request); - $results = $sm->getResults($params); + $results = $sm->setSearchClassId('Solr')->getResults($params); $helper = new ResultFeed(); $helper->setView($this->getPhpRenderer($this->getPlugins())); $mockTranslator = function ($str) { diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/tab-details.phtml b/themes/blueprint/templates/RecordDriver/SolrDefault/tab-details.phtml index 309c02c59791209b55f1fdcec9e8419c03cf4eb8..b315fec63e0c2a01e89b054088a6c39bfa4ec988 100644 --- a/themes/blueprint/templates/RecordDriver/SolrDefault/tab-details.phtml +++ b/themes/blueprint/templates/RecordDriver/SolrDefault/tab-details.phtml @@ -3,7 +3,7 @@ $this->headTitle($this->translate('Staff View') . ': ' . $this->driver->getBreadcrumb()); ?> <table class="citation"> - <? foreach ($this->driver->getAllFields() as $field => $values): ?> + <? foreach ($this->driver->getRawData() as $field => $values): ?> <tr> <th><?=$this->escapeHtml($field)?></th> <td> diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-details.phtml b/themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-details.phtml index 1f5eca6fea9d9ef642ba3b51211b74c1be42aae9..4420e0d0f2bbb1b82ff78e17d599a0faf441eb40 100644 --- a/themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-details.phtml +++ b/themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-details.phtml @@ -3,7 +3,7 @@ $this->headTitle($this->translate('Staff View') . ': ' . $this->driver->getBreadcrumb()); ?> <dl class="biblio" title="<?=$this->transEsc('Staff View')?>"> - <? foreach ($this->driver->getAllFields() as $field => $values): ?> + <? foreach ($this->driver->getRawData() as $field => $values): ?> <dt><?=$this->escapeHtml($field)?></dt> <dd> <div style="width: 500px; overflow: auto;">