ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMDVocabularyUploadHandlerGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29
31{
32 protected Filesystem $temp;
33
34 public function __construct()
35 {
36 global $DIC;
37
38 $this->temp = $DIC->filesystem()->temp();
40 }
41
42 protected function getUploadResult(): HandlerResult
43 {
44 $status = HandlerResult::STATUS_FAILED;
45 $new_identification = 'unknown';
46 $message = 'file upload failed';
47
48 $this->upload->process();
49 $uploadResults = $this->upload->getResults();
50 $result = end($uploadResults);
51
52 if ($result instanceof UploadResult && $result->isOK() && $result->getSize()) {
53 $new_identification = uniqid('md_vocab_');
54 $move_success = $this->upload->moveOneFileTo(
55 $result,
56 $new_identification,
57 Location::TEMPORARY
58 );
59 if ($move_success) {
60 $status = HandlerResult::STATUS_OK;
61 $message = 'Upload ok';
62 }
63 }
64 return new BasicHandlerResult(
66 $status,
67 $new_identification,
69 );
70 }
71
72 protected function getRemoveResult(string $identifier): HandlerResult
73 {
74 return new BasicHandlerResult(
76 HandlerResult::STATUS_OK,
77 $identifier,
78 'asynchronous removal blocked'
79 );
80 }
81
82 public function getInfoResult(string $identifier): ?FileInfoResult
83 {
84 $title = $mime = 'unknown';
85 $size = 0;
86
87 $files = $this->temp->hasDir($identifier) ?
88 $this->temp->listContents($identifier) :
89 [];
90
91 foreach ($files as $file) {
92 if (!$file->isFile()) {
93 continue;
94 }
95 $title = $file->getFilename();
96 $size = $file->getSize();
97 $mime = $file->getMimeType();
98 break;
99 }
100
101 return new BasicFileInfoResult(
103 $identifier,
104 $title,
105 $size,
106 $mime
107 );
108 }
109
110 public function getInfoForExistingFiles(array $file_ids): array
111 {
112 return [];
113 }
114}
__construct()
ilUIDemoFileUploadHandlerGUI constructor.
Interface Location.
Definition: Location.php:33
The filesystem interface provides the public interface for the Filesystem service API consumer.
Definition: Filesystem.php:37
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$message
Definition: xapiexit.php:31