Skip to content

Commit

Permalink
pkp/pkp-lib#10786 fix resolver plugin page range matching and update …
Browse files Browse the repository at this point in the history
…for 3.5
  • Loading branch information
kaitlinnewson committed Jan 8, 2025
1 parent 673b748 commit 3f04809
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plugins/gateways/resolver/ResolverPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ public function fetch($args, $request)
$doi = implode('/', $args);
$article = Repo::submission()->getByDoi($doi, $request->getJournal()->getId());
if ($article) {
$request->redirect(null, 'article', 'view', $article->getBestId());
$request->redirect(null, 'article', 'view', [$article->getBestId()]);
}
break;
case 'vnp': // Volume, number, page
case 'ynp': // Volume, number, year, page
case 'ynp': // Year, number, page
// This can only be used from within a journal context
$journal = $request->getJournal();
if (!$journal) {
Expand Down Expand Up @@ -139,17 +139,17 @@ public function fetch($args, $request)
foreach ($submissions as $submission) {
// Look for the correct page in the list of articles.
$matches = null;
if (preg_match('/^[Pp][Pp]?[.]?[ ]?(\d+)$/u', $submission->getCurrentPublication()->getData('pages'), $matches)) {
if (preg_match('/^[Pp]?[Pp]?[.]?[ ]?(\d+)$/u', $submission->getCurrentPublication()->getData('pages'), $matches)) {
$matchedPage = $matches[1];
if ($page == $matchedPage) {
$request->redirect(null, 'article', 'view', $submission->getBestId());
$request->redirect(null, 'article', 'view', [$submission->getBestId()]);
}
}
if (preg_match('/^[Pp][Pp]?[.]?[ ]?(\d+)[ ]?-[ ]?([Pp][Pp]?[.]?[ ]?)?(\d+)$/u', $submission->getCurrentPublication()->getData('pages'), $matches)) {
if (preg_match('/^[Pp]?[Pp]?[.]?[ ]?(\d+)[ ]?-[ ]?([Pp][Pp]?[.]?[ ]?)?(\d+)$/u', $submission->getCurrentPublication()->getData('pages'), $matches)) {
$matchedPageFrom = $matches[1];
$matchedPageTo = $matches[3];
if ($page >= $matchedPageFrom && ($page < $matchedPageTo || ($page == $matchedPageTo && $matchedPageFrom = $matchedPageTo))) {
$request->redirect(null, 'article', 'view', $submission->getBestId());
$request->redirect(null, 'article', 'view', [$submission->getBestId()]);
}
}
}
Expand Down

0 comments on commit 3f04809

Please sign in to comment.