ILIAS  trunk Revision v11.0_alpha-2406-g7062992332c
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler Class Reference

Class ilCtrlAwareUploadHandler. More...

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

Public Member Functions

 __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

 readChunkedInformation ()
 
 getUploadResult ()
 
 getRemoveResult (string $identifier)
 

Protected Attributes

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\AbstractCtrlAwareUploadHandler::__construct ( )

ilUIDemoFileUploadHandlerGUI constructor.

Definition at line 53 of file AbstractCtrlAwareUploadHandler.php.

References $DIC, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), and ILIAS\Repository\upload().

54  {
55  global $DIC;
56  $this->ctrl = $DIC->ctrl();
57  $this->upload = $DIC->upload();
58  $this->http = $DIC->http();
59  }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::executeCommand ( )

Since this is a ilCtrl aware UploadHandler executeCommand MUST be implemented.

The Implementation MUST make sure, the Upload and the Removal Command are handled correctly

Implements ILIAS\MetaData\OERExposer\OAIPMH\Handler\ilCtrlAwareUploadHandler.

Definition at line 108 of file AbstractCtrlAwareUploadHandler.php.

References $response, ILIAS\Repository\ctrl(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getInfoForExistingFiles(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getInfoResult(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getRemoveResult(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getUploadResult(), ILIAS\FileDelivery\http(), ILIAS\Filesystem\Stream\Streams\ofString(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\readChunkedInformation(), and ILIAS\MetaData\OERExposer\OAIPMH\Handler\HandlerResult\STATUS_FAILED.

108  : void
109  {
110  switch ($this->ctrl->getCmd()) {
111  case self::CMD_UPLOAD:
112  // Here you must save the file and tell the input item the
113  // file-id which will be a FileStorage-ID in a later version
114  // of ILIAS and for now you must implement an own ID which allows
115  // identifying the file after the request
116  try {
117  $this->readChunkedInformation();
118  $content = json_encode($this->getUploadResult());
119  } catch (\Throwable $t) {
120  $content = json_encode(
121  new BasicHandlerResult(
124  '',
125  $t->getMessage()
126  )
127  );
128  }
129  break;
130  case self::CMD_REMOVE:
131  // here you delete the previously uploaded file again, you know
132  // which file to delete since you defined what 'my_file_id' is.
133  $file_identifier = $this->http->request()->getQueryParams()[$this->getFileIdentifierParameterName()];
134  $content = json_encode($this->getRemoveResult($file_identifier));
135  break;
136  case self::CMD_INFO:
137  // here you give info about an already existing file
138  // return a JsonEncoded \ILIAS\FileUpload\Handler\FileInfoResult
139  $file_identifier = $this->http->request()->getQueryParams()[$this->getFileIdentifierParameterName()];
140  $content = json_encode($this->getInfoResult($file_identifier));
141  break;
142  default:
143  $content = '';
144  break;
145  }
146  $response = $this->http->response()->withBody(Streams::ofString($content));
147  $this->http->saveResponse($response);
148  $this->http->sendResponse();
149  $this->http->close();
150  }
$response
Definition: xapitoken.php:93
static http()
Fetches the global http state from ILIAS.
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ getExistingFileInfoURL()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::getExistingFileInfoURL ( )

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

Definition at line 83 of file AbstractCtrlAwareUploadHandler.php.

References ILIAS\Repository\ctrl().

83  : string
84  {
85  return $this->ctrl->getLinkTargetByClass([static::class], self::CMD_INFO);
86  }
+ Here is the call graph for this function:

◆ getFileIdentifierParameterName()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::getFileIdentifierParameterName ( )

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

Definition at line 65 of file AbstractCtrlAwareUploadHandler.php.

Referenced by ilSkillProfileUploadHandlerGUI\__construct(), ilMMUploadHandlerGUI\__construct(), ILIAS\File\Icon\ilIconUploadHandlerGUI\__construct(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\executeCommand(), ilSkillProfileUploadHandlerGUI\getInfoForExistingFiles(), ilMMUploadHandlerGUI\getInfoForExistingFiles(), ILIAS\File\Icon\ilIconUploadHandlerGUI\getInfoForExistingFiles(), ilMDVocabularyUploadHandlerGUI\getInfoResult(), ilSkillProfileUploadHandlerGUI\getInfoResult(), ilCtrlAwareStorageUploadHandler\getInfoResult(), ImportUploadHandlerGUI\getInfoResult(), ilMDCopyrightImageUploadHandlerGUI\getInfoResult(), ilMMUploadHandlerGUI\getInfoResult(), CustomIconUploadHandlerGUI\getInfoResult(), ILIAS\File\Icon\ilIconUploadHandlerGUI\getInfoResult(), TileImageUploadHandlerGUI\getInfoResult(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler\getInfoResult(), ilSkillProfileUploadHandlerGUI\getRemoveResult(), ilMDVocabularyUploadHandlerGUI\getRemoveResult(), ilCtrlAwareStorageUploadHandler\getRemoveResult(), ImportUploadHandlerGUI\getRemoveResult(), ilMDCopyrightImageUploadHandlerGUI\getRemoveResult(), ilMMUploadHandlerGUI\getRemoveResult(), ILIAS\File\Icon\ilIconUploadHandlerGUI\getRemoveResult(), CustomIconUploadHandlerGUI\getRemoveResult(), TileImageUploadHandlerGUI\getRemoveResult(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler\getRemoveResult(), ilOrgUnitTypeUploadHandlerGUI\getUploadResult(), ilStudyProgrammeTypeUploadHandlerGUI\getUploadResult(), ilObjBibliographicUploadHandlerGUI\getUploadResult(), ilMDVocabularyUploadHandlerGUI\getUploadResult(), ilCtrlAwareStorageUploadHandler\getUploadResult(), ilMDCopyrightImageUploadHandlerGUI\getUploadResult(), ImportUploadHandlerGUI\getUploadResult(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler\getUploadResult(), ilFileVersionsUploadHandlerGUI\getUploadResult(), CustomIconUploadHandlerGUI\getUploadResult(), TileImageUploadHandlerGUI\getUploadResult(), ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler\processChunckedUpload(), and ilFileVersionsUploadHandlerGUI\processChunckedUpload().

65  : string
66  {
67  return self::DEFAULT_FILE_ID_PARAMETER;
68  }
+ Here is the caller graph for this function:

◆ getFileRemovalURL()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::getFileRemovalURL ( )

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

Definition at line 92 of file AbstractCtrlAwareUploadHandler.php.

References ILIAS\Repository\ctrl().

92  : string
93  {
94  return $this->ctrl->getLinkTargetByClass([static::class], self::CMD_REMOVE);
95  }
+ Here is the call graph for this function:

◆ getInfoForExistingFiles()

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

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

Referenced by ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\executeCommand().

+ Here is the caller graph for this function:

◆ getInfoResult()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::getInfoResult ( string  $identifier)
abstract
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.

Referenced by ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\executeCommand().

+ Here is the caller graph for this function:

◆ getRemoveResult()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::getRemoveResult ( string  $identifier)
abstractprotected

Referenced by ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\executeCommand().

+ Here is the caller graph for this function:

◆ getUploadResult()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::getUploadResult ( )
abstractprotected

◆ getUploadURL()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::getUploadURL ( )

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

Definition at line 74 of file AbstractCtrlAwareUploadHandler.php.

References ILIAS\Repository\ctrl().

74  : string
75  {
76  return $this->ctrl->getLinkTargetByClass([static::class], self::CMD_UPLOAD);
77  }
+ Here is the call graph for this function:

◆ readChunkedInformation()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::readChunkedInformation ( )
protected

Definition at line 97 of file AbstractCtrlAwareUploadHandler.php.

References ILIAS\FileDelivery\http(), ILIAS\Repository\int(), and null.

Referenced by ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\executeCommand().

97  : void
98  {
99  $body = $this->http->request()->getParsedBody();
100  $this->chunk_id = $body['dzuuid'] ?? null;
101  $this->amount_of_chunks = (int) ($body['dztotalchunkcount'] ?? 0);
102  $this->chunk_index = (int) ($body['dzchunkindex'] ?? 0);
103  $this->chunk_total_size = (int) ($body['dztotalfilesize'] ?? 0);
104  $this->is_chunked = ($this->chunk_id !== null && $this->amount_of_chunks > 0);
105  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ supportsChunkedUploads()

ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::supportsChunkedUploads ( )
Returns
bool if this uploadhandler chan handle Chunked Uploads. These come in multiple requests and must be combined to a single file. If your UploadHandler can handle Chunked Uploads, you can use a UI with .

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

Definition at line 164 of file AbstractCtrlAwareUploadHandler.php.

164  : bool
165  {
166  return false;
167  }

Field Documentation

◆ $amount_of_chunks

int ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::$amount_of_chunks = 0
protected

◆ $chunk_id

string ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::$chunk_id = null
protected

Definition at line 46 of file AbstractCtrlAwareUploadHandler.php.

◆ $chunk_index

int ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::$chunk_index = 0
protected

Definition at line 44 of file AbstractCtrlAwareUploadHandler.php.

◆ $chunk_total_size

int ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::$chunk_total_size = 0
protected

Definition at line 47 of file AbstractCtrlAwareUploadHandler.php.

◆ $ctrl

ilCtrl ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::$ctrl
protected

Definition at line 40 of file AbstractCtrlAwareUploadHandler.php.

◆ $http

HttpServices ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::$http
protected

Definition at line 39 of file AbstractCtrlAwareUploadHandler.php.

◆ $is_chunked

bool ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::$is_chunked = false
protected

Definition at line 43 of file AbstractCtrlAwareUploadHandler.php.

◆ $upload

FileUpload ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::$upload
protected

Definition at line 41 of file AbstractCtrlAwareUploadHandler.php.

◆ CMD_INFO

const ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::CMD_INFO = 'info'
protected

Definition at line 37 of file AbstractCtrlAwareUploadHandler.php.

◆ CMD_REMOVE

const ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::CMD_REMOVE = 'remove'
protected

Definition at line 36 of file AbstractCtrlAwareUploadHandler.php.

◆ CMD_UPLOAD

const ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler::CMD_UPLOAD = 'upload'
protected

Definition at line 35 of file AbstractCtrlAwareUploadHandler.php.


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