ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilFileVersionsUploadHandlerGUI Class Reference

Class ilFileVersionsUploadHandlerGUI. More...

+ Inheritance diagram for ilFileVersionsUploadHandlerGUI:
+ Collaboration diagram for ilFileVersionsUploadHandlerGUI:

Public Member Functions

 __construct (protected ilObjFile $file, string $upload_mode=self::MODE_APPEND)
 
 supportsChunkedUploads ()
 
- Public Member Functions inherited from ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler
 __construct ()
 ilUIDemoFileUploadHandlerGUI constructor. More...
 
 getUploadURL ()
 @inheritDoc More...
 
 getExistingFileInfoURL ()
 @inheritDoc More...
 
 getFileRemovalURL ()
 @inheritDoc More...
 
 getInfoResult (string $identifier)
 
 getInfoForExistingFiles (array $file_ids)
 
- Public Member Functions inherited from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler
 __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...
 
 getInfoResult (string $identifier)
 
 getInfoForExistingFiles (array $file_ids)
 
 supportsChunkedUploads ()
 
 executeCommand ()
 Since this is a ilCtrl aware UploadHandler executeCommand MUST be implemented. More...
 
 getFileIdentifierParameterName ()
 
 getUploadURL ()
 
 getFileRemovalURL ()
 
 getExistingFileInfoURL ()
 
 getInfoForExistingFiles (array $file_ids)
 
 getInfoResult (string $identifier)
 
 supportsChunkedUploads ()
 

Data Fields

const MODE_APPEND = 'append'
 
const MODE_REPLACE = 'replace'
 
const P_UPLOAD_MODE = 'upload_mode'
 
- Data Fields inherited from ILIAS\UI\Component\Input\Field\UploadHandler
const DEFAULT_FILE_ID_PARAMETER = 'file_id'
 

Protected Member Functions

 getStakeholder ()
 
 getClassPath ()
 
 getUploadResult ()
 
 processChunckedUpload (UploadResult $result)
 
- Protected Member Functions inherited from ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler
 getStakeholder ()
 
 getClassPath ()
 
 getUploadResult ()
 
 processChunckedUpload (UploadResult $result)
 
 getRemoveResult (string $identifier)
 
- Protected Member Functions inherited from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler
 readChunkedInformation ()
 
 getUploadResult ()
 
 getRemoveResult (string $identifier)
 

Protected Attributes

bool $append
 
string $upload_mode = self::MODE_APPEND
 
- Protected Attributes inherited from ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler
ilFileServicesFilenameSanitizer $sanitizer
 
ilLanguage $language
 
Services $irss
 
ResourceStakeholder $stakeholder
 
Filesystem $temp_filesystem
 
array $class_path
 
- Protected Attributes inherited from ILIAS\FileUpload\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
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilFileVersionsUploadHandlerGUI::__construct ( protected ilObjFile  $file,
string  $upload_mode = self::MODE_APPEND 
)

Definition at line 40 of file class.ilFileVersionsUploadHandlerGUI.php.

41 {
42 global $DIC;
44 $this->upload_mode = $this->http->wrapper()->query()->has(self::P_UPLOAD_MODE)
45 ? $this->http->wrapper()->query()->retrieve(self::P_UPLOAD_MODE, $DIC->refinery()->kindlyTo()->string())
47
48 $this->ctrl->setParameter($this, self::P_UPLOAD_MODE, $this->upload_mode);
49 }
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, $upload_mode, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), and ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

Member Function Documentation

◆ getClassPath()

ilFileVersionsUploadHandlerGUI::getClassPath ( )
protected

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler.

Definition at line 57 of file class.ilFileVersionsUploadHandlerGUI.php.

57 : array
58 {
59 return [self::class];
60 }

◆ getStakeholder()

ilFileVersionsUploadHandlerGUI::getStakeholder ( )
protected

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler.

Definition at line 51 of file class.ilFileVersionsUploadHandlerGUI.php.

52 {
53 global $DIC;
54 return new ilObjFileStakeholder($DIC->user()->getId());
55 }
Class ilObjFileStakeholder.

References $DIC.

◆ getUploadResult()

ilFileVersionsUploadHandlerGUI::getUploadResult ( )
protected

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler.

Definition at line 69 of file class.ilFileVersionsUploadHandlerGUI.php.

70 {
71 $this->upload->register(new ilCountPDFPagesPreProcessors());
72 $this->upload->process();
74
75 $result_array = $this->upload->getResults();
76 $result = end($result_array);
77
78 if ($result instanceof UploadResult && $result->isOK()) {
79 if ($this->is_chunked) {
80 return $this->processChunckedUpload($result);
81 }
82
83 if ($this->upload_mode === self::MODE_REPLACE) {
84 $identifier = (string) $this->file->replaceWithUpload($result, $result->getName());
85 } else {
86 $identifier = (string) $this->file->appendUpload($result, $result->getName());
87 }
88 $status = HandlerResult::STATUS_OK;
89 $message = "file upload OK";
90 } else {
91 $identifier = '';
92 $status = HandlerResult::STATUS_FAILED;
93 $message = $result->getStatus()->getMessage();
94 }
95
96 return new BasicHandlerResult(
98 $status,
99 $identifier,
101 );
102 }
Class ilCountPDFPagesPreProcessors.
$message
Definition: xapiexit.php:31

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

+ Here is the call graph for this function:

◆ processChunckedUpload()

ilFileVersionsUploadHandlerGUI::processChunckedUpload ( UploadResult  $result)
protected

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareIRSSUploadHandler.

Definition at line 105 of file class.ilFileVersionsUploadHandlerGUI.php.

106 {
107 $temp_path = "$this->chunk_id/{$result->getName()}";
108
109 try {
110 if ($this->temp_filesystem->has($temp_path)) {
111 $stream = fopen($this->temp_filesystem->readStream($temp_path)->getMetadata()['uri'], 'ab');
112 fwrite($stream, file_get_contents($result->getPath()));
113 } else {
114 $this->temp_filesystem->write($temp_path, file_get_contents($result->getPath()));
115 }
116 } catch (Throwable $t) {
117 return new BasicHandlerResult(
119 HandlerResult::STATUS_FAILED,
120 '',
121 $t->getMessage()
122 );
123 }
124
125 if (($this->chunk_index + 1) === $this->amount_of_chunks) {
126 $whole_file = $this->temp_filesystem->readStream($temp_path);
127 if ($this->upload_mode === self::MODE_REPLACE) {
128 $revision_number = $this->file->replaceWithStream($whole_file, $result->getName());
129 } else {
130 $revision_number = $this->file->appendStream($whole_file, $result->getName());
131 }
132
133 return new BasicHandlerResult(
135 HandlerResult::STATUS_OK,
136 (string) $revision_number,
137 "file upload OK"
138 );
139 }
140
141 return new BasicHandlerResult(
143 HandlerResult::STATUS_PARTIAL,
144 '',
145 "chunk upload OK"
146 );
147 }

References ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), ILIAS\FileUpload\DTO\UploadResult\getName(), and ILIAS\FileUpload\DTO\UploadResult\getPath().

Referenced by getUploadResult().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ supportsChunkedUploads()

ilFileVersionsUploadHandlerGUI::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\Component\Input\Field\Upload\File with .

Reimplemented from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler.

Definition at line 63 of file class.ilFileVersionsUploadHandlerGUI.php.

63 : bool
64 {
65 return true;
66 }

Field Documentation

◆ $append

bool ilFileVersionsUploadHandlerGUI::$append
protected

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

◆ $upload_mode

string ilFileVersionsUploadHandlerGUI::$upload_mode = self::MODE_APPEND
protected

Definition at line 38 of file class.ilFileVersionsUploadHandlerGUI.php.

Referenced by __construct().

◆ MODE_APPEND

const ilFileVersionsUploadHandlerGUI::MODE_APPEND = 'append'

◆ MODE_REPLACE

const ilFileVersionsUploadHandlerGUI::MODE_REPLACE = 'replace'

◆ P_UPLOAD_MODE

const ilFileVersionsUploadHandlerGUI::P_UPLOAD_MODE = 'upload_mode'

Definition at line 36 of file class.ilFileVersionsUploadHandlerGUI.php.


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