ILIAS  release_8 Revision v8.24
class.ilDclMobRecordRepresentation.php
Go to the documentation of this file.
1<?php
2
20{
24 public function getHTML(bool $link = true, array $options = []): string
25 {
26 $value = $this->getRecordField()->getValue();
27
28 if (is_null($value)) {
29 return "";
30 }
31
32 // the file is only temporary uploaded. Still need to be confirmed before stored
33 $has_ilfilehash = $this->http->wrapper()->post()->has('ilfilehash');
34 if (is_array($value) && $has_ilfilehash) {
35 $ilfilehash = $this->http->wrapper()->post()->retrieve('ilfilehash', $this->refinery->kindlyTo()->string());
36
37 $this->ctrl->setParameterByClass("ildclrecordlistgui", "ilfilehash", $ilfilehash);
38 $this->ctrl->setParameterByClass(
39 "ildclrecordlistgui",
40 "field_id",
41 $this->getRecordField()->getField()->getId()
42 );
43
44 return '<a href="' . $this->ctrl->getLinkTargetByClass(
45 "ildclrecordlistgui",
46 "sendFile"
47 ) . '">' . $value['name'] . '</a>';
48 }
49
50 $mob = new ilObjMediaObject($value);
51 $med = $mob->getMediaItem('Standard');
52
53 if (!$med || $med->getLocation() === "") {
54 return "";
55 }
56
57 $field = $this->getRecordField()->getField();
58
59 $is_linked_field = $field->getProperty(ilDclBaseFieldModel::PROP_LINK_DETAIL_PAGE_MOB);
60 $has_view = false;
61 if ($this->http->wrapper()->query()->has("tableview_id")) {
62 $tableview_id = $this->http->wrapper()->query()->retrieve(
63 'tableview_id',
64 $this->refinery->kindlyTo()->int()
65 );
66 $has_view = ilDclDetailedViewDefinition::isActive($tableview_id);
67 }
68
69 $components = [];
70
71 if (in_array($med->getSuffix(), ['jpg', 'jpeg', 'png', 'gif'])) {
72 // Image
73 $dir = ilObjMediaObject::_getDirectory($mob->getId());
74
75 $image = $this->factory->image()->responsive(ilWACSignedPath::signFile($dir . "/" . $med->getLocation()), "");
76
77 if ($is_linked_field && $has_view && $link) {
78 $this->ctrl->setParameterByClass(
79 'ilDclDetailedViewGUI',
80 'record_id',
81 $this->getRecordField()->getRecord()->getId()
82 );
83 $image = $image->withAction($this->ctrl->getLinkTargetByClass("ilDclDetailedViewGUI", 'renderRecord'));
84 }
85 $components[] = $image;
86 } else {
87 $location = ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation();
88 if (in_array($med->getSuffix(), ['mp3'])) {
89 $components[] = $this->factory->player()->audio($location);
90 } else {
91 $components[] = $this->factory->player()->video($location);
92 }
93
94 if ($is_linked_field && $has_view) {
95 $this->ctrl->setParameterByClass(
96 'ilDclDetailedViewGUI',
97 'record_id',
98 $this->getRecordField()->getRecord()->getId()
99 );
100 $components[] = $this->factory->link()->standard(
101 $this->lng->txt('details'),
102 $this->ctrl->getLinkTargetByClass(
103 "ilDclDetailedViewGUI",
104 'renderRecord'
105 )
106 );
107 }
108 }
109
110 $width = "200px";
111 $height = "auto";
112 if ($field->getProperty(ilDclBaseFieldModel::PROP_WIDTH) > 0) {
113 $width = $field->getProperty(ilDclBaseFieldModel::PROP_WIDTH) . "px";
114 }
115 if ($field->getProperty(ilDclBaseFieldModel::PROP_HEIGHT) > 0) {
116 $height = $field->getProperty(ilDclBaseFieldModel::PROP_HEIGHT) . "px";
117 }
118 $content = $this->renderer->render($components);
119 $fixed_size_div = "<div style='width:$width; height:$height;'>$content</div>";
120 return $fixed_size_div;
121 }
122
128 public function parseFormInput($value)
129 {
130 if (is_null($value)) {
131 return "";
132 }
133 if (is_array($value)) {
134 return $value;
135 }
136
137 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value) != "mob") {
138 return "";
139 }
140
141 return $value;
142 }
143}
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getHTML(bool $link=true, array $options=[])
Outputs html of a certain field.
parseFormInput($value)
function parses stored value to the variable needed to fill into the form for editing.
static _getURL(int $a_mob_id)
get directory for files of media object
static _getDirectory(int $a_mob_id)
Get absolute directory.
static _lookupType(int $id, bool $reference=false)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static signFile(string $path_to_file)
static http()
Fetches the global http state from ILIAS.