ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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
 
Services $irss
 
ResourceStakeholder $stakeholder
 
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 42 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().

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  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ 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 135 of file AbstractCtrlAwareIRSSUploadHandler.php.

References ILIAS\Repository\ctrl(), and null.

135  : string
136  {
137  return $this->ctrl->getLinkTargetByClass($this->class_path, self::CMD_INFO, null, true);
138  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 141 of file AbstractCtrlAwareIRSSUploadHandler.php.

References ILIAS\Repository\ctrl(), and null.

141  : string
142  {
143  return $this->ctrl->getLinkTargetByClass($this->class_path, self::CMD_REMOVE, null, true);
144  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 175 of file AbstractCtrlAwareIRSSUploadHandler.php.

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

175  : array
176  {
177  return array_map(fn($file_id): FileInfoResult => $this->getInfoResult($file_id), $file_ids);
178  }
+ 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 160 of file AbstractCtrlAwareIRSSUploadHandler.php.

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

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

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ 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 146 of file AbstractCtrlAwareIRSSUploadHandler.php.

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

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$message
Definition: xapiexit.php:31
+ 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 62 of file AbstractCtrlAwareIRSSUploadHandler.php.

References $message, 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().

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();
75  $status = HandlerResult::STATUS_OK;
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  }
$message
Definition: xapiexit.php:31
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ 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 129 of file AbstractCtrlAwareIRSSUploadHandler.php.

References ILIAS\Repository\ctrl(), and null.

129  : string
130  {
131  return $this->ctrl->getLinkTargetByClass($this->class_path, self::CMD_UPLOAD, null, true);
132  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ processChunckedUpload()

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

Definition at line 88 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().

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  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ 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 40 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $irss

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

Definition at line 37 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $language

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

Definition at line 36 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $sanitizer

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

Definition at line 35 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $stakeholder

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

Definition at line 38 of file AbstractCtrlAwareIRSSUploadHandler.php.

◆ $temp_filesystem

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

Definition at line 39 of file AbstractCtrlAwareIRSSUploadHandler.php.


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