'Datacite Plugin', 'description' => 'Registration agency plugin for Datacite', 'type' => 'object', 'required' => [], 'properties' => (object) [ 'username' => (object) [ 'type' => 'string', 'validation' => ['nullable', 'max:50'] ], 'password' => (object) [ 'type' => 'string', 'validation' => ['nullable', 'max:50'] ], 'testMode' => (object) [ 'type' => 'boolean', 'validation' => ['nullable'] ], 'testUsername' => (object) [ 'type' => 'string', 'validation' => ['nullable', 'max:50'] ], 'testPassword' => (object) [ 'type' => 'string', 'validation' => ['nullable', 'max:50'] ], 'testDOIPrefix' => (object) [ 'type' => 'string', 'validation' => ['nullable', 'max:50'] ], ], ]; } /** * @inheritDoc */ public function getFields(Context $context): array { return [ new FieldHTML('preamble', [ 'label' => __('plugins.importexport.datacite.settings.label'), 'description' => $this->_getPreambleText(), ]), new FieldText('username', [ 'label' => __('plugins.importexport.datacite.settings.form.username'), 'value' => $this->agencyPlugin->getSetting($context->getId(), 'username'), ]), new FieldText('password', [ 'label' => __('plugins.importexport.common.settings.form.password'), 'description' => __('plugins.importexport.common.settings.form.password.description'), 'inputType' => 'password', 'value' => $this->agencyPlugin->getSetting($context->getId(), 'password'), ]), new FieldOptions('testMode', [ 'label' => __('plugins.importexport.common.settings.form.testMode.label'), 'options' => [ ['value' => true, 'label' => __('plugins.importexport.datacite.settings.form.testMode.description')], ], 'value' => $this->agencyPlugin->getSetting($context->getId(), 'testMode'), ]), new FieldText('testUsername', [ 'label' => __('plugins.importexport.datacite.settings.form.testUsername'), 'value' => $this->agencyPlugin->getSetting($context->getId(), 'testUsername'), ]), new FieldText('testPassword', [ 'label' => __('plugins.importexport.datacite.settings.form.testPassword'), 'description' => __('plugins.importexport.common.settings.form.password.description'), 'inputType' => 'password', 'value' => $this->agencyPlugin->getSetting($context->getId(), 'testPassword'), ]), new FieldText('testDOIPrefix', [ 'label' => __('plugins.importexport.datacite.settings.form.testDOIPrefix'), 'value' => $this->agencyPlugin->getSetting($context->getId(), 'testDOIPrefix'), ]), ]; } /** * @inheritDoc */ protected function addValidationChecks(Validator &$validator, $props): void { // If in test mode, the test DOI prefix must be set $validator->after(function (Validator $validator) use ($props) { if ($props['testMode']) { if (empty($props['testDOIPrefix'])) { $validator->errors()->add('testDOIPrefix', __('plugins.importexport.datacite.settings.form.testDOIPrefixRequired')); } } }); // If username exists, there will be the possibility to register from within OJS, // so the test username must exist too $validator->after(function (Validator $validator) use ($props) { if (!empty($props['username']) && empty($props['testUsername'])) { $validator->errors()->add('testUsername', __('plugins.importexport.datacite.settings.form.testUsernameRequired')); } }); } protected function _getPreambleText(): string { $text = ''; $text .= '
' . __('plugins.importexport.datacite.settings.description') . '
'; $text .= '' . __('plugins.importexport.datacite.intro') . '
'; return $text; } }