ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjFileUploadDropzone.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26
31{
34
39 protected ilAccess $access;
40 protected UIServices $ui;
41 protected Factory $refinery;
42 protected LOMServices $lom_services;
43
44 public function __construct(protected int $target_ref_id, protected ?string $content = null)
45 {
46 global $DIC;
47
48 $this->definition = $DIC['objDefinition'];
49 $this->language = $DIC->language();
50 $this->language->loadLanguageModule('file');
51 $this->access = $DIC->access();
52 $this->ctrl = $DIC->ctrl();
53 $this->ui = $DIC->ui();
54 $this->refinery = $DIC->refinery();
55 $this->lom_services = $DIC->learningObjectMetadata();
56
57 $this->upload_handler = new ilObjFileUploadHandlerGUI();
58 }
59
60 private function isCopyrightSelectionActive(): bool
61 {
62 static $active;
63 if ($active === null) {
64 $active = $this->lom_services->copyrightHelper()->isCopyrightSelectionActive();
65 }
66 return $active;
67 }
68
69 public function getDropzone(): FileDropzone
70 {
71 $this->ctrl->setParameterByClass(
72 ilObjFileGUI::class,
73 'ref_id',
74 $this->target_ref_id
75 );
76 $this->ctrl->setParameterByClass(
77 ilObjFileGUI::class,
78 'new_type',
80 );
81 $this->ctrl->setParameterByClass(
82 ilObjFileGUI::class,
85 );
86
87 // Generate POST-URL
88 $post_url = $this->ctrl->getFormActionByClass(
89 [ilRepositoryGUI::class, ilObjFileGUI::class],
91 );
92 // reset new_type again
93 $this->ctrl->clearParameterByClass(ilObjFileGUI::class, 'new_type');
94
95 $additional_input = null;
96 if ($this->isCopyrightSelectionActive()) {
97 $additional_input = $this->getCopyrightSelectionInput('set_license_for_all_files');
98 }
99
101 $dropzone = $this->ui->factory()->dropzone()->file()->wrapper(
102 $this->language->txt('upload_files'),
103 $post_url,
104 $this->ui->factory()->legacy()->content($this->content ?? ''),
105 $this->ui->factory()->input()->field()->file(
106 $this->upload_handler,
107 $this->language->txt('upload_files'),
108 null,
109 $this->ui->factory()->input()->field()->group([
110 ilObjFileGUI::PARAM_TITLE => $this->ui->factory()->input()->field()->text(
111 $this->language->txt('title')
112 )->withAdditionalTransformation(
113 $this->getEmptyStringToNullTransformation()
114 ),
115 ilObjFileGUI::PARAM_DESCRIPTION => $this->ui->factory()->input()->field()->textarea(
116 $this->language->txt('description')
117 )->withAdditionalTransformation(
118 $this->getEmptyStringToNullTransformation()
119 ),
120 ])
121 )->withRequired(
122 true
123 )->withMaxFiles(
125 ),
126 $additional_input
127 )->withSubmitLabel(
128 $this->language->txt('upload_files')
129 );
130
131 return $dropzone;
132 }
133
134 public function isUploadAllowed(string $obj_type): bool
135 {
136 if ($this->definition->isContainer($obj_type) && $obj_type !== "orgu") {
137 return $this->access->checkAccess('create_file', '', $this->target_ref_id, 'file');
138 }
139
140 return false;
141 }
142
143 public function getDropzoneHtml(): string
144 {
145 return $this->ui->renderer()->render($this->getDropzone());
146 }
147
148 protected function getUIFactory(): ILIAS\UI\Factory
149 {
150 return $this->ui->factory();
151 }
152
153 protected function getLanguage(): \ilLanguage
154 {
155 return $this->language;
156 }
157
158 protected function getRefinery(): Factory
159 {
160 return $this->refinery;
161 }
162}
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
Builds data types.
Definition: Factory.php:36
Class ilAccessHandler Checks access for ILIAS objects.
language handling
const UPLOAD_ORIGIN_DROPZONE
__construct(protected int $target_ref_id, protected ?string $content=null)
const OBJECT_TYPE
parses the objects.xml it handles the xml-description of all ilias objects
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26
trait ilObjFileCopyrightInput
trait ilObjFileTransformation