Skip to content

Commit

Permalink
Merge pull request #4543 from kaitlinnewson/10653-main
Browse files Browse the repository at this point in the history
pkp/pkp-lib#10653 remove deprecated submission functions in OAI class…
  • Loading branch information
bozana authored Dec 12, 2024
2 parents 2db933e + da87db1 commit 8e9992f
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 55 deletions.
4 changes: 2 additions & 2 deletions plugins/gateways/resolver/ResolverPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ 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->getPages(), $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());
}
}
if (preg_match('/^[Pp][Pp]?[.]?[ ]?(\d+)[ ]?-[ ]?([Pp][Pp]?[.]?[ ]?)?(\d+)$/u', $submission->getPages(), $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))) {
Expand Down
23 changes: 16 additions & 7 deletions plugins/oaiMetadataFormats/marc/OAIMetadataFormat_MARC.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @file plugins/oaiMetadataFormats/marc/OAIMetadataFormat_MARC.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2003-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class OAIMetadataFormat_MARC
Expand All @@ -18,6 +18,9 @@

namespace APP\plugins\oaiMetadataFormats\marc;

use APP\journal\Journal;
use APP\publication\Publication;
use APP\submission\Submission;
use APP\template\TemplateManager;
use PKP\core\PKPString;
use PKP\i18n\LocaleConversion;
Expand All @@ -33,27 +36,33 @@ class OAIMetadataFormat_MARC extends OAIMetadataFormat
*/
public function toXml($record, $format = null)
{
/** @var Submission $article */
$article = $record->getData('article');

/** @var Publication $publication */
$publication = $article->getCurrentPublication();

/** @var Journal $journal */
$journal = $record->getData('journal');

$templateMgr = TemplateManager::getManager();
$templateMgr->assign([
'journal' => $journal,
'article' => $article,
'publication' => $article->getCurrentPublication(),
'publication' => $publication,
'issue' => $record->getData('issue'),
'section' => $record->getData('section')
]);

$subjects = array_merge_recursive(
stripAssocArray((array) $article->getDiscipline(null)),
stripAssocArray((array) $article->getSubject(null))
stripAssocArray((array) $publication->getData('discipline')),
stripAssocArray((array) $publication->getData('subject'))
);

$templateMgr->assign([
'subject' => isset($subjects[$journal->getPrimaryLocale()]) ? $subjects[$journal->getPrimaryLocale()] : '',
'abstract' => PKPString::html2text($article->getAbstract($article->getData('locale'))),
'language' => LocaleConversion::get3LetterIsoFromLocale($article->getData('locale'))
'abstract' => PKPString::html2text($publication->getData('abstract', $publication->getData('locale'))),
'language' => LocaleConversion::get3LetterIsoFromLocale($publication->getData('locale'))
]);

$plugin = PluginRegistry::getPlugin('oaiMetadataFormats', 'OAIFormatPlugin_MARC');
Expand Down
16 changes: 8 additions & 8 deletions plugins/oaiMetadataFormats/marc/templates/record.tpl
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{**
* plugins/oaiMetadataFormats/marc/record.tpl
*
* Copyright (c) 2013-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Copyright (c) 2013-2024 Simon Fraser University
* Copyright (c) 2003-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* MARC-formatted metadata record for an article
*}
<oai_marc status="c" type="a" level="m" encLvl="3" catForm="u"
xmlns="http://www.openarchives.org/OAI/1.1/oai_marc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openarchives.org/OAI/1.1/oai_marc http://www.openarchives.org/OAI/1.1/oai_marc.xsd">
{if $article->getDatePublished()}
<fixfield id="008">"{$article->getDatePublished()|strtotime|date_format:"%y%m%d %Y"} eng "</fixfield>
{if $publication->getData('datePublished')}
<fixfield id="008">"{$publication->getData('datePublished')|strtotime|date_format:"%y%m%d %Y"} eng "</fixfield>
{/if}
{if $journal->getData('onlineIssn')}
<varfield id="022" i1="#" i2="#">
Expand Down Expand Up @@ -63,7 +63,7 @@
<subfield label="a">{$identifyType|escape}</subfield>
</varfield>{/if}

{foreach from=$article->getGalleys() item=galley}
{foreach from=$publication->getData('galleys') item=galley}
<varfield id="856" i1=" " i2=" ">
<subfield label="q">{$galley->getFileType()|escape}</subfield>
</varfield>
Expand All @@ -81,13 +81,13 @@
<subfield label="a">{$language}</subfield>
</varfield>

{if $article->getCoverage($journal->getPrimaryLocale())}
{if $publication->getData('coverage', $journal->getPrimaryLocale())}
<varfield id="500" i1=" " i2=" ">
<subfield label="a">{$article->getCoverage($journal->getPrimaryLocale())|escape}</subfield>
<subfield label="a">{$publication->getData('coverage', $journal->getPrimaryLocale())|escape}</subfield>
</varfield>
{/if}

<varfield id="540" i1=" " i2=" ">
<subfield label="a">{translate key="submission.copyrightStatement" copyrightYear=$article->getCopyrightYear() copyrightHolder=$article->getCopyrightHolder($journal->getPrimaryLocale())|escape}</subfield>
<subfield label="a">{translate key="submission.copyrightStatement" copyrightYear=$publication->getdata('copyrightYear') copyrightHolder=$publication->getData('copyrightHolder', $journal->getPrimaryLocale())|escape}</subfield>
</varfield>
</oai_marc>
23 changes: 16 additions & 7 deletions plugins/oaiMetadataFormats/marcxml/OAIMetadataFormat_MARC21.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @file plugins/oaiMetadataFormats/marcxml/OAIMetadataFormat_MARC21.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2003-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class OAIMetadataFormat_MARC21
Expand All @@ -18,6 +18,9 @@

namespace APP\plugins\oaiMetadataFormats\marcxml;

use APP\journal\Journal;
use APP\publication\Publication;
use APP\submission\Submission;
use APP\template\TemplateManager;
use PKP\core\PKPString;
use PKP\i18n\LocaleConversion;
Expand All @@ -33,27 +36,33 @@ class OAIMetadataFormat_MARC21 extends OAIMetadataFormat
*/
public function toXml($record, $format = null)
{
/** @var Submission $article */
$article = $record->getData('article');

/** @var Publication $publication */
$publication = $article->getCurrentPublication();

/* @var Journal $journal */
$journal = $record->getData('journal');

$templateMgr = TemplateManager::getManager();
$templateMgr->assign([
'journal' => $journal,
'article' => $article,
'publication' => $article->getCurrentPublication(),
'publication' => $publication,
'issue' => $record->getData('issue'),
'section' => $record->getData('section')
]);

$subjects = array_merge_recursive(
stripAssocArray((array) $article->getDiscipline(null)),
stripAssocArray((array) $article->getSubject(null))
stripAssocArray((array) $publication->getData('discipline')),
stripAssocArray((array) $publication->getData('subject'))
);

$templateMgr->assign([
'subject' => isset($subjects[$journal->getPrimaryLocale()]) ? $subjects[$journal->getPrimaryLocale()] : '',
'abstract' => PKPString::html2text($article->getAbstract($article->getData('locale'))),
'language' => LocaleConversion::get3LetterIsoFromLocale($article->getData('locale'))
'abstract' => PKPString::html2text($publication->getData('abstract', $publication->getData('locale'))),
'language' => LocaleConversion::get3LetterIsoFromLocale($publication->getData('locale'))
]);

$plugin = PluginRegistry::getPlugin('oaiMetadataFormats', 'OAIFormatPlugin_MARC21');
Expand Down
20 changes: 10 additions & 10 deletions plugins/oaiMetadataFormats/marcxml/templates/record.tpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{**
* plugins/oaiMetadataFormats/marcxml/record.tpl
*
* Copyright (c) 2013-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Copyright (c) 2013-2024 Simon Fraser University
* Copyright (c) 2003-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* MARCXML-formatted metadata record for an article
Expand All @@ -12,8 +12,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.loc.gov/MARC21/slim https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd">
<leader> nmb a2200000Iu 4500</leader>
{if $article->getDatePublished()}
<controlfield tag="008">"{$article->getDatePublished()|strtotime|date_format:"%y%m%d %Y"} eng "</controlfield>
{if $publication->getData('datePublished')}
<controlfield tag="008">"{$publication->getData('datePublished')|strtotime|date_format:"%y%m%d %Y"} eng "</controlfield>
{/if}
{if $journal->getData('onlineIssn')}
<datafield tag="022" ind1="#" ind2="#">
Expand All @@ -25,9 +25,9 @@
<subfield code="a">{$journal->getData('printIssn')|escape}</subfield>
</datafield>
{/if}
{if $article->getStoredPubId('doi')}
{if $publication->getStoredPubId('doi')}
<datafield tag="024" ind1="7" ind2="#">
<subfield code="a">{$article->getStoredPubId('doi')|escape}</subfield>
<subfield code="a">{$publication->getStoredPubId('doi')|escape}</subfield>
<subfield code="2">doi</subfield>
</datafield>
{/if}
Expand Down Expand Up @@ -72,7 +72,7 @@
<subfield code="a">{$identifyType|escape}</subfield>
</datafield>{/if}

{foreach from=$article->getGalleys() item=galley}
{foreach from=$publication->getData('galleys') item=galley}
<datafield tag="856" ind1=" " ind2=" ">
<subfield code="q">{$galley->getFileType()|escape}</subfield>
</datafield>
Expand All @@ -89,13 +89,13 @@
<subfield code="a">{$language}</subfield>
</datafield>

{if $article->getCoverage($journal->getPrimaryLocale())}
{if $publication->getData('coverage', $journal->getPrimaryLocale())}
<datafield tag="500" ind1=" " ind2=" ">
<subfield code="a">{$article->getCoverage($journal->getPrimaryLocale())|escape}</subfield>
<subfield code="a">{$publication->getData('coverage', $journal->getPrimaryLocale())|escape}</subfield>
</datafield>
{/if}

<datafield tag="540" ind1=" " ind2=" ">
<subfield code="a">{translate key="submission.copyrightStatement" copyrightYear=$article->getCopyrightYear() copyrightHolder=$article->getCopyrightHolder($journal->getPrimaryLocale())|escape}</subfield>
<subfield code="a">{translate key="submission.copyrightStatement" copyrightYear=$publication->getdata('copyrightYear') copyrightHolder=$publication->getData('copyrightHolder', $journal->getPrimaryLocale())|escape}</subfield>
</datafield>
</record>
61 changes: 40 additions & 21 deletions plugins/oaiMetadataFormats/rfc1807/OAIMetadataFormat_RFC1807.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @file plugins/oaiMetadataFormats/rfc1807/OAIMetadataFormat_RFC1807.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2003-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class OAIMetadataFormat_RFC1807
Expand All @@ -17,7 +17,12 @@
namespace APP\plugins\oaiMetadataFormats\rfc1807;

use APP\core\Application;
use APP\issue\Issue;
use APP\issue\IssueAction;
use APP\journal\Journal;
use APP\publication\Publication;
use APP\section\Section;
use APP\submission\Submission;
use PKP\db\DAORegistry;
use PKP\oai\OAIMetadataFormat;
use PKP\oai\OAIUtils;
Expand All @@ -33,15 +38,21 @@ class OAIMetadataFormat_RFC1807 extends OAIMetadataFormat
*/
public function toXml($record, $format = null)
{
/** @var Submission $article */
$article = &$record->getData('article');

/** @var Journal $journal */
$journal = &$record->getData('journal');

/* @var Section $section */
$section = &$record->getData('section');

/** @var Issue $issue */
$issue = &$record->getData('issue');
$galleys = &$record->getData('galleys');

/** @var Publication $publication */
$publication = $article->getCurrentPublication();

// Publisher
$publisher = $journal->getLocalizedName(); // Default
$publisherInstitution = $journal->getData('publisherInstitution');
if (!empty($publisherInstitution)) {
Expand All @@ -50,14 +61,14 @@ public function toXml($record, $format = null)

// Sources contains journal title, issue ID, and pages
$source = $issue->getIssueIdentification();
$pages = $article->getPages();
$pages = $publication->getData('pages');
if (!empty($pages)) {
$source .= '; ' . $pages;
}

// Format creators
$creators = [];
foreach ($publication->getAuthors() as $author) {
foreach ($publication->getData('authors') as $author) {
$authorName = $author->getFullName(false, true);
$affiliation = $author->getLocalizedAffiliation();
if (!empty($affiliation)) {
Expand All @@ -66,24 +77,35 @@ public function toXml($record, $format = null)
$creators[] = $authorName;
}

// Subject
$supportedLocales = $journal->getSupportedFormLocales();
$submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO'); /** @var SubmissionKeywordDAO $submissionKeywordDao */
$submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO'); /** @var SubmissionSubjectDAO $submissionSubjectDao */

/** @var SubmissionKeywordDAO $submissionKeywordDao */
$submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO');

/** @var SubmissionSubjectDAO $submissionSubjectDao */
$submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO');

$subjects = array_merge_recursive(
(array) $submissionKeywordDao->getKeywords($publication->getId(), $supportedLocales),
(array) $submissionSubjectDao->getSubjects($article->getCurrentPublication()->getId(), $supportedLocales)
(array) $submissionSubjectDao->getSubjects($publication->getId(), $supportedLocales)
);
$subject = $subjects[$journal->getPrimaryLocale()] ?? '';

// Coverage
$coverage = $article->getCoverage($article->getData('locale'));
$coverage = $publication->getData('coverage', $publication->getData('locale'));

$issueAction = new IssueAction();
$request = Application::get()->getRequest();
$url = $request->getDispatcher()->url($request, Application::ROUTE_PAGE, $journal->getPath(), 'article', 'view', [$article->getBestId()], urlLocaleForPage: '');
$includeUrls = $journal->getSetting('publishingMode') != \APP\journal\Journal::PUBLISHING_MODE_NONE || $issueAction->subscribedUser($request->getUser(), $journal, null, $article->getId());
$response = "<rfc1807\n" .
$url = $request->getDispatcher()->url(
$request,
Application::ROUTE_PAGE,
$journal->getPath(),
'article',
'view',
[$article->getBestId()],
urlLocaleForPage: ''
);
$includeUrls = $journal->getData('publishingMode') != Journal::PUBLISHING_MODE_NONE || $issueAction->subscribedUser($request->getUser(), $journal, null, $article->getId());
return "<rfc1807\n" .
"\txmlns=\"http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1807.txt\"\n" .
"\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" .
"\txsi:schemaLocation=\"http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1807.txt\n" .
Expand All @@ -95,19 +117,16 @@ public function toXml($record, $format = null)
$this->formatElement('organization', $source) .
$this->formatElement('title', $publication->getLocalizedTitle()) .
$this->formatElement('type', $section->getLocalizedIdentifyType()) .

$this->formatElement('author', $creators) .
($article->getDatePublished() ? $this->formatElement('date', $article->getDatePublished()) : '') .
($publication->getData('datePublished') ? $this->formatElement('date', $publication->getData('datePublished')) : '') .
$this->formatElement('copyright', strip_tags($journal->getLocalizedData('licenseTerms'))) .
($includeUrls ? $this->formatElement('other_access', "url:{$url}") : '') .
$this->formatElement('keyword', $subject) .
$this->formatElement('period', $coverage) .
$this->formatElement('monitoring', $article->getLocalizedSponsor()) .
$this->formatElement('language', $article->getData('locale')) .
$this->formatElement('monitoring', $publication->getLocalizedData('sponsor')) .
$this->formatElement('language', $publication->getData('locale')) .
$this->formatElement('abstract', strip_tags($publication->getLocalizedData('abstract'))) .
"</rfc1807>\n";

return $response;
}

/**
Expand Down

0 comments on commit 8e9992f

Please sign in to comment.