/** * Load a saved search, if appropriate and legal; assign an error to the * interface if necessary. * * @access protected * @return SearchObject_Base|boolean mixed Search Object on successful load, false otherwise */ protected function loadSavedSearch() { global $interface; global $user; // Are we editing an existing search? if (isset($_REQUEST['edit']) || isset($_SESSION['lastSearchId'])) { // Go find it $search = new SearchEntry(); $search->id = isset($_REQUEST['edit']) ? $_REQUEST['edit'] : $_SESSION['lastSearchId']; if ($search->find(true)) { // Check permissions if ($search->session_id == session_id() || $search->user_id == $user->id) { // Retrieve the search details $minSO = unserialize($search->search_object); $savedSearch = SearchObjectFactory::deminify($minSO); // Make sure it's an advanced search if ($savedSearch->getSearchType() == 'advanced') { // Activate facets so we get appropriate descriptions // in the filter list: $savedSearch->activateAllFacets('Advanced'); return $savedSearch; } else { $interface->assign('editErr', 'notAdvanced'); } // No permissions } else { $interface->assign('editErr', 'noRights'); } // Not found } else { $interface->assign('editErr', 'notFound'); } } return false; }
function launch() { global $interface; global $timer; global $logger; $interface->assign('sidebar', 'GroupedWork/full-record-sidebar.tpl'); $id = $_REQUEST['id']; require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php'; $recordDriver = new GroupedWorkDriver($id); if (!$recordDriver->isValid) { $logger->log("Did not find a record for id {$id} in solr.", PEAR_LOG_DEBUG); $interface->setTemplate('../Record/invalidRecord.tpl'); $interface->display('layout.tpl'); die; } $interface->assign('recordDriver', $recordDriver); $timer->logTime('Initialized the Record Driver'); // Retrieve User Search History $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); //Get Next/Previous Links $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local'; /** @var SearchObject_Solr $searchObject */ $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init($searchSource); $searchObject->getNextPrevLinks(); $interface->setPageTitle($recordDriver->getTitle()); $interface->assign('moreDetailsOptions', $recordDriver->getMoreDetailsOptions()); $interface->assign('moreDetailsTemplate', 'GroupedWork/moredetails-accordion.tpl'); $interface->setTemplate('full-record.tpl'); $interface->assign('metadataTemplate', 'GroupedWork/metadata.tpl'); // Display Page $interface->display('layout.tpl'); }
public function __construct($indexFields) { if (is_string($indexFields)) { $id = $indexFields; //Just got a record id, let's load the full record from Solr // Setup Search Engine Connection $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->disableScoping(); if (function_exists('disableErrorHandler')) { disableErrorHandler(); } // Retrieve the record from Solr if (!($record = $searchObject->getRecord($id))) { $this->isValid = false; } else { $this->fields = $record; } $searchObject->enableScoping(); if (function_exists('enableErrorHandler')) { enableErrorHandler(); } } else { $this->fields = $indexFields; } }
/** * Process incoming parameters and display the page. * * @return void * @access public */ public function launch() { // Initialise from the current search globals $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init(); $this->showResults($searchObject); }
function launch() { global $interface; // Create our search object /** @var SearchObject_Solr|SearchObject_Base $searchObject */ $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->initAdvancedFacets(); // We don't want this search in the search history $searchObject->disableLogging(); // Go get the facets $searchObject->processSearch(); $facetList = $searchObject->getFacetList(); //print_r($facetList); // Shutdown the search object $searchObject->close(); // Load a saved search, if any: $savedSearch = $this->loadSavedSearch(); if ($savedSearch) { $searchTerms = $savedSearch->getSearchTerms(); $searchGroups = array(); $numGroups = 0; foreach ($searchTerms as $search) { $groupStart = true; $numItemsInGroup = count($search['group']); $curItem = 0; foreach ($search['group'] as $group) { $searchGroups[$numGroups] = array('groupStart' => $groupStart ? 1 : 0, 'searchType' => $group['field'], 'lookfor' => $group['lookfor'], 'join' => $group['bool'], 'groupEnd' => ++$curItem === $numItemsInGroup ? 1 : 0); $groupStart = false; $numGroups++; } } $interface->assign('searchGroups', $searchGroups); } //Get basic search types $basicSearchTypes = $searchObject->getBasicTypes(); $interface->assign('basicSearchTypes', $basicSearchTypes); // Send search type settings to the template $advSearchTypes = $searchObject->getAdvancedTypes(); //Remove any basic search types foreach ($basicSearchTypes as $basicTypeKey => $basicType) { unset($advSearchTypes[$basicTypeKey]); } foreach ($advSearchTypes as $advSearchKey => $label) { $advSearchTypes[$advSearchKey] = translate($label); } natcasesort($advSearchTypes); $interface->assign('advSearchTypes', $advSearchTypes); foreach ($facetList as $facetKey => $facetData) { $facetList[$facetKey] = translate($facetData['label']); } natcasesort($facetList); $interface->assign('facetList', $facetList); header('Content-type: application/json'); header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past $results = array('title' => 'Advanced Search', 'modalBody' => $interface->fetch("Search/advancedPopup.tpl"), 'modalButtons' => "<span class='tool btn btn-primary' onclick='VuFind.Searches.submitAdvancedSearch(); return false;'>Find</span>"); echo json_encode($results); }
/** * Process incoming parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; header('Content-type: text/html'); header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past // Set Proxy URL if (isset($configArray['EZproxy']['host'])) { $interface->assign('proxy', $configArray['EZproxy']['host']); } $collection = $_REQUEST['collection']; // Initialise from the current search globals $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->collection_id($collection); $searchObject->init(); $results = $searchObject->processSearch(); $results = $results['response']['docs']; //print_r($results); $interface->assign('recordSet', $results); $summary = $searchObject->getResultSummary(); $interface->assign('recordCount', $summary['resultTotal']); $interface->assign('completeListUrl', $searchObject->renderLinkWithLimit(20)); $interface->display('AJAX/ResultGoogleMapInfo.tpl'); }
/** * No-op, just verify that VuFind is up and running * * @return true * @access public */ public function noop() { // Verify that the index is up $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init(); $searchObject->getIndexEngine(); return $this->output(true, JSON::STATUS_OK); }
/** * Constructor * * @access public */ public function __construct() { global $action; parent::__construct(); $this->searchObject = SearchObjectFactory::initSearchObject('PCI'); $this->filterField = 'creationdate'; $this->dateFacet = 'creationdate'; }
/** * Constructor * * @access public */ public function __construct() { global $interface; $interface->assign('currentTab', 'Authority'); // Send Authority search types to the template so the basic search box can // function on all pages of the Authority UI. $this->searchObject = SearchObjectFactory::initSearchObject('SolrAuth'); $interface->assign('authSearchTypes', $this->searchObject->getBasicTypes()); }
/** * Constructor * * @access public */ public function __construct() { global $interface; $interface->assign('currentTab', 'WorldCat'); // Send WorldCat search types to the template so the basic search box can // function on all pages of the WorldCat UI. $this->searchObject = SearchObjectFactory::initSearchObject('WorldCat'); $interface->assign('worldCatSearchTypes', $this->searchObject->getBasicTypes()); }
function launch() { global $interface; global $configArray; if (isset($_REQUEST['searchId'])) { $_SESSION['searchId'] = $_REQUEST['searchId']; $interface->assign('searchId', $_SESSION['searchId']); } else { if (isset($_SESSION['searchId'])) { $interface->assign('searchId', $_SESSION['searchId']); } } $interface->assign('overDriveVersion', isset($configArray['OverDrive']['interfaceVersion']) ? $configArray['OverDrive']['interfaceVersion'] : 1); $this->id = strip_tags($_REQUEST['id']); $interface->assign('id', $this->id); $recordDriver = new OverDriveRecordDriver($this->id); if (!$recordDriver->isValid()) { $interface->setTemplate('../Record/invalidRecord.tpl'); $interface->display('layout.tpl'); die; } else { $interface->assign('recordDriver', $recordDriver); //Load status summary require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php'; $driver = OverDriveDriverFactory::getDriver(); $holdings = $driver->getHoldings($recordDriver); $scopedAvailability = $driver->getScopedAvailability($recordDriver); $holdingsSummary = $driver->getStatusSummary($this->id, $scopedAvailability, $holdings); if (PEAR_Singleton::isError($holdingsSummary)) { PEAR_Singleton::raiseError($holdingsSummary); } $interface->assign('holdingsSummary', $holdingsSummary); //Load the citations $this->loadCitations($recordDriver); // Retrieve User Search History $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); //Get Next/Previous Links $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local'; $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init($searchSource); $searchObject->getNextPrevLinks(); // Set Show in Main Details Section options for templates // (needs to be set before moreDetailsOptions) global $library; foreach ($library->showInMainDetails as $detailoption) { $interface->assign($detailoption, true); } $interface->setPageTitle($recordDriver->getTitle()); $interface->assign('moreDetailsOptions', $recordDriver->getMoreDetailsOptions()); // Display Page $interface->assign('sidebar', 'OverDrive/full-record-sidebar.tpl'); $interface->assign('moreDetailsTemplate', 'GroupedWork/moredetails-accordion.tpl'); $interface->setTemplate('view.tpl'); $interface->display('layout.tpl'); } }
function launch() { global $interface; global $configArray; if (isset($_REQUEST['searchId'])) { $_SESSION['searchId'] = $_REQUEST['searchId']; $interface->assign('searchId', $_SESSION['searchId']); } else { if (isset($_SESSION['searchId'])) { $interface->assign('searchId', $_SESSION['searchId']); } } $this->id = strip_tags($_REQUEST['id']); $interface->assign('id', $this->id); $recordDriver = new RestrictedEContentDriver($this->id); if (!$recordDriver->isValid()) { $interface->setTemplate('../Record/invalidRecord.tpl'); $interface->display('layout.tpl'); die; } else { $interface->assign('recordDriver', $recordDriver); $items = $recordDriver->getItemsFast(); $interface->assign('items', $items); $summaryActions = array(); foreach ($items as $item) { foreach ($item['actions'] as $key => $action) { if ($action['showInSummary']) { $summaryActions[$key] = $action; } } } $interface->assign('summaryActions', $summaryActions); //Load the citations $this->loadCitations($recordDriver); // Retrieve User Search History $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); //Get Next/Previous Links $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local'; $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init($searchSource); $searchObject->getNextPrevLinks(); // Set Show in Main Details Section options for templates // (needs to be set before moreDetailsOptions) global $library; foreach ($library->showInMainDetails as $detailoption) { $interface->assign($detailoption, true); } $interface->setPageTitle($recordDriver->getTitle()); $interface->assign('moreDetailsOptions', $recordDriver->getMoreDetailsOptions()); // Display Page $interface->assign('sidebar', 'RestrictedEContent/full-record-sidebar.tpl'); $interface->assign('moreDetailsTemplate', 'GroupedWork/moredetails-accordion.tpl'); $interface->setTemplate('view.tpl'); $interface->display('layout.tpl'); } }
/** * Standard setup method. * * @return void * @access public */ public function setUp() { global $configArray; $this->oldConfigArray = $configArray; // Load the default configuration: $configArray = parse_ini_file(dirname(__FILE__) . '/../../conf/config.ini', true); $this->_searchObject = SearchObjectFactory::initSearchObject('Solr'); // TODO: load from config $this->field = "unit_daterange"; }
/** * Constructor. * * @access public */ public function __construct() { parent::__construct(); $this->_searchObject = SearchObjectFactory::initSearchObject(); // Load the desired facet information... $config = getExtraConfigArray('facets'); if (isset($config['MapFacets']['location'])) { $this->_locationFacet = is_array($config['MapFacets']['location']) ? $config['MapFacets']['location'] : array($config['MapFacets']['location']); } }
/** * Constructor * * @access public */ public function __construct() { global $interface; if (!$interface->get_template_vars('pciEnabled')) { PEAR::raiseError(new PEAR_Error("PCI is not enabled.")); } $interface->assign('currentTab', 'PCI'); // Send Summon search types to the template so the basic search box can // function on all pages of the PCI UI. $this->searchObject = SearchObjectFactory::initSearchObject('PCI'); $interface->assign('PCISearchTypes', $this->searchObject->getBasicTypes()); }
/** * Process incoming parameters and display the page. * * @return void * @access public */ public function launch() { global $configArray; global $interface; global $user; // Fetch List object $list = User_list::staticGet($_GET['id']); if (!$list->public && $list->user_id != $user->id) { PEAR::raiseError(new PEAR_Error(translate('list_access_denied'))); } $interface->assign('list', $list); $interface->assign('publicList', true); $interface->assign('ownList', $list->user_id == $user->id); $date = new VuFindDate(); if (strtotime($list->modified) !== false && strtotime($list->modified) > 0) { $interface->assign('listModified', $date->convertToDisplayDate('Y-m-d H:i:s', $list->modified)); } // Load the User object for the owner of the list (if necessary): if ($user && $user->id == $list->user_id) { $listUser = $user; } else { $listUser = User::staticGet($list->user_id); } $listOwner = null; if ($listUser->email && ($pos = strpos($listUser->email, '@')) !== false) { $listOwner = substr($listUser->email, 0, $pos); } else { if ($listUser->firstname && $listUser->lastname) { $listOwner = "{$listUser->firstname} {$listUser->lastname}"; } } if ($listOwner) { $interface->assign('listUsername', $listOwner); } $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init(); $interface->assign('viewList', $searchObject->getViewList()); // Build Favorites List $favorites = $list->getResources(isset($_GET['tag']) ? $_GET['tag'] : null); // Create a handler for displaying favorites and use it to assign // appropriate template variables: $favList = new FavoriteHandler($favorites, $listUser, $list->id, false); $favList->initPublicListView($searchObject->getView(), $listOwner); $favList->assign(); $interface->assign('recordSet', $interface->get_template_vars('resourceList')); $interface->assign('openUrlAutoCheck', true); $currentView = $searchObject->getView(); $interface->assign('subpage', 'Search/list-' . $currentView . '.tpl'); $interface->setTemplate('home.tpl'); $interface->setPageTitle($list->title); $interface->display('layout.tpl'); }
function launch() { global $interface; $interface->caching = false; // Retrieve User Search History $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); // Initialise from the current search globals $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init(); // TODO : Stats $result = $searchObject->processSearch(); if (PEAR_Singleton::isError($result)) { PEAR_Singleton::raiseError($result->getMessage()); } $interface->assign('sortList', $searchObject->getSortList()); $interface->assign('lookfor', $searchObject->displayQuery()); $interface->assign('searchType', $searchObject->getSearchType()); $interface->assign('searchIndex', $searchObject->getSearchIndex()); $interface->assign('qtime', round($searchObject->getQuerySpeed(), 2)); $summary = $searchObject->getResultSummary(); // Post processing, remember that the REAL results here with regards to // numbers and pagination are the author facet, not the document // results from the solr index. So access '$summary' with care. $page = $summary['page']; $limit = $summary['perPage']; // The search object will have returned an array of author facets that // is offset to display the current page of results but which has more // than a single page worth of content. This allows a user to dig deeper // and deeper into the result set even though we have no way of finding // out the exact count of results without risking a memory overflow or // long delay. We need to use the current page information to adjust the // known total count accordingly, and we need to use the page size to // crop off extra results when displaying the list to the user. // See VUFIND-127 in JIRA for more details. $authors = $result['facet_counts']['facet_fields']['authorStr']; $cnt = ($page - 1) * $limit + count($authors); $interface->assign('recordSet', array_slice($authors, 0, $limit)); $interface->assign('recordCount', $cnt); $interface->assign('recordStart', ($page - 1) * $limit + 1); if ($cnt < $limit || $page * $limit > $cnt) { $interface->assign('recordEnd', $cnt); } else { $interface->assign('recordEnd', $page * $limit); } $link = $searchObject->renderLinkPageTemplate(); $options = array('totalItems' => $cnt, 'fileName' => $link); $pager = new VuFindPager($options); $interface->assign('pageLinks', $pager->getLinks()); $interface->setPageTitle('Author Browse'); $interface->setTemplate('list.tpl'); $interface->display('layout.tpl'); }
/** * Constructor * * Establishes base settings for making recommendations. * * @param object $searchObject The SearchObject requesting recommendations. * @param string $params Colon-separated settings from config file. * * @access public */ public function __construct($searchObject, $params) { // Parse out parameters: $params = explode(':', $params); $requestParam = empty($params[0]) ? 'lookfor' : $params[0]; $limit = isset($params[1]) && is_numeric($params[1]) && $params[1] > 0 ? intval($params[1]) : 5; // We don't actually care about the passed-in search object; let's just // create our own! $this->_searchObject = SearchObjectFactory::initSearchObject('Summon'); $this->_searchObject->disableLogging(); $this->_searchObject->setBasicQuery($_REQUEST[$requestParam]); $this->_searchObject->setLimit($limit); }
/** * Test initialization of SearchObjects * * @return void * @access public */ public function testInitSearchObject() { // Test valid options: $options = array('Solr', 'SolrAuth', 'Summon', 'WorldCat'); foreach ($options as $current) { $obj = SearchObjectFactory::initSearchObject($current); $this->assertTrue(is_object($obj)); $this->assertEquals('SearchObject_' . $current, get_class($obj)); } // Test invalid option: $obj = SearchObjectFactory::initSearchObject('IllegalGarbage'); $this->assertFalse($obj); }
/** * Constructor * * Establishes base settings for making recommendations. * * @param object $searchObject The SearchObject requesting recommendations. * @param string $requestParam $_REQUEST field containing search terms (ignored * if $searchObject is Summon type). * * @access public */ public function __construct($searchObject, $requestParam) { // If we received a Summon search object, we'll use that. If not, we need // to create a new Summon search object using the specified REQUEST // parameter for search terms. if (strtolower(get_class($searchObject)) == 'searchobject_summon') { $this->_searchObject = $searchObject; } else { $this->_searchObject = SearchObjectFactory::initSearchObject('Summon'); $this->_searchObject->disableLogging(); $this->_searchObject->setBasicQuery($_REQUEST[$requestParam]); $this->_searchObject->processSearch(true); } }
function launch() { global $interface; // Create our search object $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->initAdvancedFacets(); // We don't want this search in the search history $searchObject->disableLogging(); // Go get the facets $searchObject->processSearch(); $facetList = $searchObject->getFacetList(); // Shutdown the search object $searchObject->close(); // Load a saved search, if any: $savedSearch = $this->loadSavedSearch(); // Process the facets for appropriate display on the Advanced Search screen: $facets = $this->processFacets($facetList, $savedSearch); //check to see if we have a facet for format category since we want to show those //as icons if (array_key_exists('format_category', $facetList)) { $label = $facetList['format_category']['label']; foreach ($facets[$label]['values'] as $key => $optionInfo) { $optionInfo['imageName'] = str_replace(" ", "", strtolower($key)) . '.png'; $facets[$label]['values'][$key] = $optionInfo; } $interface->assign('formatCategoryLimit', $facets[$label]['values']); unset($facets[$label]); } $interface->assign('facetList', $facets); // Integer for % width of each column (be careful to avoid divide by zero!) $columnWidth = count($facets) > 1 ? round(100 / count($facets), 0) : 0; $interface->assign('columnWidth', $columnWidth); // Process settings to control special-purpose facets not supported by the // more generic configuration options. $specialFacets = $searchObject->getFacetSetting('Advanced_Settings', 'special_facets'); if (stristr($specialFacets, 'illustrated')) { $interface->assign('illustratedLimit', $this->getIllustrationSettings($savedSearch)); } // Send search type settings to the template $interface->assign('advSearchTypes', $searchObject->getAdvancedTypes()); // If we found a saved search, let's assign some details to the interface: if ($savedSearch) { $interface->assign('searchDetails', $savedSearch->getSearchTerms()); $interface->assign('searchFilters', $savedSearch->getFilterList()); } $interface->setPageTitle('Advanced Search'); $interface->setTemplate('advanced.tpl'); $interface->assign('sidebar', 'Search/results-sidebar.tpl'); $interface->display('layout.tpl'); }
public function __construct($searchObject, $params) { // Parse out parameters: $params = explode(':', $params); $requestParam = empty($params[0]) ? 'lookfor' : $params[0]; $limit = isset($params[1]) && is_numeric($params[1]) && $params[1] > 0 ? intval($params[1]) : 5; // We don't actually care about the passed-in search object; let's just // create our own! $this->searchObject = SearchObjectFactory::initSearchObject(); // Not really a browse, but browse searches are similar in that they // have no facets (until added later) and no spellchecking $this->searchObject->initBrowseScreen(); $this->searchObject->disableLogging(); $this->searchObject->setBasicQuery($_REQUEST[$requestParam]); $this->searchObject->setLimit($limit); }
/** * Constructor. * * @access public */ public function __construct() { global $action; parent::__construct(); if (isset($_REQUEST['collection'])) { $this->_searchObject = SearchObjectFactory::initSearchObject('SolrCollection'); $action = isset($_REQUEST['collectionAction']) ? $_REQUEST['collectionAction'] : 'Home'; } else { $this->_searchObject = SearchObjectFactory::initSearchObject(); } // Load the desired facet information... $config = getExtraConfigArray('facets'); if (isset($config['SpecialFacets']['dateVis'])) { $this->_dateFacets = is_array($config['SpecialFacets']['dateVis']) ? $config['SpecialFacets']['dateVis'] : array($config['SpecialFacets']['dateVis']); } }
/** * Constructor * * @access public */ public function __construct() { global $action; parent::__construct(); if (isset($_REQUEST['collection'])) { $this->searchObject = SearchObjectFactory::initSearchObject('SolrCollection'); $action = isset($_REQUEST['collectionAction']) ? $_REQUEST['collectionAction'] : 'Home'; } else { $this->searchObject = SearchObjectFactory::initSearchObject(); } // Load the desired facet information... $config = getExtraConfigArray('facets'); if (isset($config['SpecialFacets']['dateRangeVis'])) { list($this->filterField, $this->dateFacet) = explode(':', $config['SpecialFacets']['dateRangeVis'], 2); } }
/** * Constructor * * @access public */ public function __construct() { global $interface; // Don't allow crawling of MetaLib results at all $this->disallowBots(); if (!$interface->get_template_vars('metalibEnabled')) { PEAR::raiseError(new PEAR_Error("MetaLib is not enabled.")); } $interface->assign('currentTab', 'MetaLib'); // Send MetaLib search types to the template so the basic search box can // function on all pages of the MetaLib. $this->searchObject = SearchObjectFactory::initSearchObject('MetaLib'); $sets = $this->searchObject->getSearchSets(); if (isset($_REQUEST['set']) && strncmp($_REQUEST['set'], '_ird:', 5) == 0) { $set = $_REQUEST['set']; $ird = substr($set, 5); if (preg_match('/\\W/', $ird)) { PEAR::raiseError(new PEAR_Error('Invalid parameter')); } $irdInfo = $this->searchObject->getIRDInfo($ird); if ($irdInfo === false) { PEAR::raiseError(new PEAR_Error('Invalid parameter')); } // Append to recently used search sets and select as active unset($_SESSION['recentMetaLibDatabases'][$set]); $_SESSION['recentMetaLibDatabases'][$set] = $irdInfo['name']; $interface->assign('searchSet', "_ird:{$ird}"); } else { // Select first set by default $interface->assign('searchSet', current(array_keys($sets))); } if ($this->isBrowseEnabled()) { include_once 'services/Browse/Database.php'; $action = new Database(); $interface->assign('browseDatabases', $action->getBrowseUrl('Database')); } $interface->assign('metalibSearchTypes', $this->searchObject->getBasicTypes()); $interface->assign('metalibSearchSets', $sets); $interface->assign('metalibRecentDatabases', $this->searchObject->getRecentDatabases()); // Increase max execution time to allow slow MetaLib searches to complete set_time_limit(60); }
function launch() { global $interface; // Initialise the search object $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->initBrowseScreen(); $searchObject->disableLogging(); // Query all records and facet on the dewey-hundreds field: $searchObject->addFacet('dewey-hundreds'); $searchObject->setFacetSortOrder(false); $searchObject->setQueryString('*:*'); $result = $searchObject->processSearch(); // Retrieve the facet data and assign to the interface $defaultList = $result['facet_counts']['facet_fields']['dewey-hundreds']; $interface->assign('defaultList', $defaultList); // Finish off the interface and display $interface->setPageTitle('Browse the Collection'); $interface->setTemplate('dewey.tpl'); $interface->display('layout.tpl'); }
function __construct() { $this->searchObject = SearchObjectFactory::initSearchObject(); }
/** * Save a user's comment to the database. * * @param object $user User whose comment is being saved. * * @return bool True for success, false for failure. * @access public */ public static function saveComment($user) { // What record are we operating on? if (!isset($_GET['id'])) { return false; } if ($_REQUEST['commentId'] == 0) { $searchObject = SearchObjectFactory::initSearchObject(); $query = 'local_ids_str_mv:"' . addcslashes($_GET['id'], '"') . '"'; $searchObject->disableLogging(); $searchObject->setQueryString($query); $result = $searchObject->processSearch(); $searchObject->close(); if (PEAR::isError($result)) { PEAR::raiseError($result->getMessage()); } if ($result['response']['numFound'] == 0) { $idArray = array($_GET['id']); } else { $idArray = $result['response']['docs'][0]["local_ids_str_mv"]; } if ($_REQUEST['type'] == 1) { $commentsByUser = new Comments(); $commentList = $commentsByUser->getComments($_REQUEST['recordId']); foreach ($commentList as $comment) { if ($comment->user_id == $user->id) { return false; } } } $comments = new Comments(); $comments->user_id = $user->id; $rating = isset($_REQUEST['rating']) ? (double) $_REQUEST['rating'] : 0; $comments->rating = $rating > 0 && $rating <= 5 ? $rating : null; $comments->comment = $_REQUEST['comment']; $comments->type = $_REQUEST['type']; $comments->created = date('Y-m-d H:i:s'); $comments->insert(); $comments->addLinks($idArray); return true; } else { $comments = new Comments(); $comments->get($_REQUEST['commentId']); if ($comments->user_id == $user->id) { $comments->comment = $_REQUEST['comment']; $comments->rating = $_REQUEST['rating']; $comments->updated = date('Y-m-d H:i:s'); $comments->update(); return true; } return false; } }
function GetSuggestions() { global $interface; global $library; global $configArray; //Make sure to initialize solr $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init(); //Get suggestions for the user $suggestions = Suggestions::getSuggestions(); $interface->assign('suggestions', $suggestions); if (isset($library)) { $interface->assign('showRatings', $library->showRatings); } else { $interface->assign('showRatings', 1); } //return suggestions as json for display in the title scroller $titles = array(); foreach ($suggestions as $suggestion) { $titles[] = array('id' => $suggestion['titleInfo']['id'], 'image' => $configArray['Site']['coverUrl'] . "/bookcover.php?id=" . $suggestion['titleInfo']['id'] . "&issn=" . $suggestion['titleInfo']['issn'] . "&isn=" . $suggestion['titleInfo']['isbn10'] . "&size=medium&upc=" . $suggestion['titleInfo']['upc'] . "&category=" . $suggestion['titleInfo']['format_category'][0], 'title' => $suggestion['titleInfo']['title'], 'author' => $suggestion['titleInfo']['author'], 'basedOn' => $suggestion['basedOn']); } foreach ($titles as $key => $rawData) { $formattedTitle = "<div id=\"scrollerTitleSuggestion{$key}\" class=\"scrollerTitle\">" . '<a href="' . $configArray['Site']['path'] . "/Record/" . $rawData['id'] . '" id="descriptionTrigger' . $rawData['id'] . '">' . "<img src=\"{$rawData['image']}\" class=\"scrollerTitleCover\" alt=\"{$rawData['title']} Cover\"/>" . "</a></div>" . "<div id='descriptionPlaceholder{$rawData['id']}' style='display:none'></div>"; $rawData['formattedTitle'] = $formattedTitle; $titles[$key] = $rawData; } $return = array('titles' => $titles, 'currentIndex' => 0); return json_encode($return); //return $interface->fetch('MyResearch/ajax-suggestionsList.tpl'); }
function launch() { global $interface; global $configArray; global $timer; global $analytics; /** @var string|LibrarySearchSource|LocationSearchSource $searchSource */ $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local'; if (preg_match('/library\\d+/', $searchSource)) { $trimmedId = str_replace('library', '', $searchSource); $searchSourceObj = new LibrarySearchSource(); $searchSourceObj->id = $trimmedId; if ($searchSourceObj->find(true)) { $searchSource = $searchSourceObj; } } if (isset($_REQUEST['replacementTerm'])) { $replacementTerm = $_REQUEST['replacementTerm']; $interface->assign('replacementTerm', $replacementTerm); $oldTerm = $_REQUEST['lookfor']; $interface->assign('oldTerm', $oldTerm); $_REQUEST['lookfor'] = $replacementTerm; $_GET['lookfor'] = $replacementTerm; $oldSearchUrl = $_SERVER['REQUEST_URI']; $oldSearchUrl = str_replace('replacementTerm=' . urlencode($replacementTerm), 'disallowReplacements', $oldSearchUrl); $interface->assign('oldSearchUrl', $oldSearchUrl); } // Include Search Engine Class require_once ROOT_DIR . '/sys/Solr.php'; $timer->logTime('Include search engine'); //Check to see if the year has been set and if so, convert to a filter and resend. $dateFilters = array('publishDate'); foreach ($dateFilters as $dateFilter) { if (isset($_REQUEST[$dateFilter . 'yearfrom']) || isset($_REQUEST[$dateFilter . 'yearto'])) { $queryParams = $_GET; $yearFrom = preg_match('/^\\d{2,4}$/', $_REQUEST[$dateFilter . 'yearfrom']) ? $_REQUEST[$dateFilter . 'yearfrom'] : '*'; $yearTo = preg_match('/^\\d{2,4}$/', $_REQUEST[$dateFilter . 'yearto']) ? $_REQUEST[$dateFilter . 'yearto'] : '*'; if (strlen($yearFrom) == 2) { $yearFrom = '19' . $yearFrom; } else { if (strlen($yearFrom) == 3) { $yearFrom = '0' . $yearFrom; } } if (strlen($yearTo) == 2) { $yearTo = '19' . $yearTo; } else { if (strlen($yearFrom) == 3) { $yearTo = '0' . $yearTo; } } if ($yearTo != '*' && $yearFrom != '*' && $yearTo < $yearFrom) { $tmpYear = $yearTo; $yearTo = $yearFrom; $yearFrom = $tmpYear; } unset($queryParams['module']); unset($queryParams['action']); unset($queryParams[$dateFilter . 'yearfrom']); unset($queryParams[$dateFilter . 'yearto']); if (!isset($queryParams['sort'])) { $queryParams['sort'] = 'year'; } $queryParamStrings = array(); foreach ($queryParams as $paramName => $queryValue) { if (is_array($queryValue)) { foreach ($queryValue as $arrayValue) { if (strlen($arrayValue) > 0) { $queryParamStrings[] = $paramName . '[]=' . $arrayValue; } } } else { if (strlen($queryValue)) { $queryParamStrings[] = $paramName . '=' . $queryValue; } } } if ($yearFrom != '*' || $yearTo != '*') { $queryParamStrings[] = "&filter[]={$dateFilter}:[{$yearFrom}+TO+{$yearTo}]"; } $queryParamString = join('&', $queryParamStrings); header("Location: {$configArray['Site']['path']}/Search/Results?{$queryParamString}"); exit; } } $rangeFilters = array('lexile_score', 'accelerated_reader_reading_level', 'accelerated_reader_point_value'); foreach ($rangeFilters as $filter) { if (isset($_REQUEST[$filter . 'from']) && strlen($_REQUEST[$filter . 'from']) > 0 || isset($_REQUEST[$filter . 'to']) && strlen($_REQUEST[$filter . 'to']) > 0) { $queryParams = $_GET; $from = isset($_REQUEST[$filter . 'from']) && preg_match('/^\\d*(\\.\\d*)?$/', $_REQUEST[$filter . 'from']) ? $_REQUEST[$filter . 'from'] : '*'; $to = isset($_REQUEST[$filter . 'to']) && preg_match('/^\\d*(\\.\\d*)?$/', $_REQUEST[$filter . 'to']) ? $_REQUEST[$filter . 'to'] : '*'; if ($to != '*' && $from != '*' && $to < $from) { $tmpFilter = $to; $to = $from; $from = $tmpFilter; } unset($queryParams['module']); unset($queryParams['action']); unset($queryParams[$filter . 'from']); unset($queryParams[$filter . 'to']); $queryParamStrings = array(); foreach ($queryParams as $paramName => $queryValue) { if (is_array($queryValue)) { foreach ($queryValue as $arrayValue) { if (strlen($arrayValue) > 0) { $queryParamStrings[] = $paramName . '[]=' . $arrayValue; } } } else { if (strlen($queryValue)) { $queryParamStrings[] = $paramName . '=' . $queryValue; } } } if ($from != '*' || $to != '*') { $queryParamStrings[] = "&filter[]={$filter}:[{$from}+TO+{$to}]"; } $queryParamString = join('&', $queryParamStrings); header("Location: {$configArray['Site']['path']}/Search/Results?{$queryParamString}"); exit; } } // Initialise from the current search globals /** @var SearchObject_Solr $searchObject */ $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init($searchSource); $timer->logTime("Init Search Object"); // Build RSS Feed for Results (if requested) if ($searchObject->getView() == 'rss') { // Throw the XML to screen echo $searchObject->buildRSS(); // And we're done exit; } else { if ($searchObject->getView() == 'excel') { // Throw the Excel spreadsheet to screen for download echo $searchObject->buildExcel(); // And we're done exit; } } // TODO : Investigate this... do we still need // If user wants to print record show directly print-dialog box if (isset($_GET['print'])) { $interface->assign('print', true); } // Set Interface Variables // Those we can construct BEFORE the search is executed $interface->setPageTitle('Search Results'); $interface->assign('sortList', $searchObject->getSortList()); $interface->assign('rssLink', $searchObject->getRSSUrl()); $interface->assign('excelLink', $searchObject->getExcelUrl()); $timer->logTime('Setup Search'); // Process Search $result = $searchObject->processSearch(true, true); if (PEAR_Singleton::isError($result)) { PEAR_Singleton::raiseError($result->getMessage()); } $timer->logTime('Process Search'); // Some more variables // Those we can construct AFTER the search is executed, but we need // no matter whether there were any results $interface->assign('qtime', round($searchObject->getQuerySpeed(), 2)); $interface->assign('spellingSuggestions', $searchObject->getSpellingSuggestions()); $interface->assign('lookfor', $searchObject->displayQuery()); $interface->assign('searchType', $searchObject->getSearchType()); // Will assign null for an advanced search $interface->assign('searchIndex', $searchObject->getSearchIndex()); // We'll need recommendations no matter how many results we found: $interface->assign('topRecommendations', $searchObject->getRecommendationsTemplates('top')); $interface->assign('sideRecommendations', $searchObject->getRecommendationsTemplates('side')); // 'Finish' the search... complete timers and log search history. $searchObject->close(); $interface->assign('time', round($searchObject->getTotalSpeed(), 2)); // Show the save/unsave code on screen // The ID won't exist until after the search has been put in the search history // so this needs to occur after the close() on the searchObject $interface->assign('showSaved', true); $interface->assign('savedSearch', $searchObject->isSavedSearch()); $interface->assign('searchId', $searchObject->getSearchId()); $currentPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; $interface->assign('page', $currentPage); //Enable and disable functionality based on library settings //This must be done before we process each result global $library; /** @var Location $locationSingleton */ global $locationSingleton; $location = $locationSingleton->getActiveLocation(); $showHoldButton = 1; $showHoldButtonInSearchResults = 1; $interface->assign('showNotInterested', false); if (isset($library) && $location != null) { $interface->assign('showFavorites', $library->showFavorites); $interface->assign('showComments', $library->showComments); $showHoldButton = $location->showHoldButton == 1 && $library->showHoldButton == 1 ? 1 : 0; $showHoldButtonInSearchResults = $location->showHoldButton == 1 && $library->showHoldButtonInSearchResults == 1 ? 1 : 0; } else { if ($location != null) { $interface->assign('showFavorites', 1); $showHoldButton = $location->showHoldButton; } else { if (isset($library)) { $interface->assign('showFavorites', $library->showFavorites); $showHoldButton = $library->showHoldButton; $showHoldButtonInSearchResults = $library->showHoldButtonInSearchResults; $interface->assign('showComments', $library->showComments); } else { $interface->assign('showFavorites', 1); $interface->assign('showComments', 1); } } } if ($showHoldButton == 0) { $showHoldButtonInSearchResults = 0; } $interface->assign('showHoldButton', $showHoldButtonInSearchResults); $interface->assign('page_body_style', 'sidebar_left'); $interface->assign('overDriveVersion', isset($configArray['OverDrive']['interfaceVersion']) ? $configArray['OverDrive']['interfaceVersion'] : 1); //Check to see if we should show unscoped results $enableUnscopedSearch = false; $searchLibrary = Library::getSearchLibrary(); if ($searchLibrary != null && $searchLibrary->showMarmotResultsAtEndOfSearch) { if (is_object($searchSource)) { $enableUnscopedSearch = $searchSource->catalogScoping != 'unscoped'; $unscopedSearch = clone $searchObject; } else { $searchSources = new SearchSources(); $searchOptions = $searchSources->getSearchSources(); if (isset($searchOptions['marmot'])) { $unscopedSearch = clone $searchObject; $enableUnscopedSearch = true; } } } $enableProspectorIntegration = isset($configArray['Content']['Prospector']) ? $configArray['Content']['Prospector'] : false; $showRatings = 1; $showProspectorResultsAtEndOfSearch = true; if (isset($library)) { $enableProspectorIntegration = $library->enablePospectorIntegration == 1; $showRatings = $library->showRatings; $showProspectorResultsAtEndOfSearch = $library->showProspectorResultsAtEndOfSearch == 1; } $interface->assign('showRatings', $showRatings); $numProspectorTitlesToLoad = 0; $numUnscopedTitlesToLoad = 0; // Save the ID of this search to the session so we can return to it easily: $_SESSION['lastSearchId'] = $searchObject->getSearchId(); // Save the URL of this search to the session so we can return to it easily: $_SESSION['lastSearchURL'] = $searchObject->renderSearchUrl(); if (is_object($searchSource)) { $translatedSearch = $searchSource->label; } else { $allSearchSources = SearchSources::getSearchSources(); if (!isset($allSearchSources[$searchSource]) && $searchSource == 'marmot') { $searchSource = 'local'; } $translatedSearch = $allSearchSources[$searchSource]['name']; } $analytics->addSearch($translatedSearch, $searchObject->displayQuery(), $searchObject->isAdvanced(), $searchObject->getFullSearchType(), $searchObject->hasAppliedFacets(), $searchObject->getResultTotal()); if ($searchObject->getResultTotal() < 1) { //We didn't find anything. Look for search Suggestions //Don't try to find suggestions if facets were applied $autoSwitchSearch = false; $disallowReplacements = isset($_REQUEST['disallowReplacements']) || isset($_REQUEST['replacementTerm']); if (!$disallowReplacements && (!isset($facetSet) || count($facetSet) == 0)) { require_once ROOT_DIR . '/services/Search/lib/SearchSuggestions.php'; $searchSuggestions = new SearchSuggestions(); $commonSearches = $searchSuggestions->getCommonSearchesMySql($searchObject->displayQuery(), $searchObject->getSearchIndex()); //If the first search in the list is used 10 times more than the next, just show results for that $numSuggestions = count($commonSearches); if ($numSuggestions == 1) { $autoSwitchSearch = true; } elseif ($numSuggestions >= 2) { $firstTimesSearched = $commonSearches[0]['numSearches']; $secondTimesSearched = $commonSearches[1]['numSearches']; if ($firstTimesSearched / $secondTimesSearched > 10) { $autoSwitchSearch = true; } } $interface->assign('autoSwitchSearch', $autoSwitchSearch); if ($autoSwitchSearch) { //Get search results for the new search $interface->assign('oldTerm', $searchObject->displayQuery()); $interface->assign('newTerm', $commonSearches[0]['phrase']); $thisUrl = $_SERVER['REQUEST_URI']; $thisUrl = $thisUrl . "&replacementTerm=" . urlencode($commonSearches[0]['phrase']); header("Location: " . $thisUrl); exit; } $interface->assign('searchSuggestions', $commonSearches); } //Var for the IDCLREADER TEMPLATE $interface->assign('ButtonBack', true); $interface->assign('ButtonHome', true); $interface->assign('MobileTitle', 'No Results Found'); // No record found $interface->setTemplate('list-none.tpl'); $interface->assign('recordCount', 0); // Was the empty result set due to an error? $error = $searchObject->getIndexError(); if ($error !== false) { // If it's a parse error or the user specified an invalid field, we // should display an appropriate message: if (stristr($error, 'org.apache.lucene.queryParser.ParseException') || preg_match('/^undefined field/', $error)) { $interface->assign('parseError', true); // Unexpected error -- let's treat this as a fatal condition. } else { PEAR_Singleton::raiseError(new PEAR_Error('Unable to process query<br />' . 'Solr Returned: ' . $error)); } } $numProspectorTitlesToLoad = 10; $numUnscopedTitlesToLoad = 10; $timer->logTime('no hits processing'); } else { if ($searchObject->getResultTotal() == 1 && (strpos($searchObject->displayQuery(), 'id') === 0 || $searchObject->getSearchType() == 'id')) { //Redirect to the home page for the record $recordSet = $searchObject->getResultRecordSet(); $record = reset($recordSet); $_SESSION['searchId'] = $searchObject->getSearchId(); if ($record['recordtype'] == 'list') { $listId = substr($record['id'], 4); header("Location: " . $configArray['Site']['path'] . "/MyResearch/MyList/{$listId}"); exit; } elseif ($record['recordtype'] == 'econtentRecord') { $shortId = str_replace('econtentRecord', '', $record['id']); header("Location: " . $configArray['Site']['path'] . "/EcontentRecord/{$shortId}/Home"); exit; } else { header("Location: " . $configArray['Site']['path'] . "/Record/{$record['id']}/Home"); exit; } } else { $timer->logTime('save search'); // Assign interface variables $summary = $searchObject->getResultSummary(); $interface->assign('recordCount', $summary['resultTotal']); $interface->assign('recordStart', $summary['startRecord']); $interface->assign('recordEnd', $summary['endRecord']); $facetSet = $searchObject->getFacetList(); $interface->assign('facetSet', $facetSet); //Check to see if a format category is already set $categorySelected = false; if (isset($facetSet['top'])) { foreach ($facetSet['top'] as $cluster) { if ($cluster['label'] == 'Category') { foreach ($cluster['list'] as $thisFacet) { if ($thisFacet['isApplied']) { $categorySelected = true; } } } } } $interface->assign('categorySelected', $categorySelected); $timer->logTime('load selected category'); // Big one - our results $recordSet = $searchObject->getResultRecordHTML(); $interface->assign('recordSet', $recordSet); $timer->logTime('load result records'); // Setup Display $interface->assign('sitepath', $configArray['Site']['path']); $interface->assign('subpage', 'Search/list-list.tpl'); $interface->setTemplate('list.tpl'); //Var for the IDCLREADER TEMPLATE $interface->assign('ButtonBack', true); $interface->assign('ButtonHome', true); $interface->assign('MobileTitle', 'Search Results'); // Process Paging $link = $searchObject->renderLinkPageTemplate(); $options = array('totalItems' => $summary['resultTotal'], 'fileName' => $link, 'perPage' => $summary['perPage']); $pager = new VuFindPager($options); $interface->assign('pageLinks', $pager->getLinks()); if ($pager->isLastPage()) { $numProspectorTitlesToLoad = 5; $numUnscopedTitlesToLoad = 5; } $timer->logTime('finish hits processing'); } } if ($numProspectorTitlesToLoad > 0 && $enableProspectorIntegration && $showProspectorResultsAtEndOfSearch) { $interface->assign('prospectorNumTitlesToLoad', $numProspectorTitlesToLoad); $interface->assign('prospectorSavedSearchId', $searchObject->getSearchId()); } else { $interface->assign('prospectorNumTitlesToLoad', 0); } if ($enableUnscopedSearch && isset($unscopedSearch)) { $unscopedSearch->setLimit($numUnscopedTitlesToLoad * 4); $unscopedSearch->disableScoping(); $unscopedSearch->processSearch(false, false); $numUnscopedResults = $unscopedSearch->getResultTotal(); $interface->assign('numUnscopedResults', $numUnscopedResults); $unscopedSearchUrl = $unscopedSearch->renderSearchUrl(); if (preg_match('/searchSource=(.*?)(?:&|$)/', $unscopedSearchUrl)) { $unscopedSearchUrl = preg_replace('/(.*searchSource=)(.*?)(&|$)(.*)/', '$1marmot$3$4', $unscopedSearchUrl); $unscopedSearchUrl = preg_replace('/&/', '&', $unscopedSearchUrl); } else { $unscopedSearchUrl .= "&searchSource=marmot"; } $unscopedSearchUrl .= "&shard="; $interface->assign('unscopedSearchUrl', $unscopedSearchUrl); if ($numUnscopedTitlesToLoad > 0) { $unscopedResults = $unscopedSearch->getSupplementalResultRecordHTML($searchObject->getResultRecordSet(), $numUnscopedTitlesToLoad, $searchObject->getResultTotal()); $interface->assign('unscopedResults', $unscopedResults); } } //Determine whether or not materials request functionality should be enabled $interface->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest()); if ($configArray['Statistics']['enabled'] && isset($_GET['lookfor'])) { require_once ROOT_DIR . '/Drivers/marmot_inc/SearchStat.php'; $searchStat = new SearchStat(); $searchStat->saveSearch(strip_tags($_GET['lookfor']), strip_tags(isset($_GET['type']) ? $_GET['type'] : (isset($_GET['basicType']) ? $_GET['basicType'] : 'Keyword')), $searchObject->getResultTotal()); } // Done, display the page $interface->display('layout.tpl'); }