ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler Class Reference

Class AbstractCtrlAwareIRSSUploadHandler. More...

+ Inheritance diagram for ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler:
+ Collaboration diagram for ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler:

Public Member Functions

 __construct ()
 ilUIDemoFileUploadHandlerGUI constructor. More...
 
 getUploadURL ()
 @inheritDoc More...
 
 getExistingFileInfoURL ()
 @inheritDoc More...
 
 getFileRemovalURL ()
 @inheritDoc More...
 
 getInfoResult (string $identifier)
 
 getInfoForExistingFiles (array $file_ids)
 
- Public Member Functions inherited from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler
 __construct ()
 ilUIDemoFileUploadHandlerGUI constructor. More...
 
 getFileIdentifierParameterName ()
 @inheritDoc More...
 
 getUploadURL ()
 @inheritDoc More...
 
 getExistingFileInfoURL ()
 @inheritDoc More...
 
 getFileRemovalURL ()
 @inheritDoc More...
 
 executeCommand ()
 Since this is a ilCtrl aware UploadHandler executeCommand MUST be implemented. More...
 
 getInfoResult (string $identifier)
 
 getInfoForExistingFiles (array $file_ids)
 
 supportsChunkedUploads ()
 
 executeCommand ()
 Since this is a ilCtrl aware UploadHandler executeCommand MUST be implemented. More...
 
 getFileIdentifierParameterName ()
 
 getUploadURL ()
 
 getFileRemovalURL ()
 
 getExistingFileInfoURL ()
 
 getInfoForExistingFiles (array $file_ids)
 
 getInfoResult (string $identifier)
 
 supportsChunkedUploads ()
 

Protected Member Functions

 getStakeholder ()
 
 getClassPath ()
 
 getUploadResult ()
 
 processChunckedUpload (UploadResult $result)
 
 getRemoveResult (string $identifier)
 
- Protected Member Functions inherited from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler
 readChunkedInformation ()
 
 getUploadResult ()
 
 getRemoveResult (string $identifier)
 

Protected Attributes

ilFileServicesFilenameSanitizer $sanitizer
 
ilLanguage $language
 
Services $irss
 
ResourceStakeholder $stakeholder
 
Filesystem $temp_filesystem
 
array $class_path
 
- Protected Attributes inherited from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler
const CMD_UPLOAD = 'upload'
 
const CMD_REMOVE = 'remove'
 
const CMD_INFO = 'info'
 
HttpServices $http
 
ilCtrl $ctrl
 
FileUpload $upload
 
bool $is_chunked = false
 
int $chunk_index = 0
 
int $amount_of_chunks = 0
 
string $chunk_id = null
 
int $chunk_total_size = 0
 

Additional Inherited Members

- Data Fields inherited from ILIAS\UI\Component\Input\Field\UploadHandler
const DEFAULT_FILE_ID_PARAMETER = 'file_id'
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::__construct ( )

ilUIDemoFileUploadHandlerGUI constructor.

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler.

Definition at line 42 of file AbstractCtrlAwareIRSSUploadHandler.php.

43 {
44 global $DIC;
45
46 $this->irss = $DIC->resourceStorage();
47 $this->stakeholder = $this->getStakeholder();
48 $this->temp_filesystem = $DIC->filesystem()->temp();
49 $this->class_path = $this->getClassPath();
50 $this->language = $DIC->language();
51 $this->sanitizer = new \ilFileServicesFilenameSanitizer(
52 $DIC->fileServiceSettings()
53 );
54
56 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler\getClassPath(), ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler\getStakeholder(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

Member Function Documentation

◆ getClassPath()

ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::getClassPath ( )
abstractprotected

Reimplemented in ilObjFileUploadHandlerGUI, and ilFileVersionsUploadHandlerGUI.

Referenced by ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler\__construct().

+ Here is the caller graph for this function:

◆ getExistingFileInfoURL()

ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::getExistingFileInfoURL ( )

@inheritDoc

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler.

Definition at line 135 of file AbstractCtrlAwareIRSSUploadHandler.php.

135 : string
136 {
137 return $this->ctrl->getLinkTargetByClass($this->class_path, self::CMD_INFO, null, true);
138 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getFileRemovalURL()

ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::getFileRemovalURL ( )

@inheritDoc

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler.

Definition at line 141 of file AbstractCtrlAwareIRSSUploadHandler.php.

141 : string
142 {
143 return $this->ctrl->getLinkTargetByClass($this->class_path, self::CMD_REMOVE, null, true);
144 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getInfoForExistingFiles()

ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::getInfoForExistingFiles ( array  $file_ids)
Parameters
array$file_ids
Returns
BasicFileInfoResult[]

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler.

Definition at line 175 of file AbstractCtrlAwareIRSSUploadHandler.php.

175 : array
176 {
177 return array_map(fn($file_id): FileInfoResult => $this->getInfoResult($file_id), $file_ids);
178 }

References ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler\getInfoResult().

+ Here is the call graph for this function:

◆ getInfoResult()

ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::getInfoResult ( string  $identifier)
Returns
null|FileInfoResult for the file with the given identifier or null if the file does not exist.

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler.

Definition at line 160 of file AbstractCtrlAwareIRSSUploadHandler.php.

160 : ?FileInfoResult
161 {
162 if (null !== ($id = $this->irss->manage()->find($identifier))) {
163 $revision = $this->irss->manage()->getCurrentRevision($id)->getInformation();
164 $title = $revision->getTitle();
165 $size = $revision->getSize();
166 $mime = $revision->getMimeType();
167 } else {
168 $title = $mime = 'unknown';
169 $size = 0;
170 }
171
172 return new BasicFileInfoResult($this->getFileIdentifierParameterName(), $identifier, $title, $size, $mime);
173 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), and ILIAS\FileUpload\Handler\FileInfoResult\getSize().

Referenced by ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler\getInfoForExistingFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRemoveResult()

ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::getRemoveResult ( string  $identifier)
protected

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler.

Definition at line 146 of file AbstractCtrlAwareIRSSUploadHandler.php.

146 : HandlerResult
147 {
148 if (null !== ($id = $this->irss->manage()->find($identifier))) {
149 $this->irss->manage()->remove($id, $this->stakeholder);
150 $status = HandlerResult::STATUS_OK;
151 $message = "file removal OK";
152 } else {
153 $status = HandlerResult::STATUS_OK;
154 $message = "file with identifier '$identifier' doesn't exist, nothing to do.";
155 }
156
157 return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
158 }
$message
Definition: xapiexit.php:31

References $id, $message, ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), and ILIAS\FileUpload\Handler\HandlerResult\STATUS_OK.

+ Here is the call graph for this function:

◆ getStakeholder()

ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::getStakeholder ( )
abstractprotected

Reimplemented in ilObjFileUploadHandlerGUI, and ilFileVersionsUploadHandlerGUI.

Referenced by ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler\__construct().

+ Here is the caller graph for this function:

◆ getUploadResult()

ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::getUploadResult ( )
protected

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler.

Reimplemented in ilFileVersionsUploadHandlerGUI.

Definition at line 62 of file AbstractCtrlAwareIRSSUploadHandler.php.

62 : HandlerResult
63 {
64 $this->upload->process(); // Process the uploads to rund things like PreProcessors
65
66 $result_array = $this->upload->getResults();
67 $result = end($result_array); // get the last result aka the Upload of the user
68
69 if ($result instanceof UploadResult && $result->isOK()) {
70 if ($this->is_chunked) {
71 return $this->processChunckedUpload($result);
72 }
73
74 $identifier = $this->irss->manage()->upload($result, $this->stakeholder)->serialize();
76 $message = "file upload OK";
77 } else {
78 $identifier = '';
80 $message = $this->language->txt(
81 'msg_info_blacklisted'
82 ); // this is the most common reason for a failed upload
83 }
84
85 return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
86 }

References $message, ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), ILIAS\FileUpload\DTO\UploadResult\isOK(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler\processChunckedUpload(), ILIAS\FileUpload\Handler\HandlerResult\STATUS_FAILED, ILIAS\FileUpload\Handler\HandlerResult\STATUS_OK, and ILIAS\Repository\upload().

+ Here is the call graph for this function:

◆ getUploadURL()

ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::getUploadURL ( )

@inheritDoc

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler.

Definition at line 129 of file AbstractCtrlAwareIRSSUploadHandler.php.

129 : string
130 {
131 return $this->ctrl->getLinkTargetByClass($this->class_path, self::CMD_UPLOAD, null, true);
132 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ processChunckedUpload()

ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::processChunckedUpload ( UploadResult  $result)
protected

Reimplemented in ilFileVersionsUploadHandlerGUI.

Definition at line 88 of file AbstractCtrlAwareIRSSUploadHandler.php.

88 : HandlerResult
89 {
90 $temp_path = $this->sanitizer->sanitize("$this->chunk_id/{$result->getName()}");
91
92 try {
93 if ($this->temp_filesystem->has($temp_path)) {
94 $stream = fopen($this->temp_filesystem->readStream($temp_path)->getMetadata()['uri'], 'ab');
95 fwrite($stream, file_get_contents($result->getPath()));
96 } else {
97 $this->temp_filesystem->write($temp_path, file_get_contents($result->getPath()));
98 }
99 } catch (\Throwable $t) {
100 return new BasicHandlerResult(
103 '',
104 $t->getMessage()
105 );
106 }
107
108 if (($this->chunk_index + 1) === $this->amount_of_chunks) {
109 $whole_file = $this->temp_filesystem->readStream($temp_path);
110 $id = $this->irss->manage()->stream($whole_file, $this->stakeholder, $result->getName());
111
112 return new BasicHandlerResult(
115 $id->serialize(),
116 "file upload OK"
117 );
118 }
119
120 return new BasicHandlerResult(
123 '',
124 "chunk upload OK"
125 );
126 }

References $id, ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), ILIAS\FileUpload\DTO\UploadResult\getName(), ILIAS\FileUpload\DTO\UploadResult\getPath(), ILIAS\FileUpload\Handler\HandlerResult\STATUS_FAILED, ILIAS\FileUpload\Handler\HandlerResult\STATUS_OK, and ILIAS\FileUpload\Handler\HandlerResult\STATUS_PARTIAL.

Referenced by ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler\getUploadResult().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $class_path

array ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::$class_path
protected

Definition at line 40 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $irss

Services ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::$irss
protected

Definition at line 37 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $language

ilLanguage ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::$language
protected

Definition at line 36 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $sanitizer

ilFileServicesFilenameSanitizer ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::$sanitizer
protected

Definition at line 35 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $stakeholder

ResourceStakeholder ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::$stakeholder
protected

Definition at line 38 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $temp_filesystem

Filesystem ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler::$temp_filesystem
protected

Definition at line 39 of file AbstractCtrlAwareIRSSUploadHandler.php.


The documentation for this class was generated from the following file: