ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilDclFileRecordFieldModel Class Reference

@noinspection AutoloadingIssuesInspection More...

+ Inheritance diagram for ilDclFileRecordFieldModel:
+ Collaboration diagram for ilDclFileRecordFieldModel:

Public Member Functions

 __construct (ilDclBaseRecordModel $record, ilDclBaseFieldModel $field)
 
 parseValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 setValueFromForm (ilPropertyFormGUI $form)
 
 delete ()
 Delete record field in database. More...
 
 parseExportValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 parseSortingValue ($value, bool $link=true)
 Returns sortable value for the specific field-types. More...
 
 afterClone ()
 
- Public Member Functions inherited from ilDclBaseRecordFieldModel
 __construct (ilDclBaseRecordModel $record, ilDclBaseFieldModel $field)
 
 setUser (ilObjUser $user)
 
 doCreate ()
 Creates an Id and a database entry. More...
 
 doUpdate ()
 Update object in database. More...
 
 delete ()
 Delete record field in database. More...
 
 getValue ()
 
 serializeData ($value)
 Serialize data before storing to db. More...
 
 deserializeData ($value)
 Deserialize data before applying to field. More...
 
 setValue ($value, bool $omit_parsing=false)
 Set value for record field. More...
 
 setValueFromForm (ilPropertyFormGUI $form)
 
 getFormulaValue ()
 
 parseExportValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 getValueFromExcel (ilExcel $excel, int $row, int $col)
 
 parseValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 getExportValue ()
 
 fillExcelExport (ilExcel $worksheet, int &$row, int &$col)
 
 getPlainText ()
 
 getSortingValue (bool $link=true)
 
 addHiddenItemsToConfirmation (ilConfirmationGUI $confirmation)
 
 parseSortingValue ($value, bool $link=true)
 Returns sortable value for the specific field-types. More...
 
 cloneStructure (ilDclBaseRecordFieldModel $old_record_field)
 
 afterClone ()
 
 getField ()
 
 getId ()
 
 getRecord ()
 
 getRecordRepresentation ()
 
 setRecordRepresentation (ilDclBaseRecordRepresentation $record_representation)
 
 getFieldRepresentation ()
 
 setFieldRepresentation (ilDclBaseFieldRepresentation $field_representation)
 

Protected Member Functions

 handleFileUpload (array $value, bool $has_save_confirmation)
 
 removeData ()
 
- Protected Member Functions inherited from ilDclBaseRecordFieldModel
 doRead ()
 Read object data from database. More...
 
 loadValue ()
 Load the value. More...
 

Protected Attributes

const FILE_TMP_NAME = 'tmp_name'
 
const FILE_NAME = "name"
 
const FILE_TYPE = "type"
 
ILIAS ResourceStorage Services $irss
 
ilDataCollectionStakeholder $stakeholder
 
ILIAS FileUpload FileUpload $upload
 
- Protected Attributes inherited from ilDclBaseRecordFieldModel
int $id = null
 
ilDclBaseFieldModel $field
 
ilDclBaseRecordModel $record
 
ilDclBaseRecordRepresentation $record_representation = null
 
ilDclBaseFieldRepresentation $field_representation = null
 
 $value
 
ilObjUser $user
 
ilCtrl $ctrl
 
ilDBInterface $db
 
ilLanguage $lng
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 

Detailed Description

@noinspection AutoloadingIssuesInspection

Definition at line 26 of file class.ilDclFileRecordFieldModel.php.

Constructor & Destructor Documentation

◆ __construct()

ilDclFileRecordFieldModel::__construct ( ilDclBaseRecordModel  $record,
ilDclBaseFieldModel  $field 
)
Parameters
ilDclBaseRecordModel$record
ilDclBaseFieldModel$field

Reimplemented from ilDclBaseRecordFieldModel.

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

