ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDclFileRecordFieldModel Class Reference

AutoloadingIssuesInspection More...

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

Public Member Functions

 __construct (ilDclBaseRecordModel $record, ilDclBaseFieldModel $field)
 
 parseValue ($value)
 
 setValueFromForm (ilPropertyFormGUI $form)
 
 delete ()
 
 parseExportValue ($value)
 
 parseSortingValue ($value, bool $link=true)
 
 afterClone ()
 
- Public Member Functions inherited from ilDclBaseRecordFieldModel
 __construct (ilDclBaseRecordModel $record, ilDclBaseFieldModel $field)
 
 doCreate ()
 Creates an Id and a database entry. More...
 
 doUpdate ()
 Update object in database. More...
 
 delete ()
 Delete record field in database. More...
 
 getValue ()
 
 getValueForRepresentation ()
 
 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

 removeData ()
 
- Protected Member Functions inherited from ilDclBaseRecordFieldModel
 doRead ()
 Read object data from database. More...
 
 loadValue ()
 Load the value. More...
 

Protected Attributes

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
 

Private Attributes

const FILE_TMP_NAME = 'tmp_name'
 
const FILE_NAME = "name"
 
const FILE_TYPE = "type"
 

Detailed Description

AutoloadingIssuesInspection

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

Constructor & Destructor Documentation

◆ __construct()

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

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

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

