Skip to content

Commit 13830d1

Browse files
Merge pull request #32 from lepidus/stable-3_3_0
Feature/add Thoth fields (OMP 3.3.0)
2 parents f44dab2 + 42f67ed commit 13830d1

9 files changed

Lines changed: 111 additions & 2 deletions

File tree

ThothPlugin.inc.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import('lib.pkp.classes.plugins.GenericPlugin');
2121
import('plugins.generic.thoth.classes.api.ThothEndpoint');
22+
import('plugins.generic.thoth.classes.components.forms.config.CatalogEntryFormConfig');
2223
import('plugins.generic.thoth.classes.components.forms.config.PublishFormConfig');
2324
import('plugins.generic.thoth.classes.templateFilters.ThothSectionTemplateFilter');
2425
import('plugins.generic.thoth.classes.listeners.PublicationEditListener');
@@ -130,13 +131,17 @@ public function addToSchema()
130131
{
131132
$thothSchema = new ThothSchema();
132133
HookRegistry::register('Schema::get::submission', [$thothSchema, 'addWorkIdToSchema']);
134+
HookRegistry::register('Schema::get::publication', [$thothSchema, 'addToPublicationSchema']);
133135
HookRegistry::register('Submission::getBackendListProperties::properties', [$thothSchema, 'addToBackendProps']);
134136
}
135137

136138
public function addFormConfig()
137139
{
138140
$publishFormConfig = new PublishFormConfig();
139141
HookRegistry::register('Form::config::before', [$publishFormConfig, 'addConfig']);
142+
143+
$catalogEntryFormConfig = new CatalogEntryFormConfig();
144+
HookRegistry::register('Form::config::before', [$catalogEntryFormConfig, 'addConfig']);
140145
}
141146

142147
public function addEndpoints()
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/**
4+
* @file plugins/generic/thoth/classes/components/forms/config/CatalogEntryFormConfig.inc.php
5+
*
6+
* Copyright (c) 2024-2025 Lepidus Tecnologia
7+
* Copyright (c) 2024-2025 Thoth
8+
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
9+
*
10+
* @class CatalogEntryFormConfig
11+
* @ingroup plugins_generic_thoth
12+
*
13+
* @brief Thoth config for catalog entry form
14+
*/
15+
16+
class CatalogEntryFormConfig
17+
{
18+
public function addConfig($hookName, $form)
19+
{
20+
if ($form->id !== 'catalogEntry' || !empty($form->errors)) {
21+
return;
22+
}
23+
24+
$actionParts = explode('/', $form->action);
25+
$publicationId = end($actionParts);
26+
$publication = Services::get('publication')->get($publicationId);
27+
28+
$form->addField(new \PKP\components\forms\FieldText('place', [
29+
'label' => __('plugins.generic.thoth.field.place.label'),
30+
'value' => $publication->getData('place'),
31+
]))
32+
->addField(new \PKP\components\forms\FieldText('pageCount', [
33+
'label' => __('plugins.generic.thoth.field.pageCount.label'),
34+
'value' => $publication->getData('pageCount'),
35+
]))
36+
->addField(new \PKP\components\forms\FieldText('imageCount', [
37+
'label' => __('plugins.generic.thoth.field.imageCount.label'),
38+
'value' => $publication->getData('imageCount'),
39+
]));
40+
41+
return false;
42+
}
43+
}

classes/factories/ThothBookFactory.inc.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public function createFromPublication($publication)
3838
'edition' => $publication->getData('version'),
3939
'doi' => $this->getDoi($publication),
4040
'publicationDate' => $publication->getData('datePublished'),
41+
'place' => $publication->getData('place'),
42+
'pageCount' => $publication->getData('pageCount'),
43+
'imageCount' => $publication->getData('imageCount'),
4144
'license' => $publication->getData('licenseUrl')
4245
?? $submission->_getContextLicenseFieldValue(
4346
null,

classes/schema/ThothSchema.inc.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,31 @@ public function addWorkIdToSchema($hookName, $args)
2626
return false;
2727
}
2828

29+
public function addToPublicationSchema($hookName, $args)
30+
{
31+
$schema = & $args[0];
32+
33+
$schema->properties->{'place'} = (object) [
34+
'type' => 'string',
35+
'apiSummary' => true,
36+
'validation' => ['nullable'],
37+
];
38+
39+
$schema->properties->{'pageCount'} = (object) [
40+
'type' => 'integer',
41+
'apiSummary' => true,
42+
'validation' => ['nullable'],
43+
];
44+
45+
$schema->properties->{'imageCount'} = (object) [
46+
'type' => 'integer',
47+
'apiSummary' => true,
48+
'validation' => ['nullable'],
49+
];
50+
51+
return false;
52+
}
53+
2954
public function addToBackendProps($hookName, $args)
3055
{
3156
$props = & $args[0];

locale/en_US/locale.po

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ msgstr "Your site administrator must set a secret in the config file ('api_key_s
3131
msgid "plugins.generic.thoth.credentialsMissing"
3232
msgstr "Thoth credentials not configured."
3333

34+
msgid "plugins.generic.thoth.field.place.label"
35+
msgstr "Place of Publication"
36+
37+
msgid "plugins.generic.thoth.field.pageCount.label"
38+
msgstr "Page Count"
39+
40+
msgid "plugins.generic.thoth.field.imageCount.label"
41+
msgstr "Image Count"
42+
3443
msgid "plugins.generic.thoth.workType"
3544
msgstr "Work Type"
3645

locale/es_ES/locale.po

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ msgstr "El administrador de su sitio debe establecer un secreto en el archivo de
3131
msgid "plugins.generic.thoth.credentialsMissing"
3232
msgstr "Credenciales de Thoth no configuradas."
3333

34+
msgid "plugins.generic.thoth.field.place.label"
35+
msgstr "Lugar de Publicación"
36+
37+
msgid "plugins.generic.thoth.field.pageCount.label"
38+
msgstr "Número de Páginas"
39+
40+
msgid "plugins.generic.thoth.field.imageCount.label"
41+
msgstr "Número de Imágenes"
42+
3443
msgid "plugins.generic.thoth.workType"
3544
msgstr "Tipo de Trabajo"
3645

locale/pt_BR/locale.po

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ msgstr "O administrador do seu site deve definir um segredo no arquivo de config
3131
msgid "plugins.generic.thoth.credentialsMissing"
3232
msgstr "Credenciais do Thoth não configuradas."
3333

34+
msgid "plugins.generic.thoth.field.place.label"
35+
msgstr "Local de Publicação"
36+
37+
msgid "plugins.generic.thoth.field.pageCount.label"
38+
msgstr "Número de Páginas"
39+
40+
msgid "plugins.generic.thoth.field.imageCount.label"
41+
msgstr "Número de Imagens"
42+
3443
msgid "plugins.generic.thoth.workType"
3544
msgstr "Tipo de Trabalho"
3645

tests/classes/factories/ThothBookFactoryTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ private function setUpMockEnvironment()
107107
->will($this->returnValueMap([
108108
['version', null, 1],
109109
['datePublished', null, '2020-01-01'],
110+
['place', null, 'Salvador, BR'],
111+
['pageCount', null, 64],
112+
['imageCount', null, 32],
110113
['licenseUrl', null, 'https://creativecommons.org/licenses/by-nc/4.0/']
111114
]));
112115
$mockPublication->expects($this->any())
@@ -150,6 +153,9 @@ public function testCreateThothBookFromPublication()
150153
'subtitle' => 'My book subtitle',
151154
'edition' => 1,
152155
'publicationDate' => '2020-01-01',
156+
'place' => 'Salvador, BR',
157+
'pageCount' => 64,
158+
'imageCount' => 32,
153159
'doi' => 'https://doi.org/10.12345/0101010101',
154160
'license' => 'https://creativecommons.org/licenses/by-nc/4.0/',
155161
'copyrightHolder' => 'Public Knowledge Press',

version.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<version>
44
<application>thoth</application>
55
<type>plugins.generic</type>
6-
<release>0.1.7.1</release>
7-
<date>2025-04-28</date>
6+
<release>0.1.8.0</release>
7+
<date>2025-04-29</date>
88
<lazy-load>1</lazy-load>
99
<class>ThothPlugin</class>
1010
</version>

0 commit comments

Comments
 (0)