ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDclMobRecordFieldModel Class Reference
+ Inheritance diagram for ilDclMobRecordFieldModel:
+ Collaboration diagram for ilDclMobRecordFieldModel:

Public Member Functions

 parseValue ($value)
 Function to parse incoming data from form input value $value. 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 ilDclFileRecordFieldModel
 __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)
 
 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

 removeData ()
 
 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 ( )

Reimplemented from ilDclFileRecordFieldModel.

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

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

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

+ 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

Reimplemented from ilDclFileRecordFieldModel.

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

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

References ilDclBaseRecordFieldModel\$value.

◆ parseSortingValue()

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

Returns sortable value for the specific field-types.

Parameters
int$value

Reimplemented from ilDclFileRecordFieldModel.

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

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

References ilDclBaseRecordFieldModel\$value.

◆ parseValue()

ilDclMobRecordFieldModel::parseValue (   $value)

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

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

Parameters
int | string$value
Returns
int|string|null

Reimplemented from ilDclFileRecordFieldModel.

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

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);
75 chmod($target_file_path, 0640);
77
78 $format = ilObjMediaObject::getMimeType($target_file_path);
79
81 $mob->getId(),
82 'dcl:html',
83 $this->getRecord()->getTable()->getCollectionObject()->getId()
84 );
85 $media_item->setFormat($format);
86 $media_item->setLocation($location);
87 $media_item->setLocationType('LocalFile');
88
90 $med = $mob->getMediaItem('Standard');
91 $mob_file = ilObjMediaObject::_getDirectory($mob->getId()) . '/' . $med->getLocation();
92 $a_target_dir = ilObjMediaObject::_getDirectory($mob->getId());
93 ilFFmpeg::extractImage($mob_file, 'mob_vpreview.png', $a_target_dir);
94 }
95
96 $mob->update();
97 $return = $mob->getId();
98 if ($this->value !== null) {
99 $this->removeData();
100 }
101 } else {
102 if (($media['tmp_name'] ?? '') !== '') {
103 $return = $media;
104 } else {
105 $return = $this->getValue();
106 }
107 }
108
109 return $return;
110 }
$location
Definition: buildRTE.php:22
static getTempFilename(string $a_hash, string $a_field, string $a_name, string $a_type, ?string $a_index=null, ?string $a_sub_index=null)
Base class for ILIAS Exception handling.
static enabled()
Checks, whether FFmpeg support is enabled (path is set in the setup)
static extractImage(string $a_file, string $a_target_filename, string $a_target_dir="", int $a_sec=1)
Extract image from video file.
static supportsImageExtraction(string $a_mime)
Check if mime type supports image extraction.
static getASCIIFilename(string $a_filename)
static rename(string $a_source, string $a_target)
static renameExecutables(string $a_dir)
Class ilMediaItem Media Item, component of a media object (file or reference)
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
static _getDirectory(int $a_mob_id)
Get absolute directory.
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 http()
Fetches the global http state from ILIAS.

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(), ILIAS\Repository\refinery(), removeData(), ilFileUtils\rename(), ilFileUtils\renameExecutables(), ilFFmpeg\supportsImageExtraction(), and ILIAS\Repository\upload().

+ Here is the call graph for this function:

◆ removeData()

ilDclMobRecordFieldModel::removeData ( )
protected

Reimplemented from ilDclFileRecordFieldModel.

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

139 : void
140 {
141 $mob = new ilObjMediaObject($this->value);
143 $mob->getId(),
144 'dcl:html',
145 $this->getRecord()->getTable()->getCollectionObject()->getId()
146 );
147 $mob->delete();
148 }
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.

References ilObjMediaObject\_removeUsage().

Referenced by parseValue().

+ 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: