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