ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilRepoStandardUploadHandlerGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29
34{
35 protected array $ctrl_path;
36 protected ?ilLogger $log = null;
37 protected Closure $result_handler;
38 protected string $file_id_parameter = "";
39
40 public function __construct(
41 Closure $result_handler,
42 string $file_id_parameter,
43 string $logger_id = "",
44 array $ctrl_path = []
45 ) {
46 global $DIC;
47 $this->ctrl_path = $ctrl_path;
49
50 if ($logger_id !== "") {
51 $this->log = ilLoggerFactory::getLogger($logger_id);
52 }
53 $this->result_handler = $result_handler;
54 $this->file_id_parameter = $file_id_parameter;
55 }
56
57 protected function getCtrlPath(): array
58 {
60 $path[] = static::class;
61 return $path;
62 }
63 public function getUploadURL(): string
64 {
65 return $this->ctrl->getLinkTargetByClass($this->getCtrlPath(), self::CMD_UPLOAD);
66 }
67
68
72 public function getExistingFileInfoURL(): string
73 {
74 return $this->ctrl->getLinkTargetByClass($this->getCtrlPath(), self::CMD_INFO);
75 }
76
77
81 public function getFileRemovalURL(): string
82 {
83 return $this->ctrl->getLinkTargetByClass($this->getCtrlPath(), self::CMD_REMOVE);
84 }
85
86 protected function debug(string $mess): void
87 {
88 if (!is_null($this->log)) {
89 $this->log->debug($mess);
90 }
91 }
92
93 protected function getUploadResult(): HandlerResult
94 {
95 $this->debug("checking for uploads...");
96 if ($this->upload->hasUploads()) {
97 $this->debug("has upload...");
98 try {
99 $this->upload->process();
100 $this->debug("nr of results: " . count($this->upload->getResults()));
101 foreach ($this->upload->getResults(
102 ) as $result) { // in this version, there will only be one upload at the time
104 $result = $rh($this->upload, $result);
105 }
106 } catch (Exception $e) {
107 $result = new BasicHandlerResult(
109 BasicHandlerResult::STATUS_FAILED,
110 '',
111 $e->getMessage()
112 );
113 }
114 $this->debug("end of 'has_uploads'");
115 } else {
116 $this->debug("has no upload...");
117 }
118 return $result;
119 }
120
121 protected function getRemoveResult(string $identifier): HandlerResult
122 {
123 return new BasicHandlerResult(
125 HandlerResult::STATUS_OK,
126 $identifier,
127 ''
128 );
129 }
130
131 public function getInfoResult(string $identifier): ?FileInfoResult
132 {
133 return null;
134 }
135
136 public function getInfoForExistingFiles(array $file_ids): array
137 {
138 return [];
139 }
140
141 public function getFileIdentifierParameterName(): string
142 {
144 }
145}
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
__construct(Closure $result_handler, string $file_id_parameter, string $logger_id="", array $ctrl_path=[])
Interface Location.
Definition: Location.php:33
A wrapper file dropzone wraps around any other component from the UI framework, e....
Definition: Wrapper.php:32
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26