ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ImportUploadHandlerGUI Class Reference
+ Inheritance diagram for ImportUploadHandlerGUI:
+ Collaboration diagram for ImportUploadHandlerGUI:

Public Member Functions

 getInfoResult (string $file_name)
 
 getInfoForExistingFiles (array $file_names)
 
- 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 ()
 

Protected Member Functions

 getUploadResult ()
 
 getRemoveResult (string $filename)
 
 moveUploadedFileToTemp (UploadResult $result)
 
- Protected Member Functions inherited from ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler
 readChunkedInformation ()
 
 getUploadResult ()
 
 getRemoveResult (string $identifier)
 

Protected Attributes

Filesystem $temp_system
 
array $supported_mime_types
 
- 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
 

Additional Inherited Members

- Data Fields inherited from ILIAS\UI\Component\Input\Field\UploadHandler
const DEFAULT_FILE_ID_PARAMETER = 'file_id'
 

Detailed Description

Member Function Documentation

◆ getInfoForExistingFiles()

ImportUploadHandlerGUI::getInfoForExistingFiles ( array  $file_names)
final
Returns
[]

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

Definition at line 115 of file class.ImportUploadHandlerGUI.php.

References getInfoResult().

115  : array
116  {
117  return [$this->getInfoResult($file_names[0])];
118  }
+ Here is the call graph for this function:

◆ getInfoResult()

ImportUploadHandlerGUI::getInfoResult ( string  $identifier)
final
Returns
null|FileInfoResult for the file with the given identifier or null if the file does not exist.

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

Definition at line 88 of file class.ImportUploadHandlerGUI.php.

References $filename, $path, and ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName().

Referenced by getInfoForExistingFiles().

89  {
90  if ($this->temp_system->hasDir($file_name)
91  && ($files = $this->temp_system->listContents($file_name))) {
92  $path = $files[0]->getPath();
93  $filename = basename($path);
94  $title = $filename;
95  $mime = $this->temp_system->getMimeType($path);
96  $size = intval($this->temp_system->getSize($path, DataSize::Byte)->inBytes());
97 
98  } else {
99  $title = $mime = 'unknown';
100  $size = 0;
101  }
102 
103  return new BasicFileInfoResult(
105  $file_name,
106  $title,
107  $size,
108  $mime
109  );
110  }
$path
Definition: ltiservices.php:29
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRemoveResult()

ImportUploadHandlerGUI::getRemoveResult ( string  $filename)
finalprotected

Definition at line 78 of file class.ImportUploadHandlerGUI.php.

References ILIAS\MetaData\OERExposer\OAIPMH\Handler\AbstractCtrlAwareUploadHandler\getFileIdentifierParameterName().

79  {
80  return new BasicHandlerResult(
82  HandlerResult::STATUS_OK,
83  $filename,
84  "We just don't do anything here."
85  );
86  }
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:

◆ getUploadResult()

ImportUploadHandlerGUI::getUploadResult ( )
finalprotected

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

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

52  {
53  $this->upload->process();
54 
55  $result_array = $this->upload->getResults();
56  $result = end($result_array);
57 
58  $tempname = '';
59  if ($result instanceof UploadResult
60  && in_array($result->getMimeType(), $this->supported_mime_types)
61  && $result->isOK()) {
62  $status = HandlerResult::STATUS_OK;
63  $message = 'Upload ok';
64  $tempname = $this->moveUploadedFileToTemp($result);
65  } else {
66  $status = HandlerResult::STATUS_FAILED;
67  $message = $result->getStatus()->getMessage();
68  }
69 
70  return new BasicHandlerResult(
72  $status,
73  $tempname,
74  $message
75  );
76  }
moveUploadedFileToTemp(UploadResult $result)
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:

◆ moveUploadedFileToTemp()

ImportUploadHandlerGUI::moveUploadedFileToTemp ( UploadResult  $result)
finalprotected

Definition at line 120 of file class.ImportUploadHandlerGUI.php.

References ILIAS\FileUpload\DTO\UploadResult\getName(), ILIAS\FileUpload\DTO\UploadResult\getPath(), and ilFileUtils\getValidFilename().

Referenced by getUploadResult().

120  : string
121  {
122  $tempfile_path = uniqid('tmp');
123  $this->temp_system->createDir($tempfile_path);
124  $this->temp_system->put(
125  $tempfile_path . DIRECTORY_SEPARATOR . ilFileUtils::getValidFilename($result->getName()),
126  file_get_contents($result->getPath())
127  );
128  return $tempfile_path;
129  }
static getValidFilename(string $a_filename)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $supported_mime_types

array ImportUploadHandlerGUI::$supported_mime_types
protected

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

Referenced by getUploadResult().

◆ $temp_system

Filesystem ImportUploadHandlerGUI::$temp_system
protected

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


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