Skip to content

Commit

Permalink
pkp/pkp-lib#10653 remove deprecated submission functions in OAI class…
Browse files Browse the repository at this point in the history
…es and templates
  • Loading branch information
kaitlinnewson committed Dec 6, 2024
1 parent 1f1bb3f commit 8d33d24
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 42 deletions.
15 changes: 10 additions & 5 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,8 @@

namespace APP\plugins\oaiMetadataFormats\marc;

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

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

$templateMgr = TemplateManager::getManager();
Expand All @@ -46,13 +51,13 @@ public function toXml($record, $format = null)
]);

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

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

Expand Down
14 changes: 7 additions & 7 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 $article->getData('datePublished')}
<fixfield id="008">"{$article->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 @@ -81,13 +81,13 @@
<subfield label="a">{$language}</subfield>
</varfield>

{if $article->getCoverage($journal->getPrimaryLocale())}
{if $article->getData('coverage', $journal->getPrimaryLocale())}
<varfield id="500" i1=" " i2=" ">
<subfield label="a">{$article->getCoverage($journal->getPrimaryLocale())|escape}</subfield>
<subfield label="a">{$article->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=$article->getdata('copyrightYear') copyrightHolder=$article->getData('copyrightHolder', $journal->getPrimaryLocale())|escape}</subfield>
</varfield>
</oai_marc>
15 changes: 10 additions & 5 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,8 @@

namespace APP\plugins\oaiMetadataFormats\marcxml;

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

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

$templateMgr = TemplateManager::getManager();
Expand All @@ -46,13 +51,13 @@ public function toXml($record, $format = null)
]);

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

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

Expand Down
14 changes: 7 additions & 7 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 $article->getData('datePublished')}
<controlfield tag="008">"{$article->getData('datePublished')|strtotime|date_format:"%y%m%d %Y"} eng "</controlfield>
{/if}
{if $journal->getData('onlineIssn')}
<datafield tag="022" ind1="#" ind2="#">
Expand Down Expand Up @@ -89,13 +89,13 @@
<subfield code="a">{$language}</subfield>
</datafield>

{if $article->getCoverage($journal->getPrimaryLocale())}
{if $article->getData('coverage', $journal->getPrimaryLocale())}
<datafield tag="500" ind1=" " ind2=" ">
<subfield code="a">{$article->getCoverage($journal->getPrimaryLocale())|escape}</subfield>
<subfield code="a">{$article->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=$article->getdata('copyrightYear') copyrightHolder=$article->getData('copyrightHolder', $journal->getPrimaryLocale())|escape}</subfield>
</datafield>
</record>
56 changes: 38 additions & 18 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 = $article->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)
);
$subject = $subjects[$journal->getPrimaryLocale()] ?? '';

// Coverage
$coverage = $article->getCoverage($article->getData('locale'));
$coverage = $article->getData('coverage', $article->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 @@ -97,17 +119,15 @@ public function toXml($record, $format = null)
$this->formatElement('type', $section->getLocalizedIdentifyType()) .

$this->formatElement('author', $creators) .
($article->getDatePublished() ? $this->formatElement('date', $article->getDatePublished()) : '') .
($article->getData('datePublished') ? $this->formatElement('date', $article->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('monitoring', $article->getLocalizedData('sponsor')) .
$this->formatElement('language', $article->getData('locale')) .
$this->formatElement('abstract', strip_tags($publication->getLocalizedData('abstract'))) .
"</rfc1807>\n";

return $response;
}

/**
Expand Down

0 comments on commit 8d33d24

Please sign in to comment.