ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilDclIliasReferenceRecordRepresentation.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
25{
28
30 {
32 global $DIC;
33
34 $this->obj_def = $DIC['objDefinition'];
35 $this->static_url = $DIC['static_url'];
36 }
37
38 public function getHTML(bool $link = true, array $options = []): string
39 {
40 $ref_id = (int) $this->getRecordField()->getValue();
41 if ($ref_id === 0) {
42 return '';
43 }
44
46 if (null === $object || !$this->access->checkAccess('visible', '', $ref_id)) {
47 return '';
48 }
49 $html = $object->getTitle() . ' [' . $ref_id . ']';
50
51 $actions = [];
52 if (
54 ) {
55 if ($this->access->checkAccess('delete', '', $ref_id) && $this->obj_def->allowLink($object->getType())) {
56 $this->ctrl->setParameterByClass(ilRepositoryGUI::class, 'item_ref_id', $ref_id);
57 $actions[] = $this->factory->link()->standard(
58 $this->lng->txt('link'),
59 $this->ctrl->getLinkTargetByClass([ilRepositoryGUI::class, ilObjRootFolderGUI::class], 'link')
60 );
61 }
62 if ($this->access->checkAccess('copy', '', $ref_id) && $this->obj_def->allowCopy($object->getType())) {
63 $this->ctrl->setParameterByClass(ilObjectCopyGUI::class, 'source_id', $ref_id);
64 $actions[] = $this->factory->link()->standard(
65 $this->lng->txt('copy'),
66 $this->ctrl->getLinkTargetByClass(ilObjectCopyGUI::class, 'initTargetSelection')
67 );
68 }
69 }
70
71 if (
73 $this->access->checkAccess('read', '', $ref_id)
74 ) {
75 $link = (string) $this->static_url->builder()->build($object->getType(), new ReferenceId($ref_id));
76 if ($actions === []) {
77 $html = $this->renderer->render($this->factory->link()->standard($html, $link));
78 } else {
79 $html = $this->renderer->render(
80 $this->factory->dropdown()->standard(
81 array_merge([$this->factory->link()->standard($this->lng->txt('view'), $link)], $actions)
82 )->withLabel($html)
83 );
84 }
85 }
86
87 return $html;
88 }
89}
renderer()
factory()
Class Services.
Definition: Services.php:38
getHTML(bool $link=true, array $options=[])
Outputs html of a certain field.
parses the objects.xml it handles the xml-description of all ilias objects
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26