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

Public Member Functions

 parseValue ($value)
 
 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 ilDclFileRecordFieldModel
 __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 ilDclFileRecordFieldModel
 removeData ()
 
- Protected Member Functions inherited from ilDclBaseRecordFieldModel
 doRead ()
 Read object data from database. More...
 
 loadValue ()
 Load the value. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilDclFileRecordFieldModel
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

Definition at line 21 of file class.ilDclMobRecordFieldModel.php.

Member Function Documentation

◆ afterClone()

ilDclMobRecordFieldModel::afterClone ( )

Definition at line 149 of file class.ilDclMobRecordFieldModel.php.

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

149  : void
150  {
154 
155  if (!$record_field->getValue()) {
156  return;
157  }
158 
159  $mob_old = new ilObjMediaObject($record_field->getValue());
160  $mob_new = $mob_old->duplicate();
161 
162  $this->setValue($mob_new->getId(), true);
163  $this->doUpdate();
164  }
setValue($value, bool $omit_parsing=false)
Set value for record field.
doUpdate()
Update object in database.
static getCloneOf(int $id, string $type)
duplicate()
Duplicate media object, return new media object.
static getRecordFieldCache(object $record, object $field)
+ Here is the call graph for this function:

◆ parseExportValue()

ilDclMobRecordFieldModel::parseExportValue (   $value)

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

returns the int|string to store in the database.

Parameters
int | string$value
Returns
int|string

Definition at line 116 of file class.ilDclMobRecordFieldModel.php.

References ilDclBaseRecordFieldModel\$value.

117  {
118  $file = $value;
119  if (is_numeric($file)) {
120  $mob = new ilObjMediaObject($file);
121  return $mob->getTitle();
122  }
123 
124  return $file;
125  }

◆ parseSortingValue()

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

Returns sortable value for the specific field-types.

Parameters
int$value

Definition at line 131 of file class.ilDclMobRecordFieldModel.php.

References ilDclBaseRecordFieldModel\$value.

131  : string
132  {
133  $mob = new ilObjMediaObject($value);
134 
135  return $mob->getTitle();
136  }

◆ parseValue()

ilDclMobRecordFieldModel::parseValue (   $value)

Definition at line 23 of file class.ilDclMobRecordFieldModel.php.

References $location, ilDclBaseRecordFieldModel\$value, ilObjMediaObject\_getDirectory(), ilObjMediaObject\_saveUsage(), ilFFmpeg\enabled(), ilFFmpeg\extractImage(), ilFileUtils\getASCIIFilename(), ilDclBaseRecordFieldModel\getField(), ilDclBaseRecordFieldModel\getId(), ilObjMediaObject\getMimeType(), ilDclBaseRecordFieldModel\getRecord(), ilDclPropertyFormGUI\getTempFilename(), ilDclBaseRecordFieldModel\getValue(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), null, ILIAS\Repository\refinery(), removeData(), ilFileUtils\rename(), ilFileUtils\renameExecutables(), ilFFmpeg\supportsImageExtraction(), and ILIAS\Repository\upload().

24  {
25  if ($value === -1) {
26  return null;
27  }
28 
29  $media = $value;
30 
31  $has_record_id = $this->http->wrapper()->query()->has('record_id');
32  $is_confirmed = $this->http->wrapper()->post()->has('save_confirmed');
33  $has_save_confirmation = ($this->getRecord()->getTable()->getSaveConfirmation() && !$has_record_id);
34 
35  if (($media['tmp_name'] ?? '') !== '' && (!$has_save_confirmation || $is_confirmed)) {
36  $mob = new ilObjMediaObject();
37  $mob->setTitle($media['name']);
38  $mob->create();
39  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
40  if (!is_dir($mob_dir)) {
41  $mob->createDirectory();
42  }
43  $media_item = new ilMediaItem();
44  $mob->addMediaItem($media_item);
45  $media_item->setPurpose('Standard');
46  $file_name = ilFileUtils::getASCIIFilename($media['name']);
47  $file_name = str_replace(' ', '_', $file_name);
48  $target_file_path = $mob_dir . '/' . $file_name;
49  $location = $file_name;
50 
51  if ($has_save_confirmation) {
52  $ilfilehash = $this->http->wrapper()->post()->retrieve(
53  'ilfilehash',
54  $this->refinery->kindlyTo()->string()
55  );
56 
58  $ilfilehash,
59  'field_' . $this->getField()->getId(),
60  $media['name'],
61  $media['type']
62  );
63  } else {
64  if (!$this->upload->hasBeenProcessed()) {
65  $this->upload->process();
66  }
67 
68  if (!$this->upload->hasUploads()) {
69  throw new ilException($this->lng->txt('upload_error_file_not_found'));
70  }
71  $move_file = $media['tmp_name'];
72  }
73 
74  ilFileUtils::rename($move_file, $target_file_path);
76 
77  $format = ilObjMediaObject::getMimeType($target_file_path);
78 
80  $mob->getId(),
81  'dcl:html',
82  $this->getRecord()->getTable()->getCollectionObject()->getId()
83  );
84  $media_item->setFormat($format);
85  $media_item->setLocation($location);
86  $media_item->setLocationType('LocalFile');
87 
89  $med = $mob->getMediaItem('Standard');
90  $mob_file = ilObjMediaObject::_getDirectory($mob->getId()) . '/' . $med->getLocation();
91  $a_target_dir = ilObjMediaObject::_getDirectory($mob->getId());
92  ilFFmpeg::extractImage($mob_file, 'mob_vpreview.png', $a_target_dir);
93  }
94 
95  $mob->update();
96  $return = $mob->getId();
97  if ($this->value !== null) {
98  $this->removeData();
99  }
100  } else {
101  if (($media['tmp_name'] ?? '') !== '') {
102  $return = $media;
103  } else {
104  $return = $this->getValue();
105  }
106  }
107 
108  return $return;
109  }
$location
Definition: buildRTE.php:22
static _saveUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Save usage of mob within another container (e.g.
static extractImage(string $a_file, string $a_target_filename, string $a_target_dir="", int $a_sec=1)
Extract image from video file.
static getASCIIFilename(string $a_filename)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static renameExecutables(string $a_dir)
static supportsImageExtraction(string $a_mime)
Check if mime type supports image extraction.
static _getDirectory(int $a_mob_id)
Get absolute directory.
static http()
Fetches the global http state from ILIAS.
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
Class ilMediaItem Media Item, component of a media object (file or reference)
static rename(string $a_source, string $a_target)
static enabled()
Checks, whether FFmpeg support is enabled (path is set in the setup)
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()

ilDclMobRecordFieldModel::removeData ( )
protected

Definition at line 138 of file class.ilDclMobRecordFieldModel.php.

References ilObjMediaObject\_removeUsage(), and ilDclBaseRecordFieldModel\getRecord().

Referenced by parseValue().

138  : void
139  {
140  $mob = new ilObjMediaObject($this->value);
142  $mob->getId(),
143  'dcl:html',
144  $this->getRecord()->getTable()->getCollectionObject()->getId()
145  );
146  $mob->delete();
147  }
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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