first commit
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/components/form/publication/AssignToIssueForm.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 AssignToIssueForm
|
||||
*
|
||||
* @ingroup classes_controllers_form
|
||||
*
|
||||
* @brief A preset form for setting a publication's issue.
|
||||
*/
|
||||
|
||||
namespace APP\components\forms\publication;
|
||||
|
||||
use APP\facades\Repo;
|
||||
use PKP\components\forms\FieldSelect;
|
||||
use PKP\components\forms\FormComponent;
|
||||
|
||||
define('FORM_ASSIGN_TO_ISSUE', 'assignToIssue');
|
||||
|
||||
class AssignToIssueForm extends FormComponent
|
||||
{
|
||||
/** @copydoc FormComponent::$id */
|
||||
public $id = FORM_ASSIGN_TO_ISSUE;
|
||||
|
||||
/** @copydoc FormComponent::$method */
|
||||
public $method = 'PUT';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $action URL to submit the form to
|
||||
* @param \APP\publication\Publication $publication The publication to change settings for
|
||||
* @param \APP\journal\Journal $publicationContext The context of the publication
|
||||
*/
|
||||
public function __construct($action, $publication, $publicationContext)
|
||||
{
|
||||
$this->action = $action;
|
||||
|
||||
// Issue options
|
||||
$issueOptions = [['value' => '', 'label' => '']];
|
||||
|
||||
$unpublishedIssues = Repo::issue()->getCollector()
|
||||
->filterByContextIds([$publicationContext->getId()])
|
||||
->filterByPublished(false)
|
||||
->getMany();
|
||||
|
||||
if ($unpublishedIssues->count() > 0) {
|
||||
$issueOptions[] = ['value' => '', 'label' => '--- ' . __('editor.issues.futureIssues') . ' ---'];
|
||||
foreach ($unpublishedIssues as $issue) {
|
||||
$issueOptions[] = [
|
||||
'value' => (int) $issue->getId(),
|
||||
'label' => htmlspecialchars($issue->getIssueIdentification()),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$publishedIssues = Repo::issue()->getCollector()
|
||||
->filterByContextIds([$publicationContext->getId()])
|
||||
->filterByPublished(true)
|
||||
->getMany();
|
||||
|
||||
if ($publishedIssues->count() > 0) {
|
||||
$issueOptions[] = ['value' => '', 'label' => '--- ' . __('editor.issues.backIssues') . ' ---'];
|
||||
foreach ($publishedIssues as $issue) {
|
||||
$issueOptions[] = [
|
||||
'value' => (int) $issue->getId(),
|
||||
'label' => htmlspecialchars($issue->getIssueIdentification()),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$this->addField(new FieldSelect('issueId', [
|
||||
'label' => __('issue.issue'),
|
||||
'options' => $issueOptions,
|
||||
'value' => $publication->getData('issueId') ? $publication->getData('issueId') : 0,
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/components/form/publication/IssueEntryForm.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 IssueEntryForm
|
||||
*
|
||||
* @ingroup classes_controllers_form
|
||||
*
|
||||
* @brief A preset form for setting a publication's issue, section, categories,
|
||||
* pages, etc.
|
||||
*/
|
||||
|
||||
namespace APP\components\forms\publication;
|
||||
|
||||
use APP\components\forms\FieldSelectIssue;
|
||||
use APP\facades\Repo;
|
||||
use PKP\components\forms\FieldOptions;
|
||||
use PKP\components\forms\FieldSelect;
|
||||
use PKP\components\forms\FieldText;
|
||||
use PKP\components\forms\FieldUploadImage;
|
||||
use PKP\components\forms\FormComponent;
|
||||
|
||||
define('FORM_ISSUE_ENTRY', 'issueEntry');
|
||||
|
||||
class IssueEntryForm extends FormComponent
|
||||
{
|
||||
/** @copydoc FormComponent::$id */
|
||||
public $id = FORM_ISSUE_ENTRY;
|
||||
|
||||
/** @copydoc FormComponent::$method */
|
||||
public $method = 'PUT';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $action URL to submit the form to
|
||||
* @param array $locales Supported locales
|
||||
* @param \APP\publication\Publication $publication The publication to change settings for
|
||||
* @param \APP\journal\Journal $publicationContext The context of the publication
|
||||
* @param string $baseUrl Site's base URL. Used for image previews.
|
||||
* @param string $temporaryFileApiUrl URL to upload files to
|
||||
*/
|
||||
public function __construct($action, $locales, $publication, $publicationContext, $baseUrl, $temporaryFileApiUrl)
|
||||
{
|
||||
$this->action = $action;
|
||||
$this->locales = $locales;
|
||||
|
||||
// Issue options
|
||||
$issueOptions = [['value' => '', 'label' => '']];
|
||||
|
||||
$unpublishedIssues = Repo::issue()->getCollector()
|
||||
->filterByContextIds([$publicationContext->getId()])
|
||||
->filterByPublished(false)
|
||||
->getMany()
|
||||
->toArray();
|
||||
|
||||
if (count($unpublishedIssues)) {
|
||||
$issueOptions[] = ['value' => '', 'label' => '--- ' . __('editor.issues.futureIssues') . ' ---'];
|
||||
foreach ($unpublishedIssues as $issue) {
|
||||
$issueOptions[] = [
|
||||
'value' => (int) $issue->getId(),
|
||||
'label' => htmlspecialchars($issue->getIssueIdentification()),
|
||||
];
|
||||
}
|
||||
}
|
||||
$publishedIssues = Repo::issue()->getCollector()
|
||||
->filterByContextIds([$publicationContext->getId()])
|
||||
->filterByPublished(true)
|
||||
->getMany()
|
||||
->toArray();
|
||||
|
||||
if (count($publishedIssues)) {
|
||||
$issueOptions[] = ['value' => '', 'label' => '--- ' . __('editor.issues.backIssues') . ' ---'];
|
||||
foreach ($publishedIssues as $issue) {
|
||||
$issueOptions[] = [
|
||||
'value' => (int) $issue->getId(),
|
||||
'label' => htmlspecialchars($issue->getIssueIdentification()),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Section options
|
||||
$sections = Repo::section()->getSectionList($publicationContext->getId());
|
||||
$sectionOptions = [];
|
||||
foreach ($sections as $section) {
|
||||
$sectionOptions[] = [
|
||||
'label' => (($section['group']) ? __('publication.inactiveSection', ['section' => $section['title']]) : $section['title']),
|
||||
'value' => (int) $section['id'],
|
||||
];
|
||||
}
|
||||
|
||||
$this->addField(new FieldSelectIssue('issueId', [
|
||||
'label' => __('issue.issue'),
|
||||
'options' => $issueOptions,
|
||||
'publicationStatus' => $publication->getData('status'),
|
||||
'value' => $publication->getData('issueId') ? $publication->getData('issueId') : 0,
|
||||
]))
|
||||
->addField(new FieldSelect('sectionId', [
|
||||
'label' => __('section.section'),
|
||||
'options' => $sectionOptions,
|
||||
'value' => (int) $publication->getData('sectionId'),
|
||||
]));
|
||||
|
||||
// Categories
|
||||
$categoryOptions = [];
|
||||
$categories = Repo::category()->getCollector()
|
||||
->filterByContextIds([$publicationContext->getId()])
|
||||
->getMany()
|
||||
->toArray();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$label = $category->getLocalizedTitle();
|
||||
if ($category->getParentId()) {
|
||||
$label = $categories[$category->getParentId()]->getLocalizedTitle() . ' > ' . $label;
|
||||
}
|
||||
$categoryOptions[] = [
|
||||
'value' => (int) $category->getId(),
|
||||
'label' => $label,
|
||||
];
|
||||
}
|
||||
if (!empty($categoryOptions)) {
|
||||
$this->addField(new FieldOptions('categoryIds', [
|
||||
'label' => __('submission.submit.placement.categories'),
|
||||
'value' => $publication->getData('categoryIds'),
|
||||
'options' => $categoryOptions,
|
||||
]));
|
||||
}
|
||||
|
||||
$this->addField(new FieldUploadImage('coverImage', [
|
||||
'label' => __('editor.article.coverImage'),
|
||||
'value' => $publication->getData('coverImage'),
|
||||
'isMultilingual' => true,
|
||||
'baseUrl' => $baseUrl,
|
||||
'options' => [
|
||||
'url' => $temporaryFileApiUrl,
|
||||
],
|
||||
]))
|
||||
->addField(new FieldText('pages', [
|
||||
'label' => __('editor.issues.pages'),
|
||||
'value' => $publication->getData('pages'),
|
||||
]))
|
||||
->addField(new FieldText('urlPath', [
|
||||
'label' => __('publication.urlPath'),
|
||||
'description' => __('publication.urlPath.description'),
|
||||
'value' => $publication->getData('urlPath'),
|
||||
]))
|
||||
->addField(new FieldText('datePublished', [
|
||||
'label' => __('publication.datePublished'),
|
||||
'description' => __('publication.datePublished.description'),
|
||||
'value' => $publication->getData('datePublished'),
|
||||
'size' => 'small',
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/components/form/publication/PublishForm.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 PublishForm
|
||||
*
|
||||
* @ingroup classes_controllers_form
|
||||
*
|
||||
* @brief A preset form for confirming a publication's issue before publishing.
|
||||
* It may also be used for scheduling a publication in an issue for later
|
||||
* publication.
|
||||
*/
|
||||
|
||||
namespace APP\components\forms\publication;
|
||||
|
||||
use APP\facades\Repo;
|
||||
use PKP\components\forms\FieldHTML;
|
||||
use PKP\components\forms\FormComponent;
|
||||
use PKP\core\Core;
|
||||
use PKP\core\PKPString;
|
||||
|
||||
define('FORM_PUBLISH', 'publish');
|
||||
|
||||
class PublishForm extends FormComponent
|
||||
{
|
||||
/** @copydoc FormComponent::$id */
|
||||
public $id = FORM_PUBLISH;
|
||||
|
||||
/** @copydoc FormComponent::$method */
|
||||
public $method = 'PUT';
|
||||
|
||||
/** @var \APP\publication\Publication */
|
||||
public $publication;
|
||||
|
||||
/** @var \APP\journal\Journal */
|
||||
public $submissionContext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $action URL to submit the form to
|
||||
* @param \APP\publication\Publication $publication The publication to change settings for
|
||||
* @param \APP\journal\Journal $submissionContext journal or press
|
||||
* @param array $requirementErrors A list of pre-publication requirements that are not met.
|
||||
*/
|
||||
public function __construct($action, $publication, $submissionContext, $requirementErrors)
|
||||
{
|
||||
$this->action = $action;
|
||||
$this->errors = $requirementErrors;
|
||||
$this->publication = $publication;
|
||||
$this->submissionContext = $submissionContext;
|
||||
|
||||
// Set separate messages and buttons if publication requirements have passed
|
||||
if (empty($requirementErrors)) {
|
||||
$msg = __('publication.publish.confirmation');
|
||||
$submitLabel = __('publication.publish');
|
||||
if ($publication->getData('issueId')) {
|
||||
$issue = Repo::issue()->get($publication->getData('issueId'));
|
||||
if ($issue) {
|
||||
if ($issue->getData('published')) {
|
||||
$msg = __('publication.publish.confirmation.backIssue', ['issue' => htmlspecialchars($issue->getIssueIdentification())]);
|
||||
} else {
|
||||
$msg = __('publication.publish.confirmation.futureIssue', ['issue' => htmlspecialchars($issue->getIssueIdentification())]);
|
||||
$submitLabel = __('editor.submission.schedulePublication');
|
||||
}
|
||||
}
|
||||
}
|
||||
// If a publication date has already been set and the date has passed this will
|
||||
// be published immediately regardless of the issue assignment
|
||||
if ($publication->getData('datePublished') && $publication->getData('datePublished') <= Core::getCurrentDate()) {
|
||||
$timestamp = strtotime($publication->getData('datePublished'));
|
||||
$dateFormatLong = PKPString::convertStrftimeFormat($submissionContext->getLocalizedDateFormatLong());
|
||||
$msg = __(
|
||||
'publication.publish.confirmation.datePublishedInPast',
|
||||
[
|
||||
'datePublished' => date($dateFormatLong, $timestamp),
|
||||
]
|
||||
);
|
||||
$submitLabel = __('publication.publish');
|
||||
}
|
||||
$this->addPage([
|
||||
'id' => 'default',
|
||||
'submitButton' => [
|
||||
'label' => $submitLabel,
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
$msg = '<p>' . __('publication.publish.requirements') . '</p>';
|
||||
$msg .= '<ul>';
|
||||
foreach ($requirementErrors as $error) {
|
||||
$msg .= '<li>' . $error . '</li>';
|
||||
}
|
||||
$msg .= '</ul>';
|
||||
$this->addPage([
|
||||
'id' => 'default',
|
||||
]);
|
||||
}
|
||||
|
||||
$this->addGroup([
|
||||
'id' => 'default',
|
||||
'pageId' => 'default',
|
||||
])
|
||||
->addField(new FieldHTML('validation', [
|
||||
'description' => $msg,
|
||||
'groupId' => 'default',
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/components/form/publication/SubmissionPaymentsForm.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 SubmissionPaymentsForm
|
||||
*
|
||||
* @ingroup classes_controllers_form
|
||||
*
|
||||
* @brief A form for managing submission fees.
|
||||
*/
|
||||
|
||||
namespace APP\components\forms\publication;
|
||||
|
||||
use APP\payment\ojs\OJSCompletedPaymentDAO;
|
||||
use APP\payment\ojs\OJSPaymentManager;
|
||||
use PKP\components\forms\FieldRadioInput;
|
||||
use PKP\components\forms\FormComponent;
|
||||
use PKP\db\DAORegistry;
|
||||
|
||||
define('FORM_SUBMISSION_PAYMENTS', 'submissionPayments');
|
||||
|
||||
class SubmissionPaymentsForm extends FormComponent
|
||||
{
|
||||
/** @copydoc FormComponent::$id */
|
||||
public $id = FORM_SUBMISSION_PAYMENTS;
|
||||
|
||||
/** @copydoc FormComponent::$method */
|
||||
public $method = 'PUT';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $action URL to submit the form to
|
||||
* @param \APP\submission\Submission $submission The submission to inspect payment status of
|
||||
* @param \APP\journal\Journal $submissionContext The context of the submission
|
||||
*/
|
||||
public function __construct($action, $submission, $submissionContext)
|
||||
{
|
||||
$this->action = $action;
|
||||
|
||||
$completedPaymentDao = DAORegistry::getDAO('OJSCompletedPaymentDAO'); /** @var OJSCompletedPaymentDAO $completedPaymentDao */
|
||||
$publicationFeePayment = $completedPaymentDao->getByAssoc(null, OJSPaymentManager::PAYMENT_TYPE_PUBLICATION, $submission->getId());
|
||||
|
||||
$this->addField(new FieldRadioInput('publicationFeeStatus', [
|
||||
'label' => __('payment.type.publication'),
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
['value' => 'waived', 'label' => __('payment.waived')],
|
||||
['value' => 'paid', 'label' => __('payment.paid')],
|
||||
['value' => 'unpaid', 'label' => __('payment.unpaid')],
|
||||
],
|
||||
'value' => $publicationFeePayment
|
||||
? ($publicationFeePayment->getAmount() ? 'paid' : 'waived')
|
||||
: 'unpaid'
|
||||
]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user