39 {
40 global $DIC;
42 $this->stakeholder = new ilDataCollectionStakeholder();
43 $this->irss = $DIC->resourceStorage();
44 $this->upload = $DIC->upload();
45 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ilDclBaseRecordFieldModel\$field, ilDclBaseRecordFieldModel\$record, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\upload().

+ Here is the call graph for this function:

Member Function Documentation

◆ afterClone()

ilDclFileRecordFieldModel::afterClone ( )

Reimplemented from ilDclBaseRecordFieldModel.

Reimplemented in ilDclMobRecordFieldModel.

Definition at line 128 of file class.ilDclFileRecordFieldModel.php.

128 : void
129 {
130 if ($this->value !== null) {
131 $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();
136 }
137 $this->setValue($value, true);
138 $this->doUpdate();
139 }
140 }
setValue($value, bool $omit_parsing=false)
Set value for record field.

References ilDclBaseRecordFieldModel\$value, ilDclBaseRecordFieldModel\doUpdate(), and ilDclBaseRecordFieldModel\setValue().

+ Here is the call graph for this function:

◆ delete()

ilDclFileRecordFieldModel::delete ( )

Delete record field in database.

Reimplemented from ilDclBaseRecordFieldModel.

Definition at line 103 of file class.ilDclFileRecordFieldModel.php.

103 : void
104 {
105 if ($this->value !== null) {
106 $this->removeData();
107 }
108 parent::delete();
109 }

References removeData().

+ Here is the call graph for this function:

◆ handleFileUpload()

ilDclFileRecordFieldModel::handleFileUpload ( array  $value,
bool  $has_save_confirmation 
)
protected

Reimplemented in ilDclMobRecordFieldModel.

Definition at line 64 of file class.ilDclFileRecordFieldModel.php.

64 : mixed
65 {
66 if ($has_save_confirmation) {
68 $this->http->wrapper()->post()->retrieve('ilfilehash', $this->refinery->kindlyTo()->string()),
69 'field_' . $this->getField()->getId(),
70 $value[self::FILE_NAME],
71 $value[self::FILE_TYPE]
72 );
73
74 $file_stream = ILIAS\Filesystem\Stream\Streams::ofResource(fopen($move_file, 'rb'));
75 } else {
76 $move_file = $value[self::FILE_TMP_NAME];
77
78 $file_stream = Streams::ofResource(fopen($move_file, 'rb'));
79 }
80
81 $file_title = $value[self::FILE_NAME] ?? basename($move_file);
82
83 $old = $this->getValue();
84 if (is_string($old) && ($rid = $this->irss->manage()->find($old)) !== null) {
85 $this->irss->manage()->replaceWithStream($rid, $file_stream, $this->stakeholder, $file_title);
86 } else {
87 $rid = $this->irss->manage()->stream($file_stream, $this->stakeholder, $file_title);
88 }
89
90 return $rid->serialize();
91 }
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:64
static getTempFilename(string $a_hash, string $a_field, string $a_name, string $a_type, ?string $a_index=null, ?string $a_sub_index=null)
static http()
Fetches the global http state from ILIAS.

References ilDclBaseRecordFieldModel\$value, FILE_NAME, FILE_TMP_NAME, ilDclPropertyFormGUI\getTempFilename(), ilDclBaseRecordFieldModel\getValue(), ILIAS\FileDelivery\http(), and ILIAS\Filesystem\Stream\Streams\ofResource().

Referenced by parseValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseExportValue()

ilDclFileRecordFieldModel::parseExportValue (   $value)

Function to parse incoming data from form input value $value.

returns the string/number/etc. to store in the database.

Parameters
mixed$value
Returns
mixed

Reimplemented from ilDclBaseRecordFieldModel.

Reimplemented in ilDclMobRecordFieldModel.

Definition at line 118 of file class.ilDclFileRecordFieldModel.php.

119 {
120 return $this->valueToFileTitle($value);
121 }

References ilDclBaseRecordFieldModel\$value.

◆ parseSortingValue()

ilDclFileRecordFieldModel::parseSortingValue (   $value,
bool  $link = true 
)

