ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDclIliasReferenceRecordRepresentation.php
Go to the documentation of this file.
1<?php
2require_once('./Modules/DataCollection/classes/Fields/Base/class.ilDclBaseRecordRepresentation.php');
3require_once("./Services/Rating/classes/class.ilRatingGUI.php");
4require_once("./Services/Link/classes/class.ilLink.php");
5require_once('./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php');
6
14
20 public function getHTML($link = true){
21 $title = $this->getRecordField()->getValueForRepresentation();
22 if (!$title) {
23 return '';
24 }
25 $field = $this->getRecordField()->getField();
26
28 $html = $this->getLinkHTML($title, true);
29 } else if ($field->getProperty(ilDclBaseFieldModel::PROP_ILIAS_REFERENCE_LINK)) {
30 $html = $this->getLinkHTML($title);
31 } else {
32 $html = $title;
33 }
34 return $html;
35 }
36
37
38 public function getSingleHTML(array $options=array(), $link = true)
39 {
40 $value = $this->getRecordField()->getValue();
41 if (!$value) {
42 return '';
43 }
44 $id = ilObject::_lookupObjId($value);
45 $value = ilObject::_lookupTitle($id);
47 return $this->getLinkHTML($value);
48 }
49 return $value;
50 }
51
52
58 public function getLinkHTML($title, $show_action_menu=false) {
59 global $DIC;
60 $lng = $DIC['lng'];
61 $this->getRecordField();
62 $link = ilLink::_getStaticLink($this->getRecordField()->getValue());
63 if ($show_action_menu) {
64 $field = $this->getRecordField()->getField();
65 $record = $this->getRecordField()->getRecord();
66
67 $list = new ilAdvancedSelectionListGUI();
68 $list->setId('adv_list_copy_link_' . $field->getId() . $record->getId());
69 $list->setListTitle($title);
70 if ($field->getProperty(ilDclBaseFieldModel::PROP_ILIAS_REFERENCE_LINK)) {
71 $list->addItem($lng->txt('view'), 'view', $link);
72 }
73 $list->addItem($lng->txt('copy'), 'copy', $this->getActionLink('copy'));
74 $list->addItem($lng->txt('link'), 'link', $this->getActionLink('link'));
75 return $list->getHTML();
76 } else {
77 return "<a href=\"$link\">$title</a>";
78 }
79 }
80
85 protected function getActionLink($mode)
86 {
87 global $DIC;
88 $ilCtrl = $DIC['ilCtrl'];
89
90 switch ($mode) {
91 case 'copy':
92 $ilCtrl->setParameterByClass('ilobjectcopygui', 'item_ref_id', $this->getRecordField()->getValue());
93 $ilCtrl->setParameterByClass('ilobjrootfoldergui', 'item_ref_id', $this->getRecordField()->getValue());
94 $ilCtrl->setParameterByClass('ilobjectcopygui', 'source_id', $this->getRecordField()->getValue());
95 return $ilCtrl->getLinkTargetByClass('ilobjectcopygui', 'initTargetSelection');
96 case 'link':
97 return $ilCtrl->getLinkTargetByClass(array('ilrepositorygui','ilobjrootfoldergui'), 'link');
98 default:
99 return '';
100 }
101 }
102
103}
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=array(), $link=true)
Returns data for single record view.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
if(!is_array($argv)) $options
global $DIC