ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler Class Reference

Class ilCtrlAwareUploadHandler. More...

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

Public Member Functions

 __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...
 
 getInfoForExistingFiles (array $file_ids)
 
 executeCommand ()
 Since this is a ilCtrl aware UploadHandler executeCommand MUST be implemented. More...
 
 getFileIdentifierParameterName ()
 
 getUploadURL ()
 
 getFileRemovalURL ()
 
 getExistingFileInfoURL ()
 
 getInfoForExistingFiles (array $file_ids)
 

Protected Member Functions

 getUploadResult ()
 
 getRemoveResult (string $identifier)
 
 getInfoResult (string $identifier)
 

Protected Attributes

const CMD_UPLOAD = 'upload'
 
const CMD_REMOVE = 'remove'
 
const CMD_INFO = 'info'
 
 $http
 
 $ctrl
 
 $upload
 

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

ilUIDemoFileUploadHandlerGUI constructor.

Reimplemented in ilMMUploadHandlerGUI.

Definition at line 35 of file AbstractCtrlAwareUploadHandler.php.

36 {
37 global $DIC;
38 $this->ctrl = $DIC->ctrl();
39 $this->upload = $DIC->upload();
40 $this->http = $DIC->http();
41 }
static http()
Fetches the global http state from ILIAS.
$DIC
Definition: xapitoken.php:46

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

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ILIAS\FileUpload\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\FileUpload\Handler\ilCtrlAwareUploadHandler.

Reimplemented in ilIndividualAssessmentMemberGUI.

Definition at line 80 of file AbstractCtrlAwareUploadHandler.php.

80 : void
81 {
82 switch ($this->ctrl->getCmd()) {
84 // Here you must save the file and tell the input item the
85 // file-id which will be a FileStorage-ID in a later version
86 // of ILIAS and for now you must implement an own ID which allows
87 // identifying the file after the request
88 $content = json_encode($this->getUploadResult());
89 break;
91 // here you delete the previously uploaded file again, you know
92 // which file to delete since you defined what 'my_file_id' is.
93 $file_identifier = $this->http->request()->getQueryParams()[$this->getFileIdentifierParameterName()];
94 $content = json_encode($this->getRemoveResult($file_identifier));
95 break;
96 case self::CMD_INFO:
97 // here you give info about an already existing file
98 // return a JsonEncoded \ILIAS\FileUpload\Handler\FileInfoResult
99 $file_identifier = $this->http->request()->getQueryParams()[$this->getFileIdentifierParameterName()];
100 $content = json_encode($this->getInfoResult($file_identifier));
101 break;
102 default:
103 $content = '';
104 break;
105 }
106 $response = $this->http->response()->withBody(Streams::ofString($content));
107 $this->http->saveResponse($response);
108 $this->http->sendResponse();
109 $this->http->close();
110 }
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
$response

References $response, ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\CMD_INFO, ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\CMD_REMOVE, ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\CMD_UPLOAD, ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\getInfoResult(), ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\getRemoveResult(), ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\getUploadResult(), ILIAS\FileDelivery\http(), and ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ getExistingFileInfoURL()

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

@inheritDoc

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

Reimplemented in ilIndividualAssessmentMemberGUI, and ilUIDemoFileUploadHandlerGUI.

Definition at line 65 of file AbstractCtrlAwareUploadHandler.php.

65 : string
66 {
67 return $this->ctrl->getLinkTargetByClass([static::class], self::CMD_INFO);
68 }

◆ getFileIdentifierParameterName()

◆ getFileRemovalURL()

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

@inheritDoc

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

Reimplemented in ilIndividualAssessmentMemberGUI, and ilUIDemoFileUploadHandlerGUI.

Definition at line 74 of file AbstractCtrlAwareUploadHandler.php.

74 : string
75 {
76 return $this->ctrl->getLinkTargetByClass([static::class], self::CMD_REMOVE);
77 }

◆ getInfoForExistingFiles()

ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler::getInfoForExistingFiles ( array  $file_ids)
abstract

◆ getInfoResult()

ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler::getInfoResult ( string  $identifier)
abstractprotected

◆ getRemoveResult()

ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler::getRemoveResult ( string  $identifier)
abstractprotected

◆ getUploadResult()

ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler::getUploadResult ( )
abstractprotected

◆ getUploadURL()

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

@inheritDoc

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

Reimplemented in ilIndividualAssessmentMemberGUI, and ilUIDemoFileUploadHandlerGUI.

Definition at line 56 of file AbstractCtrlAwareUploadHandler.php.

56 : string
57 {
58 return $this->ctrl->getLinkTargetByClass([static::class], self::CMD_UPLOAD);
59 }

Field Documentation

◆ $ctrl

ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler::$ctrl
protected

Definition at line 25 of file AbstractCtrlAwareUploadHandler.php.

◆ $http

ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler::$http
protected

Definition at line 21 of file AbstractCtrlAwareUploadHandler.php.

◆ $upload

ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler::$upload
protected

Definition at line 29 of file AbstractCtrlAwareUploadHandler.php.

◆ CMD_INFO

const ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler::CMD_INFO = 'info'
protected

◆ CMD_REMOVE

const ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler::CMD_REMOVE = 'remove'
protected

◆ CMD_UPLOAD

const ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler::CMD_UPLOAD = 'upload'
protected

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