当前位置: 首页>>代码示例>>PHP>>正文


PHP ArticleSearch::getSimilarityTerms方法代码示例

本文整理汇总了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;
 }
开发者ID:laelnasan,项目名称:UTFPR-ojs,代码行数:34,代码来源:RecommendBySimilarityPlugin.inc.php

示例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);
 }
开发者ID:jmacgreg,项目名称:ojs,代码行数:27,代码来源:SearchHandler.inc.php


注:本文中的ArticleSearch::getSimilarityTerms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。