ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 $html = $object->getTitle() . ' [' . $ref_id . ']';
47
48 $actions = [];
49 if (
51 ) {
52 if ($this->access->checkAccess('delete', '', $ref_id) && $this->obj_def->allowLink($object->getType())) {
53 $this->ctrl->setParameterByClass(ilRepositoryGUI::class, 'item_ref_id', $ref_id);
54 $actions[] = $this->factory->link()->standard(
55 $this->lng->txt('link'),
56 $this->ctrl->getLinkTargetByClass([ilRepositoryGUI::class, ilObjRootFolderGUI::class], 'link')
57 );
58 }
59 if ($this->access->checkAccess('copy', '', $ref_id) && $this->obj_def->allowCopy($object->getType())) {
60 $this->ctrl->setParameterByClass(ilObjectCopyGUI::class, 'source_id', $ref_id);
61 $actions[] = $this->factory->link()->standard(
62 $this->lng->txt('copy'),
63 $this->ctrl->getLinkTargetByClass(ilObjectCopyGUI::class, 'initTargetSelection')
64 );
65 }
66 }
67
68 if (
70 $this->access->checkAccess('read', '', $ref_id)
71 ) {
72 $link = (string) $this->static_url->builder()->build($object->getType(), new ReferenceId($ref_id));
73 if ($actions === []) {
74 $html = $this->renderer->render($this->factory->link()->standard($html, $link));
75 } else {
76 $html = $this->renderer->render(
77 $this->factory->dropdown()->standard(
78 array_merge([$this->factory->link()->standard($this->lng->txt('view'), $link)], $actions)
79 )->withLabel($html)
80 );
81 }
82 }
83
84 return $html;
85 }
86}
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