本文整理汇总了PHP中ArticleSearch::getKeywordsFromSearchFilters方法的典型用法代码示例。如果您正苦于以下问题:PHP ArticleSearch::getKeywordsFromSearchFilters方法的具体用法?PHP ArticleSearch::getKeywordsFromSearchFilters怎么用?PHP ArticleSearch::getKeywordsFromSearchFilters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArticleSearch
的用法示例。
在下文中一共展示了ArticleSearch::getKeywordsFromSearchFilters方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: queryAutocomplete
/**
* AJAX request for search query auto-completion.
* @param $args array
* @param $request Request
* @return JSON string
*/
function queryAutocomplete($args, $request)
{
$this->validate(null, $request);
// Check whether auto-suggest is enabled.
$suggestionList = array();
$lucenePlugin = $this->_getLucenePlugin();
$enabled = (bool) $lucenePlugin->getSetting(0, 'autosuggest');
if ($enabled) {
// Retrieve search criteria from the user input.
$articleSearch = new ArticleSearch();
$searchFilters = $articleSearch->getSearchFilters($request);
// Get the autosuggest input and remove it from
// the filter array.
$autosuggestField = $request->getUserVar('searchField');
$userInput = $searchFilters[$autosuggestField];
if (isset($searchFilters[$autosuggestField])) {
unset($searchFilters[$autosuggestField]);
}
// Instantiate a search request.
$searchRequest = new SolrSearchRequest();
$searchRequest->setJournal($searchFilters['searchJournal']);
$searchRequest->setFromDate($searchFilters['fromDate']);
$searchRequest->setToDate($searchFilters['toDate']);
$keywords = $articleSearch->getKeywordsFromSearchFilters($searchFilters);
$searchRequest->addQueryFromKeywords($keywords);
// Get the web service.
$solrWebService = $lucenePlugin->getSolrWebService();
/* @var $solrWebService SolrWebService */
$suggestions = $solrWebService->getAutosuggestions($searchRequest, $autosuggestField, $userInput, (int) $lucenePlugin->getSetting(0, 'autosuggestType'));
// Prepare a suggestion list as understood by the
// autocomplete JS handler.
foreach ($suggestions as $suggestion) {
$suggestionList[] = array('label' => $suggestion, 'value' => $suggestion);
}
}
// Return the suggestions as JSON message.
$json = new JSONMessage(true, $suggestionList);
return $json->getString();
}
示例2: search
/**
* Show the search form
* @param $args array
* @param $request PKPRequest
*/
function search($args, $request)
{
$this->validate(null, $request);
// Get and transform active filters.
$articleSearch = new ArticleSearch();
$searchFilters = $articleSearch->getSearchFilters($request);
$keywords = $articleSearch->getKeywordsFromSearchFilters($searchFilters);
// Get the range info.
$rangeInfo = $this->getRangeInfo($request, 'search');
// Retrieve results.
$error = '';
$results = $articleSearch->retrieveResults($request, $searchFilters['searchJournal'], $keywords, $error, $searchFilters['fromDate'], $searchFilters['toDate'], $rangeInfo);
// Prepare and display the search template.
$this->setupTemplate($request);
$templateMgr = TemplateManager::getManager($request);
$templateMgr->setCacheability(CACHEABILITY_NO_STORE);
// Result set ordering options.
$orderByOptions = $articleSearch->getResultSetOrderingOptions($request);
$templateMgr->assign('searchResultOrderOptions', $orderByOptions);
$orderDirOptions = $articleSearch->getResultSetOrderingDirectionOptions();
$templateMgr->assign('searchResultOrderDirOptions', $orderDirOptions);
// Result set ordering selection.
list($orderBy, $orderDir) = $articleSearch->getResultSetOrdering($request);
$templateMgr->assign('orderBy', $orderBy);
$templateMgr->assign('orderDir', $orderDir);
// Similar documents.
$templateMgr->assign('simDocsEnabled', true);
// Result set display.
$templateMgr->assign('jsLocaleKeys', array('search.noKeywordError'));
$this->_assignSearchFilters($request, $templateMgr, $searchFilters);
$templateMgr->assign('results', $results);
$templateMgr->assign('error', $error);
$templateMgr->display('search/search.tpl');
}
示例3: search
/**
* Show the search form
* @param $args array
* @param $request PKPRequest
*/
function search($args, &$request)
{
$this->validate();
// Get and transform active filters.
$searchFilters = ArticleSearch::getSearchFilters($request);
$keywords = ArticleSearch::getKeywordsFromSearchFilters($searchFilters);
// Get the range info.
$rangeInfo = $this->getRangeInfo('search');
// Retrieve results.
$error = '';
$results =& ArticleSearch::retrieveResults($searchFilters['searchJournal'], $keywords, $error, $searchFilters['fromDate'], $searchFilters['toDate'], $rangeInfo);
// Prepare and display the search template.
$this->setupTemplate($request);
$templateMgr =& TemplateManager::getManager();
$templateMgr->setCacheability(CACHEABILITY_NO_STORE);
$templateMgr->assign('jsLocaleKeys', array('search.noKeywordError'));
$this->_assignSearchFilters($request, $templateMgr, $searchFilters);
$templateMgr->assign_by_ref('results', $results);
$templateMgr->assign('error', $error);
$templateMgr->display('search/search.tpl');
}