ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilDclMobRecordRepresentation.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
25 public function getHTML(bool $link = true, array $options = []): string
26 {
27 $value = $this->getRecordField()->getValue();
28
29 if (is_null($value)) {
30 return "";
31 }
32
33 $mob = new ilObjMediaObject($value);
34 $item = $mob->getMediaItem('Standard');
35 $component = match (explode('/', (string) $item?->getFormat())[0] ?? '') {
36 'image' => $this->factory->image()->responsive($item->getLocationSrc(), $mob->getTitle()),
37 'video' => $this->factory->player()->video($item->getLocationSrc()),
38 'audio' => $this->factory->player()->audio($item->getLocationSrc()),
39 default => $this->factory->image()->responsive('', $mob->getTitle()),
40 };
41
42 if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_LINK_DETAIL_PAGE_MOB) && $link) {
43 if ($this->http->wrapper()->query()->has('tableview_id')) {
44 $tableview_id = $this->http->wrapper()->query()->retrieve('tableview_id', $this->refinery->kindlyTo()->int());
45 } else {
46 $tableview_id = $this->getRecord()->getTable()->getFirstTableViewId($this->user->getId());
47 }
48 $page = new ilDclDetailedViewDefinitionGUI($tableview_id);
49 if ($page->getPageObject()->isActive()) {
50 $this->ctrl->setParameterByClass(ilDclDetailedViewGUI::class, 'record_id', $this->getRecord()->getId());
51 $link = $this->ctrl->getLinkTargetByClass(ilDclDetailedViewGUI::class, 'renderRecord');
52 $this->ctrl->clearParameterByClass(ilDclDetailedViewGUI::class, 'record_id');
53 if ($component instanceof Image) {
54 $component = $component->withAction($link);
55 } else {
56 $component = [$component, $this->factory->link()->standard($this->lng->txt('details'), $link)];
57 }
58 }
59 }
60
61 return $this->renderer->render($component);
62 }
63
64 public function parseFormInput($value)
65 {
66 if (is_array($value)) {
67 return $value;
68 }
69
70 if ($value === null || !ilObject2::_exists((int) $value) || ilObject2::_lookupType((int) $value) != 'mob') {
71 return '';
72 }
73
74 return $value;
75 }
76}
renderer()
factory()
@ilCtrl_Calls ilDclDetailedViewDefinitionGUI: ilPageEditorGUI, ilEditClipboardGUI,...
@noinspection AutoloadingIssuesInspection
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 _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 http()
Fetches the global http state from ILIAS.