first commit
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/components/form/site/PKPSiteAppearanceForm.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 PKPSiteAppearanceForm
|
||||
*
|
||||
* @ingroup classes_controllers_form
|
||||
*
|
||||
* @brief A preset form for the site appearance settings.
|
||||
*/
|
||||
|
||||
namespace PKP\components\forms\site;
|
||||
|
||||
use PKP\components\forms\FieldOptions;
|
||||
use PKP\components\forms\FieldRichTextarea;
|
||||
use PKP\components\forms\FieldUpload;
|
||||
use PKP\components\forms\FieldUploadImage;
|
||||
use PKP\components\forms\FormComponent;
|
||||
use PKP\plugins\PluginRegistry;
|
||||
|
||||
define('FORM_SITE_APPEARANCE', 'siteAppearance');
|
||||
|
||||
class PKPSiteAppearanceForm extends FormComponent
|
||||
{
|
||||
/** @copydoc FormComponent::$id */
|
||||
public $id = FORM_SITE_APPEARANCE;
|
||||
|
||||
/** @copydoc FormComponent::$method */
|
||||
public $method = 'PUT';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $action URL to submit the form to
|
||||
* @param array $locales Supported locales
|
||||
* @param \PKP\site\Site $site
|
||||
* @param string $baseUrl Site's base URL. Used for image previews.
|
||||
* @param string $temporaryFileApiUrl URL to upload files to
|
||||
*/
|
||||
public function __construct($action, $locales, $site, $baseUrl, $temporaryFileApiUrl)
|
||||
{
|
||||
$this->action = $action;
|
||||
$this->locales = $locales;
|
||||
|
||||
$sidebarOptions = [];
|
||||
$plugins = PluginRegistry::loadCategory('blocks', true);
|
||||
foreach ($plugins as $pluginName => $plugin) {
|
||||
$sidebarOptions[] = [
|
||||
'value' => $pluginName,
|
||||
'label' => htmlspecialchars($plugin->getDisplayName()),
|
||||
];
|
||||
}
|
||||
|
||||
$this->addField(new FieldUploadImage('pageHeaderTitleImage', [
|
||||
'label' => __('manager.setup.logo'),
|
||||
'value' => $site->getData('pageHeaderTitleImage'),
|
||||
'isMultilingual' => true,
|
||||
'baseUrl' => $baseUrl,
|
||||
'options' => [
|
||||
'url' => $temporaryFileApiUrl,
|
||||
],
|
||||
]))
|
||||
->addField(new FieldRichTextarea('pageFooter', [
|
||||
'label' => __('manager.setup.pageFooter'),
|
||||
'description' => __('manager.setup.pageFooter.description'),
|
||||
'isMultilingual' => true,
|
||||
'value' => $site->getData('pageFooter'),
|
||||
]))
|
||||
->addField(new FieldOptions('sidebar', [
|
||||
'label' => __('manager.setup.layout.sidebar'),
|
||||
'isOrderable' => true,
|
||||
'value' => (array) $site->getData('sidebar'),
|
||||
'options' => $sidebarOptions,
|
||||
]))
|
||||
->addField(new FieldUpload('styleSheet', [
|
||||
'label' => __('admin.settings.siteStyleSheet'),
|
||||
'value' => $site->getData('styleSheet'),
|
||||
'options' => [
|
||||
'url' => $temporaryFileApiUrl,
|
||||
'acceptedFiles' => '.css',
|
||||
],
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/components/form/site/PKPSiteBulkEmailsForm.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 PKPSiteBulkEmailsForm
|
||||
*
|
||||
* @ingroup classes_controllers_form
|
||||
*
|
||||
* @brief A form for enabling the bulk email features.
|
||||
*/
|
||||
|
||||
namespace PKP\components\forms\site;
|
||||
|
||||
use APP\core\Application;
|
||||
use PKP\components\forms\FieldOptions;
|
||||
use PKP\components\forms\FormComponent;
|
||||
|
||||
define('FORM_SITE_BULK_EMAILS', 'bulkEmails');
|
||||
|
||||
class PKPSiteBulkEmailsForm extends FormComponent
|
||||
{
|
||||
/** @copydoc FormComponent::$id */
|
||||
public $id = FORM_SITE_BULK_EMAILS;
|
||||
|
||||
/** @copydoc FormComponent::$method */
|
||||
public $method = 'PUT';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $action URL to submit the form to
|
||||
* @param \PKP\site\Site $site
|
||||
* @param array $contexts List of context summary objects. See PKPContextQueryBuilder::getManySummary()
|
||||
*/
|
||||
public function __construct($action, $site, $contexts)
|
||||
{
|
||||
$this->action = $action;
|
||||
|
||||
$request = Application::get()->getRequest();
|
||||
$hostedContextsUrl = $request->getDispatcher()->url($request, Application::ROUTE_PAGE, null, 'admin', 'contexts');
|
||||
|
||||
$options = [];
|
||||
foreach ($contexts as $context) {
|
||||
$options[] = [
|
||||
'value' => $context->id,
|
||||
'label' => htmlspecialchars($context->name),
|
||||
];
|
||||
}
|
||||
|
||||
$this->addField(new FieldOptions('enableBulkEmails', [
|
||||
'label' => __('admin.settings.enableBulkEmails.label'),
|
||||
'description' => __('admin.settings.enableBulkEmails.description', ['hostedContextsUrl' => $hostedContextsUrl]),
|
||||
'value' => (array) $site->getData('enableBulkEmails'),
|
||||
'options' => $options,
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/components/form/site/PKPSiteConfigForm.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 PKPSiteConfigForm
|
||||
*
|
||||
* @ingroup classes_controllers_form
|
||||
*
|
||||
* @brief A preset form for the site config settings.
|
||||
*/
|
||||
|
||||
namespace PKP\components\forms\site;
|
||||
|
||||
use APP\core\Services;
|
||||
use PKP\components\forms\FieldOptions;
|
||||
use PKP\components\forms\FieldSelect;
|
||||
use PKP\components\forms\FieldText;
|
||||
use PKP\components\forms\FormComponent;
|
||||
|
||||
define('FORM_SITE_CONFIG', 'siteConfig');
|
||||
|
||||
class PKPSiteConfigForm extends FormComponent
|
||||
{
|
||||
/** @copydoc FormComponent::$id */
|
||||
public $id = FORM_SITE_CONFIG;
|
||||
|
||||
/** @copydoc FormComponent::$method */
|
||||
public $method = 'PUT';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $action URL to submit the form to
|
||||
* @param array $locales Supported locales
|
||||
* @param \PKP\site\Site $site
|
||||
*/
|
||||
public function __construct($action, $locales, $site)
|
||||
{
|
||||
$this->action = $action;
|
||||
$this->locales = $locales;
|
||||
|
||||
$contextsIterator = Services::get('context')->getMany(['isEnabled' => true]);
|
||||
|
||||
$this->addField(new FieldText('title', [
|
||||
'label' => __('admin.settings.siteTitle'),
|
||||
'isRequired' => true,
|
||||
'isMultilingual' => true,
|
||||
'value' => $site->getData('title'),
|
||||
]));
|
||||
|
||||
$options = [['value' => '', 'label' => '']];
|
||||
foreach ($contextsIterator as $context) {
|
||||
$options[] = [
|
||||
'value' => $context->getId(),
|
||||
'label' => htmlspecialchars($context->getLocalizedData('name')),
|
||||
];
|
||||
}
|
||||
if (count($options) > 1) {
|
||||
$this->addField(new FieldSelect('redirect', [
|
||||
'label' => __('admin.settings.redirect'),
|
||||
'description' => __('admin.settings.redirectInstructions'),
|
||||
'options' => $options,
|
||||
'value' => $site->getData('redirect'),
|
||||
]));
|
||||
}
|
||||
|
||||
$this->addField(new FieldText('minPasswordLength', [
|
||||
'label' => __('admin.settings.minPasswordLength'),
|
||||
'isRequired' => true,
|
||||
'size' => 'small',
|
||||
'value' => $site->getData('minPasswordLength'),
|
||||
]));
|
||||
|
||||
$this->addField(new FieldOptions('disableSharedReviewerStatistics', [
|
||||
'label' => __('admin.settings.sharedReviewerStatistics'),
|
||||
'description' => __('admin.settings.sharedReviewerStatistics.description'),
|
||||
'options' => [
|
||||
['value' => true, 'label' => __('admin.settings.sharedReviewerStatistics.disable')]
|
||||
],
|
||||
'value' => (bool) $site->getData('disableSharedReviewerStatistics'),
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/components/form/site/PKPSiteInformationForm.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 PKPSiteInformationForm
|
||||
*
|
||||
* @ingroup classes_controllers_form
|
||||
*
|
||||
* @brief A preset form for the site information settings.
|
||||
*/
|
||||
|
||||
namespace PKP\components\forms\site;
|
||||
|
||||
use PKP\components\forms\FieldRichTextarea;
|
||||
use PKP\components\forms\FieldText;
|
||||
use PKP\components\forms\FormComponent;
|
||||
|
||||
define('FORM_SITE_INFO', 'siteInfo');
|
||||
|
||||
class PKPSiteInformationForm extends FormComponent
|
||||
{
|
||||
/** @copydoc FormComponent::$id */
|
||||
public $id = FORM_SITE_INFO;
|
||||
|
||||
/** @copydoc FormComponent::$method */
|
||||
public $method = 'PUT';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $action URL to submit the form to
|
||||
* @param array $locales Supported locales
|
||||
* @param \PKP\site\Site $site
|
||||
*/
|
||||
public function __construct($action, $locales, $site)
|
||||
{
|
||||
$this->action = $action;
|
||||
$this->locales = $locales;
|
||||
|
||||
$this->addField(new FieldRichTextarea('about', [
|
||||
'label' => __('admin.settings.about'),
|
||||
'isMultilingual' => true,
|
||||
'value' => $site->getData('about'),
|
||||
]))
|
||||
->addField(new FieldText('contactName', [
|
||||
'label' => __('admin.settings.contactName'),
|
||||
'isRequired' => true,
|
||||
'isMultilingual' => true,
|
||||
'value' => $site->getData('contactName'),
|
||||
]))
|
||||
->addField(new FieldText('contactEmail', [
|
||||
'label' => __('admin.settings.contactEmail'),
|
||||
'isRequired' => true,
|
||||
'isMultilingual' => true,
|
||||
'value' => $site->getData('contactEmail'),
|
||||
]))
|
||||
->addField(new FieldRichTextarea('privacyStatement', [
|
||||
'label' => __('manager.setup.privacyStatement'),
|
||||
'description' => __('manager.setup.privacyStatement.description'),
|
||||
'isMultilingual' => true,
|
||||
'value' => $site->getData('privacyStatement'),
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/components/forms/site/PKPSiteStatisticsForm.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 PKPSiteStatisticsForm
|
||||
*
|
||||
* @ingroup classes_controllers_form
|
||||
*
|
||||
* @brief A preset form for the site statistics settings.
|
||||
*/
|
||||
|
||||
namespace PKP\components\forms\site;
|
||||
|
||||
use PKP\components\forms\FieldOptions;
|
||||
use PKP\components\forms\FieldText;
|
||||
use PKP\components\forms\FormComponent;
|
||||
use PKP\site\Site;
|
||||
use PKP\statistics\PKPStatisticsHelper;
|
||||
use PKP\task\FileLoader;
|
||||
|
||||
define('FORM_SITE_STATISTICS', 'siteStatistics');
|
||||
|
||||
class PKPSiteStatisticsForm extends FormComponent
|
||||
{
|
||||
public const COLLECTION_GROUP = 'collection';
|
||||
public const STORAGE_GROUP = 'storage';
|
||||
public const SUSHI_GROUP = 'sushi';
|
||||
|
||||
/** @copydoc FormComponent::$id */
|
||||
public $id = FORM_SITE_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)
|
||||
{
|
||||
$this->action = $action;
|
||||
$this->locales = $locales;
|
||||
|
||||
$usageStatsFileDir = PKPStatisticsHelper::getUsageStatsDirPath() . '/' . FileLoader::FILE_LOADER_PATH_ARCHIVE;
|
||||
|
||||
$this->addGroup([
|
||||
'id' => self::COLLECTION_GROUP,
|
||||
'label' => __('admin.settings.statistics.collection'),
|
||||
'description' => __('admin.settings.statistics.collection.description'),
|
||||
])
|
||||
->addField(new FieldOptions('enableGeoUsageStats', [
|
||||
'label' => __('manager.settings.statistics.geoUsageStats'),
|
||||
'description' => __('admin.settings.statistics.geo.description'),
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
[
|
||||
'value' => 'disabled',
|
||||
'label' => __('manager.settings.statistics.geoUsageStats.disabled'),
|
||||
],
|
||||
[
|
||||
'value' => PKPStatisticsHelper::STATISTICS_SETTING_COUNTRY,
|
||||
'label' => __('manager.settings.statistics.geoUsageStats.countryLevel'),
|
||||
],
|
||||
[
|
||||
'value' => PKPStatisticsHelper::STATISTICS_SETTING_REGION,
|
||||
'label' => __('manager.settings.statistics.geoUsageStats.regionLevel'),
|
||||
],
|
||||
[
|
||||
'value' => PKPStatisticsHelper::STATISTICS_SETTING_CITY,
|
||||
'label' => __('manager.settings.statistics.geoUsageStats.cityLevel'),
|
||||
],
|
||||
],
|
||||
'value' => $site->getData('enableGeoUsageStats') ? $site->getData('enableGeoUsageStats') : 'disabled',
|
||||
'groupId' => self::COLLECTION_GROUP,
|
||||
]))
|
||||
->addField(new FieldOptions('enableInstitutionUsageStats', [
|
||||
'label' => __('manager.settings.statistics.institutionUsageStats'),
|
||||
'description' => __('admin.settings.statistics.institutions.description'),
|
||||
'options' => [
|
||||
[
|
||||
'value' => true,
|
||||
'label' => __('manager.settings.statistics.institutionUsageStats.enable'),
|
||||
],
|
||||
],
|
||||
'value' => $site->getData('enableInstitutionUsageStats'),
|
||||
'groupId' => self::COLLECTION_GROUP,
|
||||
]))
|
||||
->addGroup([
|
||||
'id' => self::STORAGE_GROUP,
|
||||
'label' => __('admin.settings.statistics.storage'),
|
||||
'description' => __('admin.settings.statistics.storage.description'),
|
||||
])
|
||||
->addField(new FieldOptions('keepDailyUsageStats', [
|
||||
'label' => __('admin.settings.statistics.keepDaily'),
|
||||
'description' => __('admin.settings.statistics.keepDaily.description'),
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
[
|
||||
'value' => false,
|
||||
'label' => __('admin.settings.statistics.keepDaily.discard'),
|
||||
],
|
||||
[
|
||||
'value' => true,
|
||||
'label' => __('admin.settings.statistics.keepDaily.keep'),
|
||||
],
|
||||
],
|
||||
'value' => $site->getData('keepDailyUsageStats'),
|
||||
'groupId' => self::STORAGE_GROUP,
|
||||
]))
|
||||
->addField(new FieldOptions('compressStatsLogs', [
|
||||
'label' => __('admin.settings.statistics.compressStatsLogs.label'),
|
||||
'description' => __('admin.settings.statistics.compressStatsLogs.description', ['path' => $usageStatsFileDir]),
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
[
|
||||
'value' => false,
|
||||
'label' => __('admin.settings.statistics.compressStatsLogs.default'),
|
||||
],
|
||||
[
|
||||
'value' => true,
|
||||
'label' => __('admin.settings.statistics.compressStatsLogs.compress'),
|
||||
],
|
||||
],
|
||||
'value' => $site->getData('compressStatsLogs') ? $site->getData('compressStatsLogs') : false,
|
||||
'groupId' => self::STORAGE_GROUP,
|
||||
]))
|
||||
->addGroup([
|
||||
'id' => self::SUSHI_GROUP,
|
||||
'label' => __('admin.settings.statistics.sushi'),
|
||||
'description' => __('admin.settings.statistics.sushi.description'),
|
||||
])
|
||||
->addField(new FieldOptions('isSushiApiPublic', [
|
||||
'label' => __('manager.settings.statistics.publicSushiApi'),
|
||||
'description' => __('admin.settings.statistics.sushi.public.description'),
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
[
|
||||
'value' => true,
|
||||
'label' => __('manager.settings.statistics.publicSushiApi.public'),
|
||||
],
|
||||
[
|
||||
'value' => false,
|
||||
'label' => __('admin.settings.statistics.publicSushiApi.private'),
|
||||
],
|
||||
],
|
||||
'value' => $site->getData('isSushiApiPublic') ? $site->getData('isSushiApiPublic') : true,
|
||||
'groupId' => self::SUSHI_GROUP,
|
||||
]))
|
||||
->addField(new FieldOptions('isSiteSushiPlatform', [
|
||||
'label' => __('admin.settings.statistics.sushiPlatform'),
|
||||
'description' => __('admin.settings.statistics.sushiPlatform.description'),
|
||||
'options' => [
|
||||
[
|
||||
'value' => true,
|
||||
'label' => __('admin.settings.statistics.sushiPlatform.isSiteSushiPlatform'),
|
||||
],
|
||||
],
|
||||
'value' => $site->getData('isSiteSushiPlatform'),
|
||||
'groupId' => self::SUSHI_GROUP,
|
||||
]))
|
||||
->addField(new FieldText('sushiPlatformID', [
|
||||
'label' => __('admin.settings.statistics.sushiPlatform.sushiPlatformID'),
|
||||
'description' => __('admin.settings.statistics.sushiPlatform.sushiPlatformID.description'),
|
||||
'value' => $site->getData('sushiPlatformID'),
|
||||
'showWhen' => 'isSiteSushiPlatform',
|
||||
'groupId' => self::SUSHI_GROUP,
|
||||
]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user