Skip to content

Commit 5dbce74

Browse files
Merge branch 'addTranslationCitation-729' into 'main'
Adicionar citação da tradução à Folha de Rosto See merge request softwares-pkp/plugins_ojs/folhaDeRostoDoPDF!29
2 parents 0ce1b09 + d87f761 commit 5dbce74

14 files changed

+200
-89
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ include:
66
ref: main
77
file:
88
- 'templates/groups/pkp_plugin.yml'
9-
- 'templates/groups/ops_3_4_plugins_unit_tests_model.yml'
10-
- 'templates/groups/ops_3_4_plugins_cypress_tests_model.yml'
9+
- 'templates/groups/ops/unit_tests.yml'
10+
- 'templates/groups/ops/cypress_tests.yml'
1111

1212
.unit_test_template:
1313
before_script:

TitlePageForPreprintPlugin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @file plugins/generic/TitlePageForPreprint/TitlePageForPreprintPlugin.inc.php
45
*

classes/SubmissionModel.php

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,97 +2,91 @@
22

33
namespace APP\plugins\generic\titlePageForPreprint\classes;
44

5-
class SubmissionModel
6-
{
7-
private $status;
8-
private $doi;
9-
private $doiJournal;
10-
private $galleys;
11-
private $authors;
12-
private $submissionDate;
13-
private $publicationDate;
14-
private $version;
15-
private $versionJustification;
16-
private $endorserName;
17-
private $endorserOrcid;
18-
19-
public function __construct(array $title, string $status, $doi, $doiJournal, string $authors, string $submissionDate, string $publicationDate, $endorserName, $endorserOrcid, string $version, $versionJustification, array $galleys = null)
20-
{
21-
$this->title = $title;
22-
$this->status = $status;
23-
$this->doi = ((empty($doi)) ? ("Not informed") : ($doi));
24-
$this->doiJournal = ((empty($doiJournal)) ? ("Not informed") : ($doiJournal));
25-
$this->authors = $authors;
26-
$this->galleys = $galleys;
27-
$this->submissionDate = $submissionDate;
28-
$this->publicationDate = $publicationDate;
29-
$this->endorserName = $endorserName;
30-
$this->endorserOrcid = $endorserOrcid;
31-
$this->version = $version;
32-
$this->versionJustification = $versionJustification;
33-
}
5+
use PKP\core\DataObject;
346

7+
class SubmissionModel extends DataObject
8+
{
359
public function getTitle(string $locale): string
3610
{
37-
if (isset($this->title[$locale])) {
38-
return $this->title[$locale];
11+
$localizedTitle = $this->getData('title', $locale);
12+
13+
if (!is_null($localizedTitle)) {
14+
return $localizedTitle;
3915
}
4016

4117
return '';
4218
}
4319

4420
public function getStatus(): string
4521
{
46-
return $this->status;
22+
return $this->getData('status');
4723
}
4824

4925
public function getDOI(): string
5026
{
51-
return $this->doi;
27+
$doi = $this->getData('doi');
28+
return empty($doi) ? ("Not informed") : $doi;
5229
}
5330

5431
public function getJournalDOI(): string
5532
{
56-
return $this->doiJournal;
33+
$doiJournal = $this->getData('doiJournal');
34+
return empty($doiJournal) ? ("Not informed") : $doiJournal;
5735
}
5836

5937
public function getAuthors(): string
6038
{
61-
return $this->authors;
39+
return $this->getData('authors');
6240
}
6341

6442
public function getGalleys(): array
6543
{
66-
return $this->galleys;
44+
$galleys = $this->getData('galleys');
45+
return is_null($galleys) ? [] : $galleys;
6746
}
6847

6948
public function getSubmissionDate(): string
7049
{
71-
return $this->submissionDate;
50+
return $this->getData('submissionDate');
7251
}
7352

7453
public function getPublicationDate(): string
7554
{
76-
return $this->publicationDate;
55+
return $this->getData('publicationDate');
7756
}
7857

7958
public function getVersion(): string
8059
{
81-
return $this->version;
60+
return $this->getData('version');
8261
}
8362

8463
public function getEndorserName(): ?string
8564
{
86-
return $this->endorserName;
65+
return $this->getData('endorserName');
8766
}
8867

8968
public function getEndorserOrcid(): ?string
9069
{
91-
return $this->endorserOrcid;
70+
return $this->getData('endorserOrcid');
9271
}
9372

9473
public function getVersionJustification(): ?string
9574
{
96-
return $this->versionJustification;
75+
return $this->getData('versionJustification');
76+
}
77+
78+
public function setIsTranslation(bool $isTranslation)
79+
{
80+
$this->setData('isTranslation', $isTranslation);
81+
}
82+
83+
public function getIsTranslation(): bool
84+
{
85+
return $this->getData('isTranslation') ?? false;
86+
}
87+
88+
public function getCitation(): ?string
89+
{
90+
return $this->getData('citation');
9791
}
9892
}

classes/SubmissionPressFactory.php

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use APP\facades\Repo;
66
use APP\file\PublicFileManager;
77
use APP\publication\Publication;
8+
use APP\core\Application;
9+
use PKP\plugins\PluginRegistry;
810
use APP\plugins\generic\titlePageForPreprint\classes\SubmissionPress;
911
use APP\plugins\generic\titlePageForPreprint\classes\SubmissionModel;
1012
use APP\plugins\generic\titlePageForPreprint\classes\GalleyAdapterFactory;
@@ -24,24 +26,25 @@ public function createSubmissionPress($submission, $publication, $context): Subm
2426
$submissionGalleys[] = $galleyAdapterFactory->createGalleyAdapter($submission, $galley);
2527
}
2628

27-
return new SubmissionPress(
28-
new SubmissionModel(
29-
$dataPress['title'],
30-
$dataPress['status'],
31-
$dataPress['doi'],
32-
$dataPress['doiJournal'],
33-
$dataPress['authors'],
34-
$dataPress['submissionDate'],
35-
$dataPress['publicationDate'],
36-
$dataPress['endorserName'],
37-
$dataPress['endorserOrcid'],
38-
$dataPress['version'],
39-
$dataPress['versionJustification'],
40-
$submissionGalleys
41-
),
42-
$checklist,
43-
$logoPath
44-
);
29+
$submissionModel = new SubmissionModel();
30+
$submissionModel->setAllData([
31+
'title' => $dataPress['title'],
32+
'status' => $dataPress['status'],
33+
'doi' => $dataPress['doi'],
34+
'doiJournal' => $dataPress['doiJournal'],
35+
'authors' => $dataPress['authors'],
36+
'submissionDate' => $dataPress['submissionDate'],
37+
'publicationDate' => $dataPress['publicationDate'],
38+
'endorserName' => $dataPress['endorserName'],
39+
'endorserOrcid' => $dataPress['endorserOrcid'],
40+
'version' => $dataPress['version'],
41+
'versionJustification' => $dataPress['versionJustification'],
42+
'isTranslation' => $dataPress['isTranslation'],
43+
'citation' => $dataPress['citation'],
44+
'galleys' => $submissionGalleys
45+
]);
46+
47+
return new SubmissionPress($submissionModel, $checklist, $logoPath);
4548
}
4649

4750
private function getContextChecklist($context): array
@@ -99,6 +102,9 @@ private function getDataForPress($submission, $publication)
99102
$datePublished = strtotime($publication->getData('datePublished'));
100103
$data['publicationDate'] = date('Y-m-d', $datePublished);
101104

105+
$data['isTranslation'] = !is_null($publication->getData('originalDocumentDoi'));
106+
$data['citation'] = ($data['isTranslation'] ? $this->getSubmissionCitation($submission) : '');
107+
102108
$data['endorserName'] = $publication->getData('endorserName');
103109
$data['endorserOrcid'] = $publication->getData('endorserOrcid');
104110

@@ -108,4 +114,14 @@ private function getDataForPress($submission, $publication)
108114

109115
return $data;
110116
}
117+
118+
private function getSubmissionCitation($submission)
119+
{
120+
$request = Application::get()->getRequest();
121+
$cslPlugin = PluginRegistry::getPlugin('generic', 'citationstylelanguageplugin');
122+
123+
$citation = $cslPlugin->getCitation($request, $submission, 'apa');
124+
125+
return $citation;
126+
}
111127
}

classes/TitlePage.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,20 @@ private function generateTitlePage(): string
9999
$titlePage->Write(0, __('plugins.generic.titlePageForPreprint.publicationDate', ['postDate' => $this->submission->getPublicationDate(), 'version' => $this->submission->getVersion()], $this->locale), '', 0, 'JUSTIFY', true, 0, false, false, 0);
100100
$titlePage->Write(0, __('plugins.generic.titlePageForPreprint.dateFormat', [], $this->locale), '', 0, 'JUSTIFY', true, 0, false, false, 0);
101101