Returns sortable value for the specific field-types.

Parameters
int | string$value
Returns
int|string

Reimplemented from ilDclBaseRecordFieldModel.

Reimplemented in ilDclMobRecordFieldModel.

Definition at line 123 of file class.ilDclFileRecordFieldModel.php.

124 {
125 return $this->valueToFileTitle($value);
126 }

References ilDclBaseRecordFieldModel\$value.

◆ parseValue()

ilDclFileRecordFieldModel::parseValue (   $value)

Function to parse incoming data from form input value $value.

returns the string/number/etc. to store in the database.

Returns
int|string|null

Reimplemented from ilDclBaseRecordFieldModel.

Definition at line 47 of file class.ilDclFileRecordFieldModel.php.

48 {
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);
52
53 if (($value[self::FILE_TMP_NAME] ?? '') !== '' && (!$has_save_confirmation || $is_confirmed)) {
54 return $this->handleFileUpload($value, $has_save_confirmation);
55 } else {
56 if (($value[self::FILE_TMP_NAME] ?? '') !== '') {
57 return $value;
58 } else {
59 return $this->getValue();
60 }
61 }
62 }
handleFileUpload(array $value, bool $has_save_confirmation)

References ilDclBaseRecordFieldModel\$value, ilDclBaseRecordFieldModel\getRecord(), ilDclBaseRecordFieldModel\getValue(), handleFileUpload(), and ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ removeData()

ilDclFileRecordFieldModel::removeData ( )
protected

Reimplemented in ilDclMobRecordFieldModel.

Definition at line 111 of file class.ilDclFileRecordFieldModel.php.

111 : void
112 {
113 if (null !== $rid = $this->irss->manage()->find($this->getValue())) {
114 $this->irss->manage()->remove($rid, $this->stakeholder);
115 }
116 }

Referenced by delete(), and setValueFromForm().

+ Here is the caller graph for this function:

◆ setValueFromForm()

ilDclFileRecordFieldModel::setValueFromForm ( ilPropertyFormGUI  $form)

Reimplemented from ilDclBaseRecordFieldModel.

Definition at line 93 of file class.ilDclFileRecordFieldModel.php.

93 : void
94 {
95 if ($this->value !== null && $form->getItemByPostVar("field_" . $this->getField()->getId())->getDeletionFlag()) {
96 $this->removeData();
97 $this->setValue(null, true);
98 $this->doUpdate();
99 }
100 parent::setValueFromForm($form);
101 }
getItemByPostVar(string $a_post_var)

References ilDclBaseRecordFieldModel\doUpdate(), ilPropertyFormGUI\getItemByPostVar(), removeData(), and ilDclBaseRecordFieldModel\setValue().

+ Here is the call graph for this function:

Field Documentation

◆ $irss

ILIAS ResourceStorage Services ilDclFileRecordFieldModel::$irss
protected

Definition at line 34 of file class.ilDclFileRecordFieldModel.php.

◆ $stakeholder

ilDataCollectionStakeholder ilDclFileRecordFieldModel::$stakeholder
protected

Definition at line 35 of file class.ilDclFileRecordFieldModel.php.

◆ $upload

ILIAS FileUpload FileUpload ilDclFileRecordFieldModel::$upload
protected

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

◆ FILE_NAME

const ilDclFileRecordFieldModel::FILE_NAME = "name"
protected

Definition at line 31 of file class.ilDclFileRecordFieldModel.php.

Referenced by handleFileUpload().

◆ FILE_TMP_NAME

const ilDclFileRecordFieldModel::FILE_TMP_NAME = 'tmp_name'
protected

Definition at line 30 of file class.ilDclFileRecordFieldModel.php.

Referenced by handleFileUpload().

◆ FILE_TYPE

const ilDclFileRecordFieldModel::FILE_TYPE = "type"
protected

Definition at line 32 of file class.ilDclFileRecordFieldModel.php.


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