Open Monograph Press  3.3.0
PKPPublicationLicenseForm.inc.php
1 <?php
15 use \PKP\components\forms\FormComponent;
16 use \PKP\components\forms\FieldText;
17 use \PKP\components\forms\FieldHTML;
18 use \PKP\components\forms\FieldOptions;
19 
20 define('FORM_PUBLICATION_LICENSE', 'publicationLicense');
21 
25 
27  public $method = 'PUT';
28 
38  public function __construct($action, $locales, $publication, $context, $userGroups) {
39  $this->action = $action;
40  $this->locales = $locales;
41 
42  // Get the copyright that will be set on publication based on context settings
43  if ($context->getData('copyrightHolderType') === 'author') {
44  $copyright = $publication->getAuthorString($userGroups);
45  } elseif ($context->getData('copyrightHolderType') === 'other') {
46  $copyright = $context->getLocalizedData('copyrightHolderOther');
47  } else {
48  $copyright = $context->getLocalizedData('name');
49  }
50 
51  // Get the name of the context's license setting
52  $licenseUrlDescription = '';
53  if ($context->getData('licenseUrl')) {
54  $licenseOptions = \Application::getCCLicenseOptions();
55  if (array_key_exists($context->getData('licenseUrl'), $licenseOptions)) {
56  $licenseName = __($licenseOptions[$context->getData('licenseUrl')]);
57  } else {
58  $licenseName = $context->getData('licenseUrl');
59  }
60  $licenseUrlDescription = __('submission.license.description', [
61  'licenseUrl' => $context->getData('licenseUrl'),
62  'licenseName' => $licenseName,
63  ]);
64  }
65 
66  $this->addField(new FieldText('copyrightHolder', [
67  'label' => __('submission.copyrightHolder'),
68  'description' => __('submission.copyrightHolder.description', ['copyright' => $copyright]),
69  'isMultilingual' => true,
70  'optIntoEdit' => !$publication->getData('copyrightHolder'),
71  'optIntoEditLabel' => __('common.override'),
72  'value' => $publication->getData('copyrightHolder'),
73  ]))
74  ->addField(new FieldText('copyrightYear', [
75  'label' => __('submission.copyrightYear'),
76  'description' => $context->getData('copyrightYearBasis') === 'issue'
77  ? __('publication.copyrightYearBasis.issueDescription')
78  : __('publication.copyrightYearBasis.submissionDescription'),
79  'optIntoEdit' => !$publication->getData('copyrightYear'),
80  'optIntoEditLabel' => __('common.override'),
81  'value' => $publication->getData('copyrightYear'),
82  ]))
83  ->addField(new FieldText('licenseUrl', [
84  'label' => __('submission.licenseURL'),
85  'description' => $licenseUrlDescription,
86  'optIntoEdit' => $context->getData('licenseUrl') && !$publication->getData('licenseUrl'),
87  'optIntoEditLabel' => __('common.override'),
88  'value' => $publication->getData('licenseUrl'),
89  ]));
90  }
91 }
PKP\components\forms\publication\PKPPublicationLicenseForm\$id
$id
Definition: PKPPublicationLicenseForm.inc.php:24
PKP\components\forms\publication
Definition: PKPCitationsForm.inc.php:14
PKP\components\forms\FieldText
Definition: FieldText.inc.php:15
PKP\components\forms\publication\PKPPublicationLicenseForm
Definition: PKPPublicationLicenseForm.inc.php:22
PKP\components\forms\publication\PKPPublicationLicenseForm\__construct
__construct($action, $locales, $publication, $context, $userGroups)
Definition: PKPPublicationLicenseForm.inc.php:38
PKP\components\forms\publication\FORM_PUBLICATION_LICENSE
const FORM_PUBLICATION_LICENSE
Definition: PKPPublicationLicenseForm.inc.php:20
PKPApplication\getCCLicenseOptions
static getCCLicenseOptions()
Definition: PKPApplication.inc.php:686
PKP\components\forms\FormComponent\$action
$action
Definition: FormComponent.inc.php:37
PKP\components\forms\publication\PKPPublicationLicenseForm\$method
$method
Definition: PKPPublicationLicenseForm.inc.php:27
PKP\components\forms\FormComponent
Definition: FormComponent.inc.php:20
PKP\components\forms\FormComponent\addField
addField($field, $position=[])
Definition: FormComponent.inc.php:94
PKP\components\forms\FormComponent\$locales
$locales
Definition: FormComponent.inc.php:43