ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilDclMobRecordFieldModel.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
25 protected function handleFileUpload(array $value, bool $has_save_confirmation): int
26 {
27 $mob = new ilObjMediaObject();
28 $mob->setTitle($value[self::FILE_NAME]);
29 $mob->create();
30
31 $mob->addMediaItemFromUpload(
32 'Standard',
33 $this->upload->getResults()[$value[self::FILE_TMP_NAME]],
34 $this->http->wrapper()->post()->retrieve('ilfilehash', $this->refinery->kindlyTo()->string())
35 );
36 $mob->update();
37
39 $mob->getId(),
40 'dcl:html',
41 $this->getRecord()->getTable()->getCollectionObject()->getId()
42 );
43
44 return $mob->getId();
45 }
46
52 public function parseExportValue($value)
53 {
54 $file = $value;
55 if (is_numeric($file)) {
56 $mob = new ilObjMediaObject($file);
57 return $mob->getTitle();
58 }
59
60 return $file;
61 }
62
67 public function parseSortingValue($value, bool $link = true): string
68 {
69 $mob = new ilObjMediaObject($value);
70
71 return $mob->getTitle();
72 }
73
74 protected function removeData(): void
75 {
76 if (ilObjMediaObject::_exists($this->value)) {
77 $mob = new ilObjMediaObject($this->value);
78 $mob->delete();
79 }
80 }
81
82 public function afterClone(): void
83 {
84 if ($this->value !== null) {
85 $value = null;
86 if (ilObjMediaObject::_exists($this->value)) {
87 $origin = new ilObjMediaObject($this->value);
88 $new = $origin->duplicate();
89 $value = $new->getId();
90 }
91 $this->setValue($value, true);
92 $this->doUpdate();
93 }
94 }
95}
setValue($value, bool $omit_parsing=false)
Set value for record field.
@noinspection AutoloadingIssuesInspection
parseExportValue($value)
Function to parse incoming data from form input value $value.
handleFileUpload(array $value, bool $has_save_confirmation)
parseSortingValue($value, bool $link=true)
Returns sortable value for the specific field-types.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
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.
Interface Location.
Definition: Location.php:33