ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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
 
Services $irss
 
ResourceStakeholder $stakeholder
 
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:22
__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:22

◆ getUploadResult()

ilFileVersionsUploadHandlerGUI::getUploadResult ( )
protected

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

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

70  {
71  $this->upload->register(new ilCountPDFPagesPreProcessors());
72  $this->upload->process();
73  $upload_mode =
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,
100  $message
101  );
102  }
$message
Definition: xapiexit.php:31
Class ilCountPDFPagesPreProcessors.
+ Here is the call graph for this function:

◆ processChunckedUpload()

ilFileVersionsUploadHandlerGUI::processChunckedUpload ( UploadResult  $result)
protected

Definition at line 105 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().

105  : HandlerResult
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  }
+ 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 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.

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