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

Definition at line 35 of file AbstractCtrlAwareUploadHandler.php.

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

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
+ 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.

Definition at line 80 of file AbstractCtrlAwareUploadHandler.php.

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

80  : void
81  {
82  switch ($this->ctrl->getCmd()) {
83  case self::CMD_UPLOAD:
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;
90  case self::CMD_REMOVE:
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 http()
Fetches the global http state from ILIAS.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
$response
+ Here is the call graph for this function:

◆ getExistingFileInfoURL()

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

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

Definition at line 65 of file AbstractCtrlAwareUploadHandler.php.

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

◆ getFileIdentifierParameterName()

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

◆ getFileRemovalURL()

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

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

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
Parameters
array$file_ids
Returns
BasicFileInfoResult[]

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

Referenced by ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\executeCommand().

+ Here is the caller graph for this function:

◆ getInfoResult()

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

Referenced by ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\executeCommand().

+ Here is the caller graph for this function:

◆ getRemoveResult()

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

Referenced by ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\executeCommand().

+ Here is the caller graph for this function:

◆ getUploadResult()

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

◆ getUploadURL()

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

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

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

Definition at line 17 of file AbstractCtrlAwareUploadHandler.php.

◆ CMD_REMOVE

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

Definition at line 16 of file AbstractCtrlAwareUploadHandler.php.

◆ CMD_UPLOAD

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

Definition at line 15 of file AbstractCtrlAwareUploadHandler.php.


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