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


PHP ArticleSearch::formatResults方法代码示例

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


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

示例1: display

 function display(&$args, $request)
 {
     $templateMgr =& TemplateManager::getManager();
     parent::display($args, $request);
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $articleGalleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
     $journal =& Request::getJournal();
     switch (array_shift($args)) {
         case 'exportGalley':
             $articleId = array_shift($args);
             $galleyId = array_shift($args);
             $article =& $publishedArticleDao->getPublishedArticleByArticleId($articleId);
             $galley =& $articleGalleyDao->getGalley($galleyId, $articleId);
             if ($article && $galley && ($issue =& $issueDao->getIssueById($article->getIssueId(), $journal->getId()))) {
                 $this->exportArticle($journal, $issue, $article, $galley);
                 break;
             }
         default:
             // Display a list of articles for export
             $this->setBreadcrumbs();
             AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION);
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $rangeInfo = Handler::getRangeInfo('articles');
             $articleIds = $publishedArticleDao->getPublishedArticleIdsAlphabetizedByJournal($journal->getId(), false);
             $totalArticles = count($articleIds);
             $articleIds = array_slice($articleIds, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
             import('lib.pkp.classes.core.VirtualArrayIterator');
             $iterator = new VirtualArrayIterator(ArticleSearch::formatResults($articleIds), $totalArticles, $rangeInfo->getPage(), $rangeInfo->getCount());
             $templateMgr->assign_by_ref('articles', $iterator);
             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
             break;
     }
 }
开发者ID:yuricampos,项目名称:ojs,代码行数:34,代码来源:EruditExportPlugin.inc.php

