ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilFileVersionsUploadHandlerGUI Class Reference

Class ilFileVersionsUploadHandlerGUI. More...

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

Public Member Functions

 __construct (ilObjFile $existing_file, string $upload_mode=self::MODE_APPEND)
 
- Public Member Functions inherited from ilCtrlAwareStorageUploadHandler
 __construct (ResourceStakeholder $stakeholder)
 
 getInfoResult (string $identifier)
 
 getInfoForExistingFiles (array $file_ids)
 
- Public Member Functions inherited from ILIAS\FileUpload\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

 getUploadResult ()
 
- Protected Member Functions inherited from ilCtrlAwareStorageUploadHandler
 getUploadResult ()
 
 getRemoveResult (string $identifier)
 
- Protected Member Functions inherited from ILIAS\FileUpload\Handler\AbstractCtrlAwareUploadHandler
 readChunkedInformation ()
 
 getUploadResult ()
 
 getRemoveResult (string $identifier)
 

Protected Attributes

ilObjFile $file
 
bool $append
 
string $upload_mode = self::MODE_APPEND
 
- Protected Attributes inherited from ilCtrlAwareStorageUploadHandler
ResourceStakeholder $stakeholder
 
ILIAS ResourceStorage Services $storage
 
- 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 ( ilObjFile  $existing_file,
string  $upload_mode = self::MODE_APPEND 
)

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

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

42  {
43  global $DIC;
44  parent::__construct(new ilObjFileStakeholder($DIC->user()->getId()));
45  $this->file = $existing_file;
46  $this->upload_mode = $this->http->wrapper()->query()->has(self::P_UPLOAD_MODE)
47  ? $this->http->wrapper()->query()->retrieve(self::P_UPLOAD_MODE, $DIC->refinery()->kindlyTo()->string())
48  : $upload_mode;
49 
50  $this->ctrl->setParameter($this, self::P_UPLOAD_MODE, $this->upload_mode);
51  }
Class ilObjFileStakeholder.
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getUploadResult()

ilFileVersionsUploadHandlerGUI::getUploadResult ( )
protected

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

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

54  {
55  $this->upload->register(new ilCountPDFPagesPreProcessors());
56  $this->upload->process();
57  $upload_mode =
58 
59  $result_array = $this->upload->getResults();
60  $result = end($result_array);
61 
62  if ($result instanceof UploadResult && $result->isOK()) {
63  if ($this->upload_mode === self::MODE_REPLACE) {
64  $identifier = (string) $this->file->replaceWithUpload($result, $result->getName());
65  } else {
66  $identifier = (string) $this->file->appendUpload($result, $result->getName());
67  }
68  $status = HandlerResult::STATUS_OK;
69  $message = "file upload OK";
70  } else {
71  $identifier = '';
72  $status = HandlerResult::STATUS_FAILED;
73  $message = $result->getStatus()->getMessage();
74  }
75 
76  return new BasicHandlerResult(
78  $status,
79  $identifier,
80  $message
81  );
82  }
$message
Definition: xapiexit.php:32
Class ilCountPDFPagesPreProcessors.
+ Here is the call graph for this function:

Field Documentation

◆ $append

bool ilFileVersionsUploadHandlerGUI::$append
protected

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

◆ $file

ilObjFile ilFileVersionsUploadHandlerGUI::$file
protected

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

◆ $upload_mode

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

Definition at line 39 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: