ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPageLinker.php
Go to the documentation of this file.
1<?php
2
20
26{
27 protected bool $offline;
28 protected string $profile_back_url = "";
29 protected ilCtrl $ctrl;
30 protected string $cmd_gui;
31
32 public function __construct(
33 string $cmd_gui_class,
34 bool $offline = false,
35 string $profile_back_url = "",
36 ?ilCtrl $ctrl = null
37 ) {
38 global $DIC;
39
40 $this->offline = $offline;
41 $this->profile_back_url = $profile_back_url;
42 $this->cmd_gui = $cmd_gui_class;
43
44 $this->ctrl = (is_null($ctrl))
45 ? $DIC->ctrl()
46 : $ctrl;
47 }
48
49 public function setOffline(bool $offline = true): void
50 {
51 $this->offline = $offline;
52 }
53
54 public function setProfileBackUrl(string $url): void
55 {
56 $this->profile_back_url = $url;
57 }
58
59
60 public function getLayoutLinkTargets(): array
61 {
62 $targets = [];
63 return $targets;
64 }
65
66 public function getLinkTargetsXML(): string
67 {
68 $layoutLinkTargets = $this->getLayoutLinkTargets();
69
70 if (0 === count($layoutLinkTargets)) {
71 return '';
72 }
73
74 $link_info = "<LinkTargets>";
75 foreach ($layoutLinkTargets as $k => $t) {
76 $link_info .= "<LinkTarget TargetFrame=\"" . $t["Type"] . "\" LinkTarget=\"" . $t["Frame"] . "\" OnClick=\"" . $t["OnClick"] . "\" />";
77 }
78 $link_info .= "</LinkTargets>";
79 return $link_info;
80 }
81
82 public function getLinkXML(array $int_links): string
83 {
84 $ilCtrl = $this->ctrl;
85 $link_info = "<IntLinkInfos>";
86 foreach ($int_links as $int_link) {
87 $target = $int_link["Target"];
88 if (substr($target, 0, 4) == "il__") {
89 $target_arr = explode("_", $target);
90 $target_id = $target_arr[count($target_arr) - 1];
91 $type = $int_link["Type"];
92
93 $targetframe = ($int_link["TargetFrame"] != "")
94 ? $int_link["TargetFrame"]
95 : "None";
96
97 $ltarget = "_top";
98 if ($targetframe != "None") {
99 $ltarget = "_blank";
100 }
101
102 // anchor
103 $anc = $anc_add = "";
104 if (($int_link["Anchor"] ?? "") != "") {
105 $anc = $int_link["Anchor"];
106 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
107 }
108
109 $href = "";
110 $lcontent = "";
111 switch ($type) {
112 case "PageObject":
113 case "StructureObject":
114 $lm_id = ilLMObject::_lookupContObjID($target_id);
115 if ($type == "PageObject") {
116 $href = "./goto.php?target=pg_" . $target_id . $anc_add;
117 } else {
118 $href = "./goto.php?target=st_" . $target_id;
119 }
120 if ($lm_id == "") {
121 $href = "";
122 }
123 break;
124
125 case "GlossaryItem":
126 if ($targetframe == "Glossary") {
127 $ltarget = "";
128 }
129 $href = "./goto.php?target=git_" . $target_id;
130 break;
131
132 case "MediaObject":
133 if ($this->offline) {
134 $href = "media_" . $target_id . ".html";
135 } else {
136 $this->ctrl->setParameterByClass($this->cmd_gui, "mob_id", $target_id);
137 $href = $this->ctrl->getLinkTargetByClass(
138 $this->cmd_gui,
139 "displayMedia",
140 "",
141 false,
142 true
143 );
144 $this->ctrl->setParameterByClass($this->cmd_gui, "mob_id", "");
145 }
146 break;
147
148 case "WikiPage":
149 $wiki_anc = "";
150 if (($int_link["Anchor"] ?? "") != "") {
151 $wiki_anc = "#" . rawurlencode("copganc_" . $int_link["Anchor"]);
152 }
153 $href = ilWikiPage::getGotoForWikiPageTarget($target_id) . $wiki_anc;
154 break;
155
156 case "PortfolioPage":
157 $href = ilPortfolioPage::getGotoForPortfolioPageTarget($target_id, $this->offline);
158 break;
159
160 case "RepositoryItem":
161 $obj_type = ilObject::_lookupType((int) $target_id, true);
162 $obj_id = ilObject::_lookupObjId((int) $target_id);
163 $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
164 break;
165
166 case "File":
167 if (!$this->offline) {
168 $href = "#";
169 }
170 break;
171
172 case "User":
173 // target = il__user_329
174 $obj_type = ilObject::_lookupType((int) $target_id);
175 if ($obj_type == "usr") {
177 //var_dump($back); exit;
178 $this->ctrl->setParameterByClass(PublicProfileGUI::class, "user_id", $target_id);
179 if (strlen($back)) {
180 $this->ctrl->setParameterByClass(
181 PublicProfileGUI::class,
182 "back_url",
183 rawurlencode($back)
184 );
185 }
186 $href = "";
187 if (ilUserUtil::hasPublicProfile($target_id)) {
188 $href = $this->ctrl->getLinkTargetByClass(
189 [PublicProfileGUI::class],
190 "getHTML",
191 "",
192 false,
193 true
194 );
195 }
196 $this->ctrl->setParameterByClass(PublicProfileGUI::class, "user_id", "");
197 $lcontent = ilUserUtil::getNamePresentation($target_id, false, false);
198 $lcontent = str_replace("&", "&amp;", htmlentities($lcontent));
199 }
200 break;
201 }
202 if ($href != "" || $type === "User") {
203 $anc_par = 'Anchor="' . $anc . '"';
204 $link_info .= "<IntLinkInfo Target=\"$target\" Type=\"$type\" " . $anc_par . " " .
205 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" LinkContent=\"$lcontent\" />";
206 }
207 }
208 }
209 $link_info .= "</IntLinkInfos>";
210 $link_info .= $this->getLinkTargetsXML();
211 return $link_info;
212 }
213
214 public function getFullscreenLink(): string
215 {
216 if ($this->offline) {
217 return "fullscreen.html";
218 }
219
220 return $this->ctrl->getLinkTargetByClass($this->cmd_gui, "fullscreen", "", false, false);
221 }
222}
GUI class for public user profile presentation.
Class ilCtrl provides processing control methods.
static _lookupContObjID(int $a_id)
get learning module id for lm object
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
getLinkXML(array $int_links)
setOffline(bool $offline=true)
setProfileBackUrl(string $url)
__construct(string $cmd_gui_class, bool $offline=false, string $profile_back_url="", ?ilCtrl $ctrl=null)
static getGotoForPortfolioPageTarget(int $a_target, bool $a_offline=false)
Get goto href for portfolio page id.
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
static hasPublicProfile(int $a_user_id)
static getGotoForWikiPageTarget(string $a_target, bool $a_offline=false)
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68