19declare(strict_types=1);
28 use ilDclFileFieldHelper;
34 protected \ILIAS\ResourceStorage\Services
$irss;
36 protected \ILIAS\FileUpload\FileUpload
$upload;
43 $this->irss =
$DIC->resourceStorage();
44 $this->
upload = $DIC->upload();
49 $has_record_id = $this->
http->wrapper()->query()->has(
'record_id');
50 $is_confirmed = $this->
http->wrapper()->post()->has(
'save_confirmed');
51 $has_save_confirmation = ($this->
getRecord()->getTable()->getSaveConfirmation() && !$has_record_id);
53 if ((
$value[self::FILE_TMP_NAME] ??
'') !==
'' && (!$has_save_confirmation || $is_confirmed)) {
56 if ((
$value[self::FILE_TMP_NAME] ??
'') !==
'') {
66 if ($has_save_confirmation) {
68 $this->
http->wrapper()->post()->retrieve(
'ilfilehash', $this->refinery->kindlyTo()->string()),
69 'field_' . $this->getField()->getId(),
78 $file_stream = Streams::ofResource(fopen($move_file,
'rb'));
84 if (is_string($old) && ($rid = $this->irss->manage()->find($old)) !==
null) {
85 $this->irss->manage()->replaceWithStream($rid, $file_stream, $this->stakeholder, $file_title);
87 $rid = $this->irss->manage()->stream($file_stream, $this->stakeholder, $file_title);
90 return $rid->serialize();
95 if ($this->value !==
null && $form->
getItemByPostVar(
"field_" . $this->getField()->getId())->getDeletionFlag()) {
100 parent::setValueFromForm($form);
103 public function delete():
void
105 if ($this->value !==
null) {
113 if (
null !== $rid = $this->irss->manage()->find($this->getValue())) {
114 $this->irss->manage()->remove($rid, $this->stakeholder);
120 return $this->valueToFileTitle(
$value);
125 return $this->valueToFileTitle(
$value);
130 if ($this->value !==
null) {
132 $current = $this->valueToCurrentRevision($this->value);
133 if ($current !==
null) {
134 $new_rid = $this->irss->manage()->clone($current->getIdentification());
135 $value = $new_rid->serialize();
Stream factory which enables the user to create streams without the knowledge of the concrete class.
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
ilDclBaseFieldModel $field
setValue($value, bool $omit_parsing=false)
Set value for record field.
ilDclBaseRecordModel $record
doUpdate()
Update object in database.
@noinspection AutoloadingIssuesInspection
setValueFromForm(ilPropertyFormGUI $form)
parseValue($value)
Function to parse incoming data from form input value $value.
ILIAS FileUpload FileUpload $upload
handleFileUpload(array $value, bool $has_save_confirmation)
ilDataCollectionStakeholder $stakeholder
parseExportValue($value)
Function to parse incoming data from form input value $value.
ILIAS ResourceStorage Services $irss
parseSortingValue($value, bool $link=true)
Returns sortable value for the specific field-types.
__construct(ilDclBaseRecordModel $record, ilDclBaseFieldModel $field)
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc