Open Journal Systems  3.3.0
PublishForm.inc.php
1 <?php
17 use \PKP\components\forms\FormComponent;
18 use \PKP\components\forms\FieldHTML;
19 
20 define('FORM_PUBLISH', 'publish');
21 
22 class PublishForm extends FormComponent {
24  public $id = FORM_PUBLISH;
25 
27  public $method = 'PUT';
28 
30  public $publication;
31 
34 
43  public function __construct($action, $publication, $submissionContext, $requirementErrors) {
44  $this->action = $action;
45  $this->errors = $requirementErrors;
46  $this->publication = $publication;
47  $this->submissionContext = $submissionContext;
48 
49  // Set separate messages and buttons if publication requirements have passed
50  if (empty($requirementErrors)) {
51  $msg = __('publication.publish.confirmation');
52  $submitLabel = __('publication.publish');
53  if ($publication->getData('issueId')) {
54  $issue = \Services::get('issue')->get($publication->getData('issueId'));
55  if ($issue) {
56  if ($issue->getData('published')) {
57  $msg = __('publication.publish.confirmation.backIssue', ['issue' => $issue->getIssueIdentification()]);
58  } else {
59  $msg = __('publication.publish.confirmation.futureIssue', ['issue' => $issue->getIssueIdentification()]);
60  $submitLabel = __('editor.submission.schedulePublication');
61  }
62  }
63  }
64  // If a publication date has already been set and the date has passed this will
65  // be published immediately regardless of the issue assignment
66  if ($publication->getData('datePublished') && $publication->getData('datePublished') <= \Core::getCurrentDate()) {
67  $timestamp = strtotime($publication->getData('datePublished'));
68  $dateFormatLong = $submissionContext->getLocalizedDateFormatLong();
69  $msg = __(
70  'publication.publish.confirmation.datePublishedInPast',
71  [
72  'datePublished' => strftime($dateFormatLong, $timestamp),
73  ]
74  );
75  $submitLabel = __('publication.publish');
76  }
77  $this->addPage([
78  'id' => 'default',
79  'submitButton' => [
80  'label' => $submitLabel,
81  ],
82  ]);
83  } else {
84  $msg = '<p>' . __('publication.publish.requirements') . '</p>';
85  $msg .= '<ul>';
86  foreach ($requirementErrors as $error) {
87  $msg .= '<li>' . $error . '</li>';
88  }
89  $msg .= '</ul>';
90  $this->addPage([
91  'id' => 'default',
92  ]);
93  }
94 
95  $this->addGroup([
96  'id' => 'default',
97  'pageId' => 'default',
98  ])
99  ->addField(new FieldHTML('validation', [
100  'description' => $msg,
101  'groupId' => 'default',
102  ]));
103  }
104 }
APP\components\forms\publication\PublishForm\$id
$id
Definition: PublishForm.inc.php:24
PKP\components\forms\FormComponent\addGroup
addGroup($args, $position=[])
Definition: FormComponent.inc.php:145
APP\components\forms\publication\PublishForm\$publication
$publication
Definition: PublishForm.inc.php:33
PKP\components\forms\FormComponent\$action
$action
Definition: FormComponent.inc.php:37
APP\components\forms\publication\PublishForm
Definition: PublishForm.inc.php:22
PKP\components\forms\FormComponent
Definition: FormComponent.inc.php:20
APP\components\forms\publication\PublishForm\$submissionContext
$submissionContext
Definition: PublishForm.inc.php:39
PKP\components\forms\FieldHTML
Definition: FieldHTML.inc.php:16
PKP\components\forms\FormComponent\addPage
addPage($args, $position=[])
Definition: FormComponent.inc.php:188
Core\getCurrentDate
static getCurrentDate($ts=null)
Definition: Core.inc.php:63
APP\components\forms\publication\PublishForm\__construct
__construct($action, $publication, $submissionContext, $requirementErrors)
Definition: PublishForm.inc.php:49
APP\components\forms\publication\PublishForm\$method
$method
Definition: PublishForm.inc.php:27
APP\components\forms\publication
Definition: AssignToIssueForm.inc.php:14
FieldHTML
A component for inserting HTML into a form, when you don't need any input fields or values stored.
APP\components\forms\publication\FORM_PUBLISH
const FORM_PUBLISH
Definition: PublishForm.inc.php:20
PKPServices\get
static get($service)
Definition: PKPServices.inc.php:49