ILIAS  release_8 Revision v8.24
class.ilDclIliasReferenceRecordRepresentation.php
Go to the documentation of this file.
1<?php
2
20{
21 public function getHTML(bool $link = true, array $options = []): string
22 {
23 $title = $this->getRecordField()->getValueForRepresentation();
24 if (!$title) {
25 return '';
26 }
27 $field = $this->getRecordField()->getField();
28
30 $html = $this->getLinkHTML($title, true);
31 } else {
32 if ($field->getProperty(ilDclBaseFieldModel::PROP_ILIAS_REFERENCE_LINK)) {
33 $html = $this->getLinkHTML($title);
34 } else {
35 $html = $title;
36 }
37 }
38
39 return $html;
40 }
41
42 public function getSingleHTML(array $options = null, bool $link = true): string
43 {
44 $value = $this->getRecordField()->getValue();
45 if (!$value) {
46 return '';
47 }
51 return $this->getLinkHTML($value);
52 }
53
54 return $value;
55 }
56
57 public function getLinkHTML(string $title, bool $show_action_menu = false): string
58 {
61 if ($show_action_menu) {
62 $field = $this->getRecordField()->getField();
63 $record = $this->getRecordField()->getRecord();
64
65 $list = new ilAdvancedSelectionListGUI();
66 $list->setId('adv_list_copy_link_' . $field->getId() . $record->getId());
67 $list->setListTitle($title);
68 if ($field->getProperty(ilDclBaseFieldModel::PROP_ILIAS_REFERENCE_LINK)) {
69 $list->addItem($lng->txt('view'), 'view', $link);
70 }
71 $list->addItem($lng->txt('copy'), 'copy', $this->getActionLink('copy'));
72 $list->addItem($lng->txt('link'), 'link', $this->getActionLink('link'));
73
74 return $list->getHTML();
75 } else {
76 return "<a href=\"$link\">$title</a>";
77 }
78 }
79
83 protected function getActionLink(string $mode): string
84 {
85 global $DIC;
86 $ilCtrl = $DIC['ilCtrl'];
87
88 switch ($mode) {
89 case 'copy':
90 $ilCtrl->setParameterByClass('ilobjectcopygui', 'item_ref_id', $this->getRecordField()->getValue());
91 $ilCtrl->setParameterByClass('ilobjrootfoldergui', 'item_ref_id', $this->getRecordField()->getValue());
92 $ilCtrl->setParameterByClass('ilobjectcopygui', 'source_id', $this->getRecordField()->getValue());
93
94 return $ilCtrl->getLinkTargetByClass('ilobjectcopygui', 'initTargetSelection');
95 case 'link':
96 return $ilCtrl->getLinkTargetByClass(array('ilrepositorygui', 'ilobjrootfoldergui'), 'link');
97 default:
98 return '';
99 }
100 }
101}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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...
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.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
global $DIC
Definition: feed.php:28
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:47