ILIAS  release_8 Revision v8.24
class.ilObjFileUploadDropzone.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
24
29{
34 protected ilAccess $access;
35 protected UIServices $ui;
36
37 protected int $target_ref_id;
38 protected ?string $content;
39
40 public function __construct(int $target_ref_id, string $content = null)
41 {
42 global $DIC;
43
44 $this->definition = $DIC['objDefinition'];
45 $this->language = $DIC->language();
46 $this->access = $DIC->access();
47 $this->ctrl = $DIC->ctrl();
48 $this->ui = $DIC->ui();
49
50 $this->upload_handler = new ilObjFileUploadHandlerGUI();
51 $this->target_ref_id = $target_ref_id;
52 $this->content = $content;
53 }
54
55 public function getDropzone(): FileDropzone
56 {
57 $this->ctrl->setParameterByClass(
58 ilObjFileGUI::class,
59 'ref_id',
60 $this->target_ref_id
61 );
62 $this->ctrl->setParameterByClass(
63 ilObjFileGUI::class,
64 'new_type',
66 );
67 $this->ctrl->setParameterByClass(
68 ilObjFileGUI::class,
71 );
72
73 // Generate POST-URL
74 $post_url = $this->ctrl->getFormActionByClass(
75 [ilRepositoryGUI::class, ilObjFileGUI::class],
77 );
78 // reset new_type again
79 $this->ctrl->clearParameterByClass(ilObjFileGUI::class, 'new_type');
80
82 $dropzone = $this->ui->factory()->dropzone()->file()->wrapper(
83 $this->language->txt('upload_files'),
84 $post_url,
85 $this->ui->factory()->legacy($this->content ?? ''),
86 $this->ui->factory()->input()->field()->file(
87 $this->upload_handler,
88 $this->language->txt('files'),
89 null,
90 $this->ui->factory()->input()->field()->group([
91 ilObjFileProcessorInterface::OPTION_FILENAME => $this->ui->factory()->input()->field()->text(
92 $this->language->txt('title')
93 ),
94 ilObjFileProcessorInterface::OPTION_DESCRIPTION => $this->ui->factory()->input()->field()->textarea(
95 $this->language->txt('description')
96 ),
97 ])
98 )->withMaxFiles(
100 )->withMaxFileSize(
102 )
103 )->withSubmitCaption(
104 $this->language->txt('upload_files')
105 );
106
107 return $dropzone;
108 }
109
110 public function isUploadAllowed(string $obj_type): bool
111 {
112 if ($this->definition->isContainer($obj_type) && $obj_type !== "orgu") {
113 return $this->access->checkAccess('create_file', '', $this->target_ref_id, 'file');
114 }
115
116 return false;
117 }
118
119 public function getDropzoneHtml(): string
120 {
121 return $this->ui->renderer()->render($this->getDropzone());
122 }
123}
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getUploadSizeLimitBytes()
language handling
const UPLOAD_ORIGIN_DROPZONE
__construct(int $target_ref_id, string $content=null)
const OBJECT_TYPE
parses the objects.xml it handles the xml-description of all ilias objects
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...