ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilUIDemoFileUploadHandlerGUI.php
Go to the documentation of this file.
1 <?php
2 
8 
15 {
16 
20  public function getUploadURL() : string
21  {
22  $this->ctrl->initBaseClass(ilUIPluginRouterGUI::class);
23 
24  return $this->ctrl->getLinkTargetByClass([ilUIPluginRouterGUI::class, self::class], self::CMD_UPLOAD);
25  }
26 
27 
31  public function getExistingFileInfoURL() : string
32  {
33  $this->ctrl->initBaseClass(ilUIPluginRouterGUI::class);
34 
35  return $this->ctrl->getLinkTargetByClass([ilUIPluginRouterGUI::class, self::class], self::CMD_INFO);
36  }
37 
38 
42  public function getFileRemovalURL() : string
43  {
44  $this->ctrl->initBaseClass(ilUIPluginRouterGUI::class);
45 
46  return $this->ctrl->getLinkTargetByClass([ilUIPluginRouterGUI::class, self::class], self::CMD_REMOVE);
47  }
48 
49 
53  public function getFileIdentifierParameterName() : string
54  {
55  return 'my_file_id';
56  }
57 
58 
62  protected function getUploadResult() : HandlerResult
63  {
64  $status = HandlerResult::STATUS_OK;
65  $identifier = md5(random_bytes(65));
66  $message = 'Everything ok';
67 
68  return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
69  }
70 
71 
72  protected function getRemoveResult(string $identifier) : HandlerResult
73  {
74  $status = HandlerResult::STATUS_OK;
75  $message = 'File Deleted';
76 
77  return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
78  }
79 
80 
81  protected function getInfoResult(string $identifier) : FileInfoResult
82  {
83  return new BasicFileInfoResult($this->getFileIdentifierParameterName(), $identifier, "My funny Testfile $identifier.txt", 64);
84  }
85 
86 
87  public function getInfoForExistingFiles(array $file_ids) : array
88  {
89  $infos = [];
90  foreach ($file_ids as $file_id) {
91  $infos[] = new BasicFileInfoResult($this->getFileIdentifierParameterName(), $file_id, "Name $file_id.txt", rand(1000, 2000), "text/plain");
92  }
93 
94  return $infos;
95  }
96 }
Class ilUIDemoFileUploadHandlerGUI.
$message
Definition: xapiexit.php:14