Open Preprint Systems  3.3.0
IssueEntryForm.inc.php
1 <?php
15 use \PKP\components\forms\FormComponent;
16 use \PKP\components\forms\FieldOptions;
17 use \PKP\components\forms\FieldSelect;
18 use \PKP\components\forms\FieldText;
19 use \PKP\components\forms\FieldUploadImage;
20 
21 define('FORM_ISSUE_ENTRY', 'issueEntry');
22 
26 
28  public $method = 'PUT';
29 
40  public function __construct($action, $locales, $publication, $publicationContext, $baseUrl, $temporaryFileApiUrl) {
41  $this->action = $action;
42  $this->locales = $locales;
43 
44  // Section options
45  $sections = \Services::get('section')->getSectionList($publicationContext->getId());
46  $sectionOptions = [];
47  foreach ($sections as $section) {
48  $sectionOptions[] = [
49  'label' => (($section['group'])? __('publication.inactiveSection', ['section' => $section['title']]) : $section['title']),
50  'value' => (int) $section['id'],
51  ];
52  }
53  $this->addField(new FieldSelect('sectionId', [
54  'label' => __('section.section'),
55  'options' => $sectionOptions,
56  'value' => (int) $publication->getData('sectionId'),
57  ]));
58 
59  // Categories
60  $categoryOptions = [];
61  $categoryDao = \DAORegistry::getDAO('CategoryDAO'); /* @var $categoryDao CategoryDAO */
62  $categories = $categoryDao->getByContextId($publicationContext->getId())->toAssociativeArray();
63  foreach ($categories as $category) {
64  $label = $category->getLocalizedTitle();
65  if ($category->getParentId()) {
66  $label = $categories[$category->getParentId()]->getLocalizedTitle() . ' > ' . $label;
67  }
68  $categoryOptions[] = [
69  'value' => (int) $category->getId(),
70  'label' => $category->getLocalizedTitle(),
71  ];
72  }
73  if (!empty($categoryOptions)) {
74  $this->addField(new FieldOptions('categoryIds', [
75  'label' => __('submission.submit.placement.categories'),
76  'value' => (array) $publication->getData('categoryIds'),
77  'options' => $categoryOptions,
78  ]));
79  }
80 
81  $this->addField(new FieldUploadImage('coverImage', [
82  'label' => __('editor.article.coverImage'),
83  'value' => $publication->getData('coverImage'),
84  'isMultilingual' => true,
85  'baseUrl' => $baseUrl,
86  'options' => [
87  'url' => $temporaryFileApiUrl,
88  ],
89  ]))
90  ->addField(new FieldText('urlPath', [
91  'label' => __('publication.urlPath'),
92  'description' => __('publication.urlPath.description'),
93  'value' => $publication->getData('urlPath'),
94  ]))
95  ->addField(new FieldText('datePublished', [
96  'label' => __('publication.datePublished'),
97  'description' => __('publication.datePublished.description'),
98  'value' => $publication->getData('datePublished'),
99  'size' => 'small',
100  ]));
101  }
102 }
APP\components\forms\publication\IssueEntryForm
Definition: IssueEntryForm.inc.php:23
PKP\components\forms\FieldOptions
Definition: FieldOptions.inc.php:15
PKP\components\forms\FieldText
Definition: FieldText.inc.php:15
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
PKP\components\forms\FormComponent\$action
$action
Definition: FormComponent.inc.php:37
PKP\components\forms\FormComponent
Definition: FormComponent.inc.php:20
APP\components\forms\publication\IssueEntryForm\__construct
__construct($action, $locales, $publication, $publicationContext, $baseUrl, $temporaryFileApiUrl)
Definition: IssueEntryForm.inc.php:40
APP\components\forms\publication\FORM_ISSUE_ENTRY
const FORM_ISSUE_ENTRY
Definition: IssueEntryForm.inc.php:21
APP\components\forms\publication\IssueEntryForm\$method
$method
Definition: IssueEntryForm.inc.php:28
APP\components\forms\publication\IssueEntryForm\$id
$id
Definition: IssueEntryForm.inc.php:25
PKP\components\forms\FormComponent\addField
addField($field, $position=[])
Definition: FormComponent.inc.php:94
PKP\components\forms\FormComponent\$locales
$locales
Definition: FormComponent.inc.php:43
PKP\components\forms\FieldSelect
Definition: FieldSelect.inc.php:15
APP\components\forms\publication
Definition: IssueEntryForm.inc.php:14
PKP\components\forms\FieldUploadImage
Definition: FieldUploadImage.inc.php:15
PKPServices\get
static get($service)
Definition: PKPServices.inc.php:49