39  {
40  global $DIC;
41  parent::__construct($record, $field);
42  $this->stakeholder = new ilDataCollectionStakeholder();
43  $this->irss = $DIC->resourceStorage();
44  $this->upload = $DIC->upload();
45  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ afterClone()

ilDclFileRecordFieldModel::afterClone ( )

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

References ilDclBaseRecordFieldModel\$field, ilDclBaseRecordFieldModel\$record, ilDclBaseRecordFieldModel\doUpdate(), ilDclCache\getCloneOf(), ilDclBaseRecordFieldModel\getField(), ilDclBaseRecordFieldModel\getId(), ilDclBaseRecordFieldModel\getRecord(), ilDclCache\getRecordFieldCache(), null, ilDclBaseRecordFieldModel\setValue(), ilDclCache\TYPE_FIELD, and ilDclCache\TYPE_RECORD.

157  : void
158  {
162 
163  if (!$record_field->getValue()) {
164  return;
165  }
166  $current = $this->valueToCurrentRevision($record_field->getValue());
167  if ($current !== null) {
168  $new_rid = $this->irss->manage()->clone($current->getIdentification());
169  $this->setValue($new_rid->serialize());
170  $this->doUpdate();
171  }
172  }
setValue($value, bool $omit_parsing=false)
Set value for record field.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
doUpdate()
Update object in database.
static getCloneOf(int $id, string $type)
static getRecordFieldCache(object $record, object $field)
+ Here is the call graph for this function:

◆ delete()

ilDclFileRecordFieldModel::delete ( )

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

References null, and removeData().

134  : void
135  {
136  if ($this->value !== null) {
137  $this->removeData();
138  }
139  parent::delete();
140  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ parseExportValue()

ilDclFileRecordFieldModel::parseExportValue (   $value)

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

References ilDclBaseRecordFieldModel\$value.

148  {
149  return $this->valueToFileTitle($value);
150  }

◆ parseSortingValue()

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

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

References ilDclBaseRecordFieldModel\$value.

153  {
154  return $this->valueToFileTitle($value);
155  }

◆ parseValue()

ilDclFileRecordFieldModel::parseValue (   $value)

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

References ilDclBaseRecordFieldModel\$value, ilDclBaseRecordFieldModel\getField(), ilDclBaseRecordFieldModel\getId(), ilDclBaseRecordFieldModel\getRecord(), ilDclPropertyFormGUI\getTempFilename(), ilDclBaseRecordFieldModel\getValue(), ilDclBaseRecordFieldModel\getValueForRepresentation(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), null, ILIAS\Filesystem\Stream\Streams\ofResource(), ILIAS\Repository\refinery(), and ILIAS\Repository\upload().

48  {
49  $file = $value;
50 
51  // Some general Request Information
52  $has_record_id = $this->http->wrapper()->query()->has('record_id');
53  $is_confirmed = $this->http->wrapper()->post()->has('save_confirmed');
54  $has_save_confirmation = ($this->getRecord()->getTable()->getSaveConfirmation() && !$has_record_id);
55 
56  if (
57  is_array($file)
58  && isset($file[self::FILE_TMP_NAME])
59  && $file[self::FILE_TMP_NAME] !== ""
60  && (!$has_save_confirmation || $is_confirmed)
61  ) {
62  if ($has_save_confirmation) {
63  $ilfilehash = $this->http->wrapper()->post()->retrieve(
64  'ilfilehash',
65  $this->refinery->kindlyTo()->string()
66  );
67 
69  $ilfilehash,
70  'field_' . $this->getField()->getId(),
71  $file[self::FILE_NAME],
72  $file[self::FILE_TYPE]
73  );
74 
75  $file_stream = ILIAS\Filesystem\Stream\Streams::ofResource(fopen($move_file, 'rb'));
76  } else {
77  $move_file = $file[self::FILE_TMP_NAME];
78 
79  if (false === $this->upload->hasBeenProcessed()) {
80  $this->upload->process();
81  }
82 
83  if (false === $this->upload->hasUploads()) {
84  throw new ilException($this->lng->txt('upload_error_file_not_found'));
85  }
86 
87  $file_stream = Streams::ofResource(fopen($move_file, 'rb'));
88  }
89 
90  $file_title = $file[self::FILE_NAME] ?? basename($move_file);
91 
92  // Storing the File to the IRSS
93  $existing_value = $this->getValueForRepresentation();
94  if (
95  is_string($existing_value)
96  && ($rid = $this->irss->manage()->find($existing_value)) !== null
97  ) {
98  // Append to existing RID
99  $this->irss->manage()->replaceWithStream(
100  $rid,
101  $file_stream,
102  $this->stakeholder,
103  $file_title
104  );
105  } else {
106  // Create new RID
107  $rid = $this->irss->manage()->stream(
108  $file_stream,
109  $this->stakeholder,
110  $file_title
111  );
112  }
113 
114  return $rid->serialize();
115  } else {
116  // handover for save-confirmation
117  if (is_array($file) && isset($file[self::FILE_TMP_NAME]) && $file[self::FILE_TMP_NAME] != "") {
118  return $file;
119  }
120  }
121  return $this->getValue();
122  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:64
static http()
Fetches the global http state from ILIAS.
static getTempFilename(string $a_hash, string $a_field, string $a_name, string $a_type, ?string $a_index=null, ?string $a_sub_index=null)
+ Here is the call graph for this function:

◆ removeData()

ilDclFileRecordFieldModel::removeData ( )
protected

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

References $stakeholder.

Referenced by delete(), and setValueFromForm().

142  : void
143  {
144  $this->irss->manage()->remove($this->irss->manage()->find($this->value), $this->stakeholder);
145  }
ilDataCollectionStakeholder $stakeholder
+ Here is the caller graph for this function:

◆ setValueFromForm()

ilDclFileRecordFieldModel::setValueFromForm ( ilPropertyFormGUI  $form)

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

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

124  : void
125  {
126  if ($this->value !== null && $form->getItemByPostVar("field_" . $this->getField()->getId())->getDeletionFlag()) {
127  $this->removeData();
128  $this->setValue(null, true);
129  $this->doUpdate();
130  }
131  parent::setValueFromForm($form);
132  }
getItemByPostVar(string $a_post_var)
setValue($value, bool $omit_parsing=false)
Set value for record field.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
doUpdate()
Update object in database.
+ 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.

Referenced by removeData().

◆ $upload

ILIAS FileUpload FileUpload ilDclFileRecordFieldModel::$upload
protected

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

◆ FILE_NAME

const ilDclFileRecordFieldModel::FILE_NAME = "name"
private

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

◆ FILE_TMP_NAME

const ilDclFileRecordFieldModel::FILE_TMP_NAME = 'tmp_name'
private

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

◆ FILE_TYPE

const ilDclFileRecordFieldModel::FILE_TYPE = "type"
private

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


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