/**
  * @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;
 }
Beispiel #2
0
 /**
  * Check if there is a payment plugin and if is configured
  * @return bool
  */
 function isConfigured()
 {
     $paymentPlugin =& $this->getPaymentPlugin();
     if ($paymentPlugin !== null) {
         return $paymentPlugin->isConfigured(PKPApplication::getRequest());
     }
     return false;
 }
 function register($category, $path)
 {
     $success = parent::register($category, $path);
     $this->addLocaleData();
     $request =& PKPApplication::getRequest();
     $templateMgr =& TemplateManager::getManager($request);
     $templateMgr->register_modifier('bibtex_escape', array(&$this, 'bibtexEscape'));
     return $success;
 }
 /**
  * @see Form::readInputData()
  */
 function readInputData()
 {
     $this->readUserVars($this->_getFormFields());
     $request = PKPApplication::getRequest();
     $password = $request->getUserVar('password');
     if ($password === LUCENE_PLUGIN_PASSWORD_PLACEHOLDER) {
         $plugin =& $this->_plugin;
         $password = $plugin->getSetting(0, 'password');
     }
     $this->setData('password', $password);
 }
 /**
  * @see Form::readInputData()
  */
 function readInputData()
 {
     $this->readUserVars(array('dvnUri', 'username', 'password'));
     $request =& PKPApplication::getRequest();
     $password = $request->getUserVar('password');
     if ($password === DATAVERSE_PLUGIN_PASSWORD_SLUG) {
         $plugin =& $this->_plugin;
         $password = $plugin->getSetting($this->_journalId, 'password');
     }
     $this->setData('password', $password);
 }
 /**
  * @see Form::readInputData()
  */
 function readInputData()
 {
     // Read regular form data.
     $this->readUserVars($this->_getFormFields());
     $request = PKPApplication::getRequest();
     // Set the password to the one saved in the DB
     // if we only got the placehlder from the form.
     $password = $request->getUserVar('password');
     if ($password === LUCENE_PLUGIN_PASSWORD_PLACEHOLDER) {
         $plugin =& $this->_plugin;
         $password = $plugin->getSetting(0, 'password');
     }
     $this->setData('password', $password);
 }
 /**
  * @see Form::readInputData()
  */
 function readInputData()
 {
     $this->readUserVars(array('dvnUri', 'username', 'password'));
     $request =& PKPApplication::getRequest();
     $password = $request->getUserVar('password');
     if ($password === DATAVERSE_PLUGIN_PASSWORD_SLUG) {
         $plugin =& $this->_plugin;
         $password = $plugin->getSetting($this->_journalId, 'password');
     }
     if (!$password) {
         // Password not required when API token provided, but SWORDAPPClient
         // requires a non-null password.
         $password = DATAVERSE_PLUGIN_PASSWORD_SLUG;
     }
     $this->setData('password', $password);
     $this->setData('dvnUri', preg_replace("/\\/+\$/", '', $this->getData('dvnUri')));
 }
 /**
  * Attach any dependent entities to a new file upload.
  * @param $submissionFile SubmissionFile
  */
 protected function _attachEntities($submissionFile)
 {
     switch ($submissionFile->getFileStage()) {
         case SUBMISSION_FILE_REVIEW_FILE:
         case SUBMISSION_FILE_REVIEW_ATTACHMENT:
         case SUBMISSION_FILE_REVIEW_REVISION:
             // Add the uploaded review file to the review round.
             $reviewRound = $this->getReviewRound();
             $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
             $submissionFileDao->assignRevisionToReviewRound($submissionFile->getFileId(), $submissionFile->getRevision(), $reviewRound);
             if ($submissionFile->getFileStage() == SUBMISSION_FILE_REVIEW_REVISION) {
                 // Get a list of author user IDs
                 $authorUserIds = array();
                 $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
                 $submitterAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($reviewRound->getSubmissionId(), ROLE_ID_AUTHOR);
                 while ($assignment = $submitterAssignments->next()) {
                     $authorUserIds[] = $assignment->getUserId();
                 }
                 // Update the notifications
                 $notificationMgr = new NotificationManager();
                 $notificationMgr->updateNotification(PKPApplication::getRequest(), array(NOTIFICATION_TYPE_PENDING_INTERNAL_REVISIONS, NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS), $authorUserIds, ASSOC_TYPE_SUBMISSION, $reviewRound->getSubmissionId());
                 $notificationMgr->updateNotification(PKPApplication::getRequest(), array(NOTIFICATION_TYPE_ALL_REVISIONS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId());
             }
             break;
     }
 }
Beispiel #9
0
 /**
  * Send an email to the site's tech admin
  * warning that an indexing error has occured.
  *
  * @param $error array An array of article ids.
  * @param $journal Journal A journal object.
  * @param $isSearchProblem boolean Whether a search problem
  *  is being reported.
  */
 function _informTechAdmin($error, $journal = null, $isSearchProblem = false)
 {
     if (!$this->_spamCheck()) {
         return;
     }
     // Is this a search or an indexing problem?
     if ($isSearchProblem) {
         $mail =& $this->getMailTemplate('LUCENE_SEARCH_SERVICE_ERROR_NOTIFICATION', $journal);
     } else {
         // Check whether this is journal or article index update problem.
         if (is_a($journal, 'Journal')) {
             // This must be a journal indexing problem.
             $mail =& $this->getMailTemplate('LUCENE_JOURNAL_INDEXING_ERROR_NOTIFICATION', $journal);
         } else {
             // Instantiate an article mail template.
             $mail =& $this->getMailTemplate('LUCENE_ARTICLE_INDEXING_ERROR_NOTIFICATION');
         }
     }
     // Assign parameters.
     $request =& PKPApplication::getRequest();
     $site =& $request->getSite();
     $mail->assignParams(array('siteName' => $site->getLocalizedTitle(), 'error' => $error));
     // Send to the site's tech contact.
     $mail->addRecipient($site->getLocalizedContactEmail(), $site->getLocalizedContactName());
     // Send the mail.
     $mail->send($request);
 }
Beispiel #10
0
 /**
  * Add the metadata XML of a single article to an
  * XML article list.
  *
  * @param $articleDoc DOMDocument
  * @param $article PublishedArticle
  * @param $journal Journal
  * @param $markToDelete boolean If true the returned XML
  *  will only contain a deletion marker.
  */
 function _addArticleXml(&$articleDoc, &$article, &$journal, $markToDelete = false)
 {
     assert(is_a($article, 'Article'));
     // Get the root node of the list.
     assert(is_a($articleDoc, 'DOMDocument'));
     $articleList =& $articleDoc->documentElement;
     // Create a new article node.
     $articleNode =& XMLCustomWriter::createElement($articleDoc, 'article');
     // Add ID information.
     XMLCustomWriter::setAttribute($articleNode, 'id', $article->getId());
     XMLCustomWriter::setAttribute($articleNode, 'sectionId', $article->getSectionId());
     XMLCustomWriter::setAttribute($articleNode, 'journalId', $article->getJournalId());
     XMLCustomWriter::setAttribute($articleNode, 'instId', $this->_instId);
     // Set the load action.
     $loadAction = $markToDelete ? 'delete' : 'replace';
     XMLCustomWriter::setAttribute($articleNode, 'loadAction', $loadAction);
     XMLCustomWriter::appendChild($articleList, $articleNode);
     // The XML for an article marked to be deleted contains no metadata.
     if ($markToDelete) {
         return;
     }
     assert(is_a($article, 'PublishedArticle'));
     // Add authors.
     $authors = $article->getAuthors();
     if (!empty($authors)) {
         $authorList =& XMLCustomWriter::createElement($articleDoc, 'authorList');
         foreach ($authors as $author) {
             /* @var $author Author */
             XMLCustomWriter::createChildWithText($articleDoc, $authorList, 'author', $author->getFullName(true));
         }
         XMLCustomWriter::appendChild($articleNode, $authorList);
     }
     // We need the request to retrieve locales and build URLs.
     $request = PKPApplication::getRequest();
     // Get all supported locales.
     $site = $request->getSite();
     $supportedLocales = $site->getSupportedLocales() + array_keys($journal->getSupportedLocaleNames());
     assert(!empty($supportedLocales));
     // Add titles.
     $titleList =& XMLCustomWriter::createElement($articleDoc, 'titleList');
     // Titles are used for sorting, we therefore need
     // them in all supported locales.
     assert(!empty($supportedLocales));
     foreach ($supportedLocales as $locale) {
         $localizedTitle = $article->getLocalizedTitle($locale);
         if (!is_null($localizedTitle)) {
             // Add the localized title.
             $titleNode =& XMLCustomWriter::createChildWithText($articleDoc, $titleList, 'title', $localizedTitle);
             XMLCustomWriter::setAttribute($titleNode, 'locale', $locale);
             // If the title does not exist in the given locale
             // then use the localized title for sorting only.
             $title = $article->getTitle($locale);
             $sortOnly = empty($title) ? 'true' : 'false';
             XMLCustomWriter::setAttribute($titleNode, 'sortOnly', $sortOnly);
         }
     }
     XMLCustomWriter::appendChild($articleNode, $titleList);
     // Add abstracts.
     $abstracts = $article->getAbstract(null);
     // return all locales
     if (!empty($abstracts)) {
         $abstractList =& XMLCustomWriter::createElement($articleDoc, 'abstractList');
         foreach ($abstracts as $locale => $abstract) {
             $abstractNode =& XMLCustomWriter::createChildWithText($articleDoc, $abstractList, 'abstract', $abstract);
             XMLCustomWriter::setAttribute($abstractNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $abstractList);
     }
     // Add discipline.
     $disciplines = $article->getDiscipline(null);
     // return all locales
     if (!empty($disciplines)) {
         $disciplineList =& XMLCustomWriter::createElement($articleDoc, 'disciplineList');
         foreach ($disciplines as $locale => $discipline) {
             $disciplineNode =& XMLCustomWriter::createChildWithText($articleDoc, $disciplineList, 'discipline', $discipline);
             XMLCustomWriter::setAttribute($disciplineNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $disciplineList);
     }
     // Add subjects and subject classes.
     $subjectClasses = $article->getSubjectClass(null);
     $subjects = $article->getSubject(null);
     if (!empty($subjectClasses) || !empty($subjects)) {
         $subjectList =& XMLCustomWriter::createElement($articleDoc, 'subjectList');
         if (!is_array($subjectClasses)) {
             $subjectClasses = array();
         }
         if (!is_array($subjects)) {
             $subjects = array();
         }
         $locales = array_unique(array_merge(array_keys($subjectClasses), array_keys($subjects)));
         foreach ($locales as $locale) {
             $subject = '';
             if (isset($subjectClasses[$locale])) {
                 $subject .= $subjectClasses[$locale];
             }
             if (isset($subjects[$locale])) {
                 if (!empty($subject)) {
                     $subject .= ' ';
                 }
                 $subject .= $subjects[$locale];
             }
             $subjectNode =& XMLCustomWriter::createChildWithText($articleDoc, $subjectList, 'subject', $subject);
             XMLCustomWriter::setAttribute($subjectNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $subjectList);
     }
     // Add type.
     $types = $article->getType(null);
     // return all locales
     if (!empty($types)) {
         $typeList =& XMLCustomWriter::createElement($articleDoc, 'typeList');
         foreach ($types as $locale => $type) {
             $typeNode =& XMLCustomWriter::createChildWithText($articleDoc, $typeList, 'type', $type);
             XMLCustomWriter::setAttribute($typeNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $typeList);
     }
     // Add coverage.
     $coverageGeo = $article->getCoverageGeo(null);
     $coverageChron = $article->getCoverageChron(null);
     $coverageSample = $article->getCoverageSample(null);
     if (!empty($coverageGeo) || !empty($coverageChron) || !empty($coverageSample)) {
         $coverageList =& XMLCustomWriter::createElement($articleDoc, 'coverageList');
         if (!is_array($coverageGeo)) {
             $coverageGeo = array();
         }
         if (!is_array($coverageChron)) {
             $coverageChron = array();
         }
         if (!is_array($coverageSample)) {
             $coverageSample = array();
         }
         $locales = array_unique(array_merge(array_keys($coverageGeo), array_keys($coverageChron), array_keys($coverageSample)));
         foreach ($locales as $locale) {
             $coverage = '';
             if (isset($coverageGeo[$locale])) {
                 $coverage .= $coverageGeo[$locale];
             }
             if (isset($coverageChron[$locale])) {
                 if (!empty($coverage)) {
                     $coverage .= '; ';
                 }
                 $coverage .= $coverageChron[$locale];
             }
             if (isset($coverageSample[$locale])) {
                 if (!empty($coverage)) {
                     $coverage .= '; ';
                 }
                 $coverage .= $coverageSample[$locale];
             }
             $coverageNode =& XMLCustomWriter::createChildWithText($articleDoc, $coverageList, 'coverage', $coverage);
             XMLCustomWriter::setAttribute($coverageNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $coverageList);
     }
     // Add journal titles.
     $journalTitleList =& XMLCustomWriter::createElement($articleDoc, 'journalTitleList');
     // Journal titles are used for sorting, we therefore need
     // them in all supported locales.
     foreach ($supportedLocales as $locale) {
         $localizedTitle = $journal->getName($locale);
         $sortOnly = false;
         if (is_null($localizedTitle)) {
             // If the title does not exist in the given locale
             // then use the localized title for sorting only.
             $journalTitle = $journal->getLocalizedName();
             $sortOnly = true;
         } else {
             $journalTitle = $localizedTitle;
         }
         $journalTitleNode =& XMLCustomWriter::createChildWithText($articleDoc, $journalTitleList, 'journalTitle', $journalTitle);
         XMLCustomWriter::setAttribute($journalTitleNode, 'locale', $locale);
         $sortOnly = $sortOnly ? 'true' : 'false';
         XMLCustomWriter::setAttribute($journalTitleNode, 'sortOnly', $sortOnly);
     }
     XMLCustomWriter::appendChild($articleNode, $journalTitleList);
     // Add publication dates.
     $publicationDate = $article->getDatePublished();
     if (!empty($publicationDate)) {
         // Transform and store article publication date.
         $publicationDate = $this->_convertDate($publicationDate);
         $dateNode =& XMLCustomWriter::createChildWithText($articleDoc, $articleNode, 'publicationDate', $publicationDate);
     }
     $issueId = $article->getIssueId();
     if (is_numeric($issueId)) {
         $issueDao = DAORegistry::getDAO('IssueDAO');
         /* @var $issueDao IssueDAO */
         $issue = $issueDao->getById($issueId);
         if (is_a($issue, 'Issue')) {
             $issuePublicationDate = $issue->getDatePublished();
             if (!empty($issuePublicationDate)) {
                 // Transform and store issue publication date.
                 $issuePublicationDate = $this->_convertDate($issuePublicationDate);
                 $dateNode =& XMLCustomWriter::createChildWithText($articleDoc, $articleNode, 'issuePublicationDate', $issuePublicationDate);
             }
         }
     }
     // We need the router to build file URLs.
     $router = $request->getRouter();
     /* @var $router PageRouter */
     // Add galley files
     $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
     $galleys = $articleGalleyDao->getBySubmissionId($article->getId());
     $galleyList = null;
     while ($galley = $galleys->next()) {
         /* @var $galley ArticleGalley */
         $locale = $galley->getLocale();
         $galleyUrl = $router->url($request, $journal->getPath(), 'article', 'download', array(intval($article->getId()), intval($galley->getId())));
         if (!empty($locale) && !empty($galleyUrl)) {
             if (is_null($galleyList)) {
                 $galleyList =& XMLCustomWriter::createElement($articleDoc, 'galleyList');
             }
             $galleyNode =& XMLCustomWriter::createElement($articleDoc, 'galley');
             XMLCustomWriter::setAttribute($galleyNode, 'locale', $locale);
             XMLCustomWriter::setAttribute($galleyNode, 'fileName', $galleyUrl);
             XMLCustomWriter::appendChild($galleyList, $galleyNode);
         }
     }
     // Wrap the galley XML as CDATA.
     if (!is_null($galleyList)) {
         if (is_callable(array($articleDoc, 'saveXml'))) {
             $galleyXml = $articleDoc->saveXml($galleyList);
         } else {
             $galleyXml = $galleyList->toXml();
         }
         $galleyOuterNode =& XMLCustomWriter::createElement($articleDoc, 'galley-xml');
         if (is_callable(array($articleDoc, 'createCDATASection'))) {
             $cdataNode = $articleDoc->createCDATASection($galleyXml);
         } else {
             $cdataNode = new XMLNode();
             $cdataNode->setValue('<![CDATA[' . $galleyXml . ']]>');
         }
         XMLCustomWriter::appendChild($galleyOuterNode, $cdataNode);
         XMLCustomWriter::appendChild($articleNode, $galleyOuterNode);
     }
 }
 /**
  * Generate a URL into a PKPApp. (This is a wrapper around Dispatcher::url() to make it available to Smarty templates.)
  * {url} 標籤
  */
 function smartyUrl($params, &$smarty)
 {
     if (!isset($params['context'])) {
         // Extract the variables named in $paramList, and remove them
         // from the params array. Variables remaining in params will be
         // passed along to Request::url as extra parameters.
         $context = array();
         $contextList = Application::getContextList();
         foreach ($contextList as $contextName) {
             if (isset($params[$contextName])) {
                 $context[$contextName] = $params[$contextName];
                 unset($params[$contextName]);
             } else {
                 $context[$contextName] = null;
             }
         }
         $params['context'] = $context;
     }
     // Extract the variables named in $paramList, and remove them
     // from the params array. Variables remaining in params will be
     // passed along to Request::url as extra parameters.
     $paramList = array('router', 'context', 'page', 'component', 'op', 'path', 'anchor', 'escape', 'source');
     foreach ($paramList as $param) {
         if (isset($params[$param])) {
             ${$param} = $params[$param];
             unset($params[$param]);
         } else {
             ${$param} = null;
         }
     }
     if (isset($source)) {
         $params['source'] = Request::getRequestUri();
     }
     // Set the default router
     $request =& PKPApplication::getRequest();
     if (is_null($router)) {
         if (is_a($request->getRouter(), 'PKPComponentRouter')) {
             $router = ROUTE_COMPONENT;
         } else {
             $router = ROUTE_PAGE;
         }
     }
     // Check the router
     $dispatcher =& PKPApplication::getDispatcher();
     $routerShortcuts = array_keys($dispatcher->getRouterNames());
     assert(in_array($router, $routerShortcuts));
     // Identify the handler
     switch ($router) {
         case ROUTE_PAGE:
             $handler = $page;
             break;
         case ROUTE_COMPONENT:
             $handler = $component;
             break;
         default:
             // Unknown router type
             assert(false);
     }
     // Let the dispatcher create the url
     return $dispatcher->url($request, $router, $context, $handler, $op, $path, $params, $anchor, !isset($escape) || $escape);
 }
Beispiel #12
0
 /**
  * Check if the CSRF token is correct.
  * overrides FormValidator::isValid()
  * @return boolean
  */
 function isValid()
 {
     $request = PKPApplication::getRequest();
     return $request->checkCSRF();
 }
 /**
  * Callback that renders the block.
  *
  * @param $hookName string
  * @param $args array
  * @return string
  */
 function callback($hookName, $args)
 {
     $params =& $args[0];
     $smarty =& $args[1];
     $output =& $args[2];
     $output .= $this->getContents($smarty, PKPApplication::getRequest());
     return false;
 }
Beispiel #14
0
 /**
  * Get the current context ID or the site-wide context ID (0) if no context
  * can be found.
  */
 function getCurrentContextId()
 {
     $context = PKPApplication::getRequest()->getContext();
     return is_null($context) ? 0 : $context->getId();
 }
Beispiel #15
0
 /**
  * @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;
 }
 /**
  * Generate a URL into a PKPApp.
  * @param $params array
  * @param $smarty object
  * Available parameters:
  * - router: which router to use
  * - context
  * - page
  * - component
  * - op
  * - path (array)
  * - anchor
  * - escape (default to true unless otherwise specified)
  * - params: parameters to include in the URL if available as an array
  */
 function smartyUrl($parameters, &$smarty)
 {
     if (!isset($parameters['context'])) {
         // Extract the variables named in $paramList, and remove them
         // from the parameters array. Variables remaining in params will be
         // passed along to Request::url as extra parameters.
         $context = array();
         $contextList = Application::getContextList();
         foreach ($contextList as $contextName) {
             if (isset($parameters[$contextName])) {
                 $context[$contextName] = $parameters[$contextName];
                 unset($parameters[$contextName]);
             } else {
                 $context[$contextName] = null;
             }
         }
         $parameters['context'] = $context;
     }
     // Extract the reserved variables named in $paramList, and remove them
     // from the parameters array. Variables remaining in parameters will be passed
     // along to Request::url as extra parameters.
     $paramList = array('params', 'router', 'context', 'page', 'component', 'op', 'path', 'anchor', 'escape');
     foreach ($paramList as $parameter) {
         if (isset($parameters[$parameter])) {
             ${$parameter} = $parameters[$parameter];
             unset($parameters[$parameter]);
         } else {
             ${$parameter} = null;
         }
     }
     // Merge parameters specified in the {url paramName=paramValue} format with
     // those optionally supplied in {url params=$someAssociativeArray} format
     $parameters = array_merge($parameters, (array) $params);
     // Set the default router
     $request =& PKPApplication::getRequest();
     if (is_null($router)) {
         if (is_a($request->getRouter(), 'PKPComponentRouter')) {
             $router = ROUTE_COMPONENT;
         } else {
             $router = ROUTE_PAGE;
         }
     }
     // Check the router
     $dispatcher =& PKPApplication::getDispatcher();
     $routerShortcuts = array_keys($dispatcher->getRouterNames());
     assert(in_array($router, $routerShortcuts));
     // Identify the handler
     switch ($router) {
         case ROUTE_PAGE:
             $handler = $page;
             break;
         case ROUTE_COMPONENT:
             $handler = $component;
             break;
         default:
             // Unknown router type
             assert(false);
     }
     // Let the dispatcher create the url
     return $dispatcher->url($request, $router, $context, $handler, $op, $path, $parameters, $anchor, !isset($escape) || $escape);
 }
Beispiel #17
0
 /**
  * @copydoc TemplateManager::display()
  */
 function callbackTemplateDisplay($hookName, $params)
 {
     // Get request and context.
     $request =& PKPApplication::getRequest();
     $journal =& $request->getContext();
     // Assign our private stylesheet.
     $templateMgr =& $params[0];
     $templateMgr->addStylesheet($request->getBaseUrl() . '/' . $this->getStyleSheet());
     return false;
 }