Skip to content

Commit 3d87e1b

Browse files
committed
Add main contributor field to author form
Issue: documentacao-e-tarefas/desenvolvimento_e_infra#994 Signed-off-by: Thiago Brasil <thiago@lepidus.com.br>
1 parent 42f67ed commit 3d87e1b

6 files changed

Lines changed: 72 additions & 1 deletion

File tree

ThothPlugin.inc.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
import('plugins.generic.thoth.classes.api.ThothEndpoint');
2222
import('plugins.generic.thoth.classes.components.forms.config.CatalogEntryFormConfig');
2323
import('plugins.generic.thoth.classes.components.forms.config.PublishFormConfig');
24-
import('plugins.generic.thoth.classes.templateFilters.ThothSectionTemplateFilter');
24+
import('plugins.generic.thoth.classes.formModifiers.AuthorFormModifier');
2525
import('plugins.generic.thoth.classes.listeners.PublicationEditListener');
2626
import('plugins.generic.thoth.classes.listeners.PublicationPublishListener');
2727
import('plugins.generic.thoth.classes.notification.ThothNotification');
2828
import('plugins.generic.thoth.classes.schema.ThothSchema');
29+
import('plugins.generic.thoth.classes.templateFilters.ThothSectionTemplateFilter');
2930

3031
class ThothPlugin extends GenericPlugin
3132
{
@@ -41,6 +42,7 @@ public function register($category, $path, $mainContextId = null)
4142

4243
$this->addToSchema();
4344
$this->addFormConfig();
45+
$this->addFormModifiers();
4446
$this->addEndpoints();
4547
$this->addListeners();
4648
}
@@ -144,6 +146,12 @@ public function addFormConfig()
144146
HookRegistry::register('Form::config::before', [$catalogEntryFormConfig, 'addConfig']);
145147
}
146148

149+
public function addFormModifiers()
150+
{
151+
$authorFormModifier = new AuthorFormModifier($this);
152+
HookRegistry::register('authorform::Constructor', [$authorFormModifier, 'handleFormConstructor']);
153+
}
154+
147155
public function addEndpoints()
148156
{
149157
$thothEndpoint = new ThothEndpoint();
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/**
4+
* @file plugins/generic/thoth/classes/formModifiers/AuthorFormModifier.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 AuthorFormModifier
11+
* @ingroup plugins_generic_thoth
12+
*
13+
* @brief Additional fields to the author form
14+
*/
15+
16+
class AuthorFormModifier
17+
{
18+
private $plugin;
19+
20+
public function __construct($plugin)
21+
{
22+
$this->plugin = $plugin;
23+
}
24+
25+
public function handleFormConstructor($hookName, $args)
26+
{
27+
$form = & $args[0];
28+
29+
$form->setTemplate($this->plugin->getTemplateResource('form/authorForm.tpl'));
30+
}
31+
}

locale/en_US/locale.po

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

43+
msgid "plugins.generic.thoth.field.mainContributor.label"
44+
msgstr "Main Contributor."
45+
4346
msgid "plugins.generic.thoth.workType"
4447
msgstr "Work Type"
4548

locale/es_ES/locale.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ 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.mainContributor.label"
44+
msgstr "Colaborador Principal."
45+
4346
msgid "plugins.generic.thoth.workType"
4447
msgstr "Tipo de Trabajo"
4548

locale/pt_BR/locale.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ 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.mainContributor.label"
44+
msgstr "Contribuidor Principal."
45+
4346
msgid "plugins.generic.thoth.workType"
4447
msgstr "Tipo de Trabalho"
4548

templates/form/authorForm.tpl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{**
2+
* templates/controllers/grid/users/author/form/authorForm.tpl
3+
*
4+
* Copyright (c) 2014-2021 Simon Fraser University
5+
* Copyright (c) 2003-2021 John Willinsky
6+
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
7+
*
8+
* Submission Contributor grid form
9+
*
10+
*}
11+
12+
{if $submission->getData('workType') === $smarty.const.WORK_TYPE_EDITED_VOLUME}
13+
{capture assign="additionalCheckboxes"}
14+
{fbvElement type="checkbox" label="author.isVolumeEditor" id="isVolumeEditor" checked=$isVolumeEditor}
15+
{/capture}
16+
{/if}
17+
18+
{capture assign="additionalCheckboxes"}
19+
{$additionalCheckboxes}
20+
{fbvElement type="checkbox" label="plugins.generic.thoth.field.mainContributor.label" id="mainContributor" checked=$mainContributor}
21+
{/capture}
22+
23+
{include file="core:controllers/grid/users/author/form/authorForm.tpl" additionalCheckboxes=$additionalCheckboxes}

0 commit comments

Comments
 (0)