102+
if ($this->submission->getIsTranslation()) {
103+
$titlePage->Ln(5);
104+
$titlePage->writeHTML(__('plugins.generic.titlePageForPreprint.citation', ['citation' => $this->submission->getCitation()], $this->locale));
105+
}
106+
102107
$endorserName = $this->submission->getEndorserName();
103108
$endorserOrcid = $this->submission->getEndorserOrcid();
104-
if(!is_null($endorserOrcid) && !is_null($endorserName)) {
109+
if (!is_null($endorserOrcid) && !is_null($endorserName)) {
105110
$titlePage->Ln(5);
106111
$titlePage->writeHTML(__('plugins.generic.titlePageForPreprint.endorsement', ['endorserName' => $endorserName, 'endorserOrcid' => $endorserOrcid], $this->locale));
107112
}
108113

109114
$versionJustification = $this->submission->getVersionJustification();
110-
if($this->submission->getVersion() > 1 && !is_null($versionJustification)) {
115+
if ($this->submission->getVersion() > 1 && !is_null($versionJustification)) {
111116
$versionJustification = __('plugins.generic.titlePageForPreprint.versionJustification', [], $this->locale) . ": " . $versionJustification;
112117
$titlePage->Ln(5);
113118
$titlePage->Write(0, $versionJustification, '', 0, 'JUSTIFY', true, 0, false, false, 0);

classes/TitlePageRequirements.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function checkRequirements()
1616

1717
private function checkPdfManipulator()
1818
{
19-
if(!file_exists(self::CPDF_PATH)) {
19+
if (!file_exists(self::CPDF_PATH)) {
2020
$this->showMissingRequirementNotification('plugins.generic.titlePageForPreprint.requirements.pdfManipulatorMissing');
2121
return false;
2222
}

locale/en/locale.po

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ msgstr ""
3737
"The moderation of this preprint received the endorsement of:<br>"
3838
"{$endorserName} (ORCID: <a href=\"{$endorserOrcid}\">{$endorserOrcid}</a>)"
3939

40+
msgid "plugins.generic.titlePageForPreprint.citation"
41+
msgstr ""
42+
"How to cite this translation:"
43+
"{$citation}"
44+
4045
msgid "plugins.generic.titlePageForPreprint.versionJustification"
4146
msgstr "Version justification"
4247

locale/es/locale.po

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ msgstr ""
3737
"La moderación de este preprint recibió lo endoso de:<br>"
3838
"{$endorserName} (ORCID: <a href=\"{$endorserOrcid}\">{$endorserOrcid}</a>)"
3939

40+
msgid "plugins.generic.titlePageForPreprint.citation"
41+
msgstr ""
42+
"Cómo citar esta traducción:"
43+
"{$citation}"
44+
4045
msgid "plugins.generic.titlePageForPreprint.versionJustification"
4146
msgstr "Justificación de la versión"
4247

locale/pt_BR/locale.po

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ msgstr ""
3737
"A moderação deste preprint recebeu o endosso de:<br>"
3838
"{$endorserName} (ORCID: <a href=\"{$endorserOrcid}\">{$endorserOrcid}</a>)"
3939

40+
msgid "plugins.generic.titlePageForPreprint.citation"
41+
msgstr ""
42+
"Como citar esta tradução:"
43+
"{$citation}"
44+
4045
msgid "plugins.generic.titlePageForPreprint.versionJustification"
4146
msgstr "Justificativa da versão"
4247

tests/PdfHandlingTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PKP\tests\PKPTestCase;
66
use PKP\db\DAORegistry;
77
use PKP\submissionFile\SubmissionFile;
8+
use APP\plugins\generic\titlePageForPreprint\classes\SubmissionModel;
89
use APP\plugins\generic\titlePageForPreprint\classes\Translator;
910

1011
class PdfHandlingTest extends PKPTestCase
@@ -33,6 +34,8 @@ class PdfHandlingTest extends PKPTestCase
3334
protected $endorserOrcid = 'https://orcid.org/0123-4567-89AB-CDEF';
3435
protected $version = "1";
3536
protected $versionJustification = 'Nova versão criada para corrigir erros de ortografia';
37+
protected $isTranslation = false;
38+
protected $citation = 'Silva, C. & Carlos, J. (2024). Thus spoke Zarathustra. Public Knowledge Preprint Server';
3639

3740
protected function setUp(): void
3841
{
@@ -63,6 +66,28 @@ protected function tearDown(): void
6366
}
6467
}
6568

69+
protected function getSubmissionForTests(): SubmissionModel
70+
{
71+
$submission = new SubmissionModel();
72+
$submission->setAllData([
73+
'title' => $this->title,
74+
'status' => $this->status,
75+
'doi' => $this->doi,
76+
'doiJournal' => $this->doiJournal,
77+
'authors' => $this->authors,
78+
'submissionDate' => $this->submissionDate,
79+
'publicationDate' => $this->publicationDate,
80+
'endorserName' => $this->endorserName,
81+
'endorserOrcid' => $this->endorserOrcid,
82+
'version' => $this->version,
83+
'versionJustification' => $this->versionJustification,
84+
'isTranslation' => $this->isTranslation,
85+
'citation' => $this->citation,
86+
]);
87+
88+
return $submission;
89+
}
90+
6691
public function testDummy(): void
6792
{
6893
$this->assertTrue(true);

tests/SubmissionPressTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use APP\plugins\generic\titlePageForPreprint\tests\PdfHandlingTest;
44
use APP\plugins\generic\titlePageForPreprint\classes\GalleyAdapter;
55
use APP\plugins\generic\titlePageForPreprint\classes\SubmissionFileUpdater;
6-
use APP\plugins\generic\titlePageForPreprint\classes\SubmissionModel;
76
use APP\plugins\generic\titlePageForPreprint\classes\SubmissionPress;
87
use APP\plugins\generic\titlePageForPreprint\classes\Pdf;
98

@@ -17,8 +16,8 @@ private function buildMockGalleyAdapter($args): GalleyAdapter
1716
->getMock();
1817

1918
$mockGalley->expects($this->any())
20-
->method('getFullFilePath')
21-
->will($this->returnValue($args[0]));
19+
->method('getFullFilePath')
20+
->will($this->returnValue($args[0]));
2221

2322
return $mockGalley;
2423
}
@@ -36,7 +35,8 @@ public function testInsertsCorrectlySingleGalley(): void
3635
{
3736
$galleyPath = $this->pathOfTestPdf;
3837
$galley = $this->buildMockGalleyAdapter(array($galleyPath, $this->locale, 1, 2));
39-
$submission = new SubmissionModel($this->title, $this->status, $this->doi, $this->doiJournal, $this->authors, $this->submissionDate, $this->publicationDate, $this->endorserName, $this->endorserOrcid, $this->version, $this->versionJustification, array($galley));
38+
$submission = $this->getSubmissionForTests();
39+
$submission->setData('galleys', [$galley]);
4040
$press = new SubmissionPress($submission, $this->checklist, $this->logo);
4141

4242
$press->insertTitlePage($this->buildMockSubmissionFileUpdater());
@@ -51,7 +51,8 @@ public function testInsertsCorrectlyMultipleGalleys(): void
5151
$secondGalleyPath = $this->pathOfTestPdf2;
5252
$firstGalley = $this->buildMockGalleyAdapter(array($fistGalleyPath, $this->locale, 2, 2));
5353
$secondGalley = $this->buildMockGalleyAdapter(array($secondGalleyPath, "en", 3, 2));
54-
$submission = new SubmissionModel($this->title, $this->status, $this->doi, $this->doiJournal, $this->authors, $this->submissionDate, $this->publicationDate, $this->endorserName, $this->endorserOrcid, $this->version, $this->versionJustification, array($firstGalley, $secondGalley));
54+
$submission = $this->getSubmissionForTests();
55+
$submission->setData('galleys', [$firstGalley, $secondGalley]);
5556

5657
$press = new SubmissionPress($submission, $this->checklist, $this->logo);
5758
$press->insertTitlePage($this->buildMockSubmissionFileUpdater());
@@ -69,7 +70,8 @@ public function testMustIgnoreNotPdfFiles(): void
6970
$secondGalleyPath = PdfHandlingTest::TESTS_DIRECTORY . PdfHandlingTest::ASSETS_DIRECTORY . "fileNotPdf.odt";
7071
$firstGalley = $this->buildMockGalleyAdapter(array($fistGalleyPath, $this->locale, 4, 2));
7172
$secondGalley = $this->buildMockGalleyAdapter(array($secondGalleyPath, $this->locale, 5, 2));
72-
$submission = new SubmissionModel($this->title, $this->status, $this->doi, $this->doiJournal, $this->authors, $this->submissionDate, $this->publicationDate, $this->endorserName, $this->endorserOrcid, $this->version, $this->versionJustification, array($firstGalley, $secondGalley));
73+
$submission = $this->getSubmissionForTests();
74+
$submission->setData('galleys', [$firstGalley, $secondGalley]);
7375

7476
$hashOfNotPdfGalley = md5_file($secondGalleyPath);
7577
$press = new SubmissionPress($submission, $this->checklist, $this->logo);

0 commit comments

Comments
 (0)