示例2: identifyTypes

 /**
  * Show list of journal sections identify types.
  */
 function identifyTypes($args = array(), $request)
 {
     $this->setupTemplate($request);
     $router = $request->getRouter();
     $journal = $router->getContext($request);
     $browsePlugin =& PluginRegistry::getPlugin('generic', BROWSE_PLUGIN_NAME);
     $enableBrowseByIdentifyTypes = $browsePlugin->getSetting($journal->getId(), 'enableBrowseByIdentifyTypes');
     if ($enableBrowseByIdentifyTypes) {
         if (isset($args[0]) && $args[0] == 'view') {
             $identifyType = $request->getUserVar('identifyType');
             $sectionDao = DAORegistry::getDAO('SectionDAO');
             $sectionsIterator = $sectionDao->getByJournalId($journal->getId());
             $sections = array();
             while ($section = $sectionsIterator->next()) {
                 if ($section->getLocalizedIdentifyType() == $identifyType) {
                     $sections[] = $section;
                 }
             }
             $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
             $publishedArticleIds = array();
             foreach ($sections as $section) {
                 $publishedArticleIdsBySection = $publishedArticleDao->getPublishedArticleIdsBySection($section->getId());
                 $publishedArticleIds = array_merge($publishedArticleIds, $publishedArticleIdsBySection);
             }
             $rangeInfo = $this->getRangeInfo($request, 'search');
             $totalResults = count($publishedArticleIds);
             $publishedArticleIds = array_slice($publishedArticleIds, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
             $articleSearch = new ArticleSearch();
             $results = new VirtualArrayIterator($articleSearch->formatResults($publishedArticleIds), $totalResults, $rangeInfo->getPage(), $rangeInfo->getCount());
             $templateMgr = TemplateManager::getManager($request);
             $templateMgr->assign('results', $results);
             $templateMgr->assign('title', $identifyType);
             $templateMgr->assign('enableBrowseByIdentifyTypes', $enableBrowseByIdentifyTypes);
             $templateMgr->display($browsePlugin->getTemplatePath() . 'searchDetails.tpl');
         } else {
             $excludedIdentifyTypes = $browsePlugin->getSetting($journal->getId(), 'excludedIdentifyTypes');
             $sectionDao = DAORegistry::getDAO('SectionDAO');
             $sectionsIterator = $sectionDao->getByJournalId($journal->getId());
             $sectionidentifyTypes = array();
             while ($section = $sectionsIterator->next()) {
                 if ($section->getLocalizedIdentifyType() && !in_array($section->getId(), $excludedIdentifyTypes) && !in_array($section->getLocalizedIdentifyType(), $sectionidentifyTypes)) {
                     $sectionidentifyTypes[] = $section->getLocalizedIdentifyType();
                 }
             }
             sort($sectionidentifyTypes);
             $rangeInfo = $this->getRangeInfo($request, 'search');
             $totalResults = count($sectionidentifyTypes);
             $sectionidentifyTypes = array_slice($sectionidentifyTypes, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
             $results = new VirtualArrayIterator($sectionidentifyTypes, $totalResults, $rangeInfo->getPage(), $rangeInfo->getCount());
             $templateMgr = TemplateManager::getManager($request);
             $templateMgr->assign('results', $results);
             $templateMgr->assign('enableBrowseByIdentifyTypes', $enableBrowseByIdentifyTypes);
             $templateMgr->display($browsePlugin->getTemplatePath() . 'searchIndex.tpl');
         }
     } else {
         $request->redirect(null, 'index');
     }
 }
开发者ID:mosvits,项目名称:ojs,代码行数:61,代码来源:BrowseHandler.inc.php

示例3: 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

示例4: titles

 /**
  * Show index of published articles by title.
  * @param $args array
  * @param $request PKPRequest
  */
 function titles($args, &$request)
 {
     $this->validate();
     $this->setupTemplate($request, true);
     $journal =& $request->getJournal();
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $rangeInfo = $this->getRangeInfo('search');
     $articleIds =& $publishedArticleDao->getPublishedArticleIdsAlphabetizedByJournal(isset($journal) ? $journal->getId() : null);
     $totalResults = count($articleIds);
     $articleIds = array_slice($articleIds, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
     import('lib.pkp.classes.core.VirtualArrayIterator');
     $results = new VirtualArrayIterator(ArticleSearch::formatResults($articleIds), $totalResults, $rangeInfo->getPage(), $rangeInfo->getCount());
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign_by_ref('results', $results);
     $templateMgr->display('search/titleIndex.tpl');
 }
开发者ID:reconciler,项目名称:ojs,代码行数:21,代码来源:SearchHandler.inc.php

示例5: executeCLI


//.........这里部分代码省略.........
                             $section =& $sectionDao->getSectionByAbbrev($sectionIdentifier = array_shift($args), $journal->getId());
                             break;
                         default:
                             return $this->usage($scriptName);
                     }
                     if (!$section) {
                         echo __('plugins.importexport.native.cliError') . "\n";
                         echo __('plugins.importexport.native.export.error.sectionNotFound', array('sectionIdentifier' => $sectionIdentifier)) . "\n\n";
                         return;
                     }
                     $context['section'] =& $section;
             }
             $result = $this->handleImport($context, $doc, $errors, $issues, $articles, true);
             if ($result) {
                 echo __('plugins.importexport.native.import.success.description') . "\n\n";
                 if (!empty($issues)) {
                     echo __('issue.issues') . ":\n";
                 }
                 foreach ($issues as $issue) {
                     echo "\t" . $issue->getIssueIdentification() . "\n";
                 }
                 if (!empty($articles)) {
                     echo __('article.articles') . ":\n";
                 }
                 foreach ($articles as $article) {
                     echo "\t" . $article->getLocalizedTitle() . "\n";
                 }
             } else {
                 $errorsTranslated = array();
                 foreach ($errors as $error) {
                     $errorsTranslated[] = __($error[0], $error[1]);
                 }
                 echo __('plugins.importexport.native.cliError') . "\n";
                 foreach ($errorsTranslated as $errorTranslated) {
                     echo "\t" . $errorTranslated . "\n";
                 }
             }
             return;
             break;
         case 'export':
             if ($xmlFile != '') {
                 switch (array_shift($args)) {
                     case 'article':
                         $articleId = array_shift($args);
                         $publishedArticle =& $publishedArticleDao->getPublishedArticleByBestArticleId($journal->getId(), $articleId);
                         if ($publishedArticle == null) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.articleNotFound', array('articleId' => $articleId)) . "\n\n";
                             return;
                         }
                         $issue =& $issueDao->getIssueById($publishedArticle->getIssueId(), $journal->getId());
                         $sectionDao =& DAORegistry::getDAO('SectionDAO');
                         $section =& $sectionDao->getSection($publishedArticle->getSectionId());
                         if (!$this->exportArticle($journal, $issue, $section, $publishedArticle, $xmlFile)) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                         }
                         return;
                     case 'articles':
                         $results =& ArticleSearch::formatResults($args);
                         if (!$this->exportArticles($results, $xmlFile)) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                         }
                         return;
                     case 'issue':
                         $issueId = array_shift($args);
                         $issue =& $issueDao->getIssueByBestIssueId($issueId, $journal->getId());
                         if ($issue == null) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.issueNotFound', array('issueId' => $issueId)) . "\n\n";
                             return;
                         }
                         if (!$this->exportIssue($journal, $issue, $xmlFile)) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                         }
                         return;
                     case 'issues':
                         $issues = array();
                         while (($issueId = array_shift($args)) !== null) {
                             $issue =& $issueDao->getIssueByBestIssueId($issueId, $journal->getId());
                             if ($issue == null) {
                                 echo __('plugins.importexport.native.cliError') . "\n";
                                 echo __('plugins.importexport.native.export.error.issueNotFound', array('issueId' => $issueId)) . "\n\n";
                                 return;
                             }
                             $issues[] =& $issue;
                         }
                         if (!$this->exportIssues($journal, $issues, $xmlFile)) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                         }
                         return;
                 }
             }
             break;
     }
     $this->usage($scriptName);
 }
开发者ID:yuricampos,项目名称:ojs,代码行数:101,代码来源:NativeImportExportPlugin.inc.php

示例6: executeCLI

 /**
  * Execute import/export tasks using the command-line interface.
  * @param $args Parameters to the plugin
  */
 function executeCLI($scriptName, &$args)
 {
     //		$command = array_shift($args);
     $xmlFile = array_shift($args);
     $journalPath = array_shift($args);
     $journalDao = DAORegistry::getDAO('JournalDAO');
     $issueDao = DAORegistry::getDAO('IssueDAO');
     $sectionDao = DAORegistry::getDAO('SectionDAO');
     $userDao = DAORegistry::getDAO('UserDAO');
     $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
     $journal = $journalDao->getByPath($journalPath);
     if (!$journal) {
         if ($journalPath != '') {
             echo __('plugins.importexport.pubmed.cliError') . "\n";
             echo __('plugins.importexport.pubmed.error.unknownJournal', array('journalPath' => $journalPath)) . "\n\n";
         }
         $this->usage($scriptName);
         return;
     }
     if ($xmlFile != '') {
         switch (array_shift($args)) {
             case 'articles':
                 $articleSearch = new ArticleSearch();
                 $results = $articleSearch->formatResults($args);
                 if (!$this->exportArticles($results, $xmlFile)) {
                     echo __('plugins.importexport.pubmed.cliError') . "\n";
                     echo __('plugins.importexport.pubmed.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                 }
                 return;
             case 'issue':
                 $issueId = array_shift($args);
                 $issue = $issueDao->getByBestId($issueId, $journal->getId());
                 if ($issue == null) {
                     echo __('plugins.importexport.pubmed.cliError') . "\n";
                     echo __('plugins.importexport.pubmed.export.error.issueNotFound', array('issueId' => $issueId)) . "\n\n";
                     return;
                 }
                 $issues = array($issue);
                 if (!$this->exportIssues($journal, $issues, $xmlFile)) {
                     echo __('plugins.importexport.pubmed.cliError') . "\n";
                     echo __('plugins.importexport.pubmed.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                 }
                 return;
         }
     }
     $this->usage($scriptName);
 }
开发者ID:mosvits,项目名称:ojs,代码行数:51,代码来源:PubMedExportPlugin.inc.php

示例7: titles

 /**
  * Show index of published articles by title.
  */
 function titles($args)
 {
     parent::validate();
     SearchHandler::setupTemplate(true);
     $journal =& Request::getJournal();
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $rangeInfo = Handler::getRangeInfo('search');
     $articleIds =& $publishedArticleDao->getPublishedArticleIdsAlphabetizedByJournal(isset($journal) ? $journal->getJournalId() : null);
     $totalResults = count($articleIds);
     $articleIds = array_slice($articleIds, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
     $results =& new VirtualArrayIterator(ArticleSearch::formatResults($articleIds), $totalResults, $rangeInfo->getPage(), $rangeInfo->getCount());
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign_by_ref('results', $results);
     $templateMgr->display('search/titleIndex.tpl');
 }
开发者ID:alenoosh,项目名称:ojs,代码行数:18,代码来源:SearchHandler.inc.php

示例8: callbackTemplateArticlePageFooter

 /**
  * @see templates/article/footer.tpl
  */
 function callbackTemplateArticlePageFooter($hookName, $params)
 {
     $smarty =& $params[1];
     $output =& $params[2];
     // Find articles of the same author(s).
     $displayedArticle = $smarty->get_template_vars('article');
     $authors = $displayedArticle->getAuthors();
     $authorDao = DAORegistry::getDAO('AuthorDAO');
     /* @var $authorDao AuthorDAO */
     $foundArticles = array();
     foreach ($authors as $author) {
         /* @var $author Author */
         // The following article search is by name only as authors are
         // not normalized in OJS. This is rather crude and may produce
         // false positives or miss some entries. But there's no other way
         // until OJS allows users to consistently normalize authors (via name,
         // email, ORCID, whatever).
         $articles = $authorDao->getPublishedArticlesForAuthor(null, $author->getFirstName(), $author->getMiddleName(), $author->getLastName(), $author->getLocalizedAffiliation(), $author->getCountry());
         foreach ($articles as $article) {
             /* @var $article PublishedArticle */
             if ($displayedArticle->getId() == $article->getId()) {
                 continue;
             }
             $foundArticles[] = $article->getId();
         }
     }
     $results = array_unique($foundArticles);
     // Order results by metric.
     $application = PKPApplication::getApplication();
     $metricType = $application->getDefaultMetricType();
     if (empty($metricType)) {
         $smarty->assign('noMetricSelected', true);
     }
     $column = STATISTICS_DIMENSION_ARTICLE_ID;
     $filter = array(STATISTICS_DIMENSION_ASSOC_TYPE => array(ASSOC_TYPE_GALLEY, ASSOC_TYPE_ARTICLE), STATISTICS_DIMENSION_ARTICLE_ID => array($results));
     $orderBy = array(STATISTICS_METRIC => STATISTICS_ORDER_DESC);
     $statsReport = $application->getMetrics($metricType, $column, $filter, $orderBy);
     $orderedResults = array();
     foreach ($statsReport as $reportRow) {
         $orderedResults[] = $reportRow['submission_id'];
     }
     // Make sure we even get results that have no statistics (yet) and that
     // we get them in some consistent order for paging.
     $remainingResults = array_diff($results, $orderedResults);
     sort($remainingResults);
     $orderedResults = array_merge($orderedResults, $remainingResults);
     // Pagination.
     $request = PKPApplication::getRequest();
     $rangeInfo = Handler::getRangeInfo($request, 'articlesBySameAuthor');
     if ($rangeInfo && $rangeInfo->isValid()) {
         $page = $rangeInfo->getPage();
     } else {
         $page = 1;
     }
     $totalResults = count($orderedResults);
     $itemsPerPage = RECOMMEND_BY_AUTHOR_PLUGIN_COUNT;
     $offset = $itemsPerPage * ($page - 1);
     $length = max($totalResults - $offset, 0);
     $length = min($itemsPerPage, $length);
     if ($length == 0) {
         $pagedResults = array();
     } else {
         $pagedResults = array_slice($orderedResults, $offset, $length);
     }
     // Visualization.
     import('classes.search.ArticleSearch');
     $articleSearch = new ArticleSearch();
     $pagedResults = $articleSearch->formatResults($pagedResults);
     import('lib.pkp.classes.core.VirtualArrayIterator');
     $returner = new VirtualArrayIterator($pagedResults, $totalResults, $page, $itemsPerPage);
     $smarty->assign('articlesBySameAuthor', $returner);
     $output .= $smarty->fetch($this->getTemplatePath() . 'articleFooter.tpl');
     return false;
 }
开发者ID:pkp,项目名称:ojs,代码行数:77,代码来源:RecommendByAuthorPlugin.inc.php

示例9: display

 function display(&$args, $request)
 {
     $templateMgr =& TemplateManager::getManager();
     parent::display($args, $request);
     $this->setBreadcrumbs();
     $journal =& Request::getJournal();
     $plugin =& $this->getSwordPlugin();
     $swordUrl = Request::getUserVar('swordUrl');
     $depositPointKey = Request::getUserVar('depositPoint');
     $depositPoints = $plugin->getSetting($journal->getId(), 'depositPoints');
     $username = Request::getUserVar('swordUsername');
     $password = Request::getUserVar('swordPassword');
     if (isset($depositPoints[$depositPointKey])) {
         $selectedDepositPoint = $depositPoints[$depositPointKey];
         if ($selectedDepositPoint['username'] != '') {
             $username = $selectedDepositPoint['username'];
         }
         if ($selectedDepositPoint['password'] != '') {
             $password = $selectedDepositPoint['password'];
         }
     }
     $swordDepositPoint = Request::getUserVar('swordDepositPoint');
     $depositEditorial = Request::getUserVar('depositEditorial');
     $depositGalleys = Request::getUserVar('depositGalleys');
     switch (array_shift($args)) {
         case 'deposit':
             $depositIds = array();
             try {
                 foreach (Request::getUserVar('articleId') as $articleId) {
                     $depositIds[] = $this->deposit($swordDepositPoint, $username, $password, $articleId, $depositEditorial, $depositGalleys);
                 }
             } catch (Exception $e) {
                 // Deposit failed
                 $templateMgr->assign(array('pageTitle' => 'plugins.importexport.sword.depositFailed', 'messageTranslated' => $e->getMessage(), 'backLink' => Request::url(null, null, null, array('plugin', $this->getName()), array('swordUrl' => $swordUrl, 'swordUsername' => $username, 'swordDepositPoint' => $swordDepositPoint, 'depositEditorial' => $depositEditorial, 'depositGalleys' => $depositGalleys)), 'backLinkLabel' => 'common.back'));
                 return $templateMgr->display('common/message.tpl');
             }
             // Deposit was successful
             $templateMgr->assign(array('pageTitle' => 'plugins.importexport.sword.depositSuccessful', 'message' => 'plugins.importexport.sword.depositSuccessfulDescription', 'backLink' => Request::url(null, null, null, array('plugin', $this->getName()), array('swordUrl' => $swordUrl, 'swordUsername' => $username, 'swordDepositPoint' => $swordDepositPoint, 'depositEditorial' => $depositEditorial, 'depositGalleys' => $depositGalleys)), 'backLinkLabel' => 'common.continue'));
             return $templateMgr->display('common/message.tpl');
             break;
         default:
             $journal =& Request::getJournal();
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $rangeInfo = Handler::getRangeInfo('articles');
             $articleIds = $publishedArticleDao->getPublishedArticleIdsAlphabetizedByJournal($journal->getId(), false);
             $totalArticles = count($articleIds);
             if ($rangeInfo->isValid()) {
                 $articleIds = array_slice($articleIds, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
             }
             import('lib.pkp.classes.core.VirtualArrayIterator');
             $iterator = new VirtualArrayIterator(ArticleSearch::formatResults($articleIds), $totalArticles, $rangeInfo->getPage(), $rangeInfo->getCount());
             foreach (array('swordUrl', 'swordUsername', 'swordPassword', 'depositEditorial', 'depositGalleys', 'swordDepositPoint') as $var) {
                 $templateMgr->assign($var, Request::getUserVar($var));
             }
             $templateMgr->assign('depositPoints', $depositPoints);
             if (!empty($swordUrl)) {
                 $client = new SWORDAPPClient();
                 $doc = $client->servicedocument($swordUrl, $username, $password, '');
                 $depositPoints = array();
                 if (is_array($doc->sac_workspaces)) {
                     foreach ($doc->sac_workspaces as $workspace) {
                         if (is_array($workspace->sac_collections)) {
                             foreach ($workspace->sac_collections as $collection) {
                                 $depositPoints["{$collection->sac_href}"] = "{$collection->sac_colltitle}";
                             }
                         }
                     }
                 }
                 $templateMgr->assign_by_ref('swordDepositPoints', $depositPoints);
             }
             $templateMgr->assign_by_ref('articles', $iterator);
             $templateMgr->display($this->getTemplatePath() . 'articles.tpl');
             break;
     }
 }
开发者ID:yuricampos,项目名称:ojs,代码行数:75,代码来源:SwordImportExportPlugin.inc.php

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