本文整理汇总了PHP中SearchObjectFactory::initSearchObject方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchObjectFactory::initSearchObject方法的具体用法?PHP SearchObjectFactory::initSearchObject怎么用?PHP SearchObjectFactory::initSearchObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchObjectFactory
的用法示例。
在下文中一共展示了SearchObjectFactory::initSearchObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: launch
/**
* 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);
}
示例2: launch
/**
* 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');
}
示例3: __construct
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;
}
}
示例4: launch
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);
}
示例5: launch
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');
}
示例6: __construct
/**
* Constructor
*
* @access public
*/
public function __construct()
{
global $action;
parent::__construct();
$this->searchObject = SearchObjectFactory::initSearchObject('PCI');
$this->filterField = 'creationdate';
$this->dateFacet = 'creationdate';
}
示例7: noop
/**
* 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);
}
示例8: __construct
/**
* 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());
}
示例9: setUp
/**
* 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";
}
示例10: __construct
/**
* 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']);
}
}
示例11: launch
function launch()
{
global $interface;
global $configArray;
global $user;
global $library;
// 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->display('layout.tpl');
}
示例12: launch
/**
* 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');
}
示例13: launch
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');
}
示例14: testInitSearchObject
/**
* 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);
}
示例15: __construct
/**
* 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);
}