ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler Class Reference

Class AbstractCtrlAwareIRSSUploadHandler. More...

+ Inheritance diagram for ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler:
+ Collaboration diagram for ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler:

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

ilFileServicesFilenameSanitizer $sanitizer
 
ilLanguage $language
 
ILIAS ResourceStorage Services $irss
 
ResourceStakeholder $stakeholder
 
ILIAS Filesystem Filesystem $temp_filesystem
 
array $class_path
 
- Protected Attributes inherited from ILIAS\MetaData\OERExposer\OAIPMH\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\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::__construct ( )

Definition at line 40 of file AbstractCtrlAwareIRSSUploadHandler.php.

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

41  {
42  global $DIC;
43 
44  $this->irss = $DIC->resourceStorage();
45  $this->stakeholder = $this->getStakeholder();
46  $this->temp_filesystem = $DIC->filesystem()->temp();
47  $this->class_path = $this->getClassPath();
48  $this->language = $DIC->language();
49  $this->sanitizer = new \ilFileServicesFilenameSanitizer(
50  $DIC->fileServiceSettings()
51  );
52 
54  }
global $DIC
Definition: shib_login.php:25
__construct(Container $dic, ilPlugin $plugin)
language()
description: > Example for rendring a language glyph.
Definition: language.php:25
+ Here is the call graph for this function:

Member Function Documentation

◆ getClassPath()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::getClassPath ( )
abstractprotected

Referenced by ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler\__construct().

+ Here is the caller graph for this function:

◆ getExistingFileInfoURL()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::getExistingFileInfoURL ( )
Returns
string of the URL where in GUI existing files are handled. The URL is called by GET with a field with name from getFileIdentifierParameterName() and the FileID of the desired file. Return a FI

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 131 of file AbstractCtrlAwareIRSSUploadHandler.php.

References ILIAS\Repository\ctrl().

131  : string
132  {
133  return $this->ctrl->getLinkTargetByClass($this->class_path, self::CMD_INFO, null, true);
134  }
+ Here is the call graph for this function:

◆ getFileRemovalURL()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::getFileRemovalURL ( )
Returns
string of the URL where in GUI deleted files are handled. The URL is called by POST with a field with name from getFileIdentifierParameterName() and the FileID of the deleted file.

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 136 of file AbstractCtrlAwareIRSSUploadHandler.php.

References ILIAS\Repository\ctrl().

136  : string
137  {
138  return $this->ctrl->getLinkTargetByClass($this->class_path, self::CMD_REMOVE, null, true);
139  }
+ Here is the call graph for this function:

◆ getInfoForExistingFiles()

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

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 170 of file AbstractCtrlAwareIRSSUploadHandler.php.

References ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler\getInfoResult().

170  : array
171  {
172  return array_map(function ($file_id): FileInfoResult {
173  return $this->getInfoResult($file_id);
174  }, $file_ids);
175  }
+ Here is the call graph for this function:

◆ getInfoResult()

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

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 155 of file AbstractCtrlAwareIRSSUploadHandler.php.

References $id, ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), and ILIAS\MetaData\OERExposer\OAIPMH\Handler\FileInfoResult\getSize().

Referenced by ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler\getInfoForExistingFiles().

155  : ?FileInfoResult
156  {
157  if (null !== ($id = $this->irss->manage()->find($identifier))) {
158  $revision = $this->irss->manage()->getCurrentRevision($id)->getInformation();
159  $title = $revision->getTitle();
160  $size = $revision->getSize();
161  $mime = $revision->getMimeType();
162  } else {
163  $title = $mime = 'unknown';
164  $size = 0;
165  }
166 
167  return new BasicFileInfoResult($this->getFileIdentifierParameterName(), $identifier, $title, $size, $mime);
168  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRemoveResult()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::getRemoveResult ( string  $identifier)
protected

Definition at line 141 of file AbstractCtrlAwareIRSSUploadHandler.php.

References $id, ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), and ILIAS\MetaData\OERExposer\OAIPMH\Handler\HandlerResult\STATUS_OK.

141  : HandlerResult
142  {
143  if (null !== ($id = $this->irss->manage()->find($identifier))) {
144  $this->irss->manage()->remove($id, $this->stakeholder);
145  $status = HandlerResult::STATUS_OK;
146  $message = "file removal OK";
147  } else {
148  $status = HandlerResult::STATUS_OK;
149  $message = "file with identifier '$identifier' doesn't exist, nothing to do.";
150  }
151 
152  return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
153  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
+ Here is the call graph for this function:

◆ getStakeholder()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::getStakeholder ( )
abstractprotected

Referenced by ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler\__construct().

+ Here is the caller graph for this function:

◆ getUploadResult()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::getUploadResult ( )
protected

Definition at line 60 of file AbstractCtrlAwareIRSSUploadHandler.php.

References ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler\processChunckedUpload(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\HandlerResult\STATUS_FAILED, ILIAS\MetaData\OERExposer\OAIPMH\Handler\HandlerResult\STATUS_OK, and ILIAS\Repository\upload().

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

◆ getUploadURL()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::getUploadURL ( )
Returns
string of the URL where dropped files are sent to. This URL must make sure the upload is handled and a is returned as JSON.

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 126 of file AbstractCtrlAwareIRSSUploadHandler.php.

References ILIAS\Repository\ctrl().

126  : string
127  {
128  return $this->ctrl->getLinkTargetByClass($this->class_path, self::CMD_UPLOAD, null, true);
129  }
+ Here is the call graph for this function:

◆ processChunckedUpload()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::processChunckedUpload ( UploadResult  $result)
protected

Definition at line 86 of file AbstractCtrlAwareIRSSUploadHandler.php.

References ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\$amount_of_chunks, $id, ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\HandlerResult\STATUS_FAILED, ILIAS\MetaData\OERExposer\OAIPMH\Handler\HandlerResult\STATUS_OK, and ILIAS\MetaData\OERExposer\OAIPMH\Handler\HandlerResult\STATUS_PARTIAL.

Referenced by ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler\getUploadResult().

86  : HandlerResult
87  {
88  $temp_path = $this->sanitizer->sanitize("$this->chunk_id/{$result->getName()}");
89 
90  try {
91  if ($this->temp_filesystem->has($temp_path)) {
92  $stream = fopen($this->temp_filesystem->readStream($temp_path)->getMetadata()['uri'], 'ab');
93  fwrite($stream, file_get_contents($result->getPath()));
94  } else {
95  $this->temp_filesystem->write($temp_path, file_get_contents($result->getPath()));
96  }
97  } catch (\Throwable $t) {
98  return new BasicHandlerResult(
101  '',
102  $t->getMessage()
103  );
104  }
105 
106  if (($this->chunk_index + 1) === $this->amount_of_chunks) {
107  $whole_file = $this->temp_filesystem->readStream($temp_path);
108  $id = $this->irss->manage()->stream($whole_file, $this->stakeholder, $result->getName());
109 
110  return new BasicHandlerResult(
113  $id->serialize(),
114  "file upload OK"
115  );
116  }
117 
118  return new BasicHandlerResult(
121  '',
122  "chunk upload OK"
123  );
124  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $class_path

array ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::$class_path
protected

Definition at line 38 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $irss

ILIAS ResourceStorage Services ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::$irss
protected

Definition at line 35 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $language

ilLanguage ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::$language
protected

Definition at line 34 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $sanitizer

ilFileServicesFilenameSanitizer ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::$sanitizer
protected

Definition at line 33 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $stakeholder

ResourceStakeholder ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::$stakeholder
protected

Definition at line 36 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $temp_filesystem

ILIAS Filesystem Filesystem ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler::$temp_filesystem
protected

Definition at line 37 of file AbstractCtrlAwareIRSSUploadHandler.php.


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