first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-06-08 17:09:23 -04:00
commit df3a033196
17887 changed files with 8637778 additions and 0 deletions
@@ -0,0 +1,69 @@
<?php
/**
* @file classes/components/form/context/PKPAnnouncementSettingsForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPAnnouncementSettingsForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for enabling and configuring announcements.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldRichTextarea;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
use PKP\context\Context;
use PKP\site\Site;
define('FORM_ANNOUNCEMENT_SETTINGS', 'announcementSettings');
class PKPAnnouncementSettingsForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_ANNOUNCEMENT_SETTINGS;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
*/
public function __construct($action, $locales, Context|Site $context)
{
$this->action = $action;
$this->locales = $locales;
$this->addField(new FieldOptions('enableAnnouncements', [
'label' => __('manager.setup.announcements'),
'description' => __('manager.setup.enableAnnouncements.description'),
'options' => [
['value' => true, 'label' => __('manager.setup.enableAnnouncements.enable')]
],
'value' => (bool) $context->getData('enableAnnouncements'),
]))
->addField(new FieldRichTextarea('announcementsIntroduction', [
'label' => __('manager.setup.announcementsIntroduction'),
'tooltip' => __('manager.setup.announcementsIntroduction.description'),
'isMultilingual' => true,
'value' => $context->getData('announcementsIntroduction'),
'showWhen' => 'enableAnnouncements',
]))
->addField(new FieldText('numAnnouncementsHomepage', [
'label' => __('manager.setup.numAnnouncementsHomepage'),
'description' => __('manager.setup.numAnnouncementsHomepage.description'),
'size' => 'small',
'value' => $context->getData('numAnnouncementsHomepage'),
'showWhen' => 'enableAnnouncements',
]));
}
}
@@ -0,0 +1,76 @@
<?php
/**
* @file classes/components/form/context/PKPAppearanceAdvancedForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPAppearanceAdvancedForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for advanced settings under the website appearance tab.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldRichTextarea;
use PKP\components\forms\FieldUpload;
use PKP\components\forms\FieldUploadImage;
use PKP\components\forms\FormComponent;
define('FORM_APPEARANCE_ADVANCED', 'appearanceAdvanced');
class PKPAppearanceAdvancedForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_APPEARANCE_ADVANCED;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
* @param string $baseUrl Site's base URL. Used for image previews.
* @param string $temporaryFileApiUrl URL to upload files to
* @param string $imageUploadUrl The API endpoint for images uploaded through the rich text field
*/
public function __construct($action, $locales, $context, $baseUrl, $temporaryFileApiUrl, $imageUploadUrl)
{
$this->action = $action;
$this->locales = $locales;
$this->addField(new FieldUpload('styleSheet', [
'label' => __('manager.setup.useStyleSheet'),
'value' => $context->getData('styleSheet'),
'options' => [
'url' => $temporaryFileApiUrl,
'acceptedFiles' => '.css',
],
]))
->addField(new FieldUploadImage('favicon', [
'label' => __('manager.setup.favicon'),
'value' => $context->getData('favicon'),
'isMultilingual' => true,
'baseUrl' => $baseUrl,
'options' => [
'url' => $temporaryFileApiUrl,
'acceptedFiles' => 'image/x-icon,image/png,image/gif',
],
]))
->addField(new FieldRichTextarea('additionalHomeContent', [
'label' => __('manager.setup.additionalContent'),
'description' => __('manager.setup.additionalContent.description'),
'isMultilingual' => true,
'value' => $context->getData('additionalHomeContent'),
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist | image | code',
'plugins' => 'paste,link,lists,image,code',
'uploadUrl' => $imageUploadUrl,
]));
}
}
@@ -0,0 +1,112 @@
<?php
/**
* @file classes/components/form/context/PKPAppearanceSetupForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPAppearanceSetupForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for general website appearance setup, such as uploading
* a logo.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldRichTextarea;
use PKP\components\forms\FieldUploadImage;
use PKP\components\forms\FormComponent;
use PKP\plugins\PluginRegistry;
define('FORM_APPEARANCE_SETUP', 'appearanceSetup');
class PKPAppearanceSetupForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_APPEARANCE_SETUP;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
* @param string $baseUrl Site's base URL. Used for image previews.
* @param string $temporaryFileApiUrl URL to upload files to
* @param string $imageUploadUrl The API endpoint for images uploaded through the rich text field
*/
public function __construct($action, $locales, $context, $baseUrl, $temporaryFileApiUrl, $imageUploadUrl)
{
$this->action = $action;
$this->locales = $locales;
$sidebarOptions = [];
$enabledOptions = [];
$disabledOptions = [];
$currentBlocks = (array) $context->getData('sidebar');
$plugins = PluginRegistry::loadCategory('blocks', true);
foreach ($currentBlocks as $plugin) {
if (isset($plugins[$plugin])) {
$enabledOptions[] = [
'value' => $plugin,
'label' => htmlspecialchars($plugins[$plugin]->getDisplayName()),
];
}
}
foreach ($plugins as $pluginName => $plugin) {
if (!in_array($pluginName, $currentBlocks)) {
$disabledOptions[] = [
'value' => $pluginName,
'label' => htmlspecialchars($plugin->getDisplayName()),
];
}
}
$sidebarOptions = array_merge($enabledOptions, $disabledOptions);
$this->addField(new FieldUploadImage('pageHeaderLogoImage', [
'label' => __('manager.setup.logo'),
'value' => $context->getData('pageHeaderLogoImage'),
'isMultilingual' => true,
'baseUrl' => $baseUrl,
'options' => [
'url' => $temporaryFileApiUrl,
],
]))
->addField(new FieldUploadImage('homepageImage', [
'label' => __('manager.setup.homepageImage'),
'tooltip' => __('manager.setup.homepageImage.description'),
'value' => $context->getData('homepageImage'),
'isMultilingual' => true,
'baseUrl' => $baseUrl,
'options' => [
'url' => $temporaryFileApiUrl,
],
]))
->addField(new FieldRichTextarea('pageFooter', [
'label' => __('manager.setup.pageFooter'),
'tooltip' => __('manager.setup.pageFooter.description'),
'isMultilingual' => true,
'value' => $context->getData('pageFooter'),
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist | image | code',
'plugins' => 'paste,link,lists,image,code',
'uploadUrl' => $imageUploadUrl,
]))
->addField(new FieldOptions('sidebar', [
'label' => __('manager.setup.layout.sidebar'),
'isOrderable' => true,
'value' => $currentBlocks,
'options' => $sidebarOptions,
]));
}
}
@@ -0,0 +1,102 @@
<?php
/**
* @file classes/components/form/context/PKPContactForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPContactForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring a context's contact details.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldText;
use PKP\components\forms\FieldTextarea;
use PKP\components\forms\FormComponent;
define('FORM_CONTACT', 'contact');
class PKPContactForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_CONTACT;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
*/
public function __construct($action, $locales, $context)
{
$this->action = $action;
$this->locales = $locales;
$this->addGroup([
'id' => 'principal',
'label' => __('manager.setup.principalContact'),
'description' => __('manager.setup.principalContactDescription'),
])
->addField(new FieldText('contactName', [
'label' => __('common.name'),
'isRequired' => true,
'groupId' => 'principal',
'value' => $context->getData('contactName'),
]))
->addField(new FieldText('contactEmail', [
'label' => __('user.email'),
'isRequired' => true,
'groupId' => 'principal',
'value' => $context->getData('contactEmail'),
]))
->addField(new FieldText('contactPhone', [
'label' => __('user.phone'),
'groupId' => 'principal',
'value' => $context->getData('contactPhone'),
]))
->addField(new FieldText('contactAffiliation', [
'label' => __('user.affiliation'),
'isMultilingual' => true,
'groupId' => 'principal',
'value' => $context->getData('contactAffiliation'),
]))
->addField(new FieldTextarea('mailingAddress', [
'label' => __('common.mailingAddress'),
'isRequired' => false,
'size' => 'small',
'groupId' => 'principal',
'value' => $context->getData('mailingAddress'),
]))
->addGroup([
'id' => 'technical',
'label' => __('manager.setup.technicalSupportContact'),
'description' => __('manager.setup.technicalSupportContactDescription'),
])
->addField(new FieldText('supportName', [
'label' => __('common.name'),
'isRequired' => true,
'groupId' => 'technical',
'value' => $context->getData('supportName'),
]))
->addField(new FieldText('supportEmail', [
'label' => __('user.email'),
'isRequired' => true,
'groupId' => 'technical',
'value' => $context->getData('supportEmail'),
]))
->addField(new FieldText('supportPhone', [
'label' => __('user.phone'),
'groupId' => 'technical',
'value' => $context->getData('supportPhone'),
]));
}
}
@@ -0,0 +1,128 @@
<?php
/**
* @file classes/components/form/context/PKPContextForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPContextForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for adding and editing a context from the admin area.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldRichTextarea;
use PKP\components\forms\FieldSelect;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
use PKP\facades\Locale;
define('FORM_CONTEXT', 'context');
class PKPContextForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_CONTEXT;
/** @copydoc FormComponent::$method */
public $method = 'POST';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param string $baseUrl Base URL for the site
* @param \PKP\context\Context $context Journal or Press to change settings for
*/
public function __construct($action, $locales, $baseUrl, $context)
{
$this->action = $action;
$this->locales = $locales;
$this->method = $context ? 'PUT' : 'POST';
$countries = [];
foreach (Locale::getCountries() as $country) {
$countries[] = [
'value' => $country->getAlpha2(),
'label' => $country->getLocalName()
];
}
usort($countries, function ($a, $b) {
return strcmp($a['label'], $b['label']);
});
$this
->addField(new FieldText('name', [
'label' => __('manager.setup.contextTitle'),
'isRequired' => true,
'isMultilingual' => true,
'value' => $context ? $context->getData('name') : null,
]))
->addField(new FieldText('acronym', [
'label' => __('manager.setup.contextInitials'),
'size' => 'small',
'isRequired' => true,
'isMultilingual' => true,
'groupId' => 'identity',
'value' => $context ? $context->getData('acronym') : null,
]))
->addField(new FieldText('contactName', [
'label' => __('manager.setup.principalContact') . ' ' . __('common.name'),
'isRequired' => true,
'value' => $context ? $context->getData('contactName') : null,
]))
->addField(new FieldText('contactEmail', [
'label' => __('manager.setup.principalContact') . ' ' . __('user.email'),
'isRequired' => true,
'value' => $context ? $context->getData('contactEmail') : null,
]))
->addField(new FieldSelect('country', [
'label' => __('common.country'),
'description' => __('manager.setup.selectCountry'),
'options' => $countries,
'value' => $context ? $context->getData('country') : null,
]))
->addField(new FieldRichTextarea('description', [
'label' => __('admin.contexts.contextDescription'),
'isMultilingual' => true,
'value' => $context ? $context->getData('description') : null,
]))
->addField(new FieldText('urlPath', [
'label' => __('context.path'),
'isRequired' => true,
'value' => $context ? $context->getData('urlPath') : null,
'prefix' => $baseUrl . '/',
'size' => 'large',
]));
if (!$context && count($locales) > 1) {
$localeOptions = [];
foreach ($locales as $locale) {
$localeOptions[] = [
'value' => $locale['key'],
'label' => $locale['label'],
];
}
$this->addField(new FieldOptions('supportedLocales', [
'label' => __('common.languages'),
'isRequired' => true,
'value' => [],
'options' => $localeOptions,
]))
->addField(new FieldOptions('primaryLocale', [
'label' => __('locale.primary'),
'type' => 'radio',
'isRequired' => true,
'value' => null,
'options' => $localeOptions,
]));
}
}
}
@@ -0,0 +1,103 @@
<?php
/**
* @file classes/components/forms/context/PKPContextStatisticsForm.php
*
* Copyright (c) 2022 Simon Fraser University
* Copyright (c) 2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPContextStatisticsForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for the context specific statistics settings.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FormComponent;
use PKP\context\Context;
use PKP\site\Site;
use PKP\statistics\PKPStatisticsHelper;
define('FORM_CONTEXT_STATISTICS', 'contextStatistics');
class PKPContextStatisticsForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_CONTEXT_STATISTICS;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
*/
public function __construct(string $action, array $locales, Site $site, Context $context)
{
$this->action = $action;
$this->locales = $locales;
$possibleGeoOptions = [
'disabled' => __('manager.settings.statistics.geoUsageStats.disabled'),
PKPStatisticsHelper::STATISTICS_SETTING_COUNTRY => __('manager.settings.statistics.geoUsageStats.countryLevel'),
PKPStatisticsHelper::STATISTICS_SETTING_REGION => __('manager.settings.statistics.geoUsageStats.regionLevel'),
PKPStatisticsHelper::STATISTICS_SETTING_CITY => __('manager.settings.statistics.geoUsageStats.cityLevel'),
];
$geoOptions = [];
foreach ($possibleGeoOptions as $value => $label) {
$geoOptions[] = [
'value' => $value,
'label' => $label,
];
if ($site->getData('enableGeoUsageStats') === $value) {
break;
}
}
$selectedGeoOption = $site->getData('enableGeoUsageStats');
if ($context->getData('enableGeoUsageStats') != null &&
str_starts_with($selectedGeoOption, $context->getData('enableGeoUsageStats'))) {
$selectedGeoOption = $context->getData('enableGeoUsageStats');
}
if ($site->getData('enableGeoUsageStats') && $site->getData('enableGeoUsageStats') !== 'disabled') {
$this->addField(new FieldOptions('enableGeoUsageStats', [
'label' => __('manager.settings.statistics.geoUsageStats'),
'description' => __('manager.settings.statistics.geoUsageStats.description'),
'type' => 'radio',
'options' => $geoOptions,
'value' => $selectedGeoOption,
]));
}
if ($site->getData('enableInstitutionUsageStats')) {
$this->addField(new FieldOptions('enableInstitutionUsageStats', [
'label' => __('manager.settings.statistics.institutionUsageStats'),
'description' => __('manager.settings.statistics.institutionUsageStats.description'),
'options' => [
[
'value' => true,
'label' => __('manager.settings.statistics.institutionUsageStats.enable'),
],
],
'value' => $context->getData('enableInstitutionUsageStats') !== null ? $context->getData('enableInstitutionUsageStats') : $site->getData('enableInstitutionUsageStats'),
]));
}
if ($site->getData('isSushiApiPublic') !== null && $site->getData('isSushiApiPublic')) {
$this->addField(new FieldOptions('isSushiApiPublic', [
'label' => __('manager.settings.statistics.publicSushiApi'),
'description' => __('manager.settings.statistics.publicSushiApi.description'),
'options' => [
[
'value' => true,
'label' => __('manager.settings.statistics.publicSushiApi.public'),
],
],
'value' => $context->getData('isSushiApiPublic') !== null ? $context->getData('isSushiApiPublic') : $site->getData('isSushiApiPublic'),
]));
}
}
}
@@ -0,0 +1,159 @@
<?php
/**
* @file classes/components/form/context/PKPDateTimeForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPDateTimeForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for presenting date and time on the frontend
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldRadioInput;
use PKP\components\forms\FormComponent;
define('FORM_DATE_TIME', 'dateTime');
class PKPDateTimeForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_DATE_TIME;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \Context $context Journal or Press to change settings for
*/
public function __construct($action, $locales, $context)
{
$this->action = $action;
$this->locales = $locales;
$localizedOptions = []; // template for localized options to be used for date and time format
foreach ($this->locales as $key => $localeValue) {
$localizedOptions[$localeValue['key']] = $key;
}
$this->addGroup([
'id' => 'descriptions',
'label' => __('manager.setup.dateTime.descriptionTitle'),
'description' => __('manager.setup.dateTime.description'),
])
//The default date format to use in the editorial and reader interfaces.
->addField(new FieldRadioInput('dateFormatLong', [
'label' => __('manager.setup.dateTime.longDate'),
'isMultilingual' => true,
'options' => $this->_setDateOptions([
'%B %e, %Y',
'%B %e %Y',
'%e %B %Y',
'%Y %B %e',
]),
'value' => $context->getDateTimeFormats('dateFormatLong'),
'groupId' => 'descriptions',
]))
// A brief date format that is used when there is less space for the full date.
->addField(new FieldRadioInput('dateFormatShort', [
'label' => __('manager.setup.dateTime.shortDate'),
'isMultilingual' => true,
'options' => $this->_setDateOptions([
'%Y-%m-%d',
'%d-%m-%Y',
'%m/%d/%Y',
'%d.%m.%Y',
]),
'value' => $context->getDateTimeFormats('dateFormatShort'),
'groupId' => 'descriptions',
]))
->addField(new FieldRadioInput('timeFormat', [
'label' => __('manager.setup.dateTime.time'),
'isMultilingual' => true,
'options' => $this->_setDateOptions([
'%H:%M',
'%I:%M %p',
'%l:%M%P',
]),
'value' => $context->getDateTimeFormats('timeFormat'),
'groupId' => 'descriptions',
]))
->addField(new FieldRadioInput('datetimeFormatLong', [
'label' => __('manager.setup.dateTime.longDateTime'),
'isMultilingual' => true,
'options' => array_map(function ($value) use ($context, $localizedOptions) {
$locale = array_search($value, $localizedOptions);
$optionValue = $context->getLocalizedDateFormatLong($locale) . ' - ' . $context->getLocalizedTimeFormat($locale);
return [
[
'value' => $optionValue,
'label' => $optionValue,
],
[
'isInput' => true,
'label' => __('manager.setup.dateTime.custom'),
]
];
}, $localizedOptions),
'value' => $context->getDateTimeFormats('datetimeFormatLong'),
'groupId' => 'descriptions',
]))
->addField(new FieldRadioInput('datetimeFormatShort', [
'label' => __('manager.setup.dateTime.shortDateTime'),
'isMultilingual' => true,
'options' => array_map(function ($value) use ($context, $localizedOptions) {
$locale = array_search($value, $localizedOptions);
$optionValue = $context->getLocalizedDateFormatShort($locale) . ' ' . $context->getLocalizedTimeFormat($locale);
return [
[
'value' => $optionValue,
'label' => $optionValue,
],
[
'isInput' => true,
'label' => __('manager.setup.dateTime.custom'),
]
];
}, $localizedOptions),
'value' => $context->getDateTimeFormats('datetimeFormatShort'),
'groupId' => 'descriptions',
]));
}
/**
* Set localized options for date/time fields
*
* @param array $optionValues options to pass to the field
*
* @return array
*/
private function _setDateOptions($optionValues)
{
$options = [];
foreach ($this->locales as $localeValue) {
$locale = $localeValue['key'];
foreach ($optionValues as $optionValue) {
$options[$locale][] = [
'value' => $optionValue,
'label' => $optionValue
];
}
$options[$locale][] = [
'isInput' => true,
'label' => __('manager.setup.dateTime.custom'),
];
}
return $options;
}
}
@@ -0,0 +1,69 @@
<?php
/**
* @file classes/components/form/context/PKPDisableSubmissionsForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPDisableSubmissionsForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for disabling new submissions.
*/
namespace PKP\components\forms\context;
use APP\core\Application;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FormComponent;
define('FORM_DISABLE_SUBMISSIONS', 'disableSubmissions');
class PKPDisableSubmissionsForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_DISABLE_SUBMISSIONS;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
*/
public function __construct($action, $locales, $context)
{
$this->action = $action;
$this->locales = $locales;
$url = Application::get()->getRequest()->getDispatcher()->url(
Application::get()->getRequest(),
Application::ROUTE_PAGE,
null,
'management',
'settings',
'context',
null,
'sections'
);
$description = __('manager.setup.disableSubmissions.description', ['url' => $url]);
$this->addField(new FieldOptions('disableSubmissions', [
'label' => __('manager.setup.disableSubmissions'),
'description' => $description,
'options' => [
[
'value' => true,
'label' => __('manager.setup.disableSubmissions'),
],
],
'value' => (bool) $context->getData('disableSubmissions'),
]));
}
}
@@ -0,0 +1,140 @@
<?php
/**
* @file classes/components/form/context/PKPDoiRegistrationSettingsForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPDoiRegistrationSettingsForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for enabling and configuring DOI settings for a given context
*/
namespace PKP\components\forms\context;
use APP\plugins\IDoiRegistrationAgency;
use PKP\components\forms\Field;
use PKP\components\forms\FieldHTML;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldSelect;
use PKP\components\forms\FormComponent;
use PKP\context\Context;
use PKP\plugins\Hook;
use PKP\plugins\Plugin;
class PKPDoiRegistrationSettingsForm extends FormComponent
{
public const FORM_DOI_REGISTRATION_SETTINGS = 'doiRegistrationSettings';
/** @copydoc FormComponent::$id */
public $id = self::FORM_DOI_REGISTRATION_SETTINGS;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
protected const GENERAL_SETTINGS = 'generalSettings';
protected const AGENCY_SPECIFIC_SETTINGS = 'agencySpecificSettings';
/** @var Field[] Registration agency plugin-specific settings, grouped by plugin */
protected array $agencyFields;
/**
* Constructor
*
*/
public function __construct(string $action, array $locales, Context $context)
{
$this->action = $action;
$this->locales = $locales;
$registrationAgencies = collect();
Hook::call('DoiSettingsForm::setEnabledRegistrationAgencies', [&$registrationAgencies]);
// Add registration agency options for each registration agency plugin
$options = [
[
'value' => Context::SETTING_NO_REGISTRATION_AGENCY,
'label' => __('doi.manager.settings.registrationAgency.none'),
],
];
$this->agencyFields = [];
$registrationAgencies->each(function (IDoiRegistrationAgency|Plugin $agency) use (&$options, $context) {
$options[] = [
'value' => $agency->getName(),
'label' => $agency->getRegistrationAgencyName(),
];
$this->agencyFields[$agency->getName()] = array_map(function ($field) {
$field->groupId = self::AGENCY_SPECIFIC_SETTINGS;
return $field;
}, $agency->getSettingsObject()->getFields($context));
});
$this->addGroup([
'id' => self::GENERAL_SETTINGS,
]);
$this->addGroup([
'id' => self::AGENCY_SPECIFIC_SETTINGS,
'showWhen' => Context::SETTING_CONFIGURED_REGISTRATION_AGENCY,
]);
if (count($options) > 1) {
$this->addField(new FieldSelect(Context::SETTING_CONFIGURED_REGISTRATION_AGENCY, [
'label' => __('doi.manager.settings.registrationAgency'),
'description' => __('doi.manager.settings.registrationAgency.description'),
'options' => $options,
'value' => $context->getData(Context::SETTING_CONFIGURED_REGISTRATION_AGENCY) === '' ?
null :
$context->getData(Context::SETTING_CONFIGURED_REGISTRATION_AGENCY),
'groupId' => self::GENERAL_SETTINGS,
]))
->addField(new FieldOptions(Context::SETTING_DOI_AUTOMATIC_DEPOSIT, [
'label' => __('doi.manager.setup.automaticDeposit'),
'description' => __('doi.manager.setup.automaticDeposit.description'),
'options' => [
['value' => true, 'label' => __('doi.manager.setup.automaticDeposit.enable')]
],
'value' => (bool) $context->getData(Context::SETTING_DOI_AUTOMATIC_DEPOSIT),
'groupId' => self::GENERAL_SETTINGS,
'showWhen' => Context::SETTING_CONFIGURED_REGISTRATION_AGENCY,
]));
} else {
$this->addField(new FieldHTML('noPluginsEnabled', [
'label' => __('doi.manager.settings.registrationAgency.noPluginsEnabled.label'),
'description' => __('doi.manager.settings.registrationAgency.noPluginsEnabled.description'),
'groupId' => self::GENERAL_SETTINGS,
]));
}
}
public function getConfig()
{
$activeAgencyField = array_filter($this->fields, function ($field) {
return $field->name === Context::SETTING_CONFIGURED_REGISTRATION_AGENCY;
});
$activeAgency = empty($activeAgencyField) ? '' : $activeAgencyField[0]->value;
if (!empty($this->agencyFields[$activeAgency])) {
$this->fields = array_merge($this->fields, $this->agencyFields[$activeAgency]);
}
$config = parent::getConfig();
// Set up field config for non-active fields
$config['agencyFields'] = array_map(function ($agencyFields) {
return array_map(function ($agencyField) {
$field = $this->getFieldConfig($agencyField);
$field['groupId'] = self::AGENCY_SPECIFIC_SETTINGS;
return $field;
}, $agencyFields);
}, $this->agencyFields);
return $config;
}
}
@@ -0,0 +1,160 @@
<?php
/**
* @file classes/components/form/context/PKPDoiSetupSettingsForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPDoiSetupSettingsForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for enabling and configuring DOI settings for a given context
*/
namespace PKP\components\forms\context;
use APP\core\Application;
use APP\facades\Repo;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldSelect;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
use PKP\context\Context;
abstract class PKPDoiSetupSettingsForm extends FormComponent
{
public const FORM_DOI_SETUP_SETTINGS = 'doiSetupSettings';
/** @copydoc FormComponent::$id */
public $id = self::FORM_DOI_SETUP_SETTINGS;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/** @var ?string Name of registration agency for checking allowed pub object types for DOI registration */
public ?string $enabledRegistrationAgency = null;
/** @var array Default list of all possible pubObject types for DOI registration */
public array $objectTypeOptions = [];
protected const DOI_SETTINGS_GROUP = 'doiSettingsGroup';
protected const DOI_DEFAULT_GROUP = 'doiDefaultGroup';
protected const DOI_CUSTOM_SUFFIX_GROUP = 'doiCustomSuffixGroup';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param Context $context Journal or Press to change settings for
*/
public function __construct(string $action, array $locales, Context $context)
{
$this->action = $action;
$this->locales = $locales;
$this->enabledRegistrationAgency = $context->getConfiguredDoiAgency()?->getName();
$doiManagementUrl = Application::get()->getDispatcher()->url(
Application::get()->getRequest(),
Application::ROUTE_PAGE,
$context->getPath(),
'dois'
);
$this->addGroup(
[
'id' => self::DOI_DEFAULT_GROUP,
]
)
->addGroup(
[
'id' => self::DOI_SETTINGS_GROUP,
'showWhen' => Context::SETTING_ENABLE_DOIS,
]
)
->addGroup(
[
'id' => self::DOI_CUSTOM_SUFFIX_GROUP,
'label' => __('doi.manager.settings.doiSuffix.custom'),
'description' => __('doi.manager.settings.doiSuffixPattern'),
'showWhen' => [Context::SETTING_DOI_SUFFIX_TYPE, Repo::doi()::SUFFIX_CUSTOM_PATTERN],
]
)
->addField(new FieldOptions(Context::SETTING_ENABLE_DOIS, [
'label' => __('manager.setup.dois'),
'groupId' => self::DOI_DEFAULT_GROUP,
'options' => [
['value' => true, 'label' => __('manager.setup.enableDois.description')]
],
'value' => (bool) $context->getData(Context::SETTING_ENABLE_DOIS),
]))
->addField(new FieldText(Context::SETTING_DOI_PREFIX, [
'label' => __('doi.manager.settings.doiPrefix'),
'description' => __('doi.manager.settings.doiPrefix.description'),
'groupId' => self::DOI_SETTINGS_GROUP,
'value' => $context->getData(Context::SETTING_DOI_PREFIX),
'size' => 'small',
]))
->addField(new FieldSelect(Context::SETTING_DOI_CREATION_TIME, [
'label' => __('doi.manager.settings.doiCreationTime.label'),
'description' => __('doi.manager.settings.doiCreationTime.description'),
'groupId' => self::DOI_SETTINGS_GROUP,
'options' => [
[
'value' => Repo::doi()::CREATION_TIME_COPYEDIT,
'label' => __('doi.manager.settings.doiCreationTime.copyedit')
],
[
'value' => Repo::doi()::CREATION_TIME_PUBLICATION,
'label' => __('doi.manager.settings.doiCreationTime.publication')
],
[
'value' => Repo::doi()::CREATION_TIME_NEVER,
'label' => __('doi.manager.settings.doiCreationTime.never')
]
],
'value' => $context->getData(Context::SETTING_DOI_CREATION_TIME) ? $context->getData(Context::SETTING_DOI_CREATION_TIME) : Repo::doi()::CREATION_TIME_COPYEDIT,
]))
->addField(new FieldOptions(Context::SETTING_DOI_SUFFIX_TYPE, [
'label' => __('doi.manager.settings.doiSuffix'),
'description' => __('doi.manager.settings.doiSuffix.description'),
'groupId' => self::DOI_SETTINGS_GROUP,
'options' => [
[
'value' => Repo::doi()::SUFFIX_DEFAULT,
'label' => __('doi.manager.settings.doiSuffixDefault')
],
[
'value' => Repo::doi()::SUFFIX_MANUAL,
'label' => __('doi.manager.settings.doiSuffixManual', ['doiManagementUrl' => $doiManagementUrl])
],
[
'value' => Repo::doi()::SUFFIX_CUSTOM_PATTERN,
'label' => __('doi.manager.settings.doiSuffixUserDefined')
],
],
'value' => $context->getData(Context::SETTING_DOI_SUFFIX_TYPE) ? $context->getData(Context::SETTING_DOI_SUFFIX_TYPE) : Repo::doi()::SUFFIX_DEFAULT,
'type' => 'radio',
]))
->addField(new FieldText(Repo::doi()::CUSTOM_PUBLICATION_PATTERN, [
'label' => __('manager.language.submissions'),
'groupId' => self::DOI_CUSTOM_SUFFIX_GROUP,
'value' => $context->getData(Repo::doi()::CUSTOM_PUBLICATION_PATTERN),
]))
->addField(new FieldText(Repo::doi()::CUSTOM_REPRESENTATION_PATTERN, [
'label' => __('doi.manager.settings.enableRepresentationDoi'),
'groupId' => self::DOI_CUSTOM_SUFFIX_GROUP,
'value' => $context->getData(Repo::doi()::CUSTOM_REPRESENTATION_PATTERN),
]));
}
public function getConfig()
{
$config = parent::getConfig();
$config['enabledRegistrationAgency'] = $this->enabledRegistrationAgency;
$config['objectTypeOptions'] = $this->objectTypeOptions;
return $config;
}
}
@@ -0,0 +1,248 @@
<?php
/**
* @file classes/components/form/context/PKPEmailSetupForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPEmailSetupForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring a context's email settings.
*/
namespace PKP\components\forms\context;
use APP\core\Application;
use APP\mail\variables\ContextEmailVariable;
use Illuminate\Support\Arr;
use PKP\components\forms\FieldHTML;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldPreparedContent;
use PKP\components\forms\FieldRadioInput;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
use PKP\config\Config;
use PKP\context\Context;
class PKPEmailSetupForm extends FormComponent
{
public const GROUP_EMAIL_TEMPLATES = 'emailTemplates';
public const GROUP_NEW_SUBMISSION = 'newSubmission';
public const GROUP_EDITORIAL_DECISIONS = 'decisions';
public const GROUP_EDITORS = 'editors';
public const GROUP_ADVANCED = 'advanced';
public const FIELD_SUBMISSION_ACK = 'submissionAcknowledgement';
public $id = 'emailSetup';
public $method = 'PUT';
public Context $context;
public function __construct(string $action, array $locales, Context $context)
{
$this->action = $action;
$this->locales = $locales;
$this->context = $context;
$this->addGroup([
'id' => self::GROUP_EMAIL_TEMPLATES,
'label' => __('manager.manageEmails'),
'description' => __('manager.manageEmails.description'),
])
->addEmailTemplatesField()
->addSignatureField()
->addGroup([
'id' => self::GROUP_NEW_SUBMISSION,
'label' => __('manager.newSubmission'),
'description' => __('manager.newSubmission.description'),
])
->addSubmissionAcknowledgementField()
->addCopySubmissionAckPrimaryContactField()
->addCopySubmissionAckAddress()
->addGroup([
'id' => self::GROUP_EDITORIAL_DECISIONS,
'label' => __('manager.editorialDecisions'),
'description' => __('manager.editorialDecisions.description'),
])
->addNotifyAllAuthorsField()
->addGroup([
'id' => self::GROUP_EDITORS,
'label' => __('manager.forEditors'),
'description' => __('manager.forEditors.description')
])
->addStatisticsReportField()
->addGroup([
'id' => self::GROUP_ADVANCED,
'label' => __('manager.setup.advanced'),
])
->addEnveloperSenderField();
}
protected function addEmailTemplatesField(): self
{
$manageEmailsUrl = Application::get()->getRequest()->getDispatcher()->url(
Application::get()->getRequest(),
Application::ROUTE_PAGE,
$this->context->getPath(),
'management',
'settings',
'manageEmails'
);
return $this->addField(new FieldHTML('emailTemplates', [
'label' => __('manager.emails.emailTemplates'),
'description' => __('manager.manageEmailTemplates.description', ['url' => $manageEmailsUrl]),
'groupId' => self::GROUP_EMAIL_TEMPLATES,
]));
}
protected function addSignatureField(): self
{
return $this->addField(new FieldPreparedContent('emailSignature', [
'label' => __('manager.setup.emailSignature'),
'description' => __('manager.setup.emailSignature.description'),
'value' => $this->context->getData('emailSignature'),
'preparedContent' => array_values(
Arr::sort(
Arr::map(
Arr::except(ContextEmailVariable::descriptions(), ContextEmailVariable::CONTEXT_SIGNATURE),
function ($description, $key) {
return [
'key' => $key,
'description' => $description,
'value' => '{$' . $key . '}'
];
}
)
)
),
'groupId' => self::GROUP_EMAIL_TEMPLATES,
]));
}
/**
* Add the submission ack field
*/
protected function addSubmissionAcknowledgementField(): self
{
return $this->addField(new FieldOptions(self::FIELD_SUBMISSION_ACK, [
'label' => __('mailable.submissionAck.name'),
'description' => __('manager.submissionAck.description'),
'type' => 'radio',
'options' => [
['value' => Context::SUBMISSION_ACKNOWLEDGEMENT_ALL_AUTHORS, 'label' => __('manager.submissionAck.allAuthors')],
['value' => Context::SUBMISSION_ACKNOWLEDGEMENT_SUBMITTING_AUTHOR, 'label' => __('manager.submissionAck.submittingAuthor')],
['value' => Context::SUBMISSION_ACKNOWLEDGEMENT_OFF, 'label' => __('manager.submissionAck.off')],
],
'value' => $this->context->getData(self::FIELD_SUBMISSION_ACK),
'groupId' => self::GROUP_NEW_SUBMISSION,
]));
}
/**
* Add the copy submission ack primary contact field
*/
protected function addCopySubmissionAckPrimaryContactField(): self
{
$contactEmail = $this->context->getData('contactEmail');
if (!empty($contactEmail)) {
return $this->addField(new FieldRadioInput('copySubmissionAckPrimaryContact', [
'label' => __('manager.setup.notifications.copySubmissionAckPrimaryContact'),
'description' => __('manager.setup.notifications.copySubmissionAckPrimaryContact.description'),
'options' => [
['value' => true, 'label' => __('manager.setup.notifications.copySubmissionAckPrimaryContact.enabled', ['email' => $contactEmail])],
['value' => false, 'label' => __('manager.setup.notifications.copySubmissionAckPrimaryContact.disabled')],
],
'value' => $this->context->getData('copySubmissionAckPrimaryContact'),
'groupId' => self::GROUP_NEW_SUBMISSION,
'showWhen' => self::FIELD_SUBMISSION_ACK,
]));
}
$request = Application::get()->getRequest();
$pageUrl = $request->getDispatcher()
->url($request, Application::ROUTE_PAGE, null, 'management', 'settings', 'context', null, 'contact');
return $this->addField(new FieldHTML('copySubmissionAckPrimaryContact', [
'label' => __('manager.setup.notifications.copySubmissionAckPrimaryContact'),
'description' => __('manager.setup.notifications.copySubmissionAckPrimaryContact.disabled.description', ['url' => $pageUrl]),
'groupId' => self::GROUP_NEW_SUBMISSION,
'showWhen' => self::FIELD_SUBMISSION_ACK,
]));
}
/**
* Add the field to copy any email address on the submission acknowledgement
*/
protected function addCopySubmissionAckAddress(): self
{
return $this->addField(new FieldText('copySubmissionAckAddress', [
'label' => __('manager.setup.notifications.copySubmissionAckAddress'),
'description' => __('manager.setup.notifications.copySubmissionAckAddress.description'),
'size' => 'large',
'value' => $this->context->getData('copySubmissionAckAddress'),
'groupId' => self::GROUP_NEW_SUBMISSION,
'showWhen' => self::FIELD_SUBMISSION_ACK,
]));
}
/**
* Add the field to notify all authors when an editorial decision is recorded
*/
protected function addNotifyAllAuthorsField(): self
{
return $this->addField(new FieldOptions('notifyAllAuthors', [
'label' => __('manager.setup.notifyAllAuthors'),
'description' => __('manager.setup.notifyAllAuthors.description'),
'type' => 'radio',
'options' => [
['value' => true, 'label' => __('manager.setup.notifyAllAuthors.allAuthors')],
['value' => false, 'label' => __('manager.setup.notifyAllAuthors.assignedAuthors')],
],
'value' => $this->context->getData('notifyAllAuthors'),
'groupId' => self::GROUP_EDITORIAL_DECISIONS,
]));
}
/**
* Add the field to enable/disable the editorial statistics report email
*/
protected function addStatisticsReportField(): self
{
return $this->addField(new FieldOptions('editorialStatsEmail', [
'label' => __('manager.editorialStatistics'),
'description' => __('manager.editorialStatistics.description'),
'type' => 'radio',
'options' => [
['value' => true, 'label' => __('manager.editorialStatistics.on')],
['value' => false, 'label' => __('manager.editorialStatistics.off')],
],
'value' => $this->context->getData('editorialStatsEmail'),
'groupId' => self::GROUP_EDITORS,
]));
}
protected function addEnveloperSenderField(): self
{
$canEnvelopeSender = Config::getVar('email', 'allow_envelope_sender');
if ($canEnvelopeSender) {
return $this->addField(new FieldText('envelopeSender', [
'label' => __('manager.setup.emailBounceAddress'),
'tooltip' => __('manager.setup.emailBounceAddress.description'),
'value' => $this->context->getData('envelopeSender'),
'groupId' => self::GROUP_ADVANCED,
]));
}
return $this->addField(new FieldHTML('envelopeSender', [
'label' => __('manager.setup.emailBounceAddress'),
'description' => __('manager.setup.emailBounceAddress.disabled'),
'groupId' => self::GROUP_ADVANCED,
]));
}
}
@@ -0,0 +1,78 @@
<?php
/**
* @file classes/components/form/context/PKPInformationForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPInformationForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring the information fields for a
* context (eg - info for readers, authors and librarians).
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldRichTextarea;
use PKP\components\forms\FormComponent;
define('FORM_INFORMATION', 'information');
class PKPInformationForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_INFORMATION;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
* @param string $imageUploadUrl The API endpoint for images uploaded through the rich text field
*/
public function __construct($action, $locales, $context, $imageUploadUrl)
{
$this->action = $action;
$this->locales = $locales;
$this->addGroup([
'id' => 'descriptions',
'label' => __('manager.setup.information.descriptionTitle'),
'description' => __('manager.setup.information.description'),
])
->addField(new FieldRichTextarea('readerInformation', [
'label' => __('manager.setup.information.forReaders'),
'isMultilingual' => true,
'groupId' => 'descriptions',
'value' => $context->getData('readerInformation'),
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist | image | code',
'plugins' => 'paste,link,lists,image,code',
'uploadUrl' => $imageUploadUrl,
]))
->addField(new FieldRichTextarea('authorInformation', [
'label' => __('manager.setup.information.forAuthors'),
'isMultilingual' => true,
'groupId' => 'descriptions',
'value' => $context->getData('authorInformation'),
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist | image | code',
'plugins' => 'paste,link,lists,image,code',
'uploadUrl' => $imageUploadUrl,
]))
->addField(new FieldRichTextarea('librarianInformation', [
'label' => __('manager.setup.information.forLibrarians'),
'isMultilingual' => true,
'groupId' => 'descriptions',
'value' => $context->getData('librarianInformation'),
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist | image | code',
'plugins' => 'paste,link,lists,image,code',
'uploadUrl' => $imageUploadUrl,
]));
}
}
@@ -0,0 +1,92 @@
<?php
/**
* @file classes/components/form/context/PKPLicenseForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPLicenseForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring a context's default licensing details.
*/
namespace PKP\components\forms\context;
use APP\core\Application;
use PKP\components\forms\FieldRadioInput;
use PKP\components\forms\FieldRichTextarea;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
define('FORM_LICENSE', 'license');
class PKPLicenseForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_LICENSE;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
*/
public function __construct($action, $locales, $context)
{
$this->action = $action;
$this->locales = $locales;
$licenseOptions = Application::getCCLicenseOptions();
$licenseUrlOptions = [];
foreach ($licenseOptions as $url => $label) {
$licenseUrlOptions[] = [
'value' => $url,
'label' => __($label),
];
}
$licenseUrlOptions[] = [
'value' => 'other',
'label' => __('manager.distribution.license.other'),
'isInput' => true,
];
$this->addField(new FieldRadioInput('copyrightHolderType', [
'label' => __('submission.copyrightHolder'),
'type' => 'radio',
'options' => [
['value' => 'author', 'label' => __('user.role.author')],
['value' => 'context', 'label' => __('context.context')],
['value' => 'other', 'label' => __('submission.copyrightHolder.other')],
],
'value' => $context->getData('copyrightHolderType'),
]))
->addField(new FieldText('copyrightHolderOther', [
'label' => __('submission.copyrightOther'),
'description' => __('submission.copyrightOther.description'),
'isMultilingual' => true,
'showWhen' => ['copyrightHolderType', 'other'],
'value' => $context->getData('copyrightHolderOther'),
]))
->addField(new FieldRadioInput('licenseUrl', [
'label' => __('manager.distribution.license'),
'type' => 'radio',
'options' => $licenseUrlOptions,
'value' => $context->getData('licenseUrl'),
]))
->addField(new FieldRichTextarea('licenseTerms', [
'label' => __('manager.distribution.licenseTerms'),
'tooltip' => __('manager.distribution.licenseTerms.description'),
'isMultilingual' => true,
'value' => $context->getData('licenseTerms'),
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist',
'plugins' => 'paste,link,lists',
]));
}
}
@@ -0,0 +1,59 @@
<?php
/**
* @file classes/components/form/context/PKPListsForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPListsForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring how a context handles lists of
* items in the UI.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
define('FORM_LISTS', 'lists');
class PKPListsForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_LISTS;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
*/
public function __construct($action, $locales, $context)
{
$this->action = $action;
$this->locales = $locales;
$this->addField(new FieldText('itemsPerPage', [
'label' => __('common.itemsPerPage'),
'description' => __('manager.setup.itemsPerPage.description'),
'isRequired' => true,
'value' => $context->getData('itemsPerPage'),
'size' => 'small',
]))
->addField(new FieldText('numPageLinks', [
'label' => __('manager.setup.numPageLinks'),
'description' => __('manager.setup.numPageLinks.description'),
'isRequired' => true,
'value' => $context->getData('numPageLinks'),
'size' => 'small',
]));
}
}
@@ -0,0 +1,127 @@
<?php
/**
* @file classes/components/form/context/PKPMastheadForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPMastheadForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring a context's masthead details.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldRichTextarea;
use PKP\components\forms\FieldSelect;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
use PKP\facades\Locale;
define('FORM_MASTHEAD', 'masthead');
class PKPMastheadForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_MASTHEAD;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
* @param string $imageUploadUrl The API endpoint for images uploaded through the rich text field
*/
public function __construct($action, $locales, $context, $imageUploadUrl)
{
$this->action = $action;
$this->locales = $locales;
$countries = [];
foreach (Locale::getCountries() as $country) {
$countries[] = [
'value' => $country->getAlpha2(),
'label' => $country->getLocalName()
];
}
usort($countries, function ($a, $b) {
return strcmp($a['label'], $b['label']);
});
$this->addGroup([
'id' => 'identity',
'label' => __('manager.setup.identity'),
])
->addField(new FieldText('name', [
'label' => __('manager.setup.contextTitle'),
'size' => 'large',
'isRequired' => true,
'isMultilingual' => true,
'groupId' => 'identity',
'value' => $context->getData('name'),
]))
->addField(new FieldText('acronym', [
'label' => __('manager.setup.contextInitials'),
'size' => 'small',
'isRequired' => true,
'isMultilingual' => true,
'groupId' => 'identity',
'value' => $context->getData('acronym'),
]))
->addGroup([
'id' => 'publishing',
'label' => __('manager.setup.publishing'),
'description' => __('manager.setup.publishingDescription'),
])
->addField(new FieldSelect('country', [
'groupId' => 'publishing',
'label' => __('common.country'),
'description' => __('manager.setup.selectCountry'),
'options' => $countries,
'isRequired' => true,
'value' => $context ? $context->getData('country') : null,
]))
->addGroup([
'id' => 'keyInfo',
'label' => __('manager.setup.keyInfo'),
'description' => __('manager.setup.keyInfo.description'),
])
->addField(new FieldRichTextarea('description', [
'label' => __('manager.setup.contextSummary'),
'isMultilingual' => true,
'groupId' => 'keyInfo',
'value' => $context->getData('description'),
]))
->addField(new FieldRichTextarea('editorialTeam', [
'label' => __('manager.setup.editorialTeam'),
'isMultilingual' => true,
'groupId' => 'keyInfo',
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist | image | code',
'plugins' => 'paste,link,lists,image,code',
'uploadUrl' => $imageUploadUrl,
'value' => $context->getData('editorialTeam'),
]))
->addGroup([
'id' => 'about',
'label' => __('common.description'),
'description' => __('manager.setup.contextAbout.description'),
])
->addField(new FieldRichTextarea('about', [
'label' => __('manager.setup.contextAbout'),
'isMultilingual' => true,
'size' => 'large',
'groupId' => 'about',
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist | image | code',
'plugins' => 'paste,link,lists,image,code',
'uploadUrl' => $imageUploadUrl,
'value' => $context->getData('about'),
]));
}
}
@@ -0,0 +1,210 @@
<?php
/**
* @file classes/components/form/context/PKPMetadataSettingsForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPMetadataSettingsForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for enabling and configuring types of metadata to
* attach to submissions.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldMetadataSetting;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FormComponent;
use PKP\context\Context;
define('FORM_METADATA_SETTINGS', 'metadataSettings');
class PKPMetadataSettingsForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_METADATA_SETTINGS;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param Context $context Journal or Press to change settings for
*/
public function __construct($action, $context)
{
$this->action = $action;
$this
->addField(new FieldMetadataSetting('keywords', [
'label' => __('common.keywords'),
'description' => __('manager.setup.metadata.keywords.description'),
'options' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.keywords.enable')]
],
'submissionOptions' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.keywords.noRequest')],
['value' => Context::METADATA_REQUEST, 'label' => __('manager.setup.metadata.keywords.request')],
['value' => Context::METADATA_REQUIRE, 'label' => __('manager.setup.metadata.keywords.require')],
],
'value' => $context->getData('keywords') ? $context->getData('keywords') : Context::METADATA_DISABLE,
]))
->addField(new FieldMetadataSetting('subjects', [
'label' => __('common.subjects'),
'description' => __('manager.setup.metadata.subjects.description'),
'options' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.subjects.enable')]
],
'submissionOptions' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.subjects.noRequest')],
['value' => Context::METADATA_REQUEST, 'label' => __('manager.setup.metadata.subjects.request')],
['value' => Context::METADATA_REQUIRE, 'label' => __('manager.setup.metadata.subjects.require')],
],
'value' => $context->getData('subjects') ? $context->getData('subjects') : Context::METADATA_DISABLE,
]))
->addField(new FieldMetadataSetting('disciplines', [
'label' => __('search.discipline'),
'description' => __('manager.setup.metadata.disciplines.description'),
'options' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.disciplines.enable')]
],
'submissionOptions' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.disciplines.noRequest')],
['value' => Context::METADATA_REQUEST, 'label' => __('manager.setup.metadata.disciplines.request')],
['value' => Context::METADATA_REQUIRE, 'label' => __('manager.setup.metadata.disciplines.require')],
],
'value' => $context->getData('disciplines') ? $context->getData('disciplines') : Context::METADATA_DISABLE,
]))
->addField(new FieldMetadataSetting('languages', [
'label' => __('common.languages'),
'description' => __('manager.setup.metadata.languages.description'),
'options' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.languages.enable')]
],
'submissionOptions' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.languages.noRequest')],
['value' => Context::METADATA_REQUEST, 'label' => __('manager.setup.metadata.languages.request')],
['value' => Context::METADATA_REQUIRE, 'label' => __('manager.setup.metadata.languages.require')],
],
'value' => $context->getData('languages') ? $context->getData('languages') : Context::METADATA_DISABLE,
]))
->addField(new FieldMetadataSetting('agencies', [
'label' => __('submission.supportingAgencies'),
'description' => __('manager.setup.metadata.agencies.description'),
'options' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.agencies.enable')]
],
'submissionOptions' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.agencies.noRequest')],
['value' => Context::METADATA_REQUEST, 'label' => __('manager.setup.metadata.agencies.request')],
['value' => Context::METADATA_REQUIRE, 'label' => __('manager.setup.metadata.agencies.require')],
],
'value' => $context->getData('agencies') ? $context->getData('agencies') : Context::METADATA_DISABLE,
]))
->addField(new FieldMetadataSetting('coverage', [
'label' => __('manager.setup.metadata.coverage'),
'description' => __('manager.setup.metadata.coverage.description'),
'options' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.coverage.enable')]
],
'submissionOptions' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.coverage.noRequest')],
['value' => Context::METADATA_REQUEST, 'label' => __('manager.setup.metadata.coverage.request')],
['value' => Context::METADATA_REQUIRE, 'label' => __('manager.setup.metadata.coverage.require')],
],
'value' => $context->getData('coverage') ? $context->getData('coverage') : Context::METADATA_DISABLE,
]))
->addField(new FieldMetadataSetting('rights', [
'label' => __('submission.rights'),
'description' => __('manager.setup.metadata.rights.description'),
'options' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.rights.enable')]
],
'submissionOptions' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.rights.noRequest')],
['value' => Context::METADATA_REQUEST, 'label' => __('manager.setup.metadata.rights.request')],
['value' => Context::METADATA_REQUIRE, 'label' => __('manager.setup.metadata.rights.require')],
],
'value' => $context->getData('rights') ? $context->getData('rights') : Context::METADATA_DISABLE,
]))
->addField(new FieldMetadataSetting('source', [
'label' => __('submission.source'),
'description' => __('manager.setup.metadata.source.description'),
'options' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.source.enable')]
],
'submissionOptions' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.source.noRequest')],
['value' => Context::METADATA_REQUEST, 'label' => __('manager.setup.metadata.source.request')],
['value' => Context::METADATA_REQUIRE, 'label' => __('manager.setup.metadata.source.require')],
],
'value' => $context->getData('source') ? $context->getData('source') : Context::METADATA_DISABLE,
]))
->addField(new FieldMetadataSetting('type', [
'label' => __('common.type'),
'description' => __('manager.setup.metadata.type.description'),
'options' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.type.enable')]
],
'submissionOptions' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.type.noRequest')],
['value' => Context::METADATA_REQUEST, 'label' => __('manager.setup.metadata.type.request')],
['value' => Context::METADATA_REQUIRE, 'label' => __('manager.setup.metadata.type.require')],
],
'value' => $context->getData('type') ? $context->getData('type') : Context::METADATA_DISABLE,
]))
->addField(new FieldOptions('requireAuthorCompetingInterests', [
'label' => __('manager.setup.competingInterests'),
'options' => [
[
'value' => 'true',
'label' => __('manager.setup.competingInterests.requireAuthors'),
],
],
'value' => (bool) $context->getData('requireAuthorCompetingInterests'),
]))
->addField(new FieldMetadataSetting('citations', [
'label' => __('submission.citations'),
'description' => __('manager.setup.metadata.citations.description'),
'options' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.citations.enable')]
],
'submissionOptions' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.citations.noRequest')],
['value' => Context::METADATA_REQUEST, 'label' => __('manager.setup.metadata.citations.request')],
['value' => Context::METADATA_REQUIRE, 'label' => __('manager.setup.metadata.citations.require')],
],
'value' => $context->getData('citations') ? $context->getData('citations') : Context::METADATA_DISABLE,
]))
->addField(new FieldMetadataSetting('dataAvailability', [
'label' => __('submission.dataAvailability'),
'description' => __('manager.setup.metadata.dataAvailability.description'),
'options' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.dataAvailability.enable')]
],
'submissionOptions' => [
['value' => Context::METADATA_ENABLE, 'label' => __('manager.setup.metadata.dataAvailability.noRequest')],
['value' => Context::METADATA_REQUEST, 'label' => __('manager.setup.metadata.dataAvailability.request')],
['value' => Context::METADATA_REQUIRE, 'label' => __('manager.setup.metadata.dataAvailability.require')],
],
'value' => $context->getData('dataAvailability') ? $context->getData('dataAvailability') : Context::METADATA_DISABLE,
]))
->addField(new FieldOptions('submitWithCategories', [
'label' => __('category.category'),
'description' => __('manager.submitWithCategories.description'),
'type' => 'radio',
'options' => [
['value' => true, 'label' => __('manager.submitWithCategories.yes')],
['value' => false, 'label' => __('manager.submitWithCategories.no')],
],
'value' => (bool) $context->getData('submitWithCategories')
]));
}
}
@@ -0,0 +1,112 @@
<?php
/**
* @file classes/components/form/context/PKPNotifyUsersForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPNotifyUsersForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for sending an email notification to users.
*/
namespace PKP\components\forms\context;
use APP\core\Application;
use APP\facades\Repo;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldRichTextarea;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
define('FORM_NOTIFY_USERS', 'notifyUsers');
class PKPNotifyUsersForm extends FormComponent
{
public const FORM_NOTIFY_USERS = 'notifyUsers';
/** @copydoc FormComponent::$id */
public $id = self::FORM_NOTIFY_USERS;
/** @copydoc FormComponent::$method */
public $method = 'POST';
/** @var array count of users in each group */
public $userGroupCounts = [];
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param \PKP\context\Context $context Journal, press or preprint server
*/
public function __construct($action, $context)
{
$this->action = $action;
$userGroups = Repo::userGroup()->getCollector()
->filterByContextIds([$context->getId()])
->getMany();
$userCountByGroupId = Repo::userGroup()->getUserCountByContextId($context->getId());
$userGroupOptions = [];
foreach ($userGroups as $userGroup) {
if (in_array($userGroup->getId(), (array) $context->getData('disableBulkEmailUserGroups'))) {
continue;
}
$userGroupOptions[] = [
'value' => $userGroup->getId(),
'label' => $userGroup->getLocalizedData('name'),
];
$this->userGroupCounts[$userGroup->getId()] = $userCountByGroupId->get($userGroup->getId(), 0);
}
$currentUser = Application::get()->getRequest()->getUser();
$this->addField(new FieldOptions('userGroupIds', [
'label' => __('user.roles'),
'description' => __('manager.setup.notifyUsers.description'),
'value' => [],
'options' => $userGroupOptions,
'required' => true,
]))
->addField(new FieldText('subject', [
'label' => __('email.subject'),
'value' => '',
'required' => true,
]))
->addField(new FieldRichTextarea('body', [
'label' => __('email.email'),
'size' => 'large',
'value' => '',
'required' => true,
]))
->addField(new FieldOptions('copy', [
'label' => __('common.copy'),
'value' => 0,
'options' => [
[
'value' => 1,
'label' => __('manager.setup.notifyUsers.copyDetails', ['email' => $currentUser->getEmail()]),
],
]
]));
}
/**
* @copydoc FormComponent::getConfig()
*/
public function getConfig()
{
$config = parent::getConfig();
$config['confirmLabel'] = __('manager.setup.notifyUsers.confirm');
$config['sendLabel'] = __('manager.setup.notifyUsers.send');
$config['userGroupCounts'] = $this->userGroupCounts;
return $config;
}
}
@@ -0,0 +1,91 @@
<?php
/**
* @file classes/components/form/context/PKPPaymentSettingsForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPPaymentSettingsForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring the general payment settings.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldSelect;
use PKP\components\forms\FormComponent;
use PKP\facades\Locale;
use PKP\plugins\PluginRegistry;
define('FORM_PAYMENT_SETTINGS', 'paymentSettings');
class PKPPaymentSettingsForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_PAYMENT_SETTINGS;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
*/
public function __construct($action, $locales, $context)
{
$this->action = $action;
$this->locales = $locales;
$currencies = [];
foreach (Locale::getCurrencies() as $currency) {
$currencies[] = [
'value' => $currency->getLetterCode(),
'label' => htmlspecialchars($currency->getLocalName()),
];
}
// Ensure payment method plugins can hook in
$paymentPlugins = PluginRegistry::loadCategory('paymethod', true);
$pluginList = [];
foreach ($paymentPlugins as $plugin) {
$pluginList[] = [
'value' => $plugin->getName(),
'label' => htmlspecialchars($plugin->getDisplayName()),
];
}
$this->addGroup([
'id' => 'setup',
'label' => __('navigation.setup'),
])
->addField(new FieldOptions('paymentsEnabled', [
'label' => __('common.enable'),
'options' => [
['value' => true, 'label' => __('manager.payment.options.enablePayments')]
],
'value' => (bool) $context->getData('paymentsEnabled'),
'groupId' => 'setup',
]))
->addField(new FieldSelect('currency', [
'label' => __('manager.paymentMethod.currency'),
'options' => $currencies,
'showWhen' => 'paymentsEnabled',
'value' => $context->getData('currency'),
'groupId' => 'setup',
]))
->addField(new FieldSelect('paymentPluginName', [
'label' => __('plugins.categories.paymethod'),
'options' => $pluginList,
'showWhen' => 'paymentsEnabled',
'value' => $context->getData('paymentPluginName'),
'groupId' => 'setup',
]));
}
}
@@ -0,0 +1,54 @@
<?php
/**
* @file classes/components/form/context/PKPPrivacyForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPPrivacyForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring a context's privacy statement.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldRichTextarea;
use PKP\components\forms\FormComponent;
define('FORM_PRIVACY', 'privacy');
class PKPPrivacyForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_PRIVACY;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
* @param string $imageUploadUrl The API endpoint for images uploaded through the rich text field
*/
public function __construct($action, $locales, $context, $imageUploadUrl)
{
$this->action = $action;
$this->locales = $locales;
$this->addField(new FieldRichTextArea('privacyStatement', [
'label' => __('manager.setup.privacyStatement'),
'description' => __('manager.setup.privacyStatement.description'),
'isMultilingual' => true,
'value' => $context->getData('privacyStatement'),
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist | image | code',
'plugins' => 'paste,link,lists,image,code',
'uploadUrl' => $imageUploadUrl,
]));
}
}
@@ -0,0 +1,60 @@
<?php
/**
* @file classes/components/form/site/PKPRestrictBulkEmailsForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPRestrictBulkEmailsForm
*
* @ingroup classes_controllers_form
*
* @brief A form for setting restrictions on the sending of bulk emails in a context.
*/
namespace PKP\components\forms\context;
use APP\core\Application;
use Illuminate\Support\LazyCollection;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FormComponent;
define('FORM_RESTRICT_BULK_EMAILS', 'restrictBulkEmails');
class PKPRestrictBulkEmailsForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_RESTRICT_BULK_EMAILS;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
*/
public function __construct($action, $context, LazyCollection $userGroups)
{
$this->action = $action;
$userGroupOptions = [];
foreach ($userGroups as $userGroup) {
$userGroupOptions[] = [
'value' => $userGroup->getId(),
'label' => htmlspecialchars($userGroup->getLocalizedData('name')),
];
}
$request = Application::get()->getRequest();
$siteSettingsUrl = $request->getDispatcher()->url($request, Application::ROUTE_PAGE, null, 'admin', 'settings', null, null, 'setup/bulkEmails');
$this->addField(new FieldOptions('disableBulkEmailUserGroups', [
'label' => __('admin.settings.disableBulkEmailRoles.label'),
'description' => __('admin.settings.disableBulkEmailRoles.description', ['siteSettingsUrl' => $siteSettingsUrl]),
'value' => (array) $context->getData('disableBulkEmailUserGroups'),
'options' => $userGroupOptions,
]));
}
}
@@ -0,0 +1,65 @@
<?php
/**
* @file classes/components/form/context/PKPReviewGuidanceForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPReviewGuidanceForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring the guidance a reviewer should receive.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldRichTextarea;
use PKP\components\forms\FieldShowEnsuringLink;
use PKP\components\forms\FormComponent;
define('FORM_REVIEW_GUIDANCE', 'reviewerGuidance');
class PKPReviewGuidanceForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_REVIEW_GUIDANCE;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
*/
public function __construct($action, $locales, $context)
{
$this->action = $action;
$this->locales = $locales;
$this->addField(new FieldRichTextarea('reviewGuidelines', [
'label' => __('manager.setup.reviewGuidelines'),
'isMultilingual' => true,
'value' => $context->getData('reviewGuidelines'),
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist',
'plugins' => 'paste,link,lists',
]))
->addField(new FieldRichTextarea('competingInterests', [
'label' => __('manager.setup.competingInterests'),
'isMultilingual' => true,
'value' => $context->getData('competingInterests'),
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist',
'plugins' => 'paste,link,lists',
]))
->addField(new FieldShowEnsuringLink('showEnsuringLink', [
'options' => [
['value' => true, 'label' => __('manager.setup.reviewOptions.showAnonymousReviewLink')],
],
'value' => $context->getData('showEnsuringLink'),
]));
}
}
@@ -0,0 +1,108 @@
<?php
/**
* @file classes/components/form/context/PKPReviewSetupForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPReviewSetupForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring review options, such as the default
* review type and deadlines.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldHTML;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
use PKP\config\Config;
use PKP\submission\reviewAssignment\ReviewAssignment;
define('FORM_REVIEW_SETUP', 'reviewSetup');
class PKPReviewSetupForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_REVIEW_SETUP;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
*/
public function __construct($action, $locales, $context)
{
$this->action = $action;
$this->locales = $locales;
$this->addField(new FieldOptions('defaultReviewMode', [
'label' => __('manager.setup.reviewOptions.reviewMode'),
'type' => 'radio',
'value' => $context->getData('defaultReviewMode'),
'options' => [
['value' => ReviewAssignment::SUBMISSION_REVIEW_METHOD_DOUBLEANONYMOUS, 'label' => __('editor.submissionReview.doubleAnonymous')],
['value' => ReviewAssignment::SUBMISSION_REVIEW_METHOD_ANONYMOUS, 'label' => __('editor.submissionReview.anonymous')],
['value' => ReviewAssignment::SUBMISSION_REVIEW_METHOD_OPEN, 'label' => __('editor.submissionReview.open')],
],
]))
->addField(new FieldOptions('restrictReviewerFileAccess', [
'label' => __('manager.setup.reviewOptions.restrictReviewerFileAccess'),
'type' => 'checkbox',
'value' => $context->getData('restrictReviewerFileAccess'),
'options' => [
['value' => true, 'label' => __('manager.setup.reviewOptions.restrictReviewerFileAccess.description')],
]
]))
->addField(new FieldOptions('reviewerAccessKeysEnabled', [
'label' => __('manager.setup.reviewOptions.reviewerAccessKeysEnabled'),
'description' => __('manager.setup.reviewOptions.reviewerAccessKeysEnabled.description'),
'type' => 'checkbox',
'value' => $context->getData('reviewerAccessKeysEnabled'),
'options' => [
['value' => true, 'label' => __('manager.setup.reviewOptions.reviewerAccessKeysEnabled.label')],
]
]))
->addField(new FieldText('numWeeksPerResponse', [
'label' => __('manager.setup.reviewOptions.defaultReviewResponseTime'),
'description' => __('manager.setup.reviewOptions.numWeeksPerResponse'),
'value' => $context->getData('numWeeksPerResponse'),
'size' => 'small',
]))
->addField(new FieldText('numWeeksPerReview', [
'label' => __('manager.setup.reviewOptions.defaultReviewCompletionTime'),
'description' => __('manager.setup.reviewOptions.numWeeksPerReview'),
'value' => $context->getData('numWeeksPerReview'),
'size' => 'small',
]));
if (Config::getVar('general', 'scheduled_tasks')) {
$this->addField(new FieldText('numDaysBeforeInviteReminder', [
'label' => __('manager.setup.reviewOptions.reminders.response'),
'description' => __('manager.setup.reviewOptions.reminders.response.description'),
'value' => $context->getData('numDaysBeforeInviteReminder'),
'size' => 'small',
]))
->addField(new FieldText('numDaysBeforeSubmitReminder', [
'label' => __('manager.setup.reviewOptions.reminders.submit'),
'description' => __('manager.setup.reviewOptions.reminders.submit.description'),
'value' => $context->getData('numDaysBeforeSubmitReminder'),
'size' => 'small',
]));
} else {
$this->addField(new FieldHTML('reviewRemindersDisabled', [
'label' => __('manager.setup.reviewOptions.automatedReminders'),
'description' => __('manager.setup.reviewOptions.automatedRemindersDisabled'),
]));
}
}
}
@@ -0,0 +1,66 @@
<?php
/**
* @file classes/components/form/context/PKPSearchIndexingForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPSearchIndexingForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring a context's search indexing settings.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldText;
use PKP\components\forms\FieldTextarea;
use PKP\components\forms\FormComponent;
define('FORM_SEARCH_INDEXING', 'searchIndexing');
class PKPSearchIndexingForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_SEARCH_INDEXING;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
* @param string $sitemapUrl A URL to the context's sitemap for use in the
* search engine indexing group description
*/
public function __construct($action, $locales, $context, $sitemapUrl)
{
$this->action = $action;
$this->locales = $locales;
$this->addGroup([
'id' => 'search',
'label' => __('manager.setup.searchEngineIndexing'),
'description' => __('manager.setup.searchEngineIndexing.description', ['sitemapUrl' => $sitemapUrl]),
])
->addField(new FieldText('searchDescription', [
'label' => __('common.description'),
'tooltip' => __('manager.setup.searchDescription.description'),
'isMultilingual' => true,
'value' => $context->getData('searchDescription'),
'groupId' => 'search',
]))
->addField(new FieldTextArea('customHeaders', [
'label' => __('manager.distribution.customHeaders'),
'tooltip' => __('manager.distribution.customHeaders.description'),
'isMultilingual' => true,
'value' => $context->getData('customHeaders'),
'groupId' => 'search',
]));
}
}
@@ -0,0 +1,164 @@
<?php
/**
* @file classes/components/form/context/PKPThemeForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPThemeForm
*
* @ingroup classes_controllers_form
*
* @brief A form for selecting a theme and theme options. Expects to be attached
* to a <theme-form> element in the UI.
*
* This form works similarly to other form components, except that it keeps a
* separate store of fields for each theme's options. Only the active theme's
* fields are loaded into $this->fields. The <theme-form> UI component chooses
* which fields to display as the theme selection is changed.
*/
namespace PKP\components\forms\context;
use APP\core\Application;
use PKP\components\forms\FieldSelect;
use PKP\components\forms\FormComponent;
use PKP\plugins\PluginRegistry;
use PKP\plugins\ThemePlugin;
define('FORM_THEME', 'theme');
class PKPThemeForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_THEME;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/** @var array A key/value store of theme option fields, keyed by theme name */
public $themeFields = [];
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context|null $context Journal/Press to change settings for, or null
* to change settings for the Site
*/
public function __construct($action, $locales, $context = null)
{
$this->action = $action;
$this->locales = $locales;
if (!empty($context)) {
$activeTheme = $context->getData('themePluginPath');
$contextId = $context->getId();
} else {
$activeTheme = Application::get()->getRequest()->getSite()->getData('themePluginPath');
$contextId = \PKP\core\PKPApplication::CONTEXT_ID_NONE;
}
$themes = $themeOptions = [];
/** @var ThemePlugin[] */
$plugins = PluginRegistry::loadCategory('themes', true);
foreach ($plugins as $plugin) {
$themes[] = [
'value' => $plugin->getDirName(),
'label' => htmlspecialchars($plugin->getDisplayName()),
];
}
$this->addField(new FieldSelect('themePluginPath', [
'label' => __('manager.setup.theme'),
'description' => __('manager.setup.theme.description'),
'options' => $themes,
'value' => $activeTheme,
]));
// Add theme options for each theme
foreach ($plugins as $plugin) {
// Re-run the init functions for each theme so that any theme options
// are set up. Because this is run after PluginRegistry::loadCategory(),
// the scripts and styles won't actually be registered against the
// template manager. However, if PluginRegistry::loadCategory() is called
// again for the themes category, it can cause scripts and styles to be
// overwritten by inactive themes.
$plugin->init();
$themeOptions = $plugin->getOptionsConfig();
if (empty($themeOptions)) {
continue;
}
$themeOptionValues = $plugin->getOptionValues($contextId);
foreach ($themeOptions as $optionName => $optionField) {
$optionField->value = $themeOptionValues[$optionName] ?? null;
$this->addThemeField($plugin->getDirName(), $optionField);
}
}
}
/**
* Add a form field that should only appear when a particular theme is
* selected
*
* @param string $theme The theme's base plugin path
* @param \PKP\components\forms\Field $field
* @param array $position [
*
* @option string One of `before` or `after`
* @option string The field to position it before or after
* ]
*
* @return FormComponent
*/
public function addThemeField($theme, $field, $position = [])
{
if (empty($position)) {
if (!isset($this->themeFields[$theme])) {
$this->themeFields[$theme] = [];
}
$this->themeFields[$theme][] = $field;
} else {
$this->themeFields[$theme] = $this->addToPosition($position[1], $this->themeFields[$theme], $field, $position[0]);
}
return $this;
}
/**
* @copydoc FormComponent::getConfig()
*/
public function getConfig()
{
// Add the active theme's option fields to the fields array
$activeThemeField = array_filter($this->fields, function ($field) {
return $field->name === 'themePluginPath';
});
$activeTheme = $activeThemeField[0]->value;
if (!empty($this->themeFields[$activeTheme])) {
$this->fields = array_merge($this->fields, $this->themeFields[$activeTheme]);
}
$config = parent::getConfig();
// Set up field config for non-active fields
if (!$this->groups) {
$this->addGroup(['id' => 'default']);
$this->fields = array_map(function ($field) {
$field->groupId = 'default';
return $field;
}, $this->fields);
}
$defaultGroupId = $this->groups[0]['id'];
$config['themeFields'] = array_map(function ($themeOptions) use ($defaultGroupId) {
return array_map(function ($themeOption) use ($defaultGroupId) {
$field = $this->getFieldConfig($themeOption);
$field['groupId'] = $defaultGroupId;
return $field;
}, $themeOptions);
}, $this->themeFields);
return $config;
}
}
@@ -0,0 +1,59 @@
<?php
/**
* @file classes/components/form/context/PKPUserAccessForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPUserAccessForm
*
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring the user access settings on the Users
* and Roles page of a context.
*/
namespace PKP\components\forms\context;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FormComponent;
define('FORM_USER_ACCESS', 'userAccess');
class PKPUserAccessForm extends FormComponent
{
/** @copydoc FormComponent::$id */
public $id = FORM_USER_ACCESS;
/** @copydoc FormComponent::$method */
public $method = 'PUT';
/**
* Constructor
*
* @param string $action URL to submit the form to
* @param \PKP\context\Context $context Journal or Press to change settings for
*/
public function __construct($action, $context)
{
$this->action = $action;
$this->addField(new FieldOptions('restrictSiteAccess', [
'label' => __('manager.setup.siteAccess.view'),
'value' => (bool) $context->getData('restrictSiteAccess'),
'options' => [
['value' => true, 'label' => __('manager.setup.restrictSiteAccess')],
],
]))
->addField(new FieldOptions('disableUserReg', [
'type' => 'radio',
'label' => __('manager.setup.userRegistration'),
'value' => (bool) $context->getData('disableUserReg'),
'options' => [
['value' => false, 'label' => __('manager.setup.enableUserRegistration')],
['value' => true, 'label' => __('manager.setup.disableUserRegistration')],
],
]));
}
}