ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilCtrlAwareStorageUploadHandler Class Reference

Class ilCtrlAwareStorageUploadHandler. More...

+ Inheritance diagram for ilCtrlAwareStorageUploadHandler:
+ Collaboration diagram for ilCtrlAwareStorageUploadHandler:

Public Member Functions

 __construct (protected ResourceStakeholder $stakeholder)
 
 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

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

Protected Attributes

Services $storage
 
- 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()

ilCtrlAwareStorageUploadHandler::__construct ( protected ResourceStakeholder  $stakeholder)

Definition at line 39 of file class.ilCtrlAwareStorageUploadHandler.php.

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

40  {
41  global $DIC;
43  $this->storage = $DIC->resourceStorage();
44  }
global $DIC
Definition: shib_login.php:26
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getInfoForExistingFiles()

ilCtrlAwareStorageUploadHandler::getInfoForExistingFiles ( array  $file_ids)
Parameters
array$file_ids
Returns
BasicFileInfoResult[]

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

Definition at line 102 of file class.ilCtrlAwareStorageUploadHandler.php.

References getInfoResult().

102  : array
103  {
104  $info_results = [];
105  foreach ($file_ids as $identifier) {
106  $info_results[] = $this->getInfoResult($identifier);
107  }
108 
109  return $info_results;
110  }
+ Here is the call graph for this function:

◆ getInfoResult()

ilCtrlAwareStorageUploadHandler::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 87 of file class.ilCtrlAwareStorageUploadHandler.php.

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

Referenced by getInfoForExistingFiles().

88  {
89  if (null !== ($id = $this->storage->manage()->find($identifier))) {
90  $revision = $this->storage->manage()->getCurrentRevision($id)->getInformation();
91  $title = $revision->getTitle();
92  $size = $revision->getSize();
93  $mime = $revision->getMimeType();
94  } else {
95  $title = $mime = 'unknown';
96  $size = 0;
97  }
98 
99  return new BasicFileInfoResult($this->getFileIdentifierParameterName(), $identifier, $title, $size, $mime);
100  }
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()

ilCtrlAwareStorageUploadHandler::getRemoveResult ( string  $identifier)
protected

Definition at line 73 of file class.ilCtrlAwareStorageUploadHandler.php.

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

74  {
75  if (null !== ($id = $this->storage->manage()->find($identifier))) {
76  $this->storage->manage()->remove($id, $this->stakeholder);
77  $status = HandlerResult::STATUS_OK;
78  $message = "file removal OK";
79  } else {
80  $status = HandlerResult::STATUS_OK;
81  $message = "file with identifier '$identifier' doesn't exist, nothing to do.";
82  }
83 
84  return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
85  }
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:

◆ getUploadResult()

ilCtrlAwareStorageUploadHandler::getUploadResult ( )
protected

Definition at line 46 of file class.ilCtrlAwareStorageUploadHandler.php.

References $message, ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), ILIAS\FileUpload\DTO\UploadResult\isOK(), and ILIAS\Repository\upload().

47  {
48  $this->upload->register(new ilCountPDFPagesPreProcessors());
49  $this->upload->process();
50 
51  $result_array = $this->upload->getResults();
52  $result = end($result_array);
53 
54  if ($result instanceof UploadResult && $result->isOK()) {
55  if (!$this->is_chunked) {
56  $identifier = $this->storage->manage()->upload($result, $this->stakeholder)->serialize();
57  $status = HandlerResult::STATUS_OK;
58  $message = "file upload OK";
59  } else {
60  $identifier = '';
61  $status = HandlerResult::STATUS_FAILED;
62  $message = 'chunking not supported';
63  }
64  } else {
65  $identifier = '';
66  $status = HandlerResult::STATUS_FAILED;
67  $message = $result->getStatus()->getMessage();
68  }
69 
70  return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
71  }
$message
Definition: xapiexit.php:31
Class ilCountPDFPagesPreProcessors.
+ Here is the call graph for this function:

Field Documentation

◆ $storage

Services ilCtrlAwareStorageUploadHandler::$storage
protected

Definition at line 37 of file class.ilCtrlAwareStorageUploadHandler.php.


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