本文整理汇总了PHP中ArticleSearch::retrieveResults方法的典型用法代码示例。如果您正苦于以下问题:PHP ArticleSearch::retrieveResults方法的具体用法?PHP ArticleSearch::retrieveResults怎么用?PHP ArticleSearch::retrieveResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArticleSearch
的用法示例。
在下文中一共展示了ArticleSearch::retrieveResults方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: advancedResults
/**
* Show advanced search results.
* @param $args array
* @param $request PKPRequest
*/
function advancedResults($args, &$request)
{
$this->validate();
$this->setupTemplate($request, true);
$rangeInfo = $this->getRangeInfo('search');
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$searchJournalId = $request->getUserVar('searchJournal');
if (!empty($searchJournalId)) {
$journalDao =& DAORegistry::getDAO('JournalDAO');
$journal =& $journalDao->getById($searchJournalId);
$yearRange = $publishedArticleDao->getArticleYearRange($journal->getId());
} else {
$journal =& $request->getJournal();
$yearRange = $publishedArticleDao->getArticleYearRange(null);
}
// Load the keywords array with submitted values
$keywords = array(null => ArticleSearch::parseQuery($request->getUserVar('query')));
$keywords[ARTICLE_SEARCH_AUTHOR] = ArticleSearch::parseQuery($request->getUserVar('author'));
$keywords[ARTICLE_SEARCH_TITLE] = ArticleSearch::parseQuery($request->getUserVar('title'));
$keywords[ARTICLE_SEARCH_DISCIPLINE] = ArticleSearch::parseQuery($request->getUserVar('discipline'));
$keywords[ARTICLE_SEARCH_SUBJECT] = ArticleSearch::parseQuery($request->getUserVar('subject'));
$keywords[ARTICLE_SEARCH_TYPE] = ArticleSearch::parseQuery($request->getUserVar('type'));
$keywords[ARTICLE_SEARCH_COVERAGE] = ArticleSearch::parseQuery($request->getUserVar('coverage'));
$keywords[ARTICLE_SEARCH_GALLEY_FILE] = ArticleSearch::parseQuery($request->getUserVar('fullText'));
$keywords[ARTICLE_SEARCH_SUPPLEMENTARY_FILE] = ArticleSearch::parseQuery($request->getUserVar('supplementaryFiles'));
$fromDate = $request->getUserDateVar('dateFrom', 1, 1);
if ($fromDate !== null) {
$fromDate = date('Y-m-d H:i:s', $fromDate);
}
$toDate = $request->getUserDateVar('dateTo', 32, 12, null, 23, 59, 59);
if ($toDate !== null) {
$toDate = date('Y-m-d H:i:s', $toDate);
}
$results =& ArticleSearch::retrieveResults($journal, $keywords, $fromDate, $toDate, $rangeInfo);
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign_by_ref('results', $results);
$this->_assignAdvancedSearchParameters($request, $templateMgr, $yearRange);
$templateMgr->display('search/searchResults.tpl');
}
示例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: callbackTemplateArticlePageFooter
/**
* @see templates/article/footer.tpl
*/
function callbackTemplateArticlePageFooter($hookName, $params)
{
$smarty =& $params[1];
$output =& $params[2];
// Identify similarity terms for the given article.
$displayedArticle = $smarty->get_template_vars('article');
$articleId = $displayedArticle->getId();
import('classes.search.ArticleSearch');
$articleSearch = new ArticleSearch();
$searchTerms = $articleSearch->getSimilarityTerms($articleId);
if (empty($searchTerms)) {
return false;
}
// If we got similarity terms then execute a search with...
// ... request, journal and error messages, ...
$request = PKPApplication::getRequest();
$router = $request->getRouter();
$journal = $router->getContext($request);
$error = null;
// ... search keywords ...
$query = implode(' ', $searchTerms);
$keywords = array(null => $query);
// ... and pagination.
$rangeInfo = Handler::getRangeInfo($request, 'articlesBySimilarity');
$rangeInfo->setCount(RECOMMEND_BY_SIMILARITY_PLUGIN_COUNT);
$results = $articleSearch->retrieveResults($request, $journal, $keywords, $error, null, null, $rangeInfo, array($articleId));
$smarty->assign('articlesBySimilarity', $results);
$smarty->assign('articlesBySimilarityQuery', $query);
$output .= $smarty->fetch($this->getTemplatePath() . 'articleFooter.tpl');
return false;
}
示例4: testRetrieveResultsViaPluginHook
/**
* @covers ArticleSearch
*/
public function testRetrieveResultsViaPluginHook()
{
// Diverting a search to the search plugin hook.
HookRegistry::register('SubmissionSearch::retrieveResults', array($this, 'callbackRetrieveResults'));
$testCases = array(array(null => 'query'), array('1' => 'author'), array('2' => 'title'), array(null => 'query', 1 => 'author', 2 => 'title'));
$testFromDate = date('Y-m-d H:i:s', strtotime('2011-03-15 00:00:00'));
$testToDate = date('Y-m-d H:i:s', strtotime('2012-03-15 18:30:00'));
$error = '';
foreach ($testCases as $testCase) {
// Test a simple search with the simulated callback.
$journal = new Journal();
$keywords = $testCase;
$articleSearch = new ArticleSearch();
$searchResult = $articleSearch->retrieveResults($journal, $keywords, $error, $testFromDate, $testToDate);
// Check the parameters passed into the callback.
$expectedPage = 1;
$expectedItemsPerPage = 20;
$expectedTotalResults = 3;
$expectedError = '';
$expectedParams = array($journal, $testCase, $testFromDate, $testToDate, $expectedPage, $expectedItemsPerPage, $expectedTotalResults, $expectedError);
self::assertEquals($expectedParams, $this->_retrieveResultsParams);
// Test and clear the call history of the hook registry.
$calledHooks = HookRegistry::getCalledHooks();
self::assertEquals('SubmissionSearch::retrieveResults', $calledHooks[0][0]);
HookRegistry::resetCalledHooks(true);
// Test whether the result from the hook is being returned.
self::assertInstanceOf('VirtualArrayIterator', $searchResult);
// Test the total count.
self::assertEquals(3, $searchResult->getCount());
// Test the search result.
$firstResult = $searchResult->next();
self::assertArrayHasKey('article', $firstResult);
self::assertEquals(SUBMISSION_SEARCH_TEST_ARTICLE_FROM_PLUGIN, $firstResult['article']->getId());
self::assertEquals('', $error);
}
// Remove the test hook.
HookRegistry::clear('SubmissionSearch::retrieveResults');
}
示例5: 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');
}