本文整理汇总了PHP中ArticleSearch::getSimilarityTerms方法的典型用法代码示例。如果您正苦于以下问题:PHP ArticleSearch::getSimilarityTerms方法的具体用法?PHP ArticleSearch::getSimilarityTerms怎么用?PHP ArticleSearch::getSimilarityTerms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArticleSearch
的用法示例。
在下文中一共展示了ArticleSearch::getSimilarityTerms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: similarDocuments
/**
* Redirect to a search query that shows documents
* similar to the one identified by an article id in the
* request.
* @param $args array
* @param $request Request
*/
function similarDocuments($args, &$request)
{
$this->validate(null, $request);
// Retrieve the (mandatory) ID of the article that
// we want similar documents for.
$articleId = $request->getUserVar('articleId');
if (!is_numeric($articleId)) {
$request->redirect(null, 'search');
}
// Check whether a search plugin provides terms for a similarity search.
$articleSearch = new ArticleSearch();
$searchTerms = $articleSearch->getSimilarityTerms($articleId);
// Redirect to a search query with the identified search terms (if any).
if (empty($searchTerms)) {
$searchParams = null;
} else {
$searchParams = array('query' => implode(' ', $searchTerms));
}
$request->redirect(null, 'search', 'search', null, $searchParams);
}