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


PHP ArticleSearch::_getMergedArray方法代码示例

本文整理汇总了PHP中ArticleSearch::_getMergedArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ArticleSearch::_getMergedArray方法的具体用法?PHP ArticleSearch::_getMergedArray怎么用?PHP ArticleSearch::_getMergedArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArticleSearch的用法示例。


在下文中一共展示了ArticleSearch::_getMergedArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: count

 /**
  * Return an array of search results matching the supplied
  * keyword IDs in decreasing order of match quality.
  * Keywords are supplied in an array of the following format:
  * $keywords[ARTICLE_SEARCH_AUTHOR] = array('John', 'Doe');
  * $keywords[ARTICLE_SEARCH_...] = array(...);
  * $keywords[null] = array('Matches', 'All', 'Fields');
  * @param $journal object The journal to search
  * @param $keywords array List of keywords
  * @param $publishedFrom object Search-from date
  * @param $publishedTo object Search-to date
  * @param $rangeInfo Information on the range of results to return
  */
 function &retrieveResults(&$journal, &$keywords, $publishedFrom = null, $publishedTo = null, $rangeInfo = null)
 {
     // Fetch all the results from all the keywords into one array
     // (mergedResults), where mergedResults[article_id]
     // = sum of all the occurences for all keywords associated with
     // that article ID.
     // resultCount contains the sum of result counts for all keywords.
     $mergedResults =& ArticleSearch::_getMergedArray($journal, $keywords, $publishedFrom, $publishedTo, $resultCount);
     // Convert mergedResults into an array (frequencyIndicator =>
     // $articleId).
     // The frequencyIndicator is a synthetically-generated number,
     // where higher is better, indicating the quality of the match.
     // It is generated here in such a manner that matches with
     // identical frequency do not collide.
     $results =& ArticleSearch::_getSparseArray($mergedResults, $resultCount);
     $totalResults = count($results);
     // Use only the results for the specified page, if specified.
     if ($rangeInfo && $rangeInfo->isValid()) {
         $results = array_slice($results, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
         $page = $rangeInfo->getPage();
         $itemsPerPage = $rangeInfo->getCount();
     } else {
         $page = 1;
         $itemsPerPage = max($totalResults, 1);
     }
     // Take the range of results and retrieve the Article, Journal,
     // and associated objects.
     $results =& ArticleSearch::formatResults($results);
     // Return the appropriate iterator.
     $returner =& new VirtualArrayIterator($results, $totalResults, $page, $itemsPerPage);
     return $returner;
 }
开发者ID:alenoosh,项目名称:ojs,代码行数:45,代码来源:ArticleSearch.inc.php

示例2: array

 /**
  * Return an array of search results matching the supplied
  * keyword IDs in decreasing order of match quality.
  * Keywords are supplied in an array of the following format:
  * $keywords[ARTICLE_SEARCH_AUTHOR] = array('John', 'Doe');
  * $keywords[ARTICLE_SEARCH_...] = array(...);
  * $keywords[null] = array('Matches', 'All', 'Fields');
  * @param $journal object The journal to search
  * @param $keywords array List of keywords
  * @param $error string a reference to a variable that will
  *  contain an error message if the search service produces
  *  an error.
  * @param $publishedFrom object Search-from date
  * @param $publishedTo object Search-to date
  * @param $rangeInfo Information on the range of results to return
  * @return VirtualArrayIterator An iterator with one entry per retrieved
  *  article containing the article, published article, issue, journal, etc.
  */
 function &retrieveResults(&$journal, &$keywords, &$error, $publishedFrom = null, $publishedTo = null, $rangeInfo = null)
 {
     // Pagination
     if ($rangeInfo && $rangeInfo->isValid()) {
         $page = $rangeInfo->getPage();
         $itemsPerPage = $rangeInfo->getCount();
     } else {
         $page = 1;
         $itemsPerPage = ARTICLE_SEARCH_DEFAULT_RESULT_LIMIT;
     }
     // Check whether a search plug-in jumps in to provide ranked search results.
     $totalResults = null;
     $results =& HookRegistry::call('ArticleSearch::retrieveResults', array(&$journal, &$keywords, $publishedFrom, $publishedTo, $page, $itemsPerPage, &$totalResults, &$error));
     // If no search plug-in is activated then fall back to the
     // default database search implementation.
     if ($results === false) {
         // Parse the query.
         foreach ($keywords as $searchType => $query) {
             $keywords[$searchType] = ArticleSearch::_parseQuery($query);
         }
         // Fetch all the results from all the keywords into one array
         // (mergedResults), where mergedResults[article_id]
         // = sum of all the occurences for all keywords associated with
         // that article ID.
         $mergedResults =& ArticleSearch::_getMergedArray($journal, $keywords, $publishedFrom, $publishedTo);
         // Convert mergedResults into an array (frequencyIndicator =>
         // $articleId).
         // The frequencyIndicator is a synthetically-generated number,
         // where higher is better, indicating the quality of the match.
         // It is generated here in such a manner that matches with
         // identical frequency do not collide.
         $results =& ArticleSearch::_getSparseArray($mergedResults);
         $totalResults = count($results);
         // Use only the results for the specified page.
         $offset = $itemsPerPage * ($page - 1);
         $length = max($totalResults - $offset, 0);
         $length = min($itemsPerPage, $length);
         if ($length == 0) {
             $results = array();
         } else {
             $results = array_slice($results, $offset, $length);
         }
     }
     // Take the range of results and retrieve the Article, Journal,
     // and associated objects.
     $results =& ArticleSearch::formatResults($results);
     // Return the appropriate iterator.
     import('lib.pkp.classes.core.VirtualArrayIterator');
     $returner = new VirtualArrayIterator($results, $totalResults, $page, $itemsPerPage);
     return $returner;
 }
开发者ID:EreminDm,项目名称:water-cao,代码行数:69,代码来源:ArticleSearch.inc.php


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