Skip to content

Commit e3b9830

Browse files
Merge pull request #35 from lepidus/main
Feature/added main contribution field to author form (OMP 3.4.0)
2 parents 9a8b89d + c4138d0 commit e3b9830

8 files changed

Lines changed: 81 additions & 2 deletions

File tree

ThothPlugin.inc.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import('plugins.generic.thoth.classes.api.ThothEndpoint');
2525
import('plugins.generic.thoth.classes.components.forms.config.CatalogEntryFormConfig');
2626
import('plugins.generic.thoth.classes.components.forms.config.PublishFormConfig');
27+
import('plugins.generic.thoth.classes.components.forms.config.ContributorFormConfig');
2728
import('plugins.generic.thoth.classes.templateFilters.ThothSectionTemplateFilter');
2829
import('plugins.generic.thoth.classes.listeners.PublicationEditListener');
2930
import('plugins.generic.thoth.classes.listeners.PublicationPublishListener');
@@ -126,6 +127,7 @@ public function addToSchema()
126127
HookRegistry::register('Schema::get::eventLog', [$thothSchema, 'addReasonToSchema']);
127128
HookRegistry::register('Schema::get::submission', [$thothSchema, 'addWorkIdToSchema']);
128129
HookRegistry::register('Schema::get::publication', [$thothSchema, 'addToPublicationSchema']);
130+
HookRegistry::register('Schema::get::author', [$thothSchema, 'addToAuthorSchema']);
129131
HookRegistry::register('Submission::getSubmissionsListProps', [$thothSchema, 'addToSubmissionsListProps']);
130132
}
131133

@@ -161,6 +163,9 @@ public function addFormConfig()
161163

162164
$catalogEntryFormConfig = new CatalogEntryFormConfig();
163165
HookRegistry::register('Form::config::before', [$catalogEntryFormConfig, 'addConfig']);
166+
167+
$contributorFormConfig = new ContributorFormConfig();
168+
HookRegistry::register('Form::config::before', [$contributorFormConfig, 'addConfig']);
164169
}
165170

166171
public function addListeners()
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/**
4+
* @file plugins/generic/thoth/classes/components/forms/config/ContributorFormConfig.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 ContributorFormConfig
11+
* @ingroup plugins_generic_thoth
12+
*
13+
* @brief Thoth configuration for contributor form
14+
*/
15+
16+
use APP\facades\Repo;
17+
18+
class ContributorFormConfig
19+
{
20+
public function addConfig($hookName, $form)
21+
{
22+
if ($form->id !== 'contributor' || !empty($form->errors)) {
23+
return;
24+
}
25+
26+
$form->addField(new \PKP\components\forms\FieldOptions('mainContribution', [
27+
'label' => __('plugins.generic.thoth.field.mainContribution'),
28+
'value' => false,
29+
'options' => [
30+
[
31+
'value' => true,
32+
'label' => __('plugins.generic.thoth.field.mainContribution.label'),
33+
],
34+
],
35+
]));
36+
37+
return false;
38+
}
39+
}

classes/factories/ThothContributionFactory.inc.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public function createFromAuthor($author, $primaryContactId = null)
3737

3838
private function isMainContribution($author, $primaryContactId = null)
3939
{
40+
if ($mainContribution = $author->getData('mainContribution')) {
41+
return $mainContribution;
42+
}
43+
4044
return $primaryContactId == $author->getId();
4145
}
4246

classes/schema/ThothSchema.inc.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ public function addToPublicationSchema($hookName, $args)
6363
return false;
6464
}
6565

66+
public function addToAuthorSchema($hookName, $args)
67+
{
68+
$schema = & $args[0];
69+
70+
$schema->properties->{'mainContribution'} = (object) [
71+
'type' => 'boolean',
72+
'apiSummary' => true,
73+
'validation' => ['nullable'],
74+
];
75+
76+
return false;
77+
}
78+
6679
public function addToSubmissionsListProps($hookName, $args)
6780
{
6881
$props = & $args[0];

locale/en/locale.po

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ msgstr "Page Count"
4040
msgid "plugins.generic.thoth.field.imageCount.label"
4141
msgstr "Image Count"
4242

43+
msgid "plugins.generic.thoth.field.mainContribution"
44+
msgstr "Thoth Main Contribution"
45+
46+
msgid "plugins.generic.thoth.field.mainContribution.label"
47+
msgstr "Identify this contributor as main contribution in Thoth."
48+
4349
msgid "plugins.generic.thoth.workType"
4450
msgstr "Work Type"
4551

locale/es/locale.po

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ msgstr "Número de Páginas"
4040
msgid "plugins.generic.thoth.field.imageCount.label"
4141
msgstr "Número de Imágenes"
4242

43+
msgid "plugins.generic.thoth.field.mainContribution"
44+
msgstr "Colaboración Principal de Thoth"
45+
46+
msgid "plugins.generic.thoth.field.mainContribution.label"
47+
msgstr "Identificar a este colaborador como colaboración principal en Thoth."
48+
4349
msgid "plugins.generic.thoth.workType"
4450
msgstr "Tipo de Trabajo"
4551

locale/pt_BR/locale.po

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ msgstr "Número de Páginas"
4040
msgid "plugins.generic.thoth.field.imageCount.label"
4141
msgstr "Número de Imagens"
4242

43+
msgid "plugins.generic.thoth.field.mainContribution"
44+
msgstr "Contribuição Principal do Thoth"
45+
46+
msgid "plugins.generic.thoth.field.mainContribution.label"
47+
msgstr "Identificar este contribuidor como contribuição principal em Thoth."
48+
4349
msgid "plugins.generic.thoth.workType"
4450
msgstr "Tipo de Trabalho"
4551

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.2.6.0</release>
7-
<date>2025-04-29</date>
6+
<release>0.2.7.0</release>
7+
<date>2025-05-01</date>
88
<lazy-load>1</lazy-load>
99
<class>ThothPlugin</class>
1010
</version>

0 commit comments

Comments
 (0)