ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDclFileRecordRepresentation.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 use ilDclFileFieldHelper;
27
28 private \ILIAS\ResourceStorage\Services $irss;
29 private \ILIAS\DI\UIServices $ui_services;
30
32 {
33 global $DIC;
35 $this->irss = $DIC->resourceStorage();
36 $this->ui_services = $DIC->ui();
37 }
38
39 public function getSingleHTML(?array $options = null, bool $link = true): string
40 {
41 return $this->getHTML(true, $options ?? []);
42 }
43
44 public function getHTML(bool $link = true, array $options = []): string
45 {
46 $value = $this->record_field->getValue();
47
48 if ($value === null) {
49 return '';
50 }
51
52 if (is_array($value)) {
53 return $value['name'] ?? 'undefined';
54 }
55
56 $title = $this->valueToFileTitle($value);
57
58 if ($title === '') {
59 return $this->lng->txt('file_not_found');
60 }
61
62 if ($link) {
63 $link_component = $this->ui_services->factory()->link()->standard(
64 $title,
65 $this->buildDownloadLink()
66 );
67
68 return $this->ui_services->renderer()->render($link_component);
69 }
70
71 return $title;
72 }
73
74 public function parseFormInput($value)
75 {
76 if ($value === null || is_array($value)) {
77 return '';
78 }
79 return $this->valueToFileTitle($value);
80 }
81
82 private function buildDownloadLink(): string
83 {
85
86 $this->ctrl->setParameterByClass(
87 ilDclRecordListGUI::class,
88 "record_id",
89 $record_field->getRecord()->getId()
90 );
91 $this->ctrl->setParameterByClass(
92 ilDclRecordListGUI::class,
93 "field_id",
94 $record_field->getField()->getId()
95 );
96 return $this->ctrl->getLinkTargetByClass(
97 ilDclRecordListGUI::class,
98 "sendFile"
99 );
100 }
101}
@noinspection AutoloadingIssuesInspection
__construct(ilDclBaseRecordFieldModel $record_field)
getSingleHTML(?array $options=null, bool $link=true)
Returns data for single record view.
parseFormInput($value)
function parses stored value to the variable needed to fill into the form for editing.
getHTML(bool $link=true, array $options=[])
Outputs html of a certain field.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26