ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjLinkResourceListGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected function getWebLinkRepo(): ilWebLinkRepository
28 {
29 return new ilWebLinkDatabaseRepository($this->obj_id);
30 }
31
32 public function getTitle(): string
33 {
35 !$this->getWebLinkRepo()->doesListExist()) {
36 return ilObjLinkResourceAccess::_getFirstLink($this->obj_id)
37 ->getTitle();
38 }
39 return parent::getTitle();
40 }
41
42 public function getDescription(): string
43 {
45 !$this->getWebLinkRepo()->doesListExist()) {
46 $desc = ilObjLinkResourceAccess::_getFirstLink($this->obj_id)
47 ->getDescription() ?? '';
48
49 // #10682
50 if ($this->settings->get("rep_shorten_description")) {
52 $desc,
53 (int) $this->settings->get(
54 "rep_shorten_description_length"
55 ),
56 true
57 );
58 }
59
60 return $desc;
61 }
62 return parent::getDescription();
63 }
64
65 public function init(): void
66 {
67 $this->delete_enabled = true;
68 $this->cut_enabled = true;
69 $this->copy_enabled = true;
70 $this->subscribe_enabled = true;
71 $this->link_enabled = true;
72 $this->type = "webr";
73 $this->gui_class_name = "ilobjlinkresourcegui";
74 $this->info_screen_enabled = true;
75
76 // general commands array
77 $this->commands = ilObjLinkResourceAccess::_getCommands();
78 }
79
80 public function getCommandFrame(string $cmd): string
81 {
82 // #16820 / #18419 / #18622
83 if ($cmd == "" &&
85 !$this->getWebLinkRepo()->doesListExist()) {
86 $link = ilObjLinkResourceAccess::_getFirstLink($this->obj_id);
87
88 // we could use the "internal" flag, but it would not work for "old" links
89 if (!ilLinkInputGUI::isInternalLink($link->getTarget())) {
90 return '_blank';
91 }
92 }
93 return "";
94 }
95
96 public function getCommandLink(string $cmd): string
97 {
98 $cmd_class = '';
99 if ($this->request_wrapper->has('cmdClass')) {
100 $cmd_class = $this->request_wrapper->retrieve(
101 'cmdClass',
102 $this->refinery->kindlyTo()->string()
103 );
104 }
105 if (
106 $this->request_wrapper->has('wsp_id') ||
107 strcasecmp($cmd_class, ilPersonalWorkspaceGUI::class) === 0
108 ) {
109 if (
111 !$this->getWebLinkRepo()->doesListExist() &&
112 $cmd == ''
113 ) {
114 $cmd = "calldirectlink";
115 }
116 $this->ctrl->setParameterByClass(
117 $this->gui_class_name,
118 "ref_id",
119 ""
120 );
121 $this->ctrl->setParameterByClass(
122 $this->gui_class_name,
123 "wsp_id",
124 $this->ref_id
125 );
126 return $this->ctrl->getLinkTargetByClass(
127 array("ilpersonalworkspacegui", $this->gui_class_name),
128 $cmd
129 );
130 } else {
131 // separate method for this line
132 switch ($cmd) {
133 case '':
135 $this->obj_id
136 ) &&
137 !$this->getWebLinkRepo()->doesListExist()) {
138 $cmd_link = "ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=" . $this->ref_id . "&cmd=calldirectlink";
139 } else {
140 $cmd_link = "ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=" . $this->ref_id . "&cmd=$cmd";
141 }
142 break;
143
144 default:
145 $cmd_link = "ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=" . $this->ref_id . "&cmd=$cmd";
146 }
147 }
148 return $cmd_link;
149 }
150}
static isInternalLink(string $a_value)
static _checkDirectLink($a_obj_id)
Check whether there is only one active link in the web resource.
static _getFirstLink(int $a_webr_id)
Get first link item Check before with _isSingular() if there is more or less than one.
Class ilObjLinkResourceListGUI.
getCommandFrame(string $cmd)
Get command target frame.
getDescription()
getDescription overwritten in class.ilObjLinkResourceList.php
getCommandLink(string $cmd)
Get command link url.
getTitle()
getTitle overwritten in class.ilObjLinkResourceList.php
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)