ILIAS  release_8 Revision v8.24
class.ilUIDemoFileUploadHandlerGUI.php
Go to the documentation of this file.
1<?php
2
25
32{
36 public function getUploadURL(): string
37 {
38 return $this->ctrl->getLinkTargetByClass([ilUIPluginRouterGUI::class, self::class], self::CMD_UPLOAD);
39 }
40
41
45 public function getExistingFileInfoURL(): string
46 {
47 return $this->ctrl->getLinkTargetByClass([ilUIPluginRouterGUI::class, self::class], self::CMD_INFO);
48 }
49
50
54 public function getFileRemovalURL(): string
55 {
56 return $this->ctrl->getLinkTargetByClass(
57 [ilUIPluginRouterGUI::class, self::class],
58 self::CMD_REMOVE,
59 null,
60 false
61 );
62 }
63
64
68 public function getFileIdentifierParameterName(): string
69 {
70 return 'my_file_id';
71 }
72
73
77 protected function getUploadResult(): HandlerResult
78 {
79 $status = HandlerResult::STATUS_OK;
80 $identifier = md5(random_bytes(65));
81 $message = 'Everything ok';
82
83 return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
84 }
85
86
87 protected function getRemoveResult(string $identifier): HandlerResult
88 {
89 $status = HandlerResult::STATUS_OK;
90 $message = 'File Deleted';
91
92 return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
93 }
94
95
96 public function getInfoResult(string $identifier): ?FileInfoResult
97 {
98 return new BasicFileInfoResult(
100 $identifier,
101 "My funny Testfile $identifier.txt",
102 64,
103 ""
104 );
105 }
106
107
108 public function getInfoForExistingFiles(array $file_ids): array
109 {
110 $infos = [];
111 foreach ($file_ids as $file_id) {
112 $infos[] = new BasicFileInfoResult(
114 $file_id,
115 "Name $file_id.txt",
116 rand(1000, 2000),
117 "text/plain"
118 );
119 }
120
121 return $infos;
122 }
123}
Class ilUIDemoFileUploadHandlerGUI.
$message
Definition: xapiexit.php:32