static public formatResults ( &$results ) : array | ||
return | array | An array with the articles, published articles, issue, journal, section and the issue availability. |
static function formatResults(&$results)
{
$articleDao = DAORegistry::getDAO('ArticleDAO');
$publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
$issueDao = DAORegistry::getDAO('IssueDAO');
$journalDao = DAORegistry::getDAO('JournalDAO');
$sectionDao = DAORegistry::getDAO('SectionDAO');
$publishedArticleCache = array();
$articleCache = array();
$issueCache = array();
$issueAvailabilityCache = array();
$journalCache = array();
$sectionCache = array();
$returner = array();
foreach ($results as $articleId) {
// Get the article, storing in cache if necessary.
if (!isset($articleCache[$articleId])) {
$publishedArticleCache[$articleId] = $publishedArticleDao->getPublishedArticleByArticleId($articleId);
$articleCache[$articleId] = $articleDao->getById($articleId);
}
$article = $articleCache[$articleId];
$publishedArticle = $publishedArticleCache[$articleId];
if ($publishedArticle && $article) {
$sectionId = $article->getSectionId();
if (!isset($sectionCache[$sectionId])) {
$sectionCache[$sectionId] = $sectionDao->getById($sectionId);
}
// Get the journal, storing in cache if necessary.
$journalId = $article->getJournalId();
if (!isset($journalCache[$journalId])) {
$journalCache[$journalId] = $journalDao->getById($journalId);
}
// Get the issue, storing in cache if necessary.
$issueId = $publishedArticle->getIssueId();
if (!isset($issueCache[$issueId])) {
$issue = $issueDao->getById($issueId);
$issueCache[$issueId] = $issue;
import('classes.issue.IssueAction');
$issueAction = new IssueAction();
$issueAvailabilityCache[$issueId] = !$issueAction->subscriptionRequired($issue) || $issueAction->subscribedUser($journalCache[$journalId], $issueId, $articleId) || $issueAction->subscribedDomain($journalCache[$journalId], $issueId, $articleId);
}
// Only display articles from published issues.
if (!$issueCache[$issueId]->getPublished()) {
continue;
}
// Store the retrieved objects in the result array.
$returner[] = array('article' => $article, 'publishedArticle' => $publishedArticleCache[$articleId], 'issue' => $issueCache[$issueId], 'journal' => $journalCache[$journalId], 'issueAvailable' => $issueAvailabilityCache[$issueId], 'section' => $sectionCache[$sectionId]);
}
}
return $returner;
}
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; } }