ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilDclIliasReferenceRecordRepresentation.php
Go to the documentation of this file.
1<?php
2
10{
11
17 public function getHTML($link = true)
18 {
19 $title = $this->getRecordField()->getValueForRepresentation();
20 if (!$title) {
21 return '';
22 }
23 $field = $this->getRecordField()->getField();
24
26 $html = $this->getLinkHTML($title, true);
27 } else {
28 if ($field->getProperty(ilDclBaseFieldModel::PROP_ILIAS_REFERENCE_LINK)) {
29 $html = $this->getLinkHTML($title);
30 } else {
31 $html = $title;
32 }
33 }
34
35 return $html;
36 }
37
38
39 public function getSingleHTML(array $options = null, $link = true)
40 {
41 $value = $this->getRecordField()->getValue();
42 if (!$value) {
43 return '';
44 }
45 $id = ilObject::_lookupObjId($value);
46 $value = ilObject::_lookupTitle($id);
48 return $this->getLinkHTML($value);
49 }
50
51 return $value;
52 }
53
54
61 public function getLinkHTML($title, $show_action_menu = false)
62 {
63 global $DIC;
64 $lng = $DIC['lng'];
65 $this->getRecordField();
66 $link = ilLink::_getStaticLink($this->getRecordField()->getValue());
67 if ($show_action_menu) {
68 $field = $this->getRecordField()->getField();
69 $record = $this->getRecordField()->getRecord();
70
71 $list = new ilAdvancedSelectionListGUI();
72 $list->setId('adv_list_copy_link_' . $field->getId() . $record->getId());
73 $list->setListTitle($title);
74 if ($field->getProperty(ilDclBaseFieldModel::PROP_ILIAS_REFERENCE_LINK)) {
75 $list->addItem($lng->txt('view'), 'view', $link);
76 }
77 $list->addItem($lng->txt('copy'), 'copy', $this->getActionLink('copy'));
78 $list->addItem($lng->txt('link'), 'link', $this->getActionLink('link'));
79
80 return $list->getHTML();
81 } else {
82 return "<a href=\"$link\">$title</a>";
83 }
84 }
85
86
92 protected function getActionLink($mode)
93 {
94 global $DIC;
95 $ilCtrl = $DIC['ilCtrl'];
96
97 switch ($mode) {
98 case 'copy':
99 $ilCtrl->setParameterByClass('ilobjectcopygui', 'item_ref_id', $this->getRecordField()->getValue());
100 $ilCtrl->setParameterByClass('ilobjrootfoldergui', 'item_ref_id', $this->getRecordField()->getValue());
101 $ilCtrl->setParameterByClass('ilobjectcopygui', 'source_id', $this->getRecordField()->getValue());
102
103 return $ilCtrl->getLinkTargetByClass('ilobjectcopygui', 'initTargetSelection');
104 case 'link':
105 return $ilCtrl->getLinkTargetByClass(array('ilrepositorygui', 'ilobjrootfoldergui'), 'link');
106 default:
107 return '';
108 }
109 }
110}
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
Class ilDclBaseRecordRepresentation.
getSingleHTML(array $options=null, $link=true)
Returns data for single record view.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
global $ilCtrl
Definition: ilias.php:18
$DIC
Definition: xapitoken.php:46