ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPageLinker.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
11{
15 protected $offline;
16
21
25 protected $ctrl;
26
30 protected $cmd_gui;
31
35 public function __construct(string $cmd_gui_class, $offline = false, $profile_back_url = "", ilCtrl $ctrl = null)
36 {
37 global $DIC;
38
39 $this->offline = $offline;
40 $this->profile_back_url = $profile_back_url;
41 $this->cmd_gui = $cmd_gui_class;
42
43 $this->ctrl = (is_null($ctrl))
44 ? $DIC->ctrl()
45 : $ctrl;
46 }
47
51 public function setOffline($offline = true)
52 {
53 $this->offline = $offline;
54 }
55
56 public function setProfileBackUrl($url)
57 {
58 $this->profile_back_url = $url;
59 }
60
61
65 public function getLayoutLinkTargets() : array
66 {
67 $targets = [];
68
69 return $targets;
70 }
71
75 public function getLinkTargetsXML()
76 {
77 $layoutLinkTargets = $this->getLayoutLinkTargets();
78
79 if (0 === count($layoutLinkTargets)) {
80 return '';
81 }
82
83 $link_info = "<LinkTargets>";
84 foreach ($layoutLinkTargets as $k => $t) {
85 $link_info .= "<LinkTarget TargetFrame=\"" . $t["Type"] . "\" LinkTarget=\"" . $t["Frame"] . "\" OnClick=\"" . $t["OnClick"] . "\" />";
86 }
87 $link_info .= "</LinkTargets>";
88 return $link_info;
89 }
90
94 public function getLinkXML($int_links) : string
95 {
96 $link_info = "<IntLinkInfos>";
97 foreach ($int_links as $int_link) {
98 $target = $int_link["Target"];
99 if (substr($target, 0, 4) == "il__") {
100 $target_arr = explode("_", $target);
101 $target_id = $target_arr[count($target_arr) - 1];
102 $type = $int_link["Type"];
103
104 $targetframe = ($int_link["TargetFrame"] != "")
105 ? $int_link["TargetFrame"]
106 : "None";
107
108 $ltarget = "_top";
109 if ($targetframe != "None") {
110 $ltarget = "_blank";
111 }
112
113 // anchor
114 $anc = $anc_add = "";
115 if ($int_link["Anchor"] != "") {
116 $anc = $int_link["Anchor"];
117 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
118 }
119
120 $href = "";
121 $lcontent = "";
122 switch ($type) {
123 case "PageObject":
124 case "StructureObject":
126 if ($type == "PageObject") {
127 $href = "./goto.php?target=pg_" . $target_id . $anc_add;
128 } else {
129 $href = "./goto.php?target=st_" . $target_id;
130 }
131 if ($lm_id == "") {
132 $href = "";
133 }
134 break;
135
136 case "GlossaryItem":
137 if ($targetframe == "Glossary") {
138 $ltarget = "";
139 }
140 $href = "./goto.php?target=git_" . $target_id;
141 break;
142
143 case "MediaObject":
144 if ($this->offline) {
145 $href = "media_" . $target_id . ".html";
146 } else {
147 $this->ctrl->setParameterByClass($this->cmd_gui, "mob_id", $target_id);
148 $href = $this->ctrl->getLinkTargetByClass(
149 $this->cmd_gui,
150 "displayMedia",
151 "",
152 false,
153 true
154 );
155 $this->ctrl->setParameterByClass($this->cmd_gui, "mob_id", "");
156 }
157 break;
158
159 case "WikiPage":
160 $wiki_anc = "";
161 if ($int_link["Anchor"] != "") {
162 $wiki_anc = "#".rawurlencode($int_link["Anchor"]);
163 }
165 break;
166
167 case "PortfolioPage":
169 break;
170
171 case "RepositoryItem":
172 $obj_type = ilObject::_lookupType($target_id, true);
174 $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
175 break;
176
177 case "User":
179 if ($obj_type == "usr") {
180 include_once("./Services/User/classes/class.ilUserUtil.php");
182 //var_dump($back); exit;
183 $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user_id", $target_id);
184 if (strlen($back)) {
185 $this->ctrl->setParameterByClass(
186 "ilpublicuserprofilegui",
187 "back_url",
188 rawurlencode($back)
189 );
190 }
191 $href = "";
192 include_once("./Services/User/classes/class.ilUserUtil.php");
194 $href = $this->ctrl->getLinkTargetByClass(
195 ["ildashboardgui", "ilpublicuserprofilegui"],
196 "getHTML",
197 "",
198 false,
199 true
200 );
201 }
202 $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user_id", "");
203 $lcontent = ilUserUtil::getNamePresentation($target_id, false, false);
204 $lcontent = str_replace("&", "&amp;", htmlentities($lcontent));
205 }
206 break;
207
208 }
209 if ($href != "") {
210 $anc_par = 'Anchor="' . $anc . '"';
211 $link_info .= "<IntLinkInfo Target=\"$target\" Type=\"$type\" " . $anc_par . " " .
212 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" LinkContent=\"$lcontent\" />";
213 }
214 }
215 }
216 $link_info .= "</IntLinkInfos>";
217 $link_info .= $this->getLinkTargetsXML();
218 return $link_info;
219 }
220
224 public function getFullscreenLink() : string
225 {
226 if ($this->offline) {
227 return "fullscreen.html";
228 }
229
230 return $this->ctrl->getLinkTargetByClass($this->cmd_gui, "fullscreen", "", false, false);
231 }
232}
An exception for terminatinating execution or to throw for unit testing.
This class provides processing control methods.
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
getFullscreenLink()
@inheritDoc
setOffline($offline=true)
@inheritDoc
getLayoutLinkTargets()
@inheritDoc
getLinkTargetsXML()
Get XMl for Link Targets.
__construct(string $cmd_gui_class, $offline=false, $profile_back_url="", ilCtrl $ctrl=null)
Constructor.
getLinkXML($int_links)
@inheritDoc
static getGotoForPortfolioPageTarget($a_target, $a_offline=false)
Get goto href for internal wiki page link target.
static hasPublicProfile($a_user_id)
Has public profile.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static getGotoForWikiPageTarget($a_target, $a_offline=false)
Get goto href for internal wiki page link target.
global $DIC
Definition: goto.php:24
$target_id
Definition: goto.php:51
$target_arr
Definition: goto.php:49
$type
$url