ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler
 __construct ()
 
 getUploadURL ()
 
 getExistingFileInfoURL ()
 
 getFileRemovalURL ()
 
 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 ()
 

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\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareIRSSUploadHandler
 getStakeholder ()
 
 getClassPath ()
 
 getUploadResult ()
 
 processChunckedUpload (UploadResult $result)
 
 getRemoveResult (string $identifier)
 
- Protected Member Functions inherited from ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler
 readChunkedInformation ()
 
 getUploadResult ()
 
 getRemoveResult (string $identifier)
 

Protected Attributes

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

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.

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

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())
46  : $upload_mode;
47 
48  $this->ctrl->setParameter($this, self::P_UPLOAD_MODE, $this->upload_mode);
49  }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:25
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getClassPath()

ilFileVersionsUploadHandlerGUI::getClassPath ( )
protected

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

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

◆ getStakeholder()

ilFileVersionsUploadHandlerGUI::getStakeholder ( )
protected

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

References $DIC.

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

◆ getUploadResult()

ilFileVersionsUploadHandlerGUI::getUploadResult ( )
protected

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

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

68  {
69  $this->upload->register(new ilCountPDFPagesPreProcessors());
70  $this->upload->process();
71  $upload_mode =
72 
73  $result_array = $this->upload->getResults();
74  $result = end($result_array);
75 
76  if ($result instanceof UploadResult && $result->isOK()) {
77  if ($this->is_chunked) {
78  return $this->processChunckedUpload($result);
79  }
80 
81  if ($this->upload_mode === self::MODE_REPLACE) {
82  $identifier = (string) $this->file->replaceWithUpload($result, $result->getName());
83  } else {
84  $identifier = (string) $this->file->appendUpload($result, $result->getName());
85  }
86  $status = HandlerResult::STATUS_OK;
87  $message = "file upload OK";
88  } else {
89  $identifier = '';
90  $status = HandlerResult::STATUS_FAILED;
91  $message = $result->getStatus()->getMessage();
92  }
93 
94  return new BasicHandlerResult(
96  $status,
97  $identifier,
98  $message
99  );
100  }
Class ilCountPDFPagesPreProcessors.
+ Here is the call graph for this function:

◆ processChunckedUpload()

ilFileVersionsUploadHandlerGUI::processChunckedUpload ( UploadResult  $result)
protected

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

References ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\$amount_of_chunks, ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName(), ILIAS\FileUpload\DTO\UploadResult\getName(), and ILIAS\FileUpload\DTO\UploadResult\getPath().

Referenced by getUploadResult().

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

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

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

62  : bool
63  {
64  return true;
65  }

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.

◆